mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-12 08:32:21 +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:
parent
f99c0839dd
commit
dca80a3fbb
@ -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();
|
||||
|
@ -240,7 +240,7 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/application.cpp" line="93"/>
|
||||
<location filename="../src/application.cpp" line="95"/>
|
||||
<source>%1 is released under %2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@ -441,32 +441,32 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="38"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="44"/>
|
||||
<source>Submit App</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="39"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="45"/>
|
||||
<source>Submit App with client(Recommanded)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="40"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="46"/>
|
||||
<source>Settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="41"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="47"/>
|
||||
<source>APP Upgrade and Install Settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="154"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="160"/>
|
||||
<source>Spark Store</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="155"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="161"/>
|
||||
<source>Search or enter spk://</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@ -486,10 +486,15 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/application.cpp" line="90"/>
|
||||
<location filename="../src/application.cpp" line="92"/>
|
||||
<source>Spark Project</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/widgets/downloadlistwidget.cpp" line="10"/>
|
||||
<source>Download list</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsPage</name>
|
||||
@ -579,17 +584,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/pages/settingspage.cpp" line="196"/>
|
||||
<location filename="../src/pages/settingspage.cpp" line="195"/>
|
||||
<source>Updating, please wait...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/pages/settingspage.cpp" line="218"/>
|
||||
<location filename="../src/pages/settingspage.cpp" line="217"/>
|
||||
<source>Spark Store</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/pages/settingspage.cpp" line="218"/>
|
||||
<location filename="../src/pages/settingspage.cpp" line="217"/>
|
||||
<source>Temporary cache was cleaned</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -240,7 +240,7 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/application.cpp" line="93"/>
|
||||
<location filename="../src/application.cpp" line="95"/>
|
||||
<source>%1 is released under %2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@ -441,32 +441,32 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="38"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="44"/>
|
||||
<source>Submit App</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="39"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="45"/>
|
||||
<source>Submit App with client(Recommanded)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="40"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="46"/>
|
||||
<source>Settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="41"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="47"/>
|
||||
<source>APP Upgrade and Install Settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="154"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="160"/>
|
||||
<source>Spark Store</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="155"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="161"/>
|
||||
<source>Search or enter spk://</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@ -486,10 +486,15 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/application.cpp" line="90"/>
|
||||
<location filename="../src/application.cpp" line="92"/>
|
||||
<source>Spark Project</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/widgets/downloadlistwidget.cpp" line="10"/>
|
||||
<source>Download list</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsPage</name>
|
||||
@ -579,17 +584,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/pages/settingspage.cpp" line="196"/>
|
||||
<location filename="../src/pages/settingspage.cpp" line="195"/>
|
||||
<source>Updating, please wait...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/pages/settingspage.cpp" line="218"/>
|
||||
<location filename="../src/pages/settingspage.cpp" line="217"/>
|
||||
<source>Spark Store</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/pages/settingspage.cpp" line="218"/>
|
||||
<location filename="../src/pages/settingspage.cpp" line="217"/>
|
||||
<source>Temporary cache was cleaned</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -240,7 +240,7 @@
|
||||
<translation>版本:%1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/application.cpp" line="93"/>
|
||||
<location filename="../src/application.cpp" line="95"/>
|
||||
<source>%1 is released under %2</source>
|
||||
<translation>%1遵循%2协议发布</translation>
|
||||
</message>
|
||||
@ -441,32 +441,32 @@
|
||||
<translation>更新</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="38"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="44"/>
|
||||
<source>Submit App</source>
|
||||
<translation>投递应用</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="39"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="45"/>
|
||||
<source>Submit App with client(Recommanded)</source>
|
||||
<translation>使用本地投稿器投递应用(推荐)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="40"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="46"/>
|
||||
<source>Settings</source>
|
||||
<translation>设置</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="41"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="47"/>
|
||||
<source>APP Upgrade and Install Settings</source>
|
||||
<translation>应用更新和安装设置</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="154"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="160"/>
|
||||
<source>Spark Store</source>
|
||||
<translation>星火应用商店</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="155"/>
|
||||
<location filename="../src/mainwindow-dtk.cpp" line="161"/>
|
||||
<source>Search or enter spk://</source>
|
||||
<translation>搜索或打开链接</translation>
|
||||
</message>
|
||||
@ -486,10 +486,15 @@
|
||||
<translation><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></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/application.cpp" line="90"/>
|
||||
<location filename="../src/application.cpp" line="92"/>
|
||||
<source>Spark Project</source>
|
||||
<translation>星火计划</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/widgets/downloadlistwidget.cpp" line="10"/>
|
||||
<source>Download list</source>
|
||||
<translation>下载列表</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsPage</name>
|
||||
@ -579,17 +584,17 @@
|
||||
<translation><html><head/><body><p>我们并<span style=" font-weight:600;">不是</span>官方团队,和你一样,我们也只是众多Linux/deepin系统爱好者和用户之中的一员,我们开发并且运营这个“Spark应用商店”,是为了让社区的朋友们一起分享好用的软件,或者一起参与开发,让大家都用到最新的,最优秀的软件。</p><p>我们并没有因此盈利,所有开发和维护人员都不会获得报酬,我们的主要支出大部分依赖于社区对我们的捐助,很感谢大家,这部分捐助让我们并不需要耗费太多精力去担心资金问题。</p><p>我们的服务和开发的软件都是免费供给大家使用,交流,学习的,但是在您的使用过程中一定要遵守当地的法律法规,否则出现任何问题和我们无关。</p><p>如果商店中任何一部分有侵犯您权益的行为,请告知我们 &lt;jifengshenmo@outlook.com&gt; ,我们会第一时间删除侵权内容。</p><p>如果你也想参与我们,不管是参与开发,设计,投递还是投稿作品,我们都欢迎你的加入。</p><p>在 Spark IM 联系我们:<a href="https://chat.shenmo.tech"><span style=" text-decoration: underline; color:#0000ff;">https://chat.shenmo.tech<br/></span></a>QQ 群:872690351</p></body></html></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/pages/settingspage.cpp" line="196"/>
|
||||
<location filename="../src/pages/settingspage.cpp" line="195"/>
|
||||
<source>Updating, please wait...</source>
|
||||
<translation>正在更新,请稍候……</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/pages/settingspage.cpp" line="218"/>
|
||||
<location filename="../src/pages/settingspage.cpp" line="217"/>
|
||||
<source>Spark Store</source>
|
||||
<translation>星火应用商店</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/pages/settingspage.cpp" line="218"/>
|
||||
<location filename="../src/pages/settingspage.cpp" line="217"/>
|
||||
<source>Temporary cache was cleaned</source>
|
||||
<translation>缓存目录已清空</translation>
|
||||
</message>
|
||||
|
Loading…
x
Reference in New Issue
Block a user