started to make settings notifiable in qml

This commit is contained in:
Dorian Zedler 2020-07-11 11:52:09 +02:00
parent 827acf8404
commit 342dde38ad
Signed by: dorian
GPG key ID: D3B255CB8BC7CD37
5 changed files with 26 additions and 20 deletions

View file

@ -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"
}
}
}

View file

@ -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
------------------------*/

@ -1 +1 @@
Subproject commit 6c1ce8e65407452ce82f412fdd26d1367bf3ea38
Subproject commit ad3f8318c709653863058fc234469bd0ff006042

View file

@ -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;

View file

@ -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) {