34 if (!map.contains(
QSL(
"key")) || !map.contains(
QSL(
"value"))) {
35 qWarning() <<
"Unable to set value:" <<
"cannot determine Key-Value from the argument";
38 const QString key = map.value(
QSL(
"key")).toString();
39 const QVariant
value = map.value(
QSL(
"value"));
40 m_settings->setValue(key,
value);
50 if (!map.contains(
QSL(
"key"))) {
51 qWarning() <<
"Unable to get value:" <<
"key not defined";
55 const QString key = map.value(
QSL(
"key")).toString();
56 const QVariant defaultValue = map.value(
QSL(
"defaultValue"));
57 return m_settings->value(key, defaultValue);
66 return m_settings->contains(key);
75 m_settings->remove(key);
94void QmlSettings::setName(
const QString &name)
100void QmlSettings::createSettings()
102 m_settingsPath +=
QL1C(
'/') + m_name +
QL1S(
"/settings.ini");
103 m_settings =
new QSettings(m_settingsPath, QSettings::IniFormat,
this);
static QString currentProfilePath()
Q_INVOKABLE bool contains(const QString &key)
Checks if a given key exists.
QString name
name of the folder in which settings.ini file is located on the standard extension path.
Q_INVOKABLE bool setValue(const QVariantMap &map)
Sets the value for a given key.
Q_INVOKABLE bool sync()
syncs the settings
QmlSettings(QObject *parent=nullptr)
Q_INVOKABLE QVariant value(const QVariantMap &map)
Gets the value for a given key.
Q_INVOKABLE bool remove(const QString &key)
Removes the given key-value from the settings.