From a62a9377000aec68a2e8679f8292489029be8a31 Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Sun, 21 Aug 2022 12:53:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=AA=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=89=93=E5=8C=85=E5=99=A8=E5=92=8Cwine?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=B7=A5=E5=85=B7=E7=9A=84=E5=BC=82=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E4=BF=AE=E6=94=B9UI=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deepin-wine-packager.py | 21 +++++++++++++++------ wine-source/downloadthread.cpp | 7 +++++-- wine-source/downloadthread.h | 3 +++ wine-source/mainwindow.cpp | 25 ++++++++++++++++++------- wine-source/mainwindow.h | 7 +++++++ wine/winelist.json | 4 +--- 6 files changed, 49 insertions(+), 18 deletions(-) diff --git a/deepin-wine-packager.py b/deepin-wine-packager.py index 291be50..81cf0a1 100755 --- a/deepin-wine-packager.py +++ b/deepin-wine-packager.py @@ -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"
当前 deb 打包情况:{thing}
") 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): diff --git a/wine-source/downloadthread.cpp b/wine-source/downloadthread.cpp index 6eac8f8..2c67c1c 100644 --- a/wine-source/downloadthread.cpp +++ b/wine-source/downloadthread.cpp @@ -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(); } diff --git a/wine-source/downloadthread.h b/wine-source/downloadthread.h index 79938d0..540ce65 100644 --- a/wine-source/downloadthread.h +++ b/wine-source/downloadthread.h @@ -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 diff --git a/wine-source/mainwindow.cpp b/wine-source/mainwindow.cpp index 553e48e..9c1fd83 100644 --- a/wine-source/mainwindow.cpp +++ b/wine-source/mainwindow.cpp @@ -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; diff --git a/wine-source/mainwindow.h b/wine-source/mainwindow.h index fb8dbb7..956427a 100644 --- a/wine-source/mainwindow.h +++ b/wine-source/mainwindow.h @@ -3,6 +3,7 @@ #include