fixed non working settings write

This commit is contained in:
Dorian Zedler 2020-07-30 12:12:44 +02:00
parent d982bafab1
commit e3cea06558
Signed by: dorian
GPG key ID: D3B255CB8BC7CD37

View file

@ -74,14 +74,21 @@ bool ScStwSettings::setDefaultSetting(int key, int keyLevel, QVariant defaultVal
QVariant ScStwSettings::readSetting(QString key, int keyInt, int keyLevel) {
Q_UNUSED(keyInt)
Q_UNUSED(keyLevel)
if(this->settingsCache.contains(key))
return this->settingsCache[key];
else
return QVariant();
}
bool ScStwSettings::writeSetting(QString key, QVariant value, int keyInt, int keyLevel) {
if(!this->keyToTypeConverters.contains(keyInt) || !value.convert(this->keyToTypeConverters[keyLevel](keyInt)) || value.type() == QVariant::Invalid) {
// check if the value type is valid
if(!this->keyToTypeConverters.contains(keyLevel) || !value.convert(this->keyToTypeConverters[keyLevel](keyInt)) || value.type() == QVariant::Invalid) {
return false;
}
// write the setting
if(!this->settingsCache.contains(key))
this->settingsCache.insert(key, value);
else if (this->settingsCache[key] == value)