diff --git a/resources/qml/SettingsDialog/StartPage.qml b/resources/qml/SettingsDialog/StartPage.qml index 708c8cb..a93275c 100644 --- a/resources/qml/SettingsDialog/StartPage.qml +++ b/resources/qml/SettingsDialog/StartPage.qml @@ -55,12 +55,10 @@ Column { width: parent.width height: parentObj.delegateHeight - checked: speedBackend.settings.readSetting(ScStwAppSettings.AppThemeSetting) === "Dark" + checked: appThemeSetting.value === "Dark" onCheckedChanged: { - var newTheme = checked ? "Dark":"Light" - speedBackend.settings.writeSetting(ScStwAppSettings.AppThemeSetting, newTheme) - appTheme.setTheme(newTheme) + appThemeSetting.value = checked ? "Dark":"Light" } } } diff --git a/resources/qml/main.qml b/resources/qml/main.qml index 62842dd..5dd3756 100644 --- a/resources/qml/main.qml +++ b/resources/qml/main.qml @@ -107,6 +107,17 @@ Window { } } + ScStwSetting { + id: appThemeSetting + scStwSettings: speedBackend.settings + key: ScStwAppSettings.AppThemeSetting + keyLevel: ScStwAppSettings.KeyLevel + + onValueChanged: { + appTheme.setTheme(appThemeSetting.value) + } + } + /*------------------------ Timer text an upper line ------------------------*/ diff --git a/shared-libraries b/shared-libraries index 6c1ce8e..ad3f831 160000 --- a/shared-libraries +++ b/shared-libraries @@ -1 +1 @@ -Subproject commit 6c1ce8e65407452ce82f412fdd26d1367bf3ea38 +Subproject commit ad3f8318c709653863058fc234469bd0ff006042 diff --git a/sources/scstwappbackend.cpp b/sources/scstwappbackend.cpp index c53d95d..8abc557 100644 --- a/sources/scstwappbackend.cpp +++ b/sources/scstwappbackend.cpp @@ -215,6 +215,8 @@ void ScStwAppBackend::handleSettingChange(int keyInt, int keyLevel) { return; } + qDebug() << "setting changed: " << keyInt; + switch (keyLevel) { case 0: { // BaseStationSetting!! @@ -223,7 +225,10 @@ void ScStwAppBackend::handleSettingChange(int keyInt, int keyLevel) { case ScStwSettings::BaseStationSetting::InvalidSetting: return; default: - this->reloadRaceSettings(); + if(this->mode == LOCAL) + this->reloadRaceSettings(); + else + emit this->settingsChanged(); return; } break; diff --git a/sources/scstwappsettings.cpp b/sources/scstwappsettings.cpp index 7835652..0ce7b0f 100644 --- a/sources/scstwappsettings.cpp +++ b/sources/scstwappsettings.cpp @@ -29,14 +29,10 @@ QVariant ScStwAppSettings::readSetting(AppInternalSetting key) { } QVariant ScStwAppSettings::readSetting(int key, int keyLevel) { - switch (keyLevel) { - case ScStwAppSettings::KeyLevel: + if(keyLevel == ScStwAppSettings::KeyLevel) return this->readSetting(ScStwAppSettings::AppInternalSetting(key)); - case ScStwSettings::KeyLevel: - return ScStwSettings::readSetting(ScStwSettings::BaseStationSetting(key)); - default: - return QVariant(); - } + else + return ScStwSettings::readSetting(key, keyLevel); } bool ScStwAppSettings::writeSetting(AppInternalSetting key, QVariant value) { @@ -44,14 +40,10 @@ bool ScStwAppSettings::writeSetting(AppInternalSetting key, QVariant value) { } bool ScStwAppSettings::writeSetting(int key, QVariant value, int keyLevel) { - switch (keyLevel) { - case ScStwAppSettings::KeyLevel: + if(keyLevel == ScStwAppSettings::KeyLevel) return this->writeSetting(ScStwAppSettings::AppInternalSetting(key), value); - case ScStwSettings::KeyLevel: - return ScStwSettings::writeSetting(ScStwSettings::BaseStationSetting(key), value); - default: - return false; - } + else + return ScStwSettings::writeSetting(key, value, keyLevel); } void ScStwAppSettings::setDefaultSetting(AppInternalSetting key, QVariant defaultVariant) {