chore:添加更新器调用代码

This commit is contained in:
momen 2025-07-30 16:01:02 +08:00
parent ad675a92dd
commit a061170957

View File

@ -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<int>::of(&QProcess::finished),
[process](int exitCode) {
if (exitCode == 0) {
qDebug() << "Update check successful";
} else {
qWarning() << "Update check failed with exit code:" << exitCode;
}
process->deleteLater();
});
}
}
}