mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 04:42:03 +08:00
!178 fix: 修复主窗口关闭后,关于窗口没有自动关闭的问题
* 添加 Application 类,继承 DApplication,将 main 函数中设置属性、关于信息等操作移至 Application 构造函数中进行 * 1.1. 添加 setOrganizationName 操作,设置组织名称为 spark-union,与 SWRT 保持一致 * 1.2. 设置组织名称后,QStandardPaths::AppConfigLocation 等路径相应改变,修改所有配置文件和缓存文件路径(server.list/config.ini 等) * 1.3. 关于对话框设置父对象后,对话框背景色受主窗口样式表影响,移动部分控件样式表设置方式与位置 * 修复关于窗口不显示组织 Logo 的问题,补充丢失的资源文件,整理资源文件 * 去除 .pro 文件中无效的更新翻译文件脚本调用,整理 .pro 文件,添加编译时更新 ts 文件脚本调用 * 继续修复偶现关闭客户端时崩溃问题(疑似 aria2c 进程未启动,pid 未初始化为随机值,执行 kill 操作时未判断导致) * 修复进入详情页时焦点默认在分享链接按钮上的问题 * 暂时去除没有意义的 DBus 接口,使用 DGuiApplicationHelper::newProcessInstance 获取新进程的启动参数 * 更新翻译文件,去除已经不存在的翻译
This commit is contained in:
@@ -272,7 +272,8 @@ void AppIntoPage::setTheme(bool dark)
|
||||
{
|
||||
if (dark)
|
||||
{
|
||||
QString frameStyleSheet = "#frame,#frame_2,#frame_3,#frame_4{background-color: #252525;border-radius:14px;border:1px solid rgb(64, 64, 64);}";
|
||||
QString frameStyleSheet ="#frame,#frame_2,#frame_3,#frame_4 {background-color: #252525; border-radius: 14px; border: 1px solid rgb(64, 64, 64);}\
|
||||
QLabel#cardtitle,QLabel#title,QLabel#title_1,QLabel#title_2,QLabel#title_3 {color: #FFFFFF}";
|
||||
ui->frame->setStyleSheet(frameStyleSheet);
|
||||
ui->frame_2->setStyleSheet(frameStyleSheet);
|
||||
ui->frame_3->setStyleSheet(frameStyleSheet);
|
||||
@@ -284,11 +285,10 @@ void AppIntoPage::setTheme(bool dark)
|
||||
ui->icon_4->setPixmap(QPixmap(":/icon/dark/text.svg"));
|
||||
ui->icon_5->setPixmap(QPixmap(":/icon/dark/folder.svg"));
|
||||
ui->icon_6->setPixmap(QPixmap(":/icon/dark/globe.svg"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 亮色模式
|
||||
QString frameStyleSheet = "#frame,#frame_2,#frame_3,#frame_4{background-color: #fbfbfb;border-radius:14px;border:1px solid rgb(229,229,229);}";
|
||||
}else {
|
||||
//亮色模式
|
||||
QString frameStyleSheet ="#frame,#frame_2,#frame_3,#frame_4 {background-color: #fbfbfb; border-radius: 14px; border: 1px solid rgb(229,229,229);}\
|
||||
QLabel#cardtitle,QLabel#title,QLabel#title_1,QLabel#title_2,QLabel#title_3 {color: #000000}";
|
||||
ui->frame->setStyleSheet(frameStyleSheet);
|
||||
ui->frame_2->setStyleSheet(frameStyleSheet);
|
||||
ui->frame_3->setStyleSheet(frameStyleSheet);
|
||||
@@ -336,29 +336,30 @@ void AppIntoPage::on_downloadButton_clicked()
|
||||
void AppIntoPage::on_pushButton_3_clicked()
|
||||
{
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
ui->downloadButton->setEnabled(false);
|
||||
ui->pushButton_3->setEnabled(false);
|
||||
{
|
||||
ui->downloadButton->setEnabled(false);
|
||||
ui->pushButton_3->setEnabled(false);
|
||||
|
||||
QProcess uninstall;
|
||||
uninstall.start("pkexec", QStringList() << "apt" << "purge" << "-y" << info["Pkgname"].toString().toLower());
|
||||
uninstall.waitForFinished(-1);
|
||||
QProcess uninstall;
|
||||
uninstall.start("pkexec", QStringList() << "apt" << "purge" << "-y" << info["Pkgname"].toString().toLower());
|
||||
uninstall.waitForFinished(-1);
|
||||
|
||||
QProcess check;
|
||||
check.start("dpkg", QStringList() << "-s" << info["Pkgname"].toString().toLower());
|
||||
check.waitForFinished(10*1000);
|
||||
QProcess check;
|
||||
check.start("dpkg", QStringList() << "-s" << info["Pkgname"].toString().toLower());
|
||||
check.waitForFinished(10*1000);
|
||||
|
||||
if (check.readAllStandardOutput().isEmpty())
|
||||
{
|
||||
ui->downloadButton->setText(tr("Install"));
|
||||
ui->pushButton_3->hide();
|
||||
if (check.readAllStandardOutput().isEmpty())
|
||||
{
|
||||
ui->downloadButton->setText(tr("Install"));
|
||||
ui->pushButton_3->hide();
|
||||
|
||||
updatesEnabled();
|
||||
Utils::sendNotification("spark-store",tr("Spark Store"),tr("Uninstall succeeded"));
|
||||
}
|
||||
updatesEnabled();
|
||||
Utils::sendNotification("spark-store",tr("Spark Store"),tr("Uninstall succeeded"));
|
||||
}
|
||||
|
||||
ui->downloadButton->setEnabled(true);
|
||||
ui->pushButton_3->setEnabled(true); });
|
||||
ui->downloadButton->setEnabled(true);
|
||||
ui->pushButton_3->setEnabled(true);
|
||||
});
|
||||
}
|
||||
|
||||
void AppIntoPage::on_shareButton_clicked()
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
#include "settingspage.h"
|
||||
#include "ui_settingspage.h"
|
||||
#include "../backend/sparkapi.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QtConcurrent>
|
||||
#include <QDebug>
|
||||
|
||||
#define TMP_PATH "/tmp/spark-store"
|
||||
|
||||
bool SettingsPage::isdownload = false;
|
||||
SettingsPage::SettingsPage(QWidget *parent) : QWidget(parent),
|
||||
ui(new Ui::SettingsPage)
|
||||
|
||||
SettingsPage::SettingsPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::SettingsPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
configCanSave = false;
|
||||
initConfig();
|
||||
}
|
||||
@@ -25,20 +37,22 @@ void SettingsPage::setTheme(bool dark)
|
||||
void SettingsPage::readServerList()
|
||||
{
|
||||
// 读取服务器列表并初始化
|
||||
QFile file(QDir::homePath().toUtf8() + "/.config/spark-store/server.list");
|
||||
QFile file(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/server.list");
|
||||
|
||||
// 判断文件是否存在
|
||||
if (!file.exists())
|
||||
{
|
||||
ui->comboBox_server->addItem("https://d.store.deepinos.org.cn/");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug() << "无法读取server.list";
|
||||
qWarning() << "无法读取 server.list";
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建QTextStream对象
|
||||
// 创建 QTextStream 对象
|
||||
QTextStream textStream(&file);
|
||||
|
||||
QString lineData = textStream.readLine(); // 读取文件的第一行
|
||||
@@ -71,12 +85,12 @@ void SettingsPage::initConfig()
|
||||
readServerList();
|
||||
|
||||
// 读取服务器URL并初始化菜单项的链接
|
||||
QSettings readConfig(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||
if (!readConfig.value("server/choose").toString().isEmpty() && readConfig.value("server/updated").toString() == "TRUE")
|
||||
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
||||
if (!config.value("server/choose").toString().isEmpty() && config.value("server/updated").toBool())
|
||||
{
|
||||
qDebug() << readConfig.value("server/choose").toString();
|
||||
ui->comboBox_server->setCurrentText(readConfig.value("server/choose").toString());
|
||||
SparkAPI::setServerUrl(readConfig.value("server/choose").toString());
|
||||
qDebug() << config.value("server/choose").toString();
|
||||
ui->comboBox_server->setCurrentText(config.value("server/choose").toString());
|
||||
SparkAPI::setServerUrl(config.value("server/choose").toString());
|
||||
}
|
||||
configCanSave = true; // 防止触发保存配置信号
|
||||
}
|
||||
@@ -93,8 +107,8 @@ void SettingsPage::on_pushButton_updateServer_clicked()
|
||||
ui->pushButton_updateServer->setEnabled(false);
|
||||
ui->comboBox_server->clear();
|
||||
|
||||
QFile::remove(QDir::homePath().toUtf8() + "/.config/spark-store/server.list");
|
||||
system("curl -o " + QDir::homePath().toUtf8() + "/.config/spark-store/server.list https://d.store.deepinos.org.cn/store/server-and-mirror.list");
|
||||
QFile::remove(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/server.list");
|
||||
system("curl -o " + QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation).toUtf8() + "/server.list https://d.store.deepinos.org.cn/store/server-and-mirror.list");
|
||||
|
||||
ui->pushButton_updateServer->setEnabled(true);
|
||||
readServerList();
|
||||
@@ -105,14 +119,14 @@ void SettingsPage::on_comboBox_server_currentIndexChanged(const QString &arg1)
|
||||
{
|
||||
SparkAPI::setServerUrl(arg1); // 服务器信息更新
|
||||
qDebug() << arg1;
|
||||
const QString updatedInfo = "TRUE";
|
||||
if (configCanSave)
|
||||
bool updatedInfo = true;
|
||||
if(configCanSave)
|
||||
{
|
||||
// ui->label_setting1->show();
|
||||
QSettings *setConfig = new QSettings(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||
setConfig->setValue("server/choose", arg1);
|
||||
setConfig->setValue("server/updated", updatedInfo);
|
||||
setConfig->deleteLater();
|
||||
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
||||
config.setValue("server/choose", arg1);
|
||||
config.setValue("server/updated", updatedInfo);
|
||||
config.sync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +197,8 @@ void SettingsPage::on_pushButton_updateApt_clicked()
|
||||
emit openUrl(QUrl("spk://store/tools/spark-store"));
|
||||
ui->label_aptserver->setText(tr(""));
|
||||
|
||||
ui->pushButton_updateApt->setEnabled(true); });
|
||||
ui->pushButton_updateApt->setEnabled(true);
|
||||
});
|
||||
}
|
||||
|
||||
void SettingsPage::on_pushButton_clear_clicked()
|
||||
@@ -207,13 +222,15 @@ void SettingsPage::on_pushButton_clear_clicked()
|
||||
void SettingsPage::on_pushButton_clearWebCache_clicked()
|
||||
{
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
QString dataLocal = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
||||
qDebug() << dataLocal;
|
||||
QDir dataDir(dataLocal);
|
||||
{
|
||||
QString localDataLocation = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/QtWebEngine";
|
||||
qDebug() << localDataLocation;
|
||||
QDir dataDir(localDataLocation);
|
||||
dataDir.removeRecursively();
|
||||
dataLocal = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
|
||||
qDebug() << dataLocal;
|
||||
QDir cacheDir(dataLocal);
|
||||
cacheDir.removeRecursively(); });
|
||||
|
||||
QString cacheLocation = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/QtWebEngine";
|
||||
qDebug() << cacheLocation;
|
||||
QDir cacheDir(cacheLocation);
|
||||
cacheDir.removeRecursively();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,14 +2,7 @@
|
||||
#define SETTINGSPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
#include <QtConcurrent>
|
||||
#include "../backend/sparkapi.h"
|
||||
#include "utils/utils.h"
|
||||
#define TMP_PATH "/tmp/spark-store"
|
||||
#include <QUrl>
|
||||
|
||||
namespace Ui {
|
||||
class SettingsPage;
|
||||
|
||||
Reference in New Issue
Block a user