Commit 6db69ae0 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[KRunner] Watch config with KConfigWatcher

Rather than using a KDirWatch that points to the wrong place.

Differential Revision: https://phabricator.kde.org/D29411
parent f2e34dbb
......@@ -32,7 +32,6 @@
#include <KWindowSystem>
#include <KWindowEffects>
#include <KLocalizedString>
#include <KDirWatch>
#include <KCrash>
#include <kdeclarative/qmlobject.h>
......@@ -60,10 +59,17 @@ View::View(QWindow *)
//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 @@ View::View(QWindow *)
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 @@ View::View(QWindow *)
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 @@ void View::setFreeFloating(bool floating)
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());
......
......@@ -22,6 +22,7 @@
#include <QPointer>
#include <QQuickView>
#include <KConfigGroup>
#include <KConfigWatcher>
#include <KSharedConfig>
#include <KWayland/Client/plasmashell.h>
......@@ -85,7 +86,7 @@ protected Q_SLOTS:
void screenGeometryChanged();
void resetScreenPos();
void displayOrHide();
void reloadConfig();
void loadConfig();
void objectIncubated();
void slotFocusWindowChanged();
......@@ -94,6 +95,7 @@ private:
QPoint m_customPos;
KDeclarative::QmlObject *m_qmlObj;
KConfigGroup m_config;
KConfigWatcher::Ptr m_configWatcher;
qreal m_offset;
bool m_floating : 1;
QStringList m_history;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment