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

50 lines
1.8 KiB
C++
Raw Normal View History

2020-07-11 21:03:58 +02:00
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#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();
}
}