-
Notifications
You must be signed in to change notification settings - Fork 2
/
settings.cpp
72 lines (55 loc) · 1.6 KB
/
settings.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright (C) 2021-2024 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 "settings.h"
#include <QSettings>
#include <QCoreApplication>
#include <QDebug>
namespace QuasarAppUtils {
Settings::Settings() {
auto name = QCoreApplication::applicationName();
auto company = QCoreApplication::organizationName();
if (name.isEmpty()) {
name = "QuasarAppUtils";
}
if (company.isEmpty()) {
company = "QuasarApp";
}
_settings = new QSettings(QSettings::NativeFormat, QSettings::Scope::UserScope, company, name);
}
void Settings::syncImplementation() {
return _settings->sync();
}
QVariant Settings::getValueImplementation(const QString &key, const QVariant &def) {
if (isBool(key)) {
return _settings->value(key, def).toBool();
}
return _settings->value(key, def);
}
void Settings::setValueImplementation(const QString key, const QVariant &value) {
return _settings->setValue(key, value);
}
bool Settings::ignoreToRest(const QString &) const {
return false;
}
QHash<QString, QVariant> Settings::defaultSettings() {
return {};
}
bool Settings::isBool(const QString &) const {
return false;
}
const QSet<QString> &Settings::boolOptions() const
{
return _boolOptions;
}
void Settings::setBoolOptions(const QSet<QString> &newBoolOptions)
{
_boolOptions = newBoolOptions;
}
bool Settings::initService() {
return ISettings::initService(std::make_unique<Settings>());
}
}