Commit 3bc87f03 authored by Fushan Wen's avatar Fushan Wen 💬 Committed by Marco Martin
Browse files

calendar: use normal type for EventPluginsManager, don't use singleton

It fixes that when there are multiple calendar applets, each applet
doesn't have its own EventPluginsManager.

BUG: 454846
FIXED-IN: 5.26
parent 25aaec21
Pipeline #190872 passed with stage
in 13 minutes and 41 seconds
......@@ -31,8 +31,14 @@ ConfigModel {
source: "configTimeZones.qml"
}
property QtObject eventPluginsManager: PlasmaCalendar.EventPluginsManager {
Component.onCompleted: {
populateEnabledPluginsList(Plasmoid.configuration.enabledCalendarPlugins);
}
}
property Instantiator __eventPlugins: Instantiator {
model: PlasmaCalendar.EventPluginsManager.model
model: eventPluginsManager.model
delegate: ConfigCategory {
name: model.display
icon: model.decoration
......
......@@ -37,7 +37,7 @@ PlasmaExtras.Representation {
collapseMarginsHint: true
readonly property int paddings: PlasmaCore.Units.smallSpacing
readonly property bool showAgenda: PlasmaCalendar.EventPluginsManager.enabledPlugins.length > 0
readonly property bool showAgenda: eventPluginsManager.enabledPlugins.length > 0
readonly property bool showClocks: Plasmoid.configuration.selectedTimeZones.length > 1
property alias borderWidth: monthView.borderWidth
......@@ -257,6 +257,11 @@ PlasmaExtras.Representation {
}
}
PlasmaCalendar.EventPluginsManager {
id: eventPluginsManager
enabledPlugins: Plasmoid.configuration.enabledCalendarPlugins
}
// Left column containing agenda view and time zones
// ==================================================
ColumnLayout {
......@@ -335,14 +340,6 @@ PlasmaExtras.Representation {
}
}
Connections {
target: Plasmoid.configuration
onEnabledCalendarPluginsChanged: {
PlasmaCalendar.EventPluginsManager.enabledPlugins = Plasmoid.configuration.enabledCalendarPlugins;
}
}
Binding {
target: Plasmoid.self
property: "hideOnWindowDeactivate"
......@@ -629,6 +626,7 @@ PlasmaExtras.Representation {
id: monthView
anchors.margins: PlasmaCore.Units.smallSpacing
borderOpacity: 0.25
eventPluginsManager: eventPluginsManager
today: root.tzDate
firstDayOfWeek: Plasmoid.configuration.firstDayOfWeek > -1
? Plasmoid.configuration.firstDayOfWeek
......
......@@ -23,7 +23,14 @@ Item {
function saveConfig()
{
Plasmoid.configuration.enabledCalendarPlugins = PlasmaCalendar.EventPluginsManager.enabledPlugins;
Plasmoid.configuration.enabledCalendarPlugins = eventPluginsManager.enabledPlugins;
}
PlasmaCalendar.EventPluginsManager {
id: eventPluginsManager
Component.onCompleted: {
populateEnabledPluginsList(Plasmoid.configuration.enabledCalendarPlugins);
}
}
Kirigami.FormLayout {
......@@ -68,7 +75,7 @@ Item {
Repeater {
id: calendarPluginsRepeater
model: PlasmaCalendar.EventPluginsManager.model
model: eventPluginsManager.model
delegate: QtLayouts.RowLayout {
QtControls.CheckBox {
text: model.display
......@@ -83,9 +90,5 @@ Item {
}
}
}
Component.onCompleted: {
PlasmaCalendar.EventPluginsManager.populateEnabledPluginsList(Plasmoid.configuration.enabledCalendarPlugins);
}
}
......@@ -128,9 +128,5 @@ Item {
if (KCMShell.authorize("kcm_formats.desktop").length > 0) {
Plasmoid.setAction("formatskcm", i18n("Set Time Format…"), "gnumeric-format-thousand-separator");
}
// Set the list of enabled plugins from config
// to the manager
PlasmaCalendar.EventPluginsManager.enabledPlugins = Plasmoid.configuration.enabledCalendarPlugins;
}
}
......@@ -13,20 +13,12 @@
#include <QQmlEngine>
#include <QtQml>
static QObject *event_plugins_manager_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new EventPluginsManager();
}
void CalendarPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QByteArray("org.kde.plasma.workspace.calendar"));
qmlRegisterType<Calendar>(uri, 2, 0, "Calendar");
qmlRegisterType<EventPluginsManager>(uri, 2, 0, "EventPluginsManager");
qmlRegisterAnonymousType<QAbstractItemModel>(uri, 1);
qmlRegisterAnonymousType<QAbstractListModel>(uri, 1);
qmlRegisterSingletonType<EventPluginsManager>(uri, 2, 0, "EventPluginsManager", event_plugins_manager_provider);
qmlRegisterUncreatableType<EventDataDecorator>(uri, 2, 0, "EventDataDecorator", QStringLiteral("Unable to create EventDataDecorator from QML"));
}
......@@ -390,6 +390,10 @@ bool DaysModel::hasMinorEventAtDate(const QDate &date) const
void DaysModel::setPluginsManager(QObject *manager)
{
if (d->m_pluginsManager) {
disconnect(d->m_pluginsManager, nullptr, this, nullptr);
}
EventPluginsManager *m = qobject_cast<EventPluginsManager *>(manager);
if (!m) {
......
......@@ -37,6 +37,10 @@ PinchArea { // TODO KF6 switch to Item
* \sa Calendar::firstDayOfWeek
*/
property alias firstDayOfWeek: calendarBackend.firstDayOfWeek
/**
* The event plugins manager used in the view
*/
property QtObject eventPluginsManager
property QtObject date
property date currentDate
......@@ -190,7 +194,7 @@ PinchArea { // TODO KF6 switch to Item
today: root.today
Component.onCompleted: {
daysModel.setPluginsManager(EventPluginsManager);
daysModel.setPluginsManager(root.eventPluginsManager);
}
onYearChanged: {
......
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