修复未发布版本打包器和wine下载工具的异线程修改UI的问题

This commit is contained in:
gfdgd xi 2022-08-21 12:53:04 +08:00
parent aac498bf7d
commit a62a937700
6 changed files with 49 additions and 18 deletions

View File

@ -105,6 +105,7 @@ def make_deb(build=False):
QT.thread.getSavePath.connect(SavePathGet)
QT.thread.errorMsg.connect(ErrorMsg)
QT.thread.infoMsg.connect(InfoMsg)
QT.thread.disabled_or_NORMAL_all.connect(disabled_or_NORMAL_all)
QT.thread.start()
#thread.start()
@ -113,11 +114,13 @@ def label13_text_change(thing):
label13_text.setText(f"<p align='center'>当前 deb 打包情况:{thing}</p>")
class make_deb_threading(QtCore.QThread):
signal = QtCore.pyqtSignal(str)
label = QtCore.pyqtSignal(str)
getSavePath = QtCore.pyqtSignal(str)
errorMsg = QtCore.pyqtSignal(str)
infoMsg = QtCore.pyqtSignal(str)
disabled_or_NORMAL_all = QtCore.pyqtSignal(bool)
build = False
def __init__(self, build) -> None:
super().__init__()
@ -135,7 +138,6 @@ class make_deb_threading(QtCore.QThread):
self.signal.emit(text)
def run(self):
print("a")
#####################################
# 程序创建的 deb 构建临时文件夹目录树:
# /XXX
@ -180,13 +182,16 @@ class make_deb_threading(QtCore.QThread):
a = "/opt/apps/{}/entries/icons/hicolor/scalable/apps/{}.{}".format(e1_text.text(), e1_text.text(), imms)
if not os.path.exists(e9_text.text()):
self.errorMsg.emit("图标的路径填写错误,无法进行构建 deb 包")
disabled_or_NORMAL_all(True)
self.disabled_or_NORMAL_all.emit(True)
self.label.emit("图标的路径填写错误,无法进行构建 deb 包")
return
if not os.path.exists(e6_text.text()):
print("aa")
self.errorMsg.emit("路径填写错误,无法继续构建 deb 包")
disabled_or_NORMAL_all(True)
print("aaa1")
self.disabled_or_NORMAL_all.emit(True)
self.label.emit("容器路径填写错误,无法进行构建 deb 包")
print("bbb")
return
debInformation = [
{
@ -672,10 +677,12 @@ WINEPREFIX=$BOTTLE $EMU $EMU_ARGS $WINE "$EXE" --disable-gpu &""",
}}
}}'''}
]
print("c")
if os.path.exists(wine[wineVersion.currentText()]):
debInformation[0]["Depends"] = ["deepin-wine-helper (>= 5.1.30-1)",
"spark-dwine-helper (>= 1.6.2)"
][int(chooseWineHelperValue.isChecked())] #+ ["", "libasound2 (>= 1.0.16), libc6 (>= 2.28), libglib2.0-0 (>= 2.12.0), libgphoto2-6 (>= 2.5.10), libgphoto2-port12 (>= 2.5.10), libgstreamer-plugins-base1.0-0 (>= 1.0.0), libgstreamer1.0-0 (>= 1.4.0), liblcms2-2 (>= 2.2+git20110628), libldap-2.4-2 (>= 2.4.7), libmpg123-0 (>= 1.13.7), libopenal1 (>= 1.14), libpcap0.8 (>= 0.9.8), libpulse0 (>= 0.99.1), libudev1 (>= 183), libvkd3d1 (>= 1.0), libx11-6, libxext6, libxml2 (>= 2.9.0), ocl-icd-libopencl1 | libopencl1, udis86, zlib1g (>= 1:1.1.4), libasound2-plugins, libncurses6 | libncurses5 | libncurses, deepin-wine-plugin-virtual\nRecommends: libcapi20-3, libcups2, libdbus-1-3, libfontconfig1, libfreetype6, libglu1-mesa | libglu1, libgnutls30 | libgnutls28 | libgnutls26, libgsm1, libgssapi-krb5-2, libjpeg62-turbo | libjpeg8, libkrb5-3, libodbc1, libosmesa6, libpng16-16 | libpng12-0, libsane | libsane1, libsdl2-2.0-0, libtiff5, libv4l-0, libxcomposite1, libxcursor1, libxfixes3, libxi6, libxinerama1, libxrandr2, libxrender1, libxslt1.1, libxxf86vm1"][]
print("d")
debInformation[0]["run.sh"] = f'''#!/bin/sh
# Copyright (C) 2016 Deepin, Inc.
@ -744,6 +751,7 @@ else
$START_SHELL_PATH $BOTTLENAME $APPVER "uninstaller.exe" "$@"
fi
'''
#############
# 删除文件
#############
@ -752,7 +760,7 @@ fi
global savePath
self.getSavePath.emit("")
if savePath == "":
disabled_or_NORMAL_all(False)
self.disabled_or_NORMAL_all.emit(False)
return
debPackagePath = savePath
else:
@ -804,6 +812,7 @@ fi
###############
# 压缩 Wine
###############
print("e")
self.label.emit("正在处理 Wine")
if os.path.exists(wine[wineVersion.currentText()]):
if wine[wineVersion.currentText()][-3:] == ".7z":
@ -885,14 +894,14 @@ Description: {e3_text.text()}
# 完成构建
################
self.label.emit("完成构建!")
disabled_or_NORMAL_all(True)
self.disabled_or_NORMAL_all.emit(True)
self.infoMsg.emit(widget, "提示", "打包完毕!")
except:
traceback.print_exc()
self.errorMsg.emit("程序出现错误,错误信息:\n{}".format(traceback.format_exc()))
self.label.emit("deb 包构建出现错误")
self.signal.emit(traceback.format_exc())
disabled_or_NORMAL_all(True)
self.disabled_or_NORMAL_all.emit(True)
# 写入文本文档
def write_txt(path, things):

View File

@ -72,8 +72,9 @@ void DownloadThread::run(){
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
connect(reply, &QNetworkReply::downloadProgress, [=, &f, &t](qint64 bytesRead, qint64 totalBytes){
f.write(reply->readAll());
dialog->setValue((float)bytesRead / totalBytes * 100);
dialog->setLabelText(QString::number(bytesRead / 1024 / 1024) + "MB/" + QString::number(totalBytes / 1024 / 1024) + "MB在下载/安装时不要乱点程序、拖动程序,否则容易闪退)");
emit ChangeDialog(dialog, (float)bytesRead / totalBytes * 100, bytesRead / 1024 / 1024, totalBytes / 1024 / 1024);
//dialog->setValue();
//dialog->setLabelText(QString::number(bytesRead / 1024 / 1024) + "MB/" + QString::number(totalBytes / 1024 / 1024) + "MB在下载/安装时不要乱点程序、拖动程序,否则容易闪退)");
if(t.isActive()){
t.start(timeout);
}
@ -84,6 +85,7 @@ void DownloadThread::run(){
}
loop.exec();
if(reply->error() != QNetworkReply::NoError){
qDebug() << "b";
emit MessageBoxError("下载失败");
f.close();
delete reply;
@ -129,4 +131,5 @@ void DownloadThread::run(){
process.start(QCoreApplication::applicationDirPath() + "/../launch.sh", command);
process.waitForFinished();
delete reply;
emit Finish();
}

View File

@ -12,6 +12,7 @@
class DownloadThread : public QThread // 继承 QThread
{
Q_OBJECT
public:
DownloadThread(QProgressDialog *dialog, QString url, QString save, QString fileName, QListView *view, bool deleteZip, bool unzip, QJsonArray *localList);
void SettingVirtualMachine(QString savePath);
@ -32,6 +33,8 @@ signals:
// 防止非主线程刷新控件导致程序退出
void MessageBoxInfo(QString info);
void MessageBoxError(QString info);
void ChangeDialog(QProgressDialog *dialog, int value, int downloadBytes, int totalBytes);
void Finish();
};
#endif // DOWNLOADTHREAD_H

View File

@ -36,7 +36,19 @@ MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::MessageBoxInfo(QString info){
QMessageBox::information(this, "提示", info);
}
void MainWindow::MessageBoxError(QString info){
QMessageBox::critical(this, "错误", info);
}
void MainWindow::ChangeDialog(QProgressDialog *dialog, int value, int downloadBytes, int totalBytes){
dialog->setValue(value);
dialog->setLabelText(QString::number(downloadBytes) + "MB/" + QString::number(totalBytes) + "MB");
}
void MainWindow::DownloadFinish(){
ui->centralWidget->setEnabled(true);
}
void MainWindow::on_addButton_clicked()
{
// 获取下载链接
@ -76,14 +88,13 @@ void MainWindow::on_addButton_clicked()
!ui->unzip->isChecked(),
&localJsonList
);
connect(thread, &DownloadThread::MessageBoxInfo, this, &MainWindow::MessageBoxInfo);
connect(thread, &DownloadThread::MessageBoxError, this, &MainWindow::MessageBoxError);
connect(thread, &DownloadThread::ChangeDialog, this, &MainWindow::ChangeDialog);
connect(thread, &DownloadThread::Finish, this, &MainWindow::DownloadFinish);
ui->centralWidget->setDisabled(true);
thread->start();
}
void DownloadThread::MessageBoxInfo(QString info){
QMessageBox::information(NULL, "提示", info);
}
void DownloadThread::MessageBoxError(QString info){
QMessageBox::critical(NULL, "错误", info);
}
void MainWindow::ReadInternetInformation(){
// 我们采用最简单的 curl 来获取信息
QProcess internet;

View File

@ -3,6 +3,7 @@
#include <QMainWindow>
#include <QJsonArray>
#include <QProgressDialog>
namespace Ui {
class MainWindow;
@ -26,6 +27,12 @@ private slots:
void on_delButton_clicked();
public slots:
void MessageBoxInfo(QString info);
void MessageBoxError(QString info);
void ChangeDialog(QProgressDialog *dialog, int value, int downloadBytes, int totalBytes);
void DownloadFinish();
private:
Ui::MainWindow *ui;
};

View File

@ -1,3 +1 @@
[
"deepin-wine5-stable"
]
[]