-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.h
executable file
·46 lines (39 loc) · 995 Bytes
/
settings.h
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
#ifndef SETTINGSMANAGER_H
#define SETTINGSMANAGER_H
#include <QString>
#include <QVariant>
#include <QSettings>
#include <QDebug>
#include <QDir>
#include <QMap>
#include <QApplication>
const QMap<QString, QVariant> defaultSettings{
{"concurrentDownloads", 1},
{"createContainerSubfolder", true},
{"downloadSavePath", "./downloads"},
{"extractOnlyAudio", false},
{"audioFormat", "mp3"}
};
class Settings
{
public:
static Settings& getInstance()
{
static Settings instance(false);
return instance;
}
Settings(bool inMemory = true);
~Settings();
private:
QSettings *settings = nullptr;
QMap<QString, QVariant> inMemorySettings;
bool isInMemory;
public:
Settings(Settings const&) = default;
void operator=(Settings const&) = delete;
void set(QString key, QVariant val);
QVariant get(QString key);
QVariant get(QString key, QVariant defVal);
bool hasKey(QString key);
};
#endif // SETTINGSMANAGER_H