summaryrefslogtreecommitdiffstats
path: root/core/settings/qPrefPrivate.cpp
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-08-15 13:26:09 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-25 11:49:47 -0700
commit69f21d9aedcea8713cf5af6463ebacba5832162e (patch)
tree7a345586bd1a4caa311e99679b766681e03aeb41 /core/settings/qPrefPrivate.cpp
parentc3a54826a2ddb17ac00ec4fdbbd18eea8a0ecbe1 (diff)
downloadsubsurface-69f21d9aedcea8713cf5af6463ebacba5832162e.tar.gz
core: make methods in qPrefPrivate static
Small cleanup, using static methods is simpler and faster Added propSetValue and propValue instead of exposing setting variable. Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'core/settings/qPrefPrivate.cpp')
-rw-r--r--core/settings/qPrefPrivate.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/core/settings/qPrefPrivate.cpp b/core/settings/qPrefPrivate.cpp
index 0275791cf..ff335a94f 100644
--- a/core/settings/qPrefPrivate.cpp
+++ b/core/settings/qPrefPrivate.cpp
@@ -1,17 +1,30 @@
// SPDX-License-Identifier: GPL-2.0
#include "qPrefPrivate.h"
-qPrefPrivate::qPrefPrivate(QObject *parent) : QObject(parent)
+#include <QSettings>
+
+void qPrefPrivate::copy_txt(const char **name, const QString &string)
{
+ free((void *)*name);
+ *name = copy_qstring(string);
}
-qPrefPrivate *qPrefPrivate::instance()
+
+void qPrefPrivate::propSetValue(const QString &key, const QVariant &value)
{
- static qPrefPrivate *self = new qPrefPrivate;
- return self;
+ // REMARK: making s static (which would be logical) does NOT work
+ // because it gets initialized too early.
+ // Having it as a local variable is light weight, because it is an
+ // interface class.
+ QSettings s;
+ s.setValue(key, value);
}
-void qPrefPrivate::copy_txt(const char **name, const QString &string)
+QVariant qPrefPrivate::propValue(const QString &key, const QVariant &defaultValue)
{
- free((void *)*name);
- *name = copy_qstring(string);
+ // REMARK: making s static (which would be logical) does NOT work
+ // because it gets initialized too early.
+ // Having it as a local variable is light weight, because it is an
+ // interface class.
+ QSettings s;
+ return s.value(key, defaultValue);
}