From 54dd5d1f5ae8a4170ed7bfdbeb546e8340540cc3 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Mon, 4 Jun 2018 00:04:47 +0200 Subject: [PATCH] common: Notify if key was removed from settings Settings have a notification feature so consumers can subscribe to value changes. This notification should also be emitted in case a settings key is removed altogether. --- src/common/settings.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/settings.cpp b/src/common/settings.cpp index bb50f7f2..2d79ffe3 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -120,6 +120,7 @@ void Settings::setVersionMinor(const uint versionMinor) s.setValue("Config/VersionMinor", versionMinor); } + bool Settings::sync() { create_qsettings; s.sync(); @@ -131,11 +132,13 @@ bool Settings::sync() { } } + bool Settings::isWritable() { create_qsettings; return s.isWritable(); } + QStringList Settings::allLocalKeys() { create_qsettings; @@ -200,6 +203,7 @@ const QVariant &Settings::localValue(const QString &key, const QVariant &def) return cacheValue(normKey); } + bool Settings::localKeyExists(const QString &key) { QString normKey = normalizedKey(group, key); @@ -218,6 +222,10 @@ void Settings::removeLocalKey(const QString &key) s.remove(key); s.endGroup(); QString normKey = normalizedKey(group, key); - if (isCached(normKey)) + if (isCached(normKey)) { settingsCache.remove(normKey); + } + if (hasNotifier(normKey)) { + emit notifier(normKey)->valueChanged({}); + } } -- 2.20.1