mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
c3a54826a2
commit
69f21d9aed
7 changed files with 65 additions and 74 deletions
|
|
@ -1,17 +1,30 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "qPrefPrivate.h"
|
||||
|
||||
qPrefPrivate::qPrefPrivate(QObject *parent) : QObject(parent)
|
||||
{
|
||||
}
|
||||
qPrefPrivate *qPrefPrivate::instance()
|
||||
{
|
||||
static qPrefPrivate *self = new qPrefPrivate;
|
||||
return self;
|
||||
}
|
||||
#include <QSettings>
|
||||
|
||||
void qPrefPrivate::copy_txt(const char **name, const QString &string)
|
||||
{
|
||||
free((void *)*name);
|
||||
*name = copy_qstring(string);
|
||||
}
|
||||
|
||||
void qPrefPrivate::propSetValue(const QString &key, const QVariant &value)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
QVariant qPrefPrivate::propValue(const QString &key, const QVariant &defaultValue)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue