2018-07-17 13:22:51 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include "qPrefPrivate.h"
|
|
|
|
|
2018-08-15 11:26:09 +00:00
|
|
|
#include <QSettings>
|
|
|
|
|
|
|
|
void qPrefPrivate::copy_txt(const char **name, const QString &string)
|
2018-07-17 13:22:51 +00:00
|
|
|
{
|
2018-08-15 11:26:09 +00:00
|
|
|
free((void *)*name);
|
|
|
|
*name = copy_qstring(string);
|
2018-07-17 13:22:51 +00:00
|
|
|
}
|
2018-08-15 11:26:09 +00:00
|
|
|
|
2018-09-06 22:15:19 +00:00
|
|
|
void qPrefPrivate::propSetValue(const QString &key, const QVariant &value, const QVariant &defaultValue)
|
2018-07-17 13:22:51 +00:00
|
|
|
{
|
2018-08-15 11:26:09 +00:00
|
|
|
// 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;
|
2018-09-06 22:15:19 +00:00
|
|
|
if (value != defaultValue)
|
|
|
|
s.setValue(key, value);
|
|
|
|
else
|
|
|
|
s.remove(key);
|
2018-07-17 13:22:51 +00:00
|
|
|
}
|
2018-07-18 18:47:59 +00:00
|
|
|
|
2018-08-15 11:26:09 +00:00
|
|
|
QVariant qPrefPrivate::propValue(const QString &key, const QVariant &defaultValue)
|
2018-07-18 18:47:59 +00:00
|
|
|
{
|
2018-08-15 11:26:09 +00:00
|
|
|
// 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);
|
2018-07-18 18:47:59 +00:00
|
|
|
}
|