summaryrefslogtreecommitdiff
path: root/kde-plasma/plasma-workspace/files/plasma-workspace-5.27.8-plasmacalendarintegration-holidayregion.patch
blob: d9fc57716763444ecc6032c48bbaa2c815d8b1d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
From 51dcf82db5990dde9cf3e6b3132dfff2c129bee5 Mon Sep 17 00:00:00 2001
From: Eugene Popov <popov895@ukr.net>
Date: Thu, 21 Sep 2023 10:31:48 +0000
Subject: [PATCH] [plasmacalendarintegration] Fix selected regions are randomly
 reset to default

Check whether we are reading the selected regions from the group we need.

BUG: 472483
FIXED-IN: 5.27.9

(cherry picked from commit 72444337c24dac114765ff28768bd55f7e5018c5)
---
 plasmacalendarintegration/holidaysevents.cpp | 19 +++++++++----------
 plasmacalendarintegration/holidaysevents.h   |  1 -
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/plasmacalendarintegration/holidaysevents.cpp b/plasmacalendarintegration/holidaysevents.cpp
index 1e632a602e..605c1bd214 100644
--- a/plasmacalendarintegration/holidaysevents.cpp
+++ b/plasmacalendarintegration/holidaysevents.cpp
@@ -7,18 +7,19 @@
 #include "holidaysevents.h"
 
 #include <KConfigGroup>
-#include <QDebug>
 
 HolidaysEventsPlugin::HolidaysEventsPlugin(QObject *parent)
     : CalendarEvents::CalendarEventsPlugin(parent)
 {
-    KSharedConfig::Ptr m_config = KSharedConfig::openConfig(QStringLiteral("plasma_calendar_holiday_regions"));
-    const KConfigGroup regionsConfig = m_config->group("General");
-    updateSettings(regionsConfig);
+    KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasma_calendar_holiday_regions"), KConfig::NoGlobals);
+    updateSettings(config->group("General"));
 
-    m_configWatcher = KConfigWatcher::create(m_config);
-    connect(m_configWatcher.get(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &config) {
-        updateSettings(config);
+    m_configWatcher = KConfigWatcher::create(config);
+    connect(m_configWatcher.get(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &configGroup) {
+        if (configGroup.name() != QLatin1String("General")) {
+            return;
+        }
+        updateSettings(configGroup);
         loadEventsForDateRange(m_lastStartDate, m_lastEndDate);
     });
 }
@@ -35,9 +36,7 @@ void HolidaysEventsPlugin::loadEventsForDateRange(const QDate &startDate, const
         return;
     }
 
-    m_lastData.clear();
     QMultiHash<QDate, CalendarEvents::EventData> data;
-
     for (KHolidays::HolidayRegion *region : qAsConst(m_regions)) {
         const KHolidays::Holiday::List holidays = region->rawHolidays(startDate, endDate);
 
@@ -61,7 +60,7 @@ void HolidaysEventsPlugin::loadEventsForDateRange(const QDate &startDate, const
     m_lastEndDate = endDate;
     m_lastData = data;
 
-    Q_EMIT dataReady(data);
+    Q_EMIT dataReady(m_lastData);
 }
 
 void HolidaysEventsPlugin::updateSettings(const KConfigGroup &regionsConfig)
diff --git a/plasmacalendarintegration/holidaysevents.h b/plasmacalendarintegration/holidaysevents.h
index 93067049f8..1658d9d122 100644
--- a/plasmacalendarintegration/holidaysevents.h
+++ b/plasmacalendarintegration/holidaysevents.h
@@ -32,6 +32,5 @@ private:
     QDate m_lastEndDate;
     QList<KHolidays::HolidayRegion *> m_regions;
     QMultiHash<QDate, CalendarEvents::EventData> m_lastData;
-    KSharedConfig::Ptr m_config;
     KConfigWatcher::Ptr m_configWatcher;
 };
-- 
GitLab