X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fsettings.cpp;h=6273f7c7400c70c09de1fe5dad23ac8068f8be68;hb=37110ceaa070167b4f40ed449ac9ea130503a792;hp=cdb152cdf2b11b2d19b3ab7ebe2e0f0b39546cdf;hpb=10e6f4629e39c66cfb8db6ab2806bf8f13ec700b;p=quassel.git diff --git a/src/common/settings.cpp b/src/common/settings.cpp index cdb152cd..6273f7c7 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -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,12 +203,12 @@ const QVariant &Settings::localValue(const QString &key, const QVariant &def) return cacheValue(normKey); } + bool Settings::localKeyExists(const QString &key) { QString normKey = normalizedKey(group, key); - if (isCached(normKey)) - return true; - + // Do NOT check the cache as default values get cached, too. Otherwise loading a setting once + // will mark it as existing in settings, even when it only exists in cache (and not on disk). create_qsettings; return s.contains(normKey); } @@ -218,6 +221,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({}); + } }