mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-13 20:32:05 +08:00
fix: 修复配置文件写入位置异常问题
main.cpp 中通过 QStandardPaths 获取配置文件路径,此时未设置组织名称和程序名称,导致路径异常 Log: 1. main.cpp 中提前设置组织名称和程序名称,再读写配置文件 2. main.cpp 中提前检查配置文件所在文件夹是否存在,不存在则创建,再读写配置文件 3. 修复 main.cpp 中修改配置文件后没有写入的问题 4. 去除版本号中重复的 Version 字样(由关于窗口提供) 5. 修复关于窗口中组织图标显示为 deepin 的问题(已去除) 6. 修复 wayland 下窗口设置透明度相关警告(wayland 下禁用透明度动画) 7. 下载列表 wayland 下窗口标题添加翻译
This commit is contained in:
@@ -22,7 +22,7 @@ Application::Application(int &argc, char **argv)
|
||||
loadTranslator(); // 载入翻译
|
||||
|
||||
setOrganizationName("spark-union");
|
||||
setApplicationName("spark-store"); // 影响 ~/.local/share/spark-union 下文件夹名称
|
||||
setApplicationName("spark-store"); // 影响 ~/.config/spark-union ~/.local/share/spark-union 下文件夹名称
|
||||
setApplicationDisplayName(QObject::tr("Spark Store")); // 设置窗口显示标题 (Wayland 下会显示 Qt 原生标题栏)
|
||||
setProductName(QObject::tr("Spark Store"));
|
||||
setProductIcon(QIcon::fromTheme("spark-store"));
|
||||
@@ -53,6 +53,15 @@ void Application::handleAboutAction()
|
||||
DApplication::handleAboutAction();
|
||||
}
|
||||
|
||||
void Application::checkAppConfigLocation()
|
||||
{
|
||||
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
|
||||
if (!dir.exists()) {
|
||||
qWarning() << "AppConfigLocation not existed, creating...";
|
||||
dir.mkpath(dir.absolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
void Application::setVersionAndBuildDateTime(const QString &version, const QString &buildDateTime)
|
||||
{
|
||||
m_version = version;
|
||||
@@ -70,23 +79,16 @@ void Application::setVersionAndBuildDateTime(const QString &version, const QStri
|
||||
setApplicationVersion(DApplication::buildVersion(config.value("build/version").toString() + "-" + "Flamescion" + "-" + config.value("build/time").toString()));
|
||||
}
|
||||
|
||||
void Application::checkAppConfigLocation()
|
||||
{
|
||||
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
|
||||
if (!dir.exists()) {
|
||||
qWarning() << "AppConfigLocation not existed, creating...";
|
||||
dir.mkpath(dir.absolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
void Application::initAboutDialog()
|
||||
{
|
||||
// Customized DAboutDialog
|
||||
// 自定义 DAboutDialog
|
||||
DAboutDialog *dialog = new DAboutDialog(activeWindow());
|
||||
dialog->setProductName(productName());
|
||||
dialog->setProductIcon(productIcon());
|
||||
dialog->setVersion(translate("DAboutDialog", "Version: %1").arg(applicationVersion()));
|
||||
// dialog->setCompanyLogo(QPixmap(":/icon/Logo-Spark.png")); // 根据 shenmo 要求,不显示组织 Logo
|
||||
// 根据 shenmo 要求,不显示组织 Logo
|
||||
// dialog->setCompanyLogo(QPixmap(":/icon/Logo-Spark.png"));
|
||||
dialog->setCompanyLogo(QPixmap());
|
||||
dialog->setWebsiteName(QObject::tr("Spark Project"));
|
||||
dialog->setWebsiteLink(applicationHomePage());
|
||||
dialog->setDescription(applicationDescription());
|
||||
|
||||
@@ -13,10 +13,11 @@ public:
|
||||
Application(int &argc, char **argv);
|
||||
void handleAboutAction() override;
|
||||
|
||||
static void checkAppConfigLocation();
|
||||
|
||||
void setVersionAndBuildDateTime(const QString &version, const QString &buildDateTime);
|
||||
|
||||
private:
|
||||
void checkAppConfigLocation();
|
||||
void initAboutDialog();
|
||||
|
||||
private:
|
||||
|
||||
10
src/main.cpp
10
src/main.cpp
@@ -13,7 +13,7 @@ DWIDGET_USE_NAMESPACE
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Get build time
|
||||
static const QString version = "Version 4.1.2";
|
||||
static const QString version = "4.1.2";
|
||||
static const QDate buildDate = QLocale(QLocale::English).toDate(QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
|
||||
static const QTime buildTime = QTime::fromString(__TIME__, "hh:mm:ss");
|
||||
static const QString buildDateTime = buildDate.toString("yyyy.MM.dd") + "-" + buildTime.toString("hh:mm:ss");
|
||||
@@ -35,15 +35,20 @@ int main(int argc, char *argv[])
|
||||
isWayland = true;
|
||||
}
|
||||
|
||||
// NOTE: 提前设置组织名称和应用名称,避免配置文件位置错误
|
||||
DApplication::setOrganizationName("spark-union");
|
||||
DApplication::setApplicationName("spark-store");
|
||||
Application::checkAppConfigLocation(); // 检查 ~/.config/spark-union/spark-store 文件夹是否存在
|
||||
|
||||
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
||||
config.setValue("build/isWayland", isWayland);
|
||||
config.setValue("build/isDeepinOS", isDeepinOS);
|
||||
|
||||
// Check config file, if there is no wayland config, then set it to default, which means use wayland if possible.
|
||||
if (!config.contains("build/useWayland"))
|
||||
{
|
||||
config.setValue("build/useWayland", true);
|
||||
}
|
||||
config.sync(); // 写入更改至 config.ini,并同步最新内容
|
||||
|
||||
bool useWayland = config.value("build/useWayland").toBool();
|
||||
qDebug() << "System Wayland enabled:" << isWayland << ". Spark Wayland enabled:" << useWayland;
|
||||
@@ -112,7 +117,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
w.show();
|
||||
w.setWindowTitle("Spark Store");
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,13 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
setWindowTitle(QObject::tr("Spark Store"));
|
||||
initConfig();
|
||||
|
||||
WidgetAnimation::widgetOpacity(this, true);
|
||||
// FIXME: wayland 不支持直接设置窗口透明度,需要调用 wayland 相关库(考虑抄控制中心“窗口移动时启用透明特效”代码?)
|
||||
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
||||
bool isWayland = config.value("build/isWayland").toBool();
|
||||
if(!isWayland)
|
||||
{
|
||||
WidgetAnimation::widgetOpacity(this, true);
|
||||
}
|
||||
|
||||
searchEdit = new DSearchEdit(ui->titlebar);
|
||||
downloadlistwidget = new DownloadListWidget;
|
||||
@@ -157,7 +163,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
ly_titlebar->addWidget(backButtom);
|
||||
|
||||
// Check wayland configs
|
||||
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
||||
// QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
||||
if (!config.value("build/isDeepinOS").toBool() && config.value("build/useWayland").toBool())
|
||||
{
|
||||
// Wayland 搜索栏居中
|
||||
|
||||
@@ -207,7 +207,7 @@ void SettingsPage::on_pushButton_clear_clicked()
|
||||
{
|
||||
ui->pushButton_clear->setEnabled(false);
|
||||
|
||||
QDir tmpdir("/tmp/spark-store");
|
||||
QDir tmpdir(QString::fromUtf8(TMP_PATH));
|
||||
tmpdir.setFilter(QDir::Files);
|
||||
int quantity = int(tmpdir.count());
|
||||
for(int i = 0; i < quantity; i++)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "basewidgetopacity.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
BaseWidgetOpacity::BaseWidgetOpacity(QWidget *parent) : DBlurEffectWidget(parent)
|
||||
@@ -12,6 +14,14 @@ BaseWidgetOpacity::BaseWidgetOpacity(QWidget *parent) : DBlurEffectWidget(parent
|
||||
/// @param event
|
||||
void BaseWidgetOpacity::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
// FIXME: wayland 不支持直接设置窗口透明度,需要调用 wayland 相关库(考虑抄控制中心“窗口移动时启用透明特效”代码?)
|
||||
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
||||
bool isWayland = config.value("build/isWayland").toBool();
|
||||
if(isWayland)
|
||||
{
|
||||
return DBlurEffectWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
if (!closeWindowAnimation)
|
||||
{
|
||||
closeWindowAnimation = true;
|
||||
|
||||
@@ -7,7 +7,7 @@ DownloadListWidget::DownloadListWidget(QWidget *parent) : DBlurEffectWidget(pare
|
||||
ui(new Ui::DownloadListWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle("Download list");
|
||||
setWindowTitle(QObject::tr("Download list"));
|
||||
installEventFilter(this);
|
||||
this->setAttribute(Qt::WA_Hover, true);
|
||||
setFocus();
|
||||
|
||||
Reference in New Issue
Block a user