mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-01-13 10:08:28 +08:00
修复未发布版本打包器和wine下载工具的异线程修改UI的问题
This commit is contained in:
parent
aac498bf7d
commit
a62a937700
@ -105,6 +105,7 @@ def make_deb(build=False):
|
|||||||
QT.thread.getSavePath.connect(SavePathGet)
|
QT.thread.getSavePath.connect(SavePathGet)
|
||||||
QT.thread.errorMsg.connect(ErrorMsg)
|
QT.thread.errorMsg.connect(ErrorMsg)
|
||||||
QT.thread.infoMsg.connect(InfoMsg)
|
QT.thread.infoMsg.connect(InfoMsg)
|
||||||
|
QT.thread.disabled_or_NORMAL_all.connect(disabled_or_NORMAL_all)
|
||||||
QT.thread.start()
|
QT.thread.start()
|
||||||
#thread.start()
|
#thread.start()
|
||||||
|
|
||||||
@ -113,11 +114,13 @@ def label13_text_change(thing):
|
|||||||
label13_text.setText(f"<p align='center'>当前 deb 打包情况:{thing}</p>")
|
label13_text.setText(f"<p align='center'>当前 deb 打包情况:{thing}</p>")
|
||||||
|
|
||||||
class make_deb_threading(QtCore.QThread):
|
class make_deb_threading(QtCore.QThread):
|
||||||
|
|
||||||
signal = QtCore.pyqtSignal(str)
|
signal = QtCore.pyqtSignal(str)
|
||||||
label = QtCore.pyqtSignal(str)
|
label = QtCore.pyqtSignal(str)
|
||||||
getSavePath = QtCore.pyqtSignal(str)
|
getSavePath = QtCore.pyqtSignal(str)
|
||||||
errorMsg = QtCore.pyqtSignal(str)
|
errorMsg = QtCore.pyqtSignal(str)
|
||||||
infoMsg = QtCore.pyqtSignal(str)
|
infoMsg = QtCore.pyqtSignal(str)
|
||||||
|
disabled_or_NORMAL_all = QtCore.pyqtSignal(bool)
|
||||||
build = False
|
build = False
|
||||||
def __init__(self, build) -> None:
|
def __init__(self, build) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -135,7 +138,6 @@ class make_deb_threading(QtCore.QThread):
|
|||||||
self.signal.emit(text)
|
self.signal.emit(text)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
print("a")
|
|
||||||
#####################################
|
#####################################
|
||||||
# 程序创建的 deb 构建临时文件夹目录树:
|
# 程序创建的 deb 构建临时文件夹目录树:
|
||||||
# /XXX
|
# /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)
|
a = "/opt/apps/{}/entries/icons/hicolor/scalable/apps/{}.{}".format(e1_text.text(), e1_text.text(), imms)
|
||||||
if not os.path.exists(e9_text.text()):
|
if not os.path.exists(e9_text.text()):
|
||||||
self.errorMsg.emit("图标的路径填写错误,无法进行构建 deb 包")
|
self.errorMsg.emit("图标的路径填写错误,无法进行构建 deb 包")
|
||||||
disabled_or_NORMAL_all(True)
|
self.disabled_or_NORMAL_all.emit(True)
|
||||||
self.label.emit("图标的路径填写错误,无法进行构建 deb 包")
|
self.label.emit("图标的路径填写错误,无法进行构建 deb 包")
|
||||||
return
|
return
|
||||||
if not os.path.exists(e6_text.text()):
|
if not os.path.exists(e6_text.text()):
|
||||||
|
print("aa")
|
||||||
self.errorMsg.emit("路径填写错误,无法继续构建 deb 包")
|
self.errorMsg.emit("路径填写错误,无法继续构建 deb 包")
|
||||||
disabled_or_NORMAL_all(True)
|
print("aaa1")
|
||||||
|
self.disabled_or_NORMAL_all.emit(True)
|
||||||
self.label.emit("容器路径填写错误,无法进行构建 deb 包")
|
self.label.emit("容器路径填写错误,无法进行构建 deb 包")
|
||||||
|
print("bbb")
|
||||||
return
|
return
|
||||||
debInformation = [
|
debInformation = [
|
||||||
{
|
{
|
||||||
@ -672,10 +677,12 @@ WINEPREFIX=$BOTTLE $EMU $EMU_ARGS $WINE "$EXE" --disable-gpu &""",
|
|||||||
}}
|
}}
|
||||||
}}'''}
|
}}'''}
|
||||||
]
|
]
|
||||||
|
print("c")
|
||||||
if os.path.exists(wine[wineVersion.currentText()]):
|
if os.path.exists(wine[wineVersion.currentText()]):
|
||||||
debInformation[0]["Depends"] = ["deepin-wine-helper (>= 5.1.30-1)",
|
debInformation[0]["Depends"] = ["deepin-wine-helper (>= 5.1.30-1)",
|
||||||
"spark-dwine-helper (>= 1.6.2)"
|
"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"][]
|
][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
|
debInformation[0]["run.sh"] = f'''#!/bin/sh
|
||||||
|
|
||||||
# Copyright (C) 2016 Deepin, Inc.
|
# Copyright (C) 2016 Deepin, Inc.
|
||||||
@ -744,6 +751,7 @@ else
|
|||||||
$START_SHELL_PATH $BOTTLENAME $APPVER "uninstaller.exe" "$@"
|
$START_SHELL_PATH $BOTTLENAME $APPVER "uninstaller.exe" "$@"
|
||||||
fi
|
fi
|
||||||
'''
|
'''
|
||||||
|
|
||||||
#############
|
#############
|
||||||
# 删除文件
|
# 删除文件
|
||||||
#############
|
#############
|
||||||
@ -752,7 +760,7 @@ fi
|
|||||||
global savePath
|
global savePath
|
||||||
self.getSavePath.emit("")
|
self.getSavePath.emit("")
|
||||||
if savePath == "":
|
if savePath == "":
|
||||||
disabled_or_NORMAL_all(False)
|
self.disabled_or_NORMAL_all.emit(False)
|
||||||
return
|
return
|
||||||
debPackagePath = savePath
|
debPackagePath = savePath
|
||||||
else:
|
else:
|
||||||
@ -804,6 +812,7 @@ fi
|
|||||||
###############
|
###############
|
||||||
# 压缩 Wine
|
# 压缩 Wine
|
||||||
###############
|
###############
|
||||||
|
print("e")
|
||||||
self.label.emit("正在处理 Wine")
|
self.label.emit("正在处理 Wine")
|
||||||
if os.path.exists(wine[wineVersion.currentText()]):
|
if os.path.exists(wine[wineVersion.currentText()]):
|
||||||
if wine[wineVersion.currentText()][-3:] == ".7z":
|
if wine[wineVersion.currentText()][-3:] == ".7z":
|
||||||
@ -885,14 +894,14 @@ Description: {e3_text.text()}
|
|||||||
# 完成构建
|
# 完成构建
|
||||||
################
|
################
|
||||||
self.label.emit("完成构建!")
|
self.label.emit("完成构建!")
|
||||||
disabled_or_NORMAL_all(True)
|
self.disabled_or_NORMAL_all.emit(True)
|
||||||
self.infoMsg.emit(widget, "提示", "打包完毕!")
|
self.infoMsg.emit(widget, "提示", "打包完毕!")
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
self.errorMsg.emit("程序出现错误,错误信息:\n{}".format(traceback.format_exc()))
|
self.errorMsg.emit("程序出现错误,错误信息:\n{}".format(traceback.format_exc()))
|
||||||
self.label.emit("deb 包构建出现错误")
|
self.label.emit("deb 包构建出现错误")
|
||||||
self.signal.emit(traceback.format_exc())
|
self.signal.emit(traceback.format_exc())
|
||||||
disabled_or_NORMAL_all(True)
|
self.disabled_or_NORMAL_all.emit(True)
|
||||||
|
|
||||||
# 写入文本文档
|
# 写入文本文档
|
||||||
def write_txt(path, things):
|
def write_txt(path, things):
|
||||||
|
@ -72,8 +72,9 @@ void DownloadThread::run(){
|
|||||||
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
||||||
connect(reply, &QNetworkReply::downloadProgress, [=, &f, &t](qint64 bytesRead, qint64 totalBytes){
|
connect(reply, &QNetworkReply::downloadProgress, [=, &f, &t](qint64 bytesRead, qint64 totalBytes){
|
||||||
f.write(reply->readAll());
|
f.write(reply->readAll());
|
||||||
dialog->setValue((float)bytesRead / totalBytes * 100);
|
emit ChangeDialog(dialog, (float)bytesRead / totalBytes * 100, bytesRead / 1024 / 1024, totalBytes / 1024 / 1024);
|
||||||
dialog->setLabelText(QString::number(bytesRead / 1024 / 1024) + "MB/" + QString::number(totalBytes / 1024 / 1024) + "MB(在下载/安装时不要乱点程序、拖动程序,否则容易闪退)");
|
//dialog->setValue();
|
||||||
|
//dialog->setLabelText(QString::number(bytesRead / 1024 / 1024) + "MB/" + QString::number(totalBytes / 1024 / 1024) + "MB(在下载/安装时不要乱点程序、拖动程序,否则容易闪退)");
|
||||||
if(t.isActive()){
|
if(t.isActive()){
|
||||||
t.start(timeout);
|
t.start(timeout);
|
||||||
}
|
}
|
||||||
@ -84,6 +85,7 @@ void DownloadThread::run(){
|
|||||||
}
|
}
|
||||||
loop.exec();
|
loop.exec();
|
||||||
if(reply->error() != QNetworkReply::NoError){
|
if(reply->error() != QNetworkReply::NoError){
|
||||||
|
qDebug() << "b";
|
||||||
emit MessageBoxError("下载失败");
|
emit MessageBoxError("下载失败");
|
||||||
f.close();
|
f.close();
|
||||||
delete reply;
|
delete reply;
|
||||||
@ -129,4 +131,5 @@ void DownloadThread::run(){
|
|||||||
process.start(QCoreApplication::applicationDirPath() + "/../launch.sh", command);
|
process.start(QCoreApplication::applicationDirPath() + "/../launch.sh", command);
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
delete reply;
|
delete reply;
|
||||||
|
emit Finish();
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
class DownloadThread : public QThread // 继承 QThread
|
class DownloadThread : public QThread // 继承 QThread
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DownloadThread(QProgressDialog *dialog, QString url, QString save, QString fileName, QListView *view, bool deleteZip, bool unzip, QJsonArray *localList);
|
DownloadThread(QProgressDialog *dialog, QString url, QString save, QString fileName, QListView *view, bool deleteZip, bool unzip, QJsonArray *localList);
|
||||||
void SettingVirtualMachine(QString savePath);
|
void SettingVirtualMachine(QString savePath);
|
||||||
@ -32,6 +33,8 @@ signals:
|
|||||||
// 防止非主线程刷新控件导致程序退出
|
// 防止非主线程刷新控件导致程序退出
|
||||||
void MessageBoxInfo(QString info);
|
void MessageBoxInfo(QString info);
|
||||||
void MessageBoxError(QString info);
|
void MessageBoxError(QString info);
|
||||||
|
void ChangeDialog(QProgressDialog *dialog, int value, int downloadBytes, int totalBytes);
|
||||||
|
void Finish();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DOWNLOADTHREAD_H
|
#endif // DOWNLOADTHREAD_H
|
||||||
|
@ -36,7 +36,19 @@ MainWindow::~MainWindow()
|
|||||||
{
|
{
|
||||||
delete ui;
|
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()
|
void MainWindow::on_addButton_clicked()
|
||||||
{
|
{
|
||||||
// 获取下载链接
|
// 获取下载链接
|
||||||
@ -76,14 +88,13 @@ void MainWindow::on_addButton_clicked()
|
|||||||
!ui->unzip->isChecked(),
|
!ui->unzip->isChecked(),
|
||||||
&localJsonList
|
&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();
|
thread->start();
|
||||||
}
|
}
|
||||||
void DownloadThread::MessageBoxInfo(QString info){
|
|
||||||
QMessageBox::information(NULL, "提示", info);
|
|
||||||
}
|
|
||||||
void DownloadThread::MessageBoxError(QString info){
|
|
||||||
QMessageBox::critical(NULL, "错误", info);
|
|
||||||
}
|
|
||||||
void MainWindow::ReadInternetInformation(){
|
void MainWindow::ReadInternetInformation(){
|
||||||
// 我们采用最简单的 curl 来获取信息
|
// 我们采用最简单的 curl 来获取信息
|
||||||
QProcess internet;
|
QProcess internet;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
@ -26,6 +27,12 @@ private slots:
|
|||||||
|
|
||||||
void on_delButton_clicked();
|
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:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1 @@
|
|||||||
[
|
[]
|
||||||
"deepin-wine5-stable"
|
|
||||||
]
|
|
Loading…
Reference in New Issue
Block a user