This commit is contained in:
gfdgd xi 2024-01-16 22:18:09 +08:00
parent 42516f874a
commit 4a4a75eacd
4 changed files with 109 additions and 25 deletions

@ -16,9 +16,15 @@
#include <QJsonObject>
#include <QFile>
#include <QProcess>
#include <QMessageBox>
#include <QObject>
using namespace std;
QComboBox *MainWindow::e1;
QComboBox *MainWindow::e2;
QComboBox *MainWindow::o1;
QMap<QString, QString> MainWindow::setting;
QMap<QString, QString> MainWindow::wine;
QString MainWindow::lastRunCommand = "";
MainWindow::MainWindow(){
/*********
*
@ -201,22 +207,115 @@ MainWindow::MainWindow(){
}
QObject::connect(button3, &QPushButton::clicked, [&](){
Runexebutton_threading *thread = new Runexebutton_threading();
//QObject::connect(thread, &Runexebutton_threading::signal, this, [this](){});
thread->start();
});
}
void MainWindow::Runexebutton_threading::run(){
QString programPath = QCoreApplication::applicationDirPath();
QString wineBottlePath = "";
if(e1->currentText() == ""){
QString wineBottlePath = setting.value("DefultBotton");
wineBottlePath = setting.value("DefultBotton");
}
else{
QString wineBottlePath = e1->currentText();
wineBottlePath = e1->currentText();
}
QString option = "";
if(setting.value("Architecture") != "Auto"){
QString option = option + "WINEARCH=" + setting.value("Architecture") + " ";
option += "WINEARCH=" + setting.value("Architecture") + " ";
}
if(setting.value("MonoGeckoInstaller") == "1"){
option += "WINEDLLOVERRIDES=\"mscoree,mshtml=\" ";
}
if(setting.value("") != "1"){
option += "WINEDEBUG=-all ";
}
else{
option += "WINEDEBUG=FIXME,ERR,WARN,TRACE,Message ";
}
QString wineUsingOption = "";
QString exePath = e2->currentText();
QStringList fileName = {".exe"};
bool changePath = false;
for(QString i: fileName){
if(exePath.contains(i)){
qDebug() << i;
qDebug() << exePath;
int l = exePath.indexOf(i);
exePath = exePath.mid(0, l + 4) + "' " + exePath.mid(l + 4) + " '";
qDebug() << l;
qDebug() << exePath;
changePath = true;
break;
}
}
if(!changePath && QFile::exists(exePath)){
// 删除前后无用空格以防止出现问题
qDebug() << exePath;
exePath = exePath.trimmed();
// 有空格再说
if(exePath.contains(" ")){
int l = exePath.indexOf(" ");
exePath = exePath.mid(0, l) + "' " + exePath.mid(l) + " '";
qDebug() << l;
}
qDebug() << exePath;
}
if(o1->currentText() == "基于 UOS exagear 的 deepin-wine6-stable" ||
o1->currentText() == "基于 UOS box86 的 deepin-wine6-stable"){
wineUsingOption = "";
}
if(o1->currentText() == "基于 UOS box86 的 deepin-wine6-stable" ||
o1->currentText() == "基于 UOS exagear 的 deepin-wine6-stable"){
if(!QDir(programPath + "/dlls-arm").exists()){
if(system(("7z x -y \"" + programPath + "/dlls-arm.7z\" -o\"" + programPath + "\"").toUtf8())){
QMessageBox::critical(NULL, "错误", "无法解压资源");
return;
}
QFile::remove(programPath + "/dlls-arm.7z");
}
}
//QString runCommand = "";
QString runCommand = "";
QProcess *process = new QProcess();
//if(setting.value("TerminalOpen") == "True"){
if(0){
if(e2->currentText().mid(-4) == ".msi" && QFile::exists(e2->currentText())){
runCommand = "env WINEPREFIX='" + wineBottlePath + "' " + option + wine[o1->currentText()] + " msiexec /i '" + e2->currentText() + "' " + setting.value("WineOption");
// OpenTerminal(runCommand)
}
// ……
}
else{
if(e2->currentText().mid(-4) == ".msi" && QFile::exists(e2->currentText())){
runCommand = "env WINEPREFIX='" + wineBottlePath + "' " + option + wine[o1->currentText()] + " msiexec /i '" + e2->currentText() + "' " + setting.value("WineOption");
}
else if(e2->currentText().mid(-4) == ".bat" && QFile::exists(e2->currentText())){
runCommand = "WINEPREFIX='" + wineBottlePath + "' " + option + wine[o1->currentText()] + " wineconsole '" + e2->currentText() + "' " + setting["WineOption"];
}
else{
runCommand = "WINEPREFIX='" + wineBottlePath + "' " + option + wine[o1->currentText()] + " '" + exePath + "' " + setting["WineOption"];
}
}
// 实时读取程序返回
qDebug() << runCommand;
lastRunCommand = runCommand;
// 连接槽
connect(process, &QProcess::readyReadStandardOutput, this, [this, process](){
//emit this->signal(QString::fromUtf8(process.readAll()));
});
//if(setting.value("TerminalOpen") != "True"){
if(1){
process->setReadChannel(QProcess::StandardOutput);
process->start(runCommand);
process->waitForStarted();
process->waitForFinished();
process->close();
}
// ……
}
void MainWindow::DisableButton(bool things){

@ -32,10 +32,10 @@ private:
};
void runexebutton();
void DisableButton(bool things);
QString lastRunCommand = "";
static QString lastRunCommand;
QString homePath = QDir::homePath();
QString programPath = QCoreApplication::applicationDirPath();
QMap<QString, QString> wine;
static QMap<QString, QString> wine;
QStringList untipsWine = {"使用 Flatpak 安装的 Wine", "基于 exagear 的 deepin-wine6-stable", "基于 UOS box86 的 deepin-wine6-stable", "基于 UOS exagear 的 deepin-wine6-stable", "基于 linglong 的 deepin-wine6-stable不推荐"};
QStringList canUseWine = {};
QStringList qemuBottleList = {};
@ -57,8 +57,8 @@ private:
QPushButton *uninstallProgram;
QPushButton *trasButton;
static QComboBox *e1;
QComboBox *e2;
QComboBox *o1;
static QComboBox *e2;
static QComboBox *o1;
};

@ -14,23 +14,9 @@
<string>MainWindow</string>
</property>
<widget class="QWidget" name="window">
<layout class="QGridLayout" name="gridLayout" rowstretch="2,0" columnstretch="2,0,0">
<layout class="QGridLayout" name="gridLayout" rowstretch="2,0" columnstretch="2,0">
<item row="0" column="0">
<widget class="QWidget" name="leftUp" native="true">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>210</x>
<y>120</y>
<width>106</width>
<height>36</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="leftUp" native="true"/>
</item>
<item row="0" column="1">
<widget class="QTextBrowser" name="returnText">

3
qr.ui

@ -25,8 +25,7 @@
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans CJK SC'; font-size:10.5pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;如果您觉得 Wine 运行器对您有帮助,可以请作者吃点零食&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;(本来想说喝一杯咖啡的,但我不喝啊)&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:11pt;&quot;&gt;如果您觉得 Wine 运行器对你有帮助,可以请作者喝杯茶&lt;/span&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;微信:&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;img src=&quot;:/Icon/QR/Icon/QR/Wechat.png&quot; width=&quot;256&quot; /&gt;&lt;/p&gt;