From a061170957423449956891a97bfffbe92a46e131 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 30 Jul 2025 16:01:02 +0800 Subject: [PATCH] =?UTF-8?q?chore:=E6=B7=BB=E5=8A=A0=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=99=A8=E8=B0=83=E7=94=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow-dtk.cpp | 69 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/src/mainwindow-dtk.cpp b/src/mainwindow-dtk.cpp index da4b575..96d8dab 100755 --- a/src/mainwindow-dtk.cpp +++ b/src/mainwindow-dtk.cpp @@ -522,5 +522,72 @@ void MainWindow::notify(QObject *receiver, QEvent *event) void MainWindow::on_pushButton_14_clicked() { - + /** + * NOTE: No need to judget developmode status + */ + // Check UOS + // QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat); + // if (config.contains("UOS/EnableDeveloperMode") && !config.value("UOS/EnableDeveloperMode").toBool()) + if (false) + { + qDebug() << "UOS Developer Mode has not been enabled!"; + QtConcurrent::run([=] + { + auto upgradeP = new QProcess(); + upgradeP->startDetached("zenity", QStringList() << "--info" + << "--text" + << "UOS开发者模式未开启,相关功能被禁用" + << "--title" + << "功能禁用提示" + << "--width" + << "360" + ); + upgradeP->waitForStarted(); + upgradeP->waitForFinished(30); + upgradeP->deleteLater(); }); + } + else + { + QFile upgradeStatus("/tmp/spark-store/upgradeStatus.txt"); + if (!upgradeStatus.exists()) + { + QString appPath; + + // 判断路径:开发环境 vs 安装后 + #ifdef QT_DEBUG + appPath = QCoreApplication::applicationDirPath() + + "/spark-update-tool/spark-update-tool"; + #else + appPath = QStandardPaths::findExecutable("spark-update-tool"); + #endif + + if (appPath.isEmpty()) { + qWarning() << "spark-update-tool not found!"; + return; + } + + QProcess *process = new QProcess(this); + + #ifdef QT_DEBUG + // 开发模式:直接运行本地构建的更新器 + process->start(appPath, {"--silent"}); + #else + // 安装模式:使用 pkexec 提权运行系统路径下的 spark-update-tool + QString program = "pkexec"; + QStringList arguments; + arguments << appPath << "--silent"; + process->start(program, arguments); + #endif + + QObject::connect(process, QOverload::of(&QProcess::finished), + [process](int exitCode) { + if (exitCode == 0) { + qDebug() << "Update check successful"; + } else { + qWarning() << "Update check failed with exit code:" << exitCode; + } + process->deleteLater(); + }); + } + } }