2021-11-05 23:58:23 +03:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
|
|
|
|
using namespace QuasarAppUtils;
|
|
|
|
|
|
|
|
ISettings::ISettings(SettingsSaveMode mode) {
|
|
|
|
_mode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
SettingsSaveMode ISettings::getMode() const {
|
|
|
|
return _mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ISettings::setMode(const SettingsSaveMode &mode) {
|
|
|
|
_mode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
//ISettings *ISettings::initSettings(SettingsSaveMode mode) {
|
|
|
|
// static ISettings* res = new ISettings(mode);
|
|
|
|
// return res;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//ISettings *ISettings::instance() {
|
|
|
|
// return initSettings();
|
|
|
|
//}
|
|
|
|
|
|
|
|
QVariant ISettings::getValue(const QString &key, const QVariant &def) {
|
2021-11-06 10:20:20 +03:00
|
|
|
return getValueImplementation(key, def);
|
2021-11-05 23:58:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2021-11-05 23:58:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ISettings::setValue(const QString key, const QVariant &value) {
|
2021-11-06 10:20:20 +03:00
|
|
|
return setValueImplementation(key, value);
|
2021-11-05 23:58:23 +03:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|