55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
#include "scstwsetting.h"
|
|
|
|
ScStwSetting::ScStwSetting(QObject *parent) : QObject(parent)
|
|
{
|
|
|
|
}
|
|
|
|
ScStwSettings* ScStwSetting::getScStwSettings(){
|
|
return this->scStwSettings;
|
|
}
|
|
void ScStwSetting::setScStwSettings(ScStwSettings* scStwSettings) {
|
|
if(this->scStwSettings != scStwSettings && scStwSettings != nullptr) {
|
|
this->scStwSettings = scStwSettings;
|
|
connect(this->scStwSettings, &ScStwSettings::settingChanged, this, &ScStwSetting::handleSettingChange);
|
|
emit this->scStwSettingsChanged();
|
|
}
|
|
}
|
|
|
|
int ScStwSetting::getKey() {
|
|
return this->key;
|
|
}
|
|
void ScStwSetting::setKey(int key) {
|
|
if(this->key != key) {
|
|
this->key = key;
|
|
this->handleSettingChange(this->key, this->keyLevel);
|
|
emit this->keyChanged();
|
|
}
|
|
}
|
|
|
|
int ScStwSetting::getKeyLevel() {
|
|
return this->keyLevel;
|
|
}
|
|
void ScStwSetting::setKeyLevel(int keyLevel) {
|
|
if(this->keyLevel != keyLevel) {
|
|
this->keyLevel = keyLevel;
|
|
this->handleSettingChange(this->key, this->keyLevel);
|
|
emit this->keyLevelChanged();
|
|
}
|
|
}
|
|
|
|
QVariant ScStwSetting::getValue() {
|
|
return this->valueCache;
|
|
}
|
|
void ScStwSetting::setValue(QVariant value) {
|
|
if(value != this->valueCache && this->scStwSettings != nullptr) {
|
|
this->scStwSettings->writeSetting(this->key, value, this->keyLevel);
|
|
}
|
|
}
|
|
|
|
void ScStwSetting::handleSettingChange(int key, int keyLevel) {
|
|
if(keyLevel == this->keyLevel && key == this->key) {
|
|
this->valueCache = this->scStwSettings->readSetting(key, keyLevel);
|
|
emit this->valueChanged();
|
|
}
|
|
}
|