This repository has been archived on 2024-06-03. You can view files and clone it, but cannot push or open issues or pull requests.
shared-libraries/ScStwLibraries/sources/scstwsetting.cpp

32 lines
941 B
C++
Raw Normal View History

#include "scstwsetting.h"
#include <QtDebug>
ScStwSetting::ScStwSetting(QObject *parent) : QObject(parent)
{
}
QVariant ScStwSetting::getValue() {
if(this->hasToReload) {
this->valueCache = this->readSetting(this->key, this->keyLevel);
this->hasToReload = false;
}
return this->valueCache;
}
void ScStwSetting::setValue(QVariant value) {
if(value != this->valueCache) {
this->writeSetting(this->key, this->keyLevel, value);
}
}
void ScStwSetting::handleSettingChange(int key, int keyLevel, QVariant value) {
if(keyLevel == this->keyLevel && key == this->key) {
this->valueCache = value;
qDebug() << "value changed!!! key: " << key << " new value " << value;
emit this->valueChanged();
}
else if(key == -1 && this->key != -1 && this->keyLevel != -1 && this->keyLevel == keyLevel) {
this->hasToReload = true;
emit this->valueChanged();
}
}