32 lines
941 B
C++
32 lines
941 B
C++
|
#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();
|
||
|
}
|
||
|
}
|