Only adjust reading positon during orientation switch.
[dorian] / model / settings.cpp
index ea2f8c2..810e15e 100644 (file)
@@ -1,20 +1,28 @@
 #include <QSettings>
+#include <QString>
+#include <QStringList>
 
 #include "settings.h"
+#include "trace.h"
 
-static Settings *inst;
+static Settings *theInstance;
 
-Settings::Settings(QObject *parent) :
-    QObject(parent)
+Settings::Settings(): QObject(0)
 {
 }
 
 Settings *Settings::instance()
 {
-    if (!inst) {
-        inst = new Settings();
+    if (!theInstance) {
+        theInstance = new Settings();
     }
-    return inst;
+    return theInstance;
+}
+
+void Settings::close()
+{
+    delete theInstance;
+    theInstance = 0;
 }
 
 void Settings::setValue(const QString &key, const QVariant &value)
@@ -29,3 +37,15 @@ QVariant Settings::value(const QString &key, const QVariant &defaultValue) const
     QSettings s;
     return s.value(QString("settings/") + key, defaultValue);
 }
+
+void Settings::apply()
+{
+    TRACE;
+    QSettings s;
+    foreach (QString key, s.allKeys()) {
+        if (key.startsWith("settings/")) {
+            key = key.mid(9);
+            setValue(key, value(key));
+        }
+    }
+}