From 2861b0573b673f73b187abfdf2e82141d3d3936b Mon Sep 17 00:00:00 2001 From: uniartisan Date: Thu, 29 Dec 2022 11:55:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A3=80=E6=B5=8BUOS=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E8=80=85=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 23 ++++++ src/mainwindow-dtk.cpp | 27 ++++++- src/pages/appintopage.cpp | 116 ++++++++++++++++-------------- translations/spark-store_en.ts | 33 +++++---- translations/spark-store_fr.ts | 33 +++++---- translations/spark-store_zh_CN.ts | 35 +++++---- 6 files changed, 169 insertions(+), 98 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index aab3c76..6f8b915 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,8 @@ DCORE_USE_NAMESPACE DWIDGET_USE_NAMESPACE +#define UOSCheckFile "/var/lib/deepin/developer-mode/enabled" + int main(int argc, char *argv[]) { // Get build time @@ -67,6 +69,27 @@ int main(int argc, char *argv[]) qputenv("QT_QPA_PLATFORM", "dxcb"); } + // Check UOS developer mode. + QFile UOSDevelopFile(UOSCheckFile); + if (UOSDevelopFile.exists() && isDeepinOS) + { + config.setValue("UOS/isUOS", true); + QTextStream UOStextStream(&UOSDevelopFile); + QString lineData = UOStextStream.readLine(); + bool devmode = lineData.toInt(); + qDebug() << "UOS Developer Mode Status:" << devmode; + config.setValue("UOS/EnableDeveloperMode", devmode); + } + else + { + if (config.contains("UOS/isUOS")) + { + config.remove("UOS/isUOS"); + config.remove("UOS/EnableDeveloperMode"); + } + } + config.sync(); // 写入更改至 config.ini,并同步最新内容 + // 龙芯机器配置,使得 DApplication 能正确加载 QTWEBENGINE qputenv("DTK_FORCE_RASTER_WIDGETS", "FALSE"); // qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-features=UseModernMediaControls"); diff --git a/src/mainwindow-dtk.cpp b/src/mainwindow-dtk.cpp index 5db6020..87d8a1a 100644 --- a/src/mainwindow-dtk.cpp +++ b/src/mainwindow-dtk.cpp @@ -322,15 +322,36 @@ void MainWindow::updateUi(int now) void MainWindow::on_pushButton_14_clicked() { - QFile upgradeStatus("/tmp/spark-store/upgradeStatus.txt"); - if (!upgradeStatus.exists()) + // Check UOS + QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat); + if (config.contains("UOS/EnableDeveloperMode") && !config.value("UOS/EnableDeveloperMode").toBool()) { + qDebug() << "UOS Developer Mode has not been enabled!"; QtConcurrent::run([=] { auto upgradeP = new QProcess(); + upgradeP->startDetached("zenity", QStringList() << "--info" + << "--text" + << "UOS专业模式未开启,相关功能被禁用" + << "--title" + << "功能禁用提示" + ); + upgradeP->waitForStarted(); + upgradeP->waitForFinished(30); + upgradeP->deleteLater(); }); + } + else + { + QFile upgradeStatus("/tmp/spark-store/upgradeStatus.txt"); + if (!upgradeStatus.exists()) + { + QtConcurrent::run([=] + { + auto upgradeP = new QProcess(); upgradeP->startDetached("/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade.sh", QStringList()); upgradeP->waitForStarted(); upgradeP->waitForFinished(-1); upgradeP->deleteLater(); }); - } + } + } } diff --git a/src/pages/appintopage.cpp b/src/pages/appintopage.cpp index c71ca96..507f2b5 100644 --- a/src/pages/appintopage.cpp +++ b/src/pages/appintopage.cpp @@ -89,81 +89,93 @@ void AppIntoPage::openUrl(QUrl url) ui->d_contributor->setText(info["Contributor"].toString()); ui->label_2->setText(info["More"].toString()); - QProcess isInstall; - bool isInstalled; - bool isUpdated; - QString packagename = info["Pkgname"].toString(); - isInstall.start("dpkg", QStringList() << "-s" << info["Pkgname"].toString()); - qDebug() << info["Pkgname"].toString(); - isInstall.waitForFinished(180*1000); // 默认超时 3 分钟 - int error = QString::fromStdString(isInstall.readAllStandardError().toStdString()).length(); - if(error == 0) + + // Check UOS + QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat); + if (config.contains("UOS/EnableDeveloperMode") && !config.value("UOS/EnableDeveloperMode").toBool()){ + qDebug() << "UOS Developer Mode has not been enabled!"; + ui->downloadButton->setText(tr("Developer Mode Disabled")); + ui->downloadButton->setEnabled(false); + ui->downloadButton->show(); + } + else // 非 UOS 或 UOS 已经开启开发者模式 { - isInstalled = true; + QProcess isInstall; + bool isInstalled; + bool isUpdated; + QString packagename = info["Pkgname"].toString(); + isInstall.start("dpkg", QStringList() << "-s" << info["Pkgname"].toString()); + qDebug() << info["Pkgname"].toString(); + isInstall.waitForFinished(180 * 1000); // 默认超时 3 分钟 + int error = QString::fromStdString(isInstall.readAllStandardError().toStdString()).length(); + if (error == 0) + { + isInstalled = true; - QProcess isUpdate; - isUpdate.start("dpkg-query", QStringList() << "--showformat='${Version}'" - << "--show" << info["Pkgname"].toString()); - isUpdate.waitForFinished(180*1000); // 默认超时 3 分钟 - QString localVersion = isUpdate.readAllStandardOutput(); - localVersion.replace("'", ""); + QProcess isUpdate; + isUpdate.start("dpkg-query", QStringList() << "--showformat='${Version}'" + << "--show" << info["Pkgname"].toString()); + isUpdate.waitForFinished(180 * 1000); // 默认超时 3 分钟 + QString localVersion = isUpdate.readAllStandardOutput(); + localVersion.replace("'", ""); - isUpdate.start("dpkg", QStringList() << "--compare-versions" << localVersion << "ge" << info["Version"].toString()); - isUpdate.waitForFinished(180*1000); // 默认超时 3 分钟 - if(!isUpdate.exitCode()) - { - isUpdated = true; - } - else - { - isUpdated = false; - } + isUpdate.start("dpkg", QStringList() << "--compare-versions" << localVersion << "ge" << info["Version"].toString()); + isUpdate.waitForFinished(180 * 1000); // 默认超时 3 分钟 + if (!isUpdate.exitCode()) + { + isUpdated = true; } else { - isInstalled = false; isUpdated = false; } - - if(isInstalled) - { - if(isUpdated) - { - ui->downloadButton->setText(tr("Reinstall")); - ui->downloadButton->setEnabled(true); - ui->downloadButton->show(); - ui->pushButton_3->show(); } else { - ui->downloadButton->setText(tr("Upgrade")); + isInstalled = false; + isUpdated = false; + } + + if (isInstalled) + { + if (isUpdated) + { + ui->downloadButton->setText(tr("Reinstall")); + ui->downloadButton->setEnabled(true); + ui->downloadButton->show(); + ui->pushButton_3->show(); + } + else + { + ui->downloadButton->setText(tr("Upgrade")); + ui->downloadButton->setEnabled(true); + ui->downloadButton->show(); + ui->pushButton_3->show(); + } + } + else + { + ui->downloadButton->setText(tr("Download")); + isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString()); ui->downloadButton->setEnabled(true); ui->downloadButton->show(); - ui->pushButton_3->show(); } } - else - { - ui->downloadButton->setText(tr("Download")); - isDownloading(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString()); - ui->downloadButton->setEnabled(true); - ui->downloadButton->show(); - } QStringList taglist = info["Tags"].toString().split(";"); QString tmp=info["img_urls"].toString(); - qDebug()< - - + + Download @@ -179,42 +179,47 @@ - - - + + Developer Mode Disabled + + + + + + Reinstall - + Upgrade - - - + + + Install - + Installing - - + + Spark Store - + Uninstall succeeded - + The URL has been copied to the clipboard diff --git a/translations/spark-store_fr.ts b/translations/spark-store_fr.ts index c5b9d98..ede392e 100644 --- a/translations/spark-store_fr.ts +++ b/translations/spark-store_fr.ts @@ -10,8 +10,8 @@ - - + + Download @@ -179,42 +179,47 @@ - - - + + Developer Mode Disabled + + + + + + Reinstall - + Upgrade - - - + + + Install - + Installing - - + + Spark Store - + Uninstall succeeded - + The URL has been copied to the clipboard diff --git a/translations/spark-store_zh_CN.ts b/translations/spark-store_zh_CN.ts index c8753f1..4977927 100644 --- a/translations/spark-store_zh_CN.ts +++ b/translations/spark-store_zh_CN.ts @@ -10,8 +10,8 @@ - - + + Download 下载 @@ -179,42 +179,47 @@ 点击跳转 - - - + + Developer Mode Disabled + 开发者模式未开启 + + + + + Reinstall 重新安装 - + Upgrade 升级 - - - + + + Install 安装 - + Installing 正在安装 - - + + Spark Store 星火应用商店 - + Uninstall succeeded 卸载成功 - + The URL has been copied to the clipboard 链接已复制到剪贴板 @@ -483,7 +488,7 @@ <span style=' font-size:10pt;font-weight:60;'>An appstore powered by community</span><br/><a href='https://www.spark-app.store/'>https://www.spark-app.store</a><br/><span style=' font-size:12pt;'>Spark developers</span> - <span style=' font-size:10pt;font-weight:60;'>一款由社区提供的应用商店</span><br/><a href='https://www.spark-app.store/'>https://www.spark-app.store</a><br/><span style=' font-size:12pt;'>星火计划开发者</span> + <span style=' font-size:10pt;font-weight:60;'>一款由社区提供的应用商店</span><br/><a href='https://www.spark-app.store/'>https://www.spark-app.store</a><br/><span style=' font-size:12pt;'>星火计划开发者</span>