subsurface/core/settings/qPrefPrivate.cpp
Dirk Hohndel e71b049498 qPref: only save settings that aren't the default
This brings us back to the previous behavior.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-06 16:13:44 -07:00

33 lines
950 B
C++

// SPDX-License-Identifier: GPL-2.0
#include "qPrefPrivate.h"
#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, 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;
if (value != defaultValue)
s.setValue(key, value);
else
s.remove(key);
}
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);
}