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/client/scstwsetting.cpp

54 lines
1.6 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, this->scStwSettings->readSetting(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, this->scStwSettings->readSetting(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, QVariant value) {
if(keyLevel == this->keyLevel && key == this->key) {
this->valueCache = value;
emit this->valueChanged();
}
}