From d1708e3011969823e67869b8a1c639f15b6fd73a Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 10 Oct 2016 16:30:24 +0200 Subject: [PATCH 1/2] Port to new plasma-framework API Reduces unnecessary castings. Ports away the WindowedWidgets runner from KService REVIEW: 129101 --- applets/systemtray/systemtray.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/applets/systemtray/systemtray.cpp b/applets/systemtray/systemtray.cpp index e1cd610..ecc23a4 100644 --- a/applets/systemtray/systemtray.cpp +++ b/applets/systemtray/systemtray.cpp @@ -99,19 +99,19 @@ void SystemTray::init() { Containment::init(); - for (const auto &info: Plasma::PluginLoader::self()->listAppletInfo(QString())) { - if (!info.isValid() || info.property(QStringLiteral("X-Plasma-NotificationArea")) != "true") { + for (const auto &info: Plasma::PluginLoader::self()->listAppletMetaData(QString())) { + if (!info.isValid() || info.value(QStringLiteral("X-Plasma-NotificationArea")) != "true") { continue; } - m_systrayApplets[info.pluginName()] = info; + m_systrayApplets[info.pluginId()] = KPluginInfo(info); - if (info.isPluginEnabledByDefault()) { - m_defaultPlasmoids += info.pluginName(); + if (info.isEnabledByDefault()) { + m_defaultPlasmoids += info.pluginId(); } - const QString dbusactivation = info.property(QStringLiteral("X-Plasma-DBusActivationService")).toString(); + const QString dbusactivation = info.value(QStringLiteral("X-Plasma-DBusActivationService")); if (!dbusactivation.isEmpty()) { - qCDebug(SYSTEM_TRAY) << "ST Found DBus-able Applet: " << info.pluginName() << dbusactivation; - m_dbusActivatableTasks[info.pluginName()] = dbusactivation; + qCDebug(SYSTEM_TRAY) << "ST Found DBus-able Applet: " << info.pluginId() << dbusactivation; + m_dbusActivatableTasks[info.pluginId()] = dbusactivation; } } } @@ -119,12 +119,12 @@ void SystemTray::init() void SystemTray::newTask(const QString &task) { foreach (Plasma::Applet *applet, applets()) { - if (!applet->pluginInfo().isValid()) { + if (!applet->pluginMetaData().isValid()) { continue; } //only allow one instance per applet - if (task == applet->pluginInfo().pluginName()) { + if (task == applet->pluginMetaData().pluginId()) { //Applet::destroy doesn't delete the applet from Containment::applets in the same event //potentially a dbus activated service being restarted can be added in this time. if (!applet->destroyed()) { @@ -156,7 +156,7 @@ void SystemTray::newTask(const QString &task) void SystemTray::cleanupTask(const QString &task) { foreach (Plasma::Applet *applet, applets()) { - if (!applet->pluginInfo().isValid() || task == applet->pluginInfo().pluginName()) { + if (!applet->pluginMetaData().isValid() || task == applet->pluginMetaData().pluginId()) { //we are *not* cleaning the config here, because since is one //of those automatically loaded/unloaded by dbus, we want to recycle //the config the next time it's loaded, in case the user configured something here @@ -255,11 +255,11 @@ Q_INVOKABLE QString SystemTray::plasmoidCategory(QQuickItem *appletInterface) co } Plasma::Applet *applet = appletInterface->property("_plasma_applet").value(); - if (!applet || !applet->pluginInfo().isValid()) { + if (!applet || !applet->pluginMetaData().isValid()) { return "UnknownCategory"; } - const QString cat = applet->pluginInfo().property(QStringLiteral("X-Plasma-NotificationAreaCategory")).toString(); + const QString cat = applet->pluginMetaData().value(QStringLiteral("X-Plasma-NotificationAreaCategory")); if (cat.isEmpty()) { return "UnknownCategory"; @@ -385,11 +385,11 @@ void SystemTray::restorePlasmoids() foreach (Plasma::Applet *applet, applets()) { //Here it should always be valid. //for some reason it not always is. - if (!applet->pluginInfo().isValid()) { + if (!applet->pluginMetaData().isValid()) { applet->config().parent().deleteGroup(); applet->deleteLater(); } else { - const QString task = applet->pluginInfo().pluginName(); + const QString task = applet->pluginMetaData().pluginId(); if (!m_allowedPlasmoids.contains(task)) { //in those cases we do delete the applet config completely //as they were explicitly disabled by the user -- 2.7.4