started to make settings notifiable in qml
This commit is contained in:
parent
827acf8404
commit
342dde38ad
5 changed files with 26 additions and 20 deletions
|
@ -55,12 +55,10 @@ Column {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parentObj.delegateHeight
|
height: parentObj.delegateHeight
|
||||||
|
|
||||||
checked: speedBackend.settings.readSetting(ScStwAppSettings.AppThemeSetting) === "Dark"
|
checked: appThemeSetting.value === "Dark"
|
||||||
|
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
var newTheme = checked ? "Dark":"Light"
|
appThemeSetting.value = checked ? "Dark":"Light"
|
||||||
speedBackend.settings.writeSetting(ScStwAppSettings.AppThemeSetting, newTheme)
|
|
||||||
appTheme.setTheme(newTheme)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
Timer text an upper line
|
||||||
------------------------*/
|
------------------------*/
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6c1ce8e65407452ce82f412fdd26d1367bf3ea38
|
Subproject commit ad3f8318c709653863058fc234469bd0ff006042
|
|
@ -215,6 +215,8 @@ void ScStwAppBackend::handleSettingChange(int keyInt, int keyLevel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "setting changed: " << keyInt;
|
||||||
|
|
||||||
switch (keyLevel) {
|
switch (keyLevel) {
|
||||||
case 0: {
|
case 0: {
|
||||||
// BaseStationSetting!!
|
// BaseStationSetting!!
|
||||||
|
@ -223,7 +225,10 @@ void ScStwAppBackend::handleSettingChange(int keyInt, int keyLevel) {
|
||||||
case ScStwSettings::BaseStationSetting::InvalidSetting:
|
case ScStwSettings::BaseStationSetting::InvalidSetting:
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
if(this->mode == LOCAL)
|
||||||
this->reloadRaceSettings();
|
this->reloadRaceSettings();
|
||||||
|
else
|
||||||
|
emit this->settingsChanged();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -29,14 +29,10 @@ QVariant ScStwAppSettings::readSetting(AppInternalSetting key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ScStwAppSettings::readSetting(int key, int keyLevel) {
|
QVariant ScStwAppSettings::readSetting(int key, int keyLevel) {
|
||||||
switch (keyLevel) {
|
if(keyLevel == ScStwAppSettings::KeyLevel)
|
||||||
case ScStwAppSettings::KeyLevel:
|
|
||||||
return this->readSetting(ScStwAppSettings::AppInternalSetting(key));
|
return this->readSetting(ScStwAppSettings::AppInternalSetting(key));
|
||||||
case ScStwSettings::KeyLevel:
|
else
|
||||||
return ScStwSettings::readSetting(ScStwSettings::BaseStationSetting(key));
|
return ScStwSettings::readSetting(key, keyLevel);
|
||||||
default:
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScStwAppSettings::writeSetting(AppInternalSetting key, QVariant value) {
|
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) {
|
bool ScStwAppSettings::writeSetting(int key, QVariant value, int keyLevel) {
|
||||||
switch (keyLevel) {
|
if(keyLevel == ScStwAppSettings::KeyLevel)
|
||||||
case ScStwAppSettings::KeyLevel:
|
|
||||||
return this->writeSetting(ScStwAppSettings::AppInternalSetting(key), value);
|
return this->writeSetting(ScStwAppSettings::AppInternalSetting(key), value);
|
||||||
case ScStwSettings::KeyLevel:
|
else
|
||||||
return ScStwSettings::writeSetting(ScStwSettings::BaseStationSetting(key), value);
|
return ScStwSettings::writeSetting(key, value, keyLevel);
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScStwAppSettings::setDefaultSetting(AppInternalSetting key, QVariant defaultVariant) {
|
void ScStwAppSettings::setDefaultSetting(AppInternalSetting key, QVariant defaultVariant) {
|
||||||
|
|
Reference in a new issue