From cfd0ba7806d454fe4b5d0e96a5e6cb8ab254fd8b Mon Sep 17 00:00:00 2001 From: David Redondo Date: Mon, 1 Mar 2021 10:44:32 +0100 Subject: [PATCH] Use separate face controller for appearance config This is a workaround for the page being totally broken on when opened again after the dialog was closed for the first time. Using a new controller works around that. BUG:424458 --- .../package/contents/ui/config/ConfigAppearance.qml | 8 +++++--- applets/systemmonitor/systemmonitor/systemmonitor.cpp | 7 +++++++ applets/systemmonitor/systemmonitor/systemmonitor.h | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/applets/systemmonitor/systemmonitor/package/contents/ui/config/ConfigAppearance.qml b/applets/systemmonitor/systemmonitor/package/contents/ui/config/ConfigAppearance.qml index 71dfc747e..f5b95df83 100644 --- a/applets/systemmonitor/systemmonitor/package/contents/ui/config/ConfigAppearance.qml +++ b/applets/systemmonitor/systemmonitor/package/contents/ui/config/ConfigAppearance.qml @@ -39,10 +39,12 @@ QQC2.Control { function saveConfig() { contentItem.saveConfig(); + plasmoid.nativeInterface.faceController.reloadConfig() } - - contentItem: plasmoid.nativeInterface.faceController.appearanceConfigUi - + + // Workaround for Bug 424458, when reusing the controller/item things break + contentItem: plasmoid.nativeInterface.workaroundController(root).appearanceConfigUi + Connections { target: contentItem function onConfigurationChanged() { diff --git a/applets/systemmonitor/systemmonitor/systemmonitor.cpp b/applets/systemmonitor/systemmonitor/systemmonitor.cpp index 345d4483f..613e07c8e 100644 --- a/applets/systemmonitor/systemmonitor/systemmonitor.cpp +++ b/applets/systemmonitor/systemmonitor/systemmonitor.cpp @@ -77,6 +77,13 @@ KSysGuard::SensorFaceController *SystemMonitor::faceController() const return m_sensorFaceController; } +KSysGuard::SensorFaceController *SystemMonitor::workaroundController(QQuickItem *context) const +{ + KConfigGroup cg = config(); + return new KSysGuard::SensorFaceController(cg, qmlEngine(context)); +} + + void SystemMonitor::configChanged() { if (m_sensorFaceController) { diff --git a/applets/systemmonitor/systemmonitor/systemmonitor.h b/applets/systemmonitor/systemmonitor/systemmonitor.h index b81e9d549..f1b6fa828 100644 --- a/applets/systemmonitor/systemmonitor/systemmonitor.h +++ b/applets/systemmonitor/systemmonitor/systemmonitor.h @@ -52,6 +52,9 @@ public: KSysGuard::SensorFaceController *faceController() const; + // Workaround for Bug 424458, when reusing the controller/item things break in ConfigAppearance + Q_INVOKABLE KSysGuard::SensorFaceController *workaroundController(QQuickItem *context) const; + public Q_SLOTS: void configChanged() override;