app/sources/scstwappsettings.cpp

65 lines
2.3 KiB
C++

/*
Speed Climbing Stopwatch - Simple Stopwatch for Climbers
Copyright (C) 2018 Itsblue Development - Dorian Zeder
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.
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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "headers/scstwappsettings.h"
ScStwAppSettings * pGlobalAppSettings = nullptr;
ScStwAppSettings::ScStwAppSettings(ScStwClient * client, QObject* parent)
:ScStwRemoteSettings(client, parent)
{
}
QVariant ScStwAppSettings::readSetting(AppInternalSetting key) {
return ScStwSettings::readSetting(QMetaEnum::fromType<AppInternalSetting>().valueToKey(int(key)), int(key), 1);
}
QVariant ScStwAppSettings::readSetting(int key, int keyLevel) {
switch (keyLevel) {
case ScStwAppSettings::KeyLevel:
return this->readSetting(ScStwAppSettings::AppInternalSetting(key));
case ScStwSettings::KeyLevel:
return ScStwSettings::readSetting(ScStwSettings::BaseStationSetting(key));
default:
return QVariant();
}
}
bool ScStwAppSettings::writeSetting(AppInternalSetting key, QVariant value) {
return ScStwSettings::writeSetting(QMetaEnum::fromType<AppInternalSetting>().valueToKey(int(key)), value, int(key), 1);
}
bool ScStwAppSettings::writeSetting(int key, QVariant value, int keyLevel) {
switch (keyLevel) {
case ScStwAppSettings::KeyLevel:
return this->writeSetting(ScStwAppSettings::AppInternalSetting(key), value);
case ScStwSettings::KeyLevel:
return ScStwSettings::writeSetting(ScStwSettings::BaseStationSetting(key), value);
default:
return false;
}
}
void ScStwAppSettings::setDefaultSetting(AppInternalSetting key, QVariant defaultVariant) {
ScStwSettings::setDefaultSetting(QMetaEnum::fromType<AppInternalSetting>().valueToKey(int(key)), defaultVariant, int(key), 1);
}
ScStwAppSettings::~ScStwAppSettings()
{
}