4
0
mirror of https://github.com/QuasarApp/QuasarAppLib.git synced 2025-04-28 10:44:41 +00:00

57 lines
1.3 KiB
C++
Raw Normal View History

/*
* Copyright (C) 2018-2021 QuasarApp.
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
#include "isettings.h"
#include <QSettings>
#include <QCoreApplication>
2021-11-06 18:07:15 +03:00
namespace QuasarAppUtils {
ISettings* ISettings::_settings = nullptr;
ISettings::ISettings(SettingsSaveMode mode) {
_mode = mode;
}
SettingsSaveMode ISettings::getMode() const {
return _mode;
}
void ISettings::setMode(const SettingsSaveMode &mode) {
_mode = mode;
}
QVariant ISettings::getValue(const QString &key, const QVariant &def) {
2021-11-06 10:20:20 +03:00
return getValueImplementation(key, def);
}
QString ISettings::getStrValue(const QString &key, const QString &def) {
return getValue(key, QVariant(def)).toString();
}
void ISettings::sync() {
2021-11-06 10:20:20 +03:00
return syncImplementation();
}
void ISettings::setValue(const QString key, const QVariant &value) {
2021-11-06 10:20:20 +03:00
return setValueImplementation(key, value);
emit valueChanged(key, value);
emit valueStrChanged(key, value.toString());
if (_mode == SettingsSaveMode::Auto) {
sync();
}
}
void ISettings::setStrValue(const QString &key, const QString &value) {
setValue(key, value);
}
2021-11-06 18:07:15 +03:00
}