diff --git a/krunner/view.h b/krunner/view.h --- a/krunner/view.h +++ b/krunner/view.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -85,15 +86,16 @@ void screenGeometryChanged(); void resetScreenPos(); void displayOrHide(); - void reloadConfig(); + void loadConfig(); void objectIncubated(); void slotFocusWindowChanged(); private: void writeHistory(); QPoint m_customPos; KDeclarative::QmlObject *m_qmlObj; KConfigGroup m_config; + KConfigWatcher::Ptr m_configWatcher; qreal m_offset; bool m_floating : 1; QStringList m_history; diff --git a/krunner/view.cpp b/krunner/view.cpp --- a/krunner/view.cpp +++ b/krunner/view.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -60,10 +59,17 @@ //used only by screen readers setTitle(i18n("KRunner")); - m_config = KConfigGroup(KSharedConfig::openConfig(QStringLiteral("krunnerrc")), "General"); - setFreeFloating(m_config.readEntry("FreeFloating", false)); - reloadConfig(); + m_config = KConfigGroup(KSharedConfig::openConfig(), "General"); + m_configWatcher = KConfigWatcher::create(KSharedConfig::openConfig()); + connect(m_configWatcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &names) { + Q_UNUSED(names); + if (group.name() == QLatin1String("General")) { + loadConfig(); + } + }); + + loadConfig(); new AppAdaptor(this); QDBusConnection::sessionBus().registerObject(QStringLiteral("/App"), this); @@ -73,7 +79,7 @@ connect(m_qmlObj, &KDeclarative::QmlObject::finished, this, &View::objectIncubated); KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); - KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE"); + KConfigGroup cg(KSharedConfig::openConfig(), "KDE"); const QString packageName = cg.readEntry("LookAndFeelPackage", QString()); if (!packageName.isEmpty()) { package.setPath(packageName); @@ -106,12 +112,6 @@ connect(this, &View::visibleChanged, this, &View::resetScreenPos); - KDirWatch::self()->addFile(m_config.name()); - - // Catch both, direct changes to the config file ... - connect(KDirWatch::self(), &KDirWatch::dirty, this, &View::reloadConfig); - connect(KDirWatch::self(), &KDirWatch::created, this, &View::reloadConfig); - if (m_floating) { setLocation(Plasma::Types::Floating); } else { @@ -160,9 +160,8 @@ positionOnScreen(); } -void View::reloadConfig() +void View::loadConfig() { - m_config.config()->reparseConfiguration(); setFreeFloating(m_config.readEntry("FreeFloating", false)); const QStringList history = m_config.readEntry("history", QStringList());