diff --git a/src/blackcore/context/contextapplication.h b/src/blackcore/context/contextapplication.h index 776ecfe30..f874fb904 100644 --- a/src/blackcore/context/contextapplication.h +++ b/src/blackcore/context/contextapplication.h @@ -60,6 +60,9 @@ namespace BlackCore //! Used when marshalling CLogSubscriptionHash, as a QHash with CIdentifier keys can't be marshalled using CLogSubscriptionPair = QPair>; + //! Value type for settings keys with descriptions + using CSettingsDictionary = BlackMisc::CDictionary; + //! Application context interface class BLACKCORE_EXPORT IContextApplication : public CContext { @@ -152,6 +155,9 @@ namespace BlackCore //! Get keys of all unsaved settings currently in core settings cache virtual QStringList getUnsavedSettingsKeys() const = 0; + //! Get keys and descriptions of all unsaved settings currently in core settings cache + virtual BlackCore::Context::CSettingsDictionary getUnsavedSettingsKeysDescribed() const = 0; + //! Update local settings with settings from core virtual void synchronizeLocalSettings() = 0; @@ -219,5 +225,6 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, BlackCore::Context::C Q_DECLARE_METATYPE(BlackCore::Context::CLogSubscriptionHash) Q_DECLARE_METATYPE(BlackCore::Context::CLogSubscriptionPair) +Q_DECLARE_METATYPE(BlackCore::Context::CSettingsDictionary) #endif // guard diff --git a/src/blackcore/context/contextapplicationempty.h b/src/blackcore/context/contextapplicationempty.h index 599266de1..9864a4b02 100644 --- a/src/blackcore/context/contextapplicationempty.h +++ b/src/blackcore/context/contextapplicationempty.h @@ -90,6 +90,13 @@ namespace BlackCore return QStringList(); } + //! \copydoc IContextApplication::getUnsavedSettingsKeys + virtual BlackCore::Context::CSettingsDictionary getUnsavedSettingsKeysDescribed() const override + { + logEmptyContextWarning(Q_FUNC_INFO); + return CSettingsDictionary(); + } + //! \copydoc IContextApplication::synchronizeLocalSettings virtual void synchronizeLocalSettings() override { diff --git a/src/blackcore/context/contextapplicationimpl.cpp b/src/blackcore/context/contextapplicationimpl.cpp index 547f2102d..7c6d0ce03 100644 --- a/src/blackcore/context/contextapplicationimpl.cpp +++ b/src/blackcore/context/contextapplicationimpl.cpp @@ -92,6 +92,15 @@ namespace BlackCore return CSettingsCache::instance()->getAllUnsavedKeys(); } + CSettingsDictionary CContextApplication::getUnsavedSettingsKeysDescribed() const + { + if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } + const QStringList keys = CSettingsCache::instance()->getAllUnsavedKeys(); + CSettingsDictionary result; + for (const QString &key : keys) { result.insert(key, CSettingsCache::instance()->getHumanReadableName(key)); } + return result; + } + void CContextApplication::synchronizeLocalSettings() { // no-op: proxy implements this method by calling getAllSettings diff --git a/src/blackcore/context/contextapplicationimpl.h b/src/blackcore/context/contextapplicationimpl.h index 1b98cdaac..afdd3249e 100644 --- a/src/blackcore/context/contextapplicationimpl.h +++ b/src/blackcore/context/contextapplicationimpl.h @@ -54,6 +54,7 @@ namespace BlackCore virtual void changeSettings(const BlackMisc::CValueCachePacket &settings, const BlackMisc::CIdentifier &origin) override; virtual BlackMisc::CValueCachePacket getAllSettings() const override; virtual QStringList getUnsavedSettingsKeys() const override; + virtual BlackCore::Context::CSettingsDictionary getUnsavedSettingsKeysDescribed() const override; virtual void synchronizeLocalSettings() override; virtual BlackMisc::CStatusMessage saveSettings(const QString &keyPrefix = {}) override; virtual BlackMisc::CStatusMessage saveSettingsByKey(const QStringList &keys) override; diff --git a/src/blackcore/context/contextapplicationproxy.cpp b/src/blackcore/context/contextapplicationproxy.cpp index 21fad64cf..b7885b2a3 100644 --- a/src/blackcore/context/contextapplicationproxy.cpp +++ b/src/blackcore/context/contextapplicationproxy.cpp @@ -111,6 +111,17 @@ namespace BlackCore return this->m_dBusInterface->callDBusRet(QLatin1String("getUnsavedSettingsKeys")); } + CSettingsDictionary CContextApplicationProxy::getUnsavedSettingsKeysDescribed() const + { + CSettingsDictionary result = this->m_dBusInterface->callDBusRet(QLatin1String("getUnsavedSettingsKeysDescribed")); + for (auto it = result.begin(); it != result.end(); ++it) + { + // consolidate with local names to fill any gaps in remote names + if (it.value().isEmpty()) { it.value() = CSettingsCache::instance()->getHumanReadableName(it.key()); } + } + return result; + } + void CContextApplicationProxy::synchronizeLocalSettings() { // note this proxy method does not call synchronizeLocalSettings in core diff --git a/src/blackcore/context/contextapplicationproxy.h b/src/blackcore/context/contextapplicationproxy.h index e6d543685..7e4f5880b 100644 --- a/src/blackcore/context/contextapplicationproxy.h +++ b/src/blackcore/context/contextapplicationproxy.h @@ -59,6 +59,7 @@ namespace BlackCore virtual void changeSettings(const BlackMisc::CValueCachePacket &settings, const BlackMisc::CIdentifier &origin) override; virtual BlackMisc::CValueCachePacket getAllSettings() const override; virtual QStringList getUnsavedSettingsKeys() const override; + virtual BlackCore::Context::CSettingsDictionary getUnsavedSettingsKeysDescribed() const override; virtual void synchronizeLocalSettings() override; virtual BlackMisc::CStatusMessage saveSettings(const QString &keyPrefix = {}) override; virtual BlackMisc::CStatusMessage saveSettingsByKey(const QStringList &keys) override; diff --git a/src/blackcore/registermetadata.cpp b/src/blackcore/registermetadata.cpp index 32d082b41..e93a6d2af 100644 --- a/src/blackcore/registermetadata.cpp +++ b/src/blackcore/registermetadata.cpp @@ -30,6 +30,7 @@ namespace BlackCore { qDBusRegisterMetaType(); qDBusRegisterMetaType(); + qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType();