From 77bac859bcecf145bf0d3a544fcb2f821c2240e0 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Thu, 15 Mar 2018 12:16:30 +0100 Subject: [PATCH] [ToolTip] Check file name in KDirWatch handler KDirWatch::self() is a singleton so we would get change events also for other files like plasma-appletsrc needlessly reloading plasmarc all the time. Differential Revision: https://phabricator.kde.org/D11326 --- src/declarativeimports/core/tooltip.cpp | 10 +++++++--- src/declarativeimports/core/tooltip.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/declarativeimports/core/tooltip.cpp b/src/declarativeimports/core/tooltip.cpp index 735f456ea..b4c825a3c 100644 --- a/src/declarativeimports/core/tooltip.cpp +++ b/src/declarativeimports/core/tooltip.cpp @@ -54,8 +54,8 @@ ToolTip::ToolTip(QQuickItem *parent) const QString configFile = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QStringLiteral("/plasmarc"); KDirWatch::self()->addFile(configFile); - QObject::connect(KDirWatch::self(), SIGNAL(created(QString)), this, SLOT(settingsChanged())); - QObject::connect(KDirWatch::self(), SIGNAL(dirty(QString)), this, SLOT(settingsChanged())); + QObject::connect(KDirWatch::self(), &KDirWatch::created, this, &ToolTip::settingsChanged); + QObject::connect(KDirWatch::self(), &KDirWatch::dirty, this, &ToolTip::settingsChanged); } ToolTip::~ToolTip() @@ -74,8 +74,12 @@ ToolTip::~ToolTip() } } -void ToolTip::settingsChanged() +void ToolTip::settingsChanged(const QString &file) { + if (!file.endsWith(QLatin1String("plasmarc"))) { + return; + } + KSharedConfig::openConfig(QStringLiteral("plasmarc"))->reparseConfiguration(); loadSettings(); } diff --git a/src/declarativeimports/core/tooltip.h b/src/declarativeimports/core/tooltip.h index 06593ad3d..653908ad9 100644 --- a/src/declarativeimports/core/tooltip.h +++ b/src/declarativeimports/core/tooltip.h @@ -189,7 +189,7 @@ Q_SIGNALS: void interactiveChanged(); private Q_SLOTS: - void settingsChanged(); + void settingsChanged(const QString &file); private: bool isValid() const;