mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 12:52:04 +08:00
添加设置UI
This commit is contained in:
62
gui/page/spkpagesettings.cpp
Normal file
62
gui/page/spkpagesettings.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
#include "spkutils.h"
|
||||
#include "page/spkpagesettings.h"
|
||||
|
||||
namespace SpkUi
|
||||
{
|
||||
SpkPageSettings::SpkPageSettings(QWidget *parent) :
|
||||
SpkPageBase(parent)
|
||||
{
|
||||
mMainArea = new QScrollArea();
|
||||
mMainLay = new QVBoxLayout(this);
|
||||
mSettingsWidget = new QWidget(this);
|
||||
mSettingsUi = new Ui::SpkUiSettings;
|
||||
|
||||
mSettingsUi->setupUi(mSettingsWidget);
|
||||
|
||||
mMainLay->addWidget(mMainArea);
|
||||
|
||||
mMainArea->setWidget(mSettingsWidget);
|
||||
mMainArea->setWidgetResizable(true);
|
||||
|
||||
SetupUi();
|
||||
}
|
||||
|
||||
SpkPageSettings::~SpkPageSettings()
|
||||
{
|
||||
delete mSettingsWidget;
|
||||
}
|
||||
|
||||
void SpkPageSettings::SetupUi()
|
||||
{
|
||||
auto ui = mSettingsUi;
|
||||
|
||||
ui->lblSettingsTitle->setObjectName("styConfTitle");
|
||||
ui->lblCleanup->setObjectName("styConfTitle");
|
||||
ui->lblAdvanced->setObjectName("styConfTitle");
|
||||
}
|
||||
|
||||
void SpkPageSettings::ReadConfiguration()
|
||||
{
|
||||
auto ui = mSettingsUi;
|
||||
|
||||
ui->spnConcurrentResDownloads->setValue(CFG->ReadField("resource/concurrent", 5).toInt());
|
||||
ui->edtApiUrl->setText(CFG->ReadField("url/api", "").toString());
|
||||
ui->edtResourceUrl->setText(CFG->ReadField("url/res", "").toString());
|
||||
ui->edtResourceCachePath->setText(CFG->ReadField("dirs/cache", "").toString());
|
||||
ui->edtDownloadPath->setText(CFG->ReadField("dirs/download", "").toString());
|
||||
ui->edtDownloadServers->setPlainText(CFG->ReadField("download/servers", "").toString());
|
||||
ui->edtQssPath->setText(CFG->ReadField("internal/qss_path", "").toString());
|
||||
}
|
||||
|
||||
void SpkPageSettings::SaveConfiguration()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SpkPageSettings::Activated()
|
||||
{
|
||||
ReadConfiguration();
|
||||
}
|
||||
|
||||
}
|
||||
430
gui/page/ui/settings.ui
Normal file
430
gui/page/ui/settings.ui
Normal file
@@ -0,0 +1,430 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SpkUiSettings</class>
|
||||
<widget class="QWidget" name="SpkUiSettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>501</width>
|
||||
<height>699</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblSettingsTitle">
|
||||
<property name="text">
|
||||
<string>Spark Store Settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="lineTitle">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblRestartHint">
|
||||
<property name="text">
|
||||
<string>Configuration entries marked "*" will only take effect after restarting Spark Store.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="laySettings">
|
||||
<item row="3" column="1">
|
||||
<widget class="QPlainTextEdit" name="edtDownloadServers">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="spkcfg_key" stdset="0">
|
||||
<string notr="true">download/servers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblLightDarkTheme">
|
||||
<property name="text">
|
||||
<string>Light/dark theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="edtDownloadPath">
|
||||
<property name="spkcfg_key" stdset="0">
|
||||
<string notr="true">dirs/download</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cmbLightDarkTheme">
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="spkcfg_key" stdset="0">
|
||||
<string notr="true">gui/theme</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Auto</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Always Light</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Always Dark</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lblApiUrl">
|
||||
<property name="text">
|
||||
<string>Store API URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblAptRepo">
|
||||
<property name="text">
|
||||
<string>APT Repository</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="edtApiUrl">
|
||||
<property name="spkcfg_key" stdset="0">
|
||||
<string>url/api</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lblDownloadServers">
|
||||
<property name="toolTip">
|
||||
<string>Server addresses are separated with two semicolons (;;).</string>
|
||||
</property>
|
||||
<property name="toolTipDuration">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Download servers</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="edtResourceCachePath">
|
||||
<property name="spkcfg_key" stdset="0">
|
||||
<string>dirs/cache</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lblResourceCachePath">
|
||||
<property name="text">
|
||||
<string>Resource cache path*</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblDownloadPath">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="toolTipDuration">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Download path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lblResourceUrl">
|
||||
<property name="text">
|
||||
<string>Store resource URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="edtResourceUrl">
|
||||
<property name="spkcfg_key" stdset="0">
|
||||
<string>url/res</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="layAptRepo">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cmbAptRepo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="spkcfg_key" stdset="0">
|
||||
<string notr="true">pkgmgr/apt_repo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnFetchAptRepo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fetch all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnApplyAptRepo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblHomeNotice">
|
||||
<property name="text">
|
||||
<string>Note: character "*" in paths are replaced with the current user's home path.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblCleanup">
|
||||
<property name="text">
|
||||
<string>Cache and Downloads cleanup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblCleanupDescription">
|
||||
<property name="text">
|
||||
<string>Spark Store caches resources such as app icons and screenshots locally. If you want to free up space, you can clear them here or delete them manually.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="layCleanup">
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="btnCleanDownloadedContent">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="btnViewResourceCache">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>View</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="btnViewDownloadedContent">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>View</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblDownloadedContent">
|
||||
<property name="text">
|
||||
<string>Downloaded content</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblResourceCache">
|
||||
<property name="text">
|
||||
<string>Resource cache</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="btnCleanResourceCache">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblSizeResourceCache">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblSizeDownloadedContent">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblAdvanced">
|
||||
<property name="text">
|
||||
<string>Advanced</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblAdvancedDescription">
|
||||
<property name="text">
|
||||
<string>Advanced settings are low-level configurations that can affect usability and are not meant to be modified by average users.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="layAdvanced">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblConcurrentResDownloads">
|
||||
<property name="text">
|
||||
<string>Concurrent resource downloads*</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spnConcurrentResDownloads">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="spkcfg_key" stdset="0">
|
||||
<string>resource/concurrent</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblQssPath">
|
||||
<property name="text">
|
||||
<string>Default Qt Style Sheet template*</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="edtQssPath">
|
||||
<property name="spkcfg_key" stdset="0">
|
||||
<string>internal/qss_path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -425,7 +425,7 @@ SpkUi::SpkMainWidget::SpkMainWidget(QWidget *parent) : QFrame(parent)
|
||||
BtnSettings->setCheckable(true);
|
||||
BtnSettings->setFixedSize({ 40, 40 });
|
||||
BtnSettings->SetIcon(QIcon(":/icons/settings.svg"), QSize(20, 20));
|
||||
BtnSettings->setProperty("spk_pageno", 0);
|
||||
BtnSettings->setProperty("spk_pageno", PgSettings);
|
||||
SidebarMgr->BindPageSwitcherButton(BtnSettings);
|
||||
|
||||
BtnDayNight = new SpkIconButton(this);
|
||||
@@ -562,6 +562,10 @@ SpkUi::SpkMainWidget::SpkMainWidget(QWidget *parent) : QFrame(parent)
|
||||
PageDownloads->setProperty("spk_pageid", SpkStackedPages::PgDownloads);
|
||||
sorter[PgDownloads] = PageDownloads;
|
||||
|
||||
PageSettings = new SpkUi::SpkPageSettings(this);
|
||||
PageSettings->setProperty("spk_pageid", SpkStackedPages::PgSettings);
|
||||
sorter[PgSettings] = PageSettings;
|
||||
|
||||
#ifndef NDEBUG // If only in debug mode should we initialize QSS test page
|
||||
PageQssTest = new SpkUi::SpkPageUiTest(this);
|
||||
PageQssTest->setProperty("spk_pageid", SpkStackedPages::PgQssTest);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "spkpopup.h"
|
||||
#include "spklogging.h"
|
||||
#include "spkstore.h"
|
||||
#include "spkutils.h"
|
||||
|
||||
namespace SpkUi
|
||||
{
|
||||
@@ -60,7 +61,9 @@ namespace SpkUi
|
||||
{
|
||||
// Obtain global stylesheets
|
||||
QFile ObtainStylesheet;
|
||||
ObtainStylesheet.setFileName(":/stylesheets/stylesheets/mainwindow_dark.css");
|
||||
ObtainStylesheet.setFileName(CFG->ReadField("internal/qss_path",
|
||||
":/stylesheet/stylesheet/default.css")
|
||||
.toString());
|
||||
ObtainStylesheet.open(QIODevice::ReadOnly);
|
||||
StylesheetBase = ObtainStylesheet.readAll();
|
||||
ObtainStylesheet.close();
|
||||
@@ -70,7 +73,7 @@ namespace SpkUi
|
||||
#ifdef NDEBUG
|
||||
SetGlobalStyle(Light, false);
|
||||
#else
|
||||
SetGlobalStyle(qgetenv("SPK_FORCE_DARK").toInt() ? Dark : Light, false);
|
||||
SetGlobalStyle(qEnvironmentVariableIntValue("SPK_FORCE_DARK") ? Dark : Light, false);
|
||||
#endif
|
||||
|
||||
// Initalize crash handler
|
||||
@@ -111,7 +114,7 @@ namespace SpkUi
|
||||
qApp->addLibraryPath("/usr/local/lib");
|
||||
qApp->addLibraryPath("/usr/lib");
|
||||
#endif
|
||||
if(!qgetenv("SPARK_NO_DTK_PLUGIN").toInt())
|
||||
if(!qEnvironmentVariableIntValue("SPARK_NO_DTK_PLUGIN"))
|
||||
{
|
||||
QPluginLoader p("libspkdtkplugin");
|
||||
if(p.load())
|
||||
@@ -121,24 +124,24 @@ namespace SpkUi
|
||||
{
|
||||
DtkPlugin = i;
|
||||
States::IsUsingDtkPlugin = true;
|
||||
|
||||
i->Initialize();
|
||||
|
||||
SpkUiMetaObject.SetAccentColor(i->GetAccentColor()); // Match OS accent color
|
||||
SpkUiMetaObject.SetDarkLightTheme(i->GetIsDarkTheme()); // Match OS dark theme type
|
||||
|
||||
QObject::connect(i, &SpkDtkPlugin::AccentColorChanged,
|
||||
&SpkUiMetaObject, &UiMetaObject::SetAccentColor);
|
||||
QObject::connect(i, &SpkDtkPlugin::DarkLightThemeChanged,
|
||||
&SpkUiMetaObject, &UiMetaObject::SetDarkLightTheme);
|
||||
}
|
||||
|
||||
i->Initialize();
|
||||
|
||||
SpkUiMetaObject.SetAccentColor(i->GetAccentColor()); // Match OS accent color
|
||||
SpkUiMetaObject.SetDarkLightTheme(i->GetIsDarkTheme()); // Match OS dark theme type
|
||||
|
||||
QObject::connect(i, &SpkDtkPlugin::AccentColorChanged,
|
||||
&SpkUiMetaObject, &UiMetaObject::SetAccentColor);
|
||||
QObject::connect(i, &SpkDtkPlugin::DarkLightThemeChanged,
|
||||
&SpkUiMetaObject, &UiMetaObject::SetDarkLightTheme);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Chameleon style kept adding unwanted blue focus indication border
|
||||
// to widgets that shouldn't have borders.
|
||||
// We need to eliminate this irritating problem.
|
||||
if(qgetenv("SPARK_NO_QSTYLE_CHANGE").toInt())
|
||||
if(qEnvironmentVariableIntValue("SPARK_NO_QSTYLE_CHANGE"))
|
||||
return;
|
||||
OldSystemStyle = QStyleFactory::create("chameleon"); // TreeWidget doesn't work well with Fusion
|
||||
auto styles = QStyleFactory::keys();
|
||||
|
||||
Reference in New Issue
Block a user