-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.cpp
More file actions
41 lines (34 loc) · 989 Bytes
/
settings.cpp
File metadata and controls
41 lines (34 loc) · 989 Bytes
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
#include <QDebug>
#include "settings.h"
#include <QSettings>
Settings::Settings(QObject *parent) : QObject(parent)
{
// On Windows settings are stored in the application's folder - because application run out of box without installation
// On Unix settings are stored in $HOME/.config/asa/asa.ini
#ifdef Q_OS_WIN
m_settings = new QSettings("settings.ini", QSettings::IniFormat);
#else
m_settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "asa", "asa");
#endif
}
Settings *Settings::getSettings()
{
static Settings *settings = nullptr;
if (settings != nullptr) {
return settings;
}
settings = new Settings();
return settings;
}
Settings::~Settings()
{
}
void Settings::setValue(const QString &key, const QVariant &value)
{
m_settings->setValue(key, value);
m_settings->sync();
}
QVariant Settings::value(const QString &key, const QVariant &defaultValue) const
{
return m_settings->value(key, defaultValue);
}