[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
This commit is contained in:
Kai Uwe Broulik 2018-03-15 12:16:30 +01:00
parent f65393c68e
commit 77bac859bc
2 changed files with 8 additions and 4 deletions

View File

@ -54,8 +54,8 @@ ToolTip::ToolTip(QQuickItem *parent)
const QString configFile = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QStringLiteral("/plasmarc"); const QString configFile = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QStringLiteral("/plasmarc");
KDirWatch::self()->addFile(configFile); KDirWatch::self()->addFile(configFile);
QObject::connect(KDirWatch::self(), SIGNAL(created(QString)), this, SLOT(settingsChanged())); QObject::connect(KDirWatch::self(), &KDirWatch::created, this, &ToolTip::settingsChanged);
QObject::connect(KDirWatch::self(), SIGNAL(dirty(QString)), this, SLOT(settingsChanged())); QObject::connect(KDirWatch::self(), &KDirWatch::dirty, this, &ToolTip::settingsChanged);
} }
ToolTip::~ToolTip() 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(); KSharedConfig::openConfig(QStringLiteral("plasmarc"))->reparseConfiguration();
loadSettings(); loadSettings();
} }

View File

@ -189,7 +189,7 @@ Q_SIGNALS:
void interactiveChanged(); void interactiveChanged();
private Q_SLOTS: private Q_SLOTS:
void settingsChanged(); void settingsChanged(const QString &file);
private: private:
bool isValid() const; bool isValid() const;