From 5114494b57fef1551667e598686026b04d54e2b6 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 10 Dec 2019 11:21:23 +0000 Subject: [PATCH] [effects/startupfeedback] Port to KConfigWatcher Summary: startupfeedback is a special case, rather than loading our own config we load settings from klaunchrc. In order to reload this means leaking kwin specific calls into the launch feedback KCM. Using the new KConfigWatcher syntax, we can use a generic solution for all this code. Test Plan: Changed the value in KCM Opened dolphin cursor did the right thing Reviewers: zzag Reviewed By: zzag Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D25834 --- effects/startupfeedback/startupfeedback.cpp | 10 +++++++--- effects/startupfeedback/startupfeedback.h | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/effects/startupfeedback/startupfeedback.cpp b/effects/startupfeedback/startupfeedback.cpp index f28d0d25da..f7b7e538bc 100644 --- a/effects/startupfeedback/startupfeedback.cpp +++ b/effects/startupfeedback/startupfeedback.cpp @@ -82,6 +82,7 @@ StartupFeedbackEffect::StartupFeedbackEffect() , m_type(BouncingFeedback) , m_blinkingShader(nullptr) , m_cursorSize(0) + , m_configWatcher(KConfigWatcher::create(KSharedConfig::openConfig("klaunchrc", KConfig::NoGlobals))) { for (int i = 0; i < 5; ++i) { m_bouncingTextures[i] = nullptr; @@ -94,7 +95,11 @@ StartupFeedbackEffect::StartupFeedbackEffect() connect(m_startupInfo, &KStartupInfo::gotRemoveStartup, this, &StartupFeedbackEffect::gotRemoveStartup); connect(m_startupInfo, &KStartupInfo::gotStartupChange, this, &StartupFeedbackEffect::gotStartupChange); connect(effects, &EffectsHandler::mouseChanged, this, &StartupFeedbackEffect::slotMouseChanged); + connect(m_configWatcher.data(), &KConfigWatcher::configChanged, this, [this]() { + reconfigure(ReconfigureAll); + }); reconfigure(ReconfigureAll); + } StartupFeedbackEffect::~StartupFeedbackEffect() @@ -117,11 +122,10 @@ bool StartupFeedbackEffect::supported() void StartupFeedbackEffect::reconfigure(Effect::ReconfigureFlags flags) { Q_UNUSED(flags) - KConfig conf(QStringLiteral("klaunchrc"), KConfig::NoGlobals); - KConfigGroup c = conf.group("FeedbackStyle"); + KConfigGroup c = m_configWatcher->config()->group("FeedbackStyle"); const bool busyCursor = c.readEntry("BusyCursor", true); - c = conf.group("BusyCursorSettings"); + c = m_configWatcher->config()->group("BusyCursorSettings"); m_startupInfo->setTimeout(c.readEntry("Timeout", s_startupDefaultTimeout)); const bool busyBlinking = c.readEntry("Blinking", false); const bool busyBouncing = c.readEntry("Bouncing", true); diff --git a/effects/startupfeedback/startupfeedback.h b/effects/startupfeedback/startupfeedback.h index aa02f05121..59b94b9db7 100644 --- a/effects/startupfeedback/startupfeedback.h +++ b/effects/startupfeedback/startupfeedback.h @@ -23,6 +23,7 @@ along with this program. If not, see . #include #include #include +#include class KSelectionOwner; namespace KWin @@ -87,6 +88,7 @@ private: QRect m_currentGeometry, m_dirtyRect; GLShader *m_blinkingShader; int m_cursorSize; + KConfigWatcher::Ptr m_configWatcher; }; } // namespace