From 913c912677aa01949b39d6eb486fa69e7337d4e6 Mon Sep 17 00:00:00 2001 From: Timon Reinold Date: Wed, 9 Jul 2025 16:57:48 +0200 Subject: [PATCH] Remove FdoSecretsSettings::collectionAliasesChanged() Remove the collectionAliasesChanged() signal from FdoSecretsSettings to avoid making it a QObject. Instead connect to Config::changed and check which Config key changed. This does break the abstraction layer that FdoSecretsSettings was between Service and Config, and requires comparing the key each time any config value is updated, but averts the QObject overhead for FdoSecretsSettings. Suggested-by: Jonathan White (https://github.com/keepassxreboot/keepassxc/pull/12252#discussion_r2181100088) --- src/fdosecrets/FdoSecretsSettings.cpp | 1 - src/fdosecrets/FdoSecretsSettings.h | 7 +------ src/fdosecrets/objects/Service.cpp | 10 ++++++++-- src/fdosecrets/objects/Service.h | 2 ++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/fdosecrets/FdoSecretsSettings.cpp b/src/fdosecrets/FdoSecretsSettings.cpp index ff31c63af..30376c84b 100644 --- a/src/fdosecrets/FdoSecretsSettings.cpp +++ b/src/fdosecrets/FdoSecretsSettings.cpp @@ -112,7 +112,6 @@ namespace FdoSecrets void FdoSecretsSettings::setCollectionAliases(const QVariantMap& aliases) { config()->set(Config::FdoSecrets_CollectionAliasDatabaseUUIDs, aliases); - emit collectionAliasesChanged(); } void FdoSecretsSettings::setCollectionAlias(QString alias, QUuid publicUuid) diff --git a/src/fdosecrets/FdoSecretsSettings.h b/src/fdosecrets/FdoSecretsSettings.h index 68a7f07d2..ea0b94437 100644 --- a/src/fdosecrets/FdoSecretsSettings.h +++ b/src/fdosecrets/FdoSecretsSettings.h @@ -27,10 +27,8 @@ class Database; namespace FdoSecrets { - class FdoSecretsSettings : public QObject + class FdoSecretsSettings { - Q_OBJECT - public: FdoSecretsSettings() = default; static FdoSecretsSettings* instance(); @@ -62,9 +60,6 @@ namespace FdoSecrets QUuid exposedGroup(Database* db) const; void setExposedGroup(Database* db, const QUuid& group); - signals: - void collectionAliasesChanged() const; - private: static FdoSecretsSettings* m_instance; }; diff --git a/src/fdosecrets/objects/Service.cpp b/src/fdosecrets/objects/Service.cpp index 637ca35e7..5641f041a 100644 --- a/src/fdosecrets/objects/Service.cpp +++ b/src/fdosecrets/objects/Service.cpp @@ -81,8 +81,7 @@ namespace FdoSecrets // when a new database is opened, apply it's aliases connect(m_databases.data(), &DatabaseTabWidget::databaseOpened, this, &Service::applyCollectionAliasSettings); // apply aliases from settings, when they change - connect( - settings(), &FdoSecretsSettings::collectionAliasesChanged, this, &Service::applyCollectionAliasSettings); + connect(config(), &Config::changed, this, &Service::handleSettingsChanged); // make default alias track current activated database connect(m_databases.data(), &DatabaseTabWidget::activeDatabaseChanged, this, &Service::ensureDefaultAlias); @@ -469,6 +468,13 @@ namespace FdoSecrets return collection->addAlias(name); } + void Service::handleSettingsChanged(Config::ConfigKey key) + { + if (key == Config::FdoSecrets_CollectionAliasDatabaseUUIDs) { + applyCollectionAliasSettings(); + } + } + void Service::applyCollectionAliasSettings() { auto aliases = settings()->collectionAliases(); diff --git a/src/fdosecrets/objects/Service.h b/src/fdosecrets/objects/Service.h index 63e39db4c..24068b854 100644 --- a/src/fdosecrets/objects/Service.h +++ b/src/fdosecrets/objects/Service.h @@ -18,6 +18,7 @@ #ifndef KEEPASSXC_FDOSECRETS_SERVICE_H #define KEEPASSXC_FDOSECRETS_SERVICE_H +#include "core/Config.h" #include "fdosecrets/dbus/DBusClient.h" #include "fdosecrets/dbus/DBusObject.h" @@ -143,6 +144,7 @@ namespace FdoSecrets void onCollectionAliasRemoved(const QString& alias); + void handleSettingsChanged(Config::ConfigKey key); void applyCollectionAliasSettings(); private: