Directly apply configuration

When a configuration option is changed on the settings page, the new configuration is immediately applied. On application quit, the config file is updated as well.
This commit is contained in:
Dimitris Kardarakos 2021-02-17 17:19:23 +02:00
parent 220d3bea3f
commit 8d850b39df
2 changed files with 11 additions and 12 deletions

View File

@ -76,6 +76,8 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty(QStringLiteral("_settings"), &settings);
QObject::connect(&app, &QCoreApplication::aboutToQuit, &settings, &AlligatorSettings::save);
Database::instance();
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));

View File

@ -13,7 +13,6 @@ import org.kde.kirigami 2.12 as Kirigami
Kirigami.ScrollablePage {
title: i18n("Settings")
Kirigami.FormLayout {
Kirigami.Heading {
@ -28,12 +27,16 @@ Kirigami.ScrollablePage {
id: deleteAfterCount
value: _settings.deleteAfterCount
enabled: deleteAfterType.currentIndex !== 0
onValueModified: _settings.deleteAfterCount = value
}
Controls.ComboBox {
id: deleteAfterType
currentIndex: _settings.deleteAfterType
model: [i18n("Never"), i18n("Articles"), i18n("Days"), i18n("Weeks"), i18n("Months")]
onActivated: _settings.deleteAfterType = index
}
}
@ -50,24 +53,18 @@ Kirigami.ScrollablePage {
Kirigami.FormData.label: i18n("Font size:")
from: 6
to: 20
onValueModified: _settings.articleFontSize = value
}
Controls.CheckBox {
id: useSystemFontCheckBox
checked: _settings.articleFontUseSystem
text: i18n("Use system default")
onToggled: _settings.articleFontUseSystem = checked
}
Controls.Button {
text: i18n("Save")
onClicked: {
_settings.deleteAfterCount = deleteAfterCount.value
_settings.deleteAfterType = deleteAfterType.currentIndex
_settings.articleFontSize = articleFontSizeSpinBox.value
_settings.articleFontUseSystem = useSystemFontCheckBox.checked
_settings.save()
pageStack.pop()
}
}
}
}