blob: a67897ed05fea28e12c18e29fa61490608dd0d40 (
plain) (
blame)
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
|
/*
* choosersettings.cpp
*
* Created on: Mar 24, 2014
* Author: nils
*/
#include "choosersettings.h"
#include "globals.h"
bool ChooserSettings::settingsLoaded = false;
ChooserSettings* ChooserSettings::chooserSettings = NULL;
ChooserSettings::ChooserSettings() {
// test (and make) directory
QDir saveFileDir(QFileInfo(previousSessionFile).absoluteDir());
if (!saveFileDir.exists()) {
if (!saveFileDir.mkpath(saveFileDir.path())) {
return;
}
}
settings = new QSettings(previousSessionFile, QSettings::IniFormat);
settings->setIniCodec("UTF-8");
if (settings->status() != QSettings::NoError) {
if (debugMode) {
qDebug() << "Settings: " << previousSessionFile << " contains erros.";
}
return;
}
settingsLoaded = true;
}
ChooserSettings::~ChooserSettings() {
settings->deleteLater();
}
QString ChooserSettings::getSetting(QString key) {
if (!settingsLoaded) {
chooserSettings = new ChooserSettings();
if (!settingsLoaded) return "";
}
return chooserSettings->settings->value(key).toString();
}
bool ChooserSettings::setSetting(QString key, QString value) {
if (!settingsLoaded) {
chooserSettings = new ChooserSettings();
if (!settingsLoaded) return false;
}
chooserSettings->settings->setValue(key, value);
// chooserSettings->settings->sync();
return true;
}
|