mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 04:42:03 +08:00
跟随
提交者:沫 <jifengshenmo@outlook.com> 修改: downloadlist.cpp 修改: downloadlist.h 修改: downloadlist.ui 新文件: server.list 修改: widget.cpp 修改: widget.h 修改: widget.ui
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user