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(); + }); + } + } }