forked from blue/squawk
basic theme changing
This commit is contained in:
parent
a8a7ce2538
commit
c708c33a92
8 changed files with 108 additions and 4 deletions
|
@ -3,11 +3,19 @@
|
|||
|
||||
Settings::Settings(QWidget* parent):
|
||||
QWidget(parent),
|
||||
m_ui(new Ui::Settings())
|
||||
m_ui(new Ui::Settings()),
|
||||
modifiedSettings()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->list, &QListWidget::currentItemChanged, this, &Settings::onCurrentPageChanged);
|
||||
|
||||
connect(m_ui->General, &PageGeneral::variableModified, this, &Settings::onVariableModified);
|
||||
connect(m_ui->Appearance, &PageAppearance::variableModified, this, &Settings::onVariableModified);
|
||||
|
||||
connect(m_ui->applyButton, &QPushButton::clicked, this, &Settings::apply);
|
||||
connect(m_ui->okButton, &QPushButton::clicked, this, &Settings::confirm);
|
||||
connect(m_ui->cancelButton, &QPushButton::clicked, this, &Settings::close);
|
||||
}
|
||||
|
||||
Settings::~Settings()
|
||||
|
@ -22,3 +30,33 @@ void Settings::onCurrentPageChanged(QListWidgetItem* current)
|
|||
m_ui->content->setCurrentIndex(m_ui->list->currentRow());
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::onVariableModified(const QString& key, const QVariant& value)
|
||||
{
|
||||
modifiedSettings[key] = value;
|
||||
}
|
||||
|
||||
void Settings::apply()
|
||||
{
|
||||
QSettings settings;
|
||||
for (const std::pair<const QString, QVariant>& pair: modifiedSettings) {
|
||||
if (pair.first == "theme") {
|
||||
QString theme = pair.second.toString();
|
||||
if (theme.toLower() == "system") {
|
||||
QApplication::setStyle(Shared::Global::getInstance()->defaultSystemStyle);
|
||||
} else {
|
||||
QApplication::setStyle(theme);
|
||||
}
|
||||
}
|
||||
|
||||
settings.setValue(pair.first, pair.second);
|
||||
}
|
||||
|
||||
modifiedSettings.clear();
|
||||
}
|
||||
|
||||
void Settings::confirm()
|
||||
{
|
||||
apply();
|
||||
close();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue