mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
2ecbea3d24
We had a couple of instances of names being incorrectly merged with their group, this should handle that better. It's a bit of a big hammer to use, but it seems to work (and it makes it easy to then git grep for cases that don't use the new helper function. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
39 lines
1.1 KiB
C++
39 lines
1.1 KiB
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);
|
|
}
|
|
|
|
QString keyFromGroupAndName(QString group, QString name)
|
|
{
|
|
QString slash = (group.endsWith('/') || name.startsWith('/')) ? "" : "/";
|
|
return group + slash + name;
|
|
}
|
|
|
|
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);
|
|
}
|