mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-12 00:22:21 +08:00
跟随
提交者:沫 <jifengshenmo@outlook.com> 修改: downloadlist.cpp 修改: downloadlist.h 修改: downloadlist.ui 新文件: server.list 修改: widget.cpp 修改: widget.h 修改: widget.ui
This commit is contained in:
parent
5c8ee91a76
commit
8e3f235910
@ -3,6 +3,10 @@
|
||||
#include <QDebug>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QtConcurrent>
|
||||
#include <QProcess>
|
||||
bool downloadlist::isInstall=false;
|
||||
|
||||
downloadlist::downloadlist(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::downloadlist)
|
||||
@ -11,6 +15,7 @@ downloadlist::downloadlist(QWidget *parent) :
|
||||
ui->pushButton->setEnabled(false);
|
||||
ui->progressBar->setValue(0);
|
||||
ui->label_filename->hide();
|
||||
ui->pushButton->hide();
|
||||
ui->label->setStyleSheet("color:#000000");
|
||||
}
|
||||
|
||||
@ -45,9 +50,13 @@ QString downloadlist::getName()
|
||||
|
||||
void downloadlist::readyInstall()
|
||||
{
|
||||
ui->progressBar->hide();
|
||||
ui->pushButton->setEnabled(true);
|
||||
system("notify-send \""+ui->label->text().toUtf8()+"下载完成,等待安装\"");
|
||||
if(!close){
|
||||
ui->progressBar->hide();
|
||||
ui->pushButton->setEnabled(true);
|
||||
ui->pushButton->show();
|
||||
ui->pushButton_2->hide();
|
||||
system("notify-send \""+ui->label->text().toUtf8()+"下载完成,等待安装\"");
|
||||
}
|
||||
}
|
||||
|
||||
void downloadlist::choose(bool isChoosed)
|
||||
@ -71,8 +80,49 @@ void downloadlist::seticon(const QPixmap icon)
|
||||
ui->label_3->setPixmap(icon);
|
||||
}
|
||||
|
||||
void downloadlist::closeDownload()
|
||||
{
|
||||
on_pushButton_2_clicked();
|
||||
}
|
||||
|
||||
void downloadlist::on_pushButton_clicked()
|
||||
{
|
||||
system("x-terminal-emulator -e sudo apt install -y ./"+ui->label_filename->text().toUtf8());
|
||||
qDebug()<<ui->label_filename->text().toUtf8();
|
||||
if(!isInstall){
|
||||
isInstall=true;
|
||||
ui->pushButton->setEnabled(false);
|
||||
ui->label_2->setText("正在安装,请稍候");
|
||||
QtConcurrent::run([=](){
|
||||
QProcess installer;
|
||||
installer.start("pkexec apt install -y /tmp/deepin-community-store/"+ui->label_filename->text().toUtf8());
|
||||
installer.waitForFinished();
|
||||
QString error=QString::fromStdString(installer.readAllStandardError().toStdString());
|
||||
QStringList everyError=error.split("\n");
|
||||
bool haveError=false;
|
||||
for (int i=0;i<everyError.size();i++) {
|
||||
qDebug()<<everyError[i].left(2);
|
||||
if(everyError[i].left(2)=="E:"){
|
||||
haveError=true;
|
||||
}
|
||||
}
|
||||
if(!haveError){
|
||||
ui->pushButton->hide();
|
||||
ui->label_2->setText("安装完成");
|
||||
}else {
|
||||
ui->pushButton->hide();
|
||||
ui->label_2->setText("安装出现错误");
|
||||
}
|
||||
isInstall=false;
|
||||
});
|
||||
// system("x-terminal-emulator -e sudo apt install -y ./"+ui->label_filename->text().toUtf8());
|
||||
qDebug()<<ui->label_filename->text().toUtf8();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void downloadlist::on_pushButton_2_clicked()
|
||||
{
|
||||
ui->label_2->setText("已取消下载");
|
||||
ui->pushButton_2->setEnabled(false);
|
||||
ui->progressBar->hide();
|
||||
close=true;
|
||||
}
|
||||
|
@ -22,13 +22,20 @@ public:
|
||||
bool free;
|
||||
void setFileName(QString);
|
||||
void seticon(const QPixmap);
|
||||
public: signals:
|
||||
void closeDownload();
|
||||
int num;
|
||||
bool close=false;
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
|
||||
private:
|
||||
Ui::downloadlist *ui;
|
||||
};
|
||||
static bool isInstall;
|
||||
|
||||
};
|
||||
//bool downloadlist::isInstall=false;
|
||||
#endif // DOWNLOADLIST_H
|
||||
|
137
downloadlist.ui
137
downloadlist.ui
@ -17,65 +17,6 @@
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>安装</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>名称</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_filename">
|
||||
<property name="text">
|
||||
@ -172,6 +113,65 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>安装</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>名称</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="maximumSize">
|
||||
@ -188,6 +188,25 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="8">
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
5
server.list
Normal file
5
server.list
Normal file
@ -0,0 +1,5 @@
|
||||
http://dcstore.shenmo.tech/
|
||||
http://store.shenmo.tech/
|
||||
http://store2.shenmo.tech/
|
||||
http://store.moshengren.xyz/
|
||||
http://127.0.0.1:8000/#/
|
48
widget.cpp
48
widget.cpp
@ -16,6 +16,7 @@
|
||||
#include <QtConcurrent> //并发
|
||||
#include <QSettings>
|
||||
#include <QIcon>
|
||||
#include <QGraphicsOpacityEffect>
|
||||
Widget::Widget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Widget)
|
||||
@ -74,6 +75,15 @@ Widget::Widget(QWidget *parent) :
|
||||
menuUrl[10]=serverUrl + "store/tools/";
|
||||
menuUrl[11]=serverUrl + "store/others/";
|
||||
menuUrl[12]=serverUrl + "themes";
|
||||
for (int i =0; i<15;i++){
|
||||
download_list[i].num=i;
|
||||
}
|
||||
QGraphicsOpacityEffect *opacityEffect=new QGraphicsOpacityEffect;
|
||||
ui->line1_widget->setStyleSheet("background-color:#808080");
|
||||
ui->line2_widget->setStyleSheet("background-color:#808080");
|
||||
ui->line1_widget->setGraphicsEffect(opacityEffect);
|
||||
ui->line2_widget->setGraphicsEffect(opacityEffect);
|
||||
opacityEffect->setOpacity(0.2);
|
||||
}
|
||||
|
||||
Widget::~Widget()
|
||||
@ -139,8 +149,13 @@ void Widget::loadappinfo(QUrl arg1)
|
||||
//软件信息加载
|
||||
QString info;
|
||||
info="版本号:"+json["Version"].toString()+"\n";
|
||||
info+="作者:"+json["Author"].toString()+"\n";
|
||||
info+="官网:"+json["Website"].toString()+"\n";
|
||||
if(json["Author"].toString()!="" && json["Author"].toString()!=" "){
|
||||
info+="作者:"+json["Author"].toString()+"\n";
|
||||
}
|
||||
|
||||
if(json["Website"].toString()!="" && json["Website"].toString()!=" "){
|
||||
info+="官网:"+json["Website"].toString()+"\n";
|
||||
}
|
||||
info+="投稿者:"+json["Contributor"].toString()+"\n";
|
||||
info+="更新时间:"+json["Update"].toString()+"\n";
|
||||
info+="大小:"+json["Size"].toString()+"\n";
|
||||
@ -208,6 +223,7 @@ void Widget::loadappinfo(QUrl arg1)
|
||||
void Widget::chooseLeftMenu(int index)
|
||||
{
|
||||
for (int i=0;i<15;i++) {
|
||||
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||
left_list[i]->setStyleSheet("");
|
||||
left_menu_bg[i]->setStyleSheet("");
|
||||
}
|
||||
@ -249,7 +265,7 @@ void Widget::on_pushButton_clicked()
|
||||
file = new QFile(fileName);
|
||||
if(!file->open(QIODevice::WriteOnly)){
|
||||
delete file;
|
||||
file = 0;
|
||||
file = nullptr;
|
||||
return ;
|
||||
}
|
||||
nowDownload+=1;
|
||||
@ -263,6 +279,7 @@ void Widget::startRequest(QUrl url)
|
||||
ui->label->hide();
|
||||
isBusy=true;
|
||||
isdownload=true;
|
||||
download_list[allDownload-1].free=false;
|
||||
reply = manager->get(QNetworkRequest(url));
|
||||
connect(reply,SIGNAL(finished()),this,SLOT(httpFinished()));
|
||||
connect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));
|
||||
@ -270,11 +287,6 @@ void Widget::startRequest(QUrl url)
|
||||
|
||||
}
|
||||
|
||||
void Widget::closeList(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Widget::httpReadyRead()
|
||||
{
|
||||
@ -287,7 +299,11 @@ void Widget::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
|
||||
{
|
||||
download_list[nowDownload-1].setMax(10000); //最大值
|
||||
download_list[nowDownload-1].setValue((bytesRead*10000)/totalBytes); //当前值
|
||||
if(download_list[nowDownload-1].close){
|
||||
download_list[nowDownload-1].closeDownload();
|
||||
httpFinished();
|
||||
|
||||
}
|
||||
// download_list[nowDownload-1].setMax(bytesRead/10);
|
||||
// download_list[nowDownload-1].setValue(totalBytes/10);
|
||||
}
|
||||
@ -298,23 +314,27 @@ void Widget::httpFinished() //完成下载
|
||||
file->flush();
|
||||
file->close();
|
||||
reply->deleteLater();
|
||||
reply = 0;
|
||||
reply = nullptr;
|
||||
delete file;
|
||||
file = 0;
|
||||
file = nullptr;
|
||||
isdownload=false;
|
||||
isBusy=false;
|
||||
download_list[nowDownload-1].readyInstall();
|
||||
download_list[nowDownload-1].free=true;
|
||||
if(nowDownload<allDownload){
|
||||
QString fileName=download_list[nowDownload].getName();
|
||||
nowDownload+=1;
|
||||
while (download_list[nowDownload-1].close) {
|
||||
nowDownload+=1;
|
||||
}
|
||||
QString fileName=download_list[nowDownload-1].getName();
|
||||
file = new QFile(fileName);
|
||||
if(!file->open(QIODevice::WriteOnly))
|
||||
{
|
||||
qDebug()<<"file open error";
|
||||
delete file;
|
||||
file = 0;
|
||||
file = nullptr;
|
||||
return ;
|
||||
}
|
||||
nowDownload+=1;
|
||||
startRequest(urList.at(nowDownload-1));
|
||||
}
|
||||
}
|
||||
@ -398,7 +418,7 @@ void Widget::on_webView_loadStarted()
|
||||
ui->label_show->show();
|
||||
}
|
||||
|
||||
void Widget::on_webView_loadFinished(bool arg1)
|
||||
void Widget::on_webView_loadFinished()
|
||||
{
|
||||
ui->label_show->setText("");
|
||||
ui->label_show->hide();
|
||||
|
3
widget.h
3
widget.h
@ -27,7 +27,6 @@ public:
|
||||
int nowDownload=0;
|
||||
int allDownload=0;
|
||||
int isdownload=false;
|
||||
void closeList(int);
|
||||
void loadappinfo(QUrl);
|
||||
void chooseLeftMenu(int index);
|
||||
QPixmap screen[5];
|
||||
@ -74,7 +73,7 @@ private slots:
|
||||
|
||||
void on_webView_loadStarted();
|
||||
|
||||
void on_webView_loadFinished(bool arg1);
|
||||
void on_webView_loadFinished();
|
||||
|
||||
void on_menu_btn_theme_clicked();
|
||||
|
||||
|
14
widget.ui
14
widget.ui
@ -38,7 +38,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
@ -87,7 +87,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color:#FFFFFF</string>
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>当前下载列表为空</string>
|
||||
@ -495,8 +495,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>547</width>
|
||||
<height>130</height>
|
||||
<width>765</width>
|
||||
<height>595</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_23">
|
||||
@ -1147,7 +1147,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>系统管理</string>
|
||||
<string>系统工具</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1247,7 +1247,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<widget class="QWidget" name="line1_widget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@ -1374,7 +1374,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
<widget class="QWidget" name="widget_8" native="true">
|
||||
<widget class="QWidget" name="line2_widget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>1</width>
|
||||
|
Loading…
x
Reference in New Issue
Block a user