Verified Commit a9f85e2e authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

alternatecalendar: Reload config on config changed

CCBUG: 429892
parent 1123ebec
......@@ -7,6 +7,7 @@
#include "alternatecalendarplugin.h"
#include <KConfigGroup>
#include <KConfigWatcher>
#include <KSharedConfig>
#include "provider/qtcalendar.h"
......@@ -26,7 +27,10 @@ public:
private:
std::unique_ptr<AbstractCalendarProvider> m_calendarProvider;
// For updating config
KConfigGroup m_generalConfigGroup;
KConfigWatcher::Ptr m_configWatcher;
AlternateCalendarPlugin *q;
};
......@@ -35,6 +39,8 @@ AlternateCalendarPluginPrivate::AlternateCalendarPluginPrivate(AlternateCalendar
{
auto config = KSharedConfig::openConfig(QStringLiteral("plasma_calendar_alternatecalendar"));
m_generalConfigGroup = config->group("General");
m_configWatcher = KConfigWatcher::create(config);
QObject::connect(m_configWatcher.get(), &KConfigWatcher::configChanged, q, &AlternateCalendarPlugin::updateSettings);
init();
}
......@@ -87,6 +93,9 @@ void AlternateCalendarPlugin::loadEventsForDateRange(const QDate &startDate, con
return;
}
m_lastStartDate = startDate;
m_lastEndDate = endDate;
QHash<QDate, QDate> alternateDatesData;
QHash<QDate, SubLabel> subLabelsData;
......@@ -105,3 +114,9 @@ void AlternateCalendarPlugin::loadEventsForDateRange(const QDate &startDate, con
}
Q_EMIT subLabelReady(subLabelsData);
}
void AlternateCalendarPlugin::updateSettings()
{
d->init();
loadEventsForDateRange(m_lastStartDate, m_lastEndDate);
}
......@@ -25,8 +25,14 @@ public:
void loadEventsForDateRange(const QDate &startDate, const QDate &endDate) override;
public Q_SLOTS:
void updateSettings();
private:
const std::unique_ptr<class AlternateCalendarPluginPrivate> d;
QDate m_lastStartDate;
QDate m_lastEndDate;
};
#endif
Supports Markdown
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