2018-09-29 15:56:04 +03:00
|
|
|
/*
|
2022-03-03 19:00:49 +03:00
|
|
|
* Copyright (C) 2021-2022 QuasarApp.
|
2018-09-29 15:56:04 +03:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2021-11-05 23:58:23 +03:00
|
|
|
|
2018-09-29 15:56:04 +03:00
|
|
|
#include "settings.h"
|
|
|
|
#include <QSettings>
|
2019-09-23 18:36:29 +03:00
|
|
|
#include <QCoreApplication>
|
2018-09-29 15:56:04 +03:00
|
|
|
|
2021-11-05 23:58:23 +03:00
|
|
|
namespace QuasarAppUtils {
|
2018-09-29 15:56:04 +03:00
|
|
|
|
2021-11-05 23:58:23 +03:00
|
|
|
Settings::Settings() {
|
2019-09-23 18:36:29 +03:00
|
|
|
auto name = QCoreApplication::applicationName();
|
2019-09-27 20:35:37 +03:00
|
|
|
auto company = QCoreApplication::organizationName();
|
2019-09-23 18:36:29 +03:00
|
|
|
if (name.isEmpty()) {
|
|
|
|
name = "QuasarAppUtils";
|
|
|
|
}
|
|
|
|
|
2019-09-27 20:35:37 +03:00
|
|
|
if (company.isEmpty()) {
|
|
|
|
company = "QuasarApp";
|
|
|
|
}
|
|
|
|
|
|
|
|
_settings = new QSettings(QSettings::IniFormat, QSettings::Scope::UserScope, company, name);
|
2018-09-29 15:56:04 +03:00
|
|
|
}
|
|
|
|
|
2022-02-22 17:01:53 +03:00
|
|
|
ISettings *Settings::init() {
|
|
|
|
return ISettings::init<Settings>();
|
|
|
|
}
|
|
|
|
|
2021-11-05 23:58:23 +03:00
|
|
|
void Settings::syncImplementation() {
|
|
|
|
return _settings->sync();
|
2018-09-29 15:56:04 +03:00
|
|
|
}
|
|
|
|
|
2021-11-05 23:58:23 +03:00
|
|
|
QVariant Settings::getValueImplementation(const QString &key, const QVariant &def) {
|
2018-09-29 15:56:04 +03:00
|
|
|
return _settings->value(key, def);
|
|
|
|
}
|
|
|
|
|
2021-11-05 23:58:23 +03:00
|
|
|
void Settings::setValueImplementation(const QString key, const QVariant &value) {
|
|
|
|
return _settings->setValue(key, value);
|
2018-09-29 15:56:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|