Fix forward navigation control on Linux.
[dorian] / model / settings.cpp
1 #include <QSettings>
2 #include <QString>
3 #include <QStringList>
4
5 #include "settings.h"
6 #include "trace.h"
7
8 static Settings *theInstance;
9
10 Settings::Settings(): QObject(0)
11 {
12 }
13
14 Settings *Settings::instance()
15 {
16     if (!theInstance) {
17         theInstance = new Settings();
18     }
19     return theInstance;
20 }
21
22 void Settings::close()
23 {
24     delete theInstance;
25     theInstance = 0;
26 }
27
28 void Settings::setValue(const QString &key, const QVariant &value)
29 {
30     QSettings s;
31     s.setValue(QString("settings/") + key, value);
32     emit valueChanged(key);
33 }
34
35 QVariant Settings::value(const QString &key, const QVariant &defaultValue) const
36 {
37     QSettings s;
38     return s.value(QString("settings/") + key, defaultValue);
39 }
40
41 void Settings::apply()
42 {
43     TRACE;
44     QSettings s;
45     foreach (QString key, s.allKeys()) {
46         if (key.startsWith("settings/")) {
47             key = key.mid(9);
48             setValue(key, value(key));
49         }
50     }
51 }