You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
410 lines
19 KiB
410 lines
19 KiB
From d1708e3011969823e67869b8a1c639f15b6fd73a Mon Sep 17 00:00:00 2001
|
|
From: Aleix Pol <aleixpol@kde.org>
|
|
Date: Mon, 10 Oct 2016 16:30:24 +0200
|
|
Subject: [PATCH 31/59] Port to new plasma-framework API
|
|
|
|
Reduces unnecessary castings.
|
|
Ports away the WindowedWidgets runner from KService
|
|
|
|
REVIEW: 129101
|
|
---
|
|
applets/systemtray/systemtray.cpp | 30 +++++++-------
|
|
.../shellprivate/widgetexplorer/widgetexplorer.cpp | 14 +++----
|
|
plasma-windowed/plasmawindowedcorona.cpp | 2 +-
|
|
runners/windowedwidgets/windowedwidgetsrunner.cpp | 46 ++++++++++------------
|
|
runners/windowedwidgets/windowedwidgetsrunner.h | 2 +-
|
|
shell/alternativeshelper.cpp | 6 +--
|
|
shell/containmentconfigview.cpp | 2 +-
|
|
shell/scripting/containment.cpp | 4 +-
|
|
shell/scripting/widget.cpp | 2 +-
|
|
shell/shellcorona.cpp | 15 +++----
|
|
10 files changed, 60 insertions(+), 63 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<Plasma::Applet*>();
|
|
- 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
|
|
diff --git a/components/shellprivate/widgetexplorer/widgetexplorer.cpp b/components/shellprivate/widgetexplorer/widgetexplorer.cpp
|
|
index 7274d04..4915ab2 100644
|
|
--- a/components/shellprivate/widgetexplorer/widgetexplorer.cpp
|
|
+++ b/components/shellprivate/widgetexplorer/widgetexplorer.cpp
|
|
@@ -249,14 +249,14 @@ void WidgetExplorerPrivate::addContainment(Containment *containment)
|
|
QObject::connect(containment, SIGNAL(appletRemoved(Plasma::Applet*)), q, SLOT(appletRemoved(Plasma::Applet*)));
|
|
|
|
foreach (Applet *applet, containment->applets()) {
|
|
- if (applet->pluginInfo().isValid()) {
|
|
+ if (applet->pluginMetaData().isValid()) {
|
|
Containment *childContainment = applet->property("containment").value<Containment*>();
|
|
if (childContainment) {
|
|
addContainment(childContainment);
|
|
}
|
|
- runningApplets[applet->pluginInfo().pluginName()]++;
|
|
+ runningApplets[applet->pluginMetaData().pluginId()]++;
|
|
} else {
|
|
- qDebug() << "Invalid plugininfo. :(";
|
|
+ qDebug() << "Invalid plugin metadata. :(";
|
|
}
|
|
}
|
|
}
|
|
@@ -268,10 +268,10 @@ void WidgetExplorerPrivate::containmentDestroyed()
|
|
|
|
void WidgetExplorerPrivate::appletAdded(Plasma::Applet *applet)
|
|
{
|
|
- if (!applet->pluginInfo().isValid()) {
|
|
+ if (!applet->pluginMetaData().isValid()) {
|
|
return;
|
|
}
|
|
- QString name = applet->pluginInfo().pluginName();
|
|
+ QString name = applet->pluginMetaData().pluginId();
|
|
|
|
runningApplets[name]++;
|
|
appletNames.insert(applet, name);
|
|
@@ -471,9 +471,9 @@ void WidgetExplorer::uninstall(const QString &pluginName)
|
|
const auto &applets = c->applets();
|
|
|
|
foreach (Applet *applet, applets) {
|
|
- const auto &appletInfo = applet->pluginInfo();
|
|
+ const auto &appletInfo = applet->pluginMetaData();
|
|
|
|
- if (appletInfo.isValid() && appletInfo.pluginName() == pluginName) {
|
|
+ if (appletInfo.isValid() && appletInfo.pluginId() == pluginName) {
|
|
applet->destroy();
|
|
}
|
|
}
|
|
diff --git a/plasma-windowed/plasmawindowedcorona.cpp b/plasma-windowed/plasmawindowedcorona.cpp
|
|
index fbacbf8..b68d270 100644
|
|
--- a/plasma-windowed/plasmawindowedcorona.cpp
|
|
+++ b/plasma-windowed/plasmawindowedcorona.cpp
|
|
@@ -51,7 +51,7 @@ void PlasmaWindowedCorona::loadApplet(const QString &applet, const QVariantList
|
|
|
|
//forbid more instances per applet (todo: activate the correpsponding already loaded applet)
|
|
for (Plasma::Applet *a : cont->applets()) {
|
|
- if (a->pluginInfo().pluginName() == applet) {
|
|
+ if (a->pluginMetaData().pluginId() == applet) {
|
|
return;
|
|
}
|
|
}
|
|
diff --git a/runners/windowedwidgets/windowedwidgetsrunner.cpp b/runners/windowedwidgets/windowedwidgetsrunner.cpp
|
|
index 5ccbd27..7f093a7 100644
|
|
--- a/runners/windowedwidgets/windowedwidgetsrunner.cpp
|
|
+++ b/runners/windowedwidgets/windowedwidgetsrunner.cpp
|
|
@@ -60,24 +60,22 @@ void WindowedWidgetsRunner::match(Plasma::RunnerContext &context)
|
|
|
|
QList<Plasma::QueryMatch> matches;
|
|
|
|
- foreach (const KPluginInfo &info, Plasma::PluginLoader::self()->listAppletInfo(QString())) {
|
|
- KService::Ptr service = info.service();
|
|
-
|
|
- if (((service->name().contains(term, Qt::CaseInsensitive) ||
|
|
- service->genericName().contains(term, Qt::CaseInsensitive) ||
|
|
- service->comment().contains(term, Qt::CaseInsensitive)) ||
|
|
- service->categories().contains(term, Qt::CaseInsensitive) ||
|
|
+ foreach (const KPluginMetaData &md, Plasma::PluginLoader::self()->listAppletMetaData(QString())) {
|
|
+ if (((md.name().contains(term, Qt::CaseInsensitive) ||
|
|
+ md.value(QLatin1String("GenericName")).contains(term, Qt::CaseInsensitive) ||
|
|
+ md.description().contains(term, Qt::CaseInsensitive)) ||
|
|
+ md.category().contains(term, Qt::CaseInsensitive) ||
|
|
term.startsWith(i18nc("Note this is a KRunner keyword", "mobile applications"))) &&
|
|
- !info.property(QStringLiteral("NoDisplay")).toBool()) {
|
|
+ !md.rawData().value(QStringLiteral("NoDisplay")).toBool()) {
|
|
|
|
- QVariant val = info.property(QStringLiteral("X-Plasma-StandAloneApp"));
|
|
+ QVariant val = md.value(QStringLiteral("X-Plasma-StandAloneApp"));
|
|
if (!val.isValid() || !val.toBool()) {
|
|
continue;
|
|
}
|
|
|
|
Plasma::QueryMatch match(this);
|
|
- setupMatch(service, match);
|
|
- if (service->name().compare(term, Qt::CaseInsensitive) == 0) {
|
|
+ setupMatch(md, match);
|
|
+ if (md.name().compare(term, Qt::CaseInsensitive) == 0) {
|
|
match.setType(Plasma::QueryMatch::ExactMatch);
|
|
match.setRelevance(1);
|
|
} else {
|
|
@@ -85,8 +83,6 @@ void WindowedWidgetsRunner::match(Plasma::RunnerContext &context)
|
|
match.setRelevance(0.7);
|
|
}
|
|
matches << match;
|
|
-
|
|
- qDebug() << service;
|
|
}
|
|
}
|
|
|
|
@@ -100,27 +96,27 @@ void WindowedWidgetsRunner::match(Plasma::RunnerContext &context)
|
|
void WindowedWidgetsRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
|
|
{
|
|
Q_UNUSED(context);
|
|
- KService::Ptr service = KService::serviceByStorageId(match.data().toString());
|
|
- if (service) {
|
|
- QProcess::startDetached(QStringLiteral("plasmawindowed"), QStringList() << service->property(QStringLiteral("X-KDE-PluginInfo-Name"), QVariant::String).toString());
|
|
+ KPluginMetaData md(match.data().toString());
|
|
+ if (md.isValid()) {
|
|
+ QProcess::startDetached(QStringLiteral("plasmawindowed"), QStringList() << md.pluginId());
|
|
}
|
|
}
|
|
|
|
-void WindowedWidgetsRunner::setupMatch(const KService::Ptr &service, Plasma::QueryMatch &match)
|
|
+void WindowedWidgetsRunner::setupMatch(const KPluginMetaData &md, Plasma::QueryMatch &match)
|
|
{
|
|
- const QString name = service->name();
|
|
+ const QString name = md.pluginId();
|
|
|
|
match.setText(name);
|
|
- match.setData(service->storageId());
|
|
+ match.setData(md.metaDataFileName());
|
|
|
|
- if (!service->genericName().isEmpty() && service->genericName() != name) {
|
|
- match.setSubtext(service->genericName());
|
|
- } else if (!service->comment().isEmpty()) {
|
|
- match.setSubtext(service->comment());
|
|
+ if (!md.name().isEmpty() && md.name() != name) {
|
|
+ match.setSubtext(md.name());
|
|
+ } else if (!md.description().isEmpty()) {
|
|
+ match.setSubtext(md.description());
|
|
}
|
|
|
|
- if (!service->icon().isEmpty()) {
|
|
- match.setIconName(service->icon());
|
|
+ if (!md.iconName().isEmpty()) {
|
|
+ match.setIconName(md.iconName());
|
|
}
|
|
}
|
|
|
|
diff --git a/runners/windowedwidgets/windowedwidgetsrunner.h b/runners/windowedwidgets/windowedwidgetsrunner.h
|
|
index 2294965..fbc8006 100644
|
|
--- a/runners/windowedwidgets/windowedwidgetsrunner.h
|
|
+++ b/runners/windowedwidgets/windowedwidgetsrunner.h
|
|
@@ -48,7 +48,7 @@ protected Q_SLOTS:
|
|
|
|
|
|
protected:
|
|
- void setupMatch(const KService::Ptr &service, Plasma::QueryMatch &action);
|
|
+ void setupMatch(const KPluginMetaData &md, Plasma::QueryMatch &action);
|
|
};
|
|
|
|
#endif
|
|
diff --git a/shell/alternativeshelper.cpp b/shell/alternativeshelper.cpp
|
|
index d0f5dfd..6d76307 100644
|
|
--- a/shell/alternativeshelper.cpp
|
|
+++ b/shell/alternativeshelper.cpp
|
|
@@ -38,12 +38,12 @@ AlternativesHelper::~AlternativesHelper()
|
|
|
|
QStringList AlternativesHelper::appletProvides() const
|
|
{
|
|
- return m_applet->pluginInfo().property(QStringLiteral("X-Plasma-Provides")).toStringList();
|
|
+ return KPluginMetaData::readStringList(m_applet->pluginMetaData().rawData(), QStringLiteral("X-Plasma-Provides"));
|
|
}
|
|
|
|
QString AlternativesHelper::currentPlugin() const
|
|
{
|
|
- return m_applet->pluginInfo().pluginName();
|
|
+ return m_applet->pluginMetaData().pluginId();
|
|
}
|
|
|
|
QQuickItem *AlternativesHelper::applet() const
|
|
@@ -53,7 +53,7 @@ QQuickItem *AlternativesHelper::applet() const
|
|
|
|
void AlternativesHelper::loadAlternative(const QString &plugin)
|
|
{
|
|
- if (plugin == m_applet->pluginInfo().pluginName() || m_applet->isContainment()) {
|
|
+ if (plugin == m_applet->pluginMetaData().pluginId() || m_applet->isContainment()) {
|
|
return;
|
|
}
|
|
|
|
diff --git a/shell/containmentconfigview.cpp b/shell/containmentconfigview.cpp
|
|
index cec067e..4c9d146 100644
|
|
--- a/shell/containmentconfigview.cpp
|
|
+++ b/shell/containmentconfigview.cpp
|
|
@@ -104,7 +104,7 @@ QAbstractItemModel *ContainmentConfigView::currentContainmentActionsModel()
|
|
|
|
QString ContainmentConfigView::containmentPlugin() const
|
|
{
|
|
- return m_containment->pluginInfo().pluginName();
|
|
+ return m_containment->pluginMetaData().pluginId();
|
|
}
|
|
|
|
void ContainmentConfigView::setContainmentPlugin(const QString &plugin)
|
|
diff --git a/shell/scripting/containment.cpp b/shell/scripting/containment.cpp
|
|
index 6040e62..96e2009 100644
|
|
--- a/shell/scripting/containment.cpp
|
|
+++ b/shell/scripting/containment.cpp
|
|
@@ -248,7 +248,7 @@ QScriptValue Containment::widgets(QScriptContext *context, QScriptEngine *engine
|
|
int count = 0;
|
|
|
|
foreach (Plasma::Applet *widget, c->d->containment.data()->applets()) {
|
|
- if (widgetType.isEmpty() || widget->pluginInfo().pluginName() == widgetType) {
|
|
+ if (widgetType.isEmpty() || widget->pluginMetaData().pluginId() == widgetType) {
|
|
widgets.setProperty(count, env->wrap(widget));
|
|
++count;
|
|
}
|
|
@@ -273,7 +273,7 @@ QString Containment::type() const
|
|
return QString();
|
|
}
|
|
|
|
- return d->containment.data()->pluginInfo().pluginName();
|
|
+ return d->containment.data()->pluginMetaData().pluginId();
|
|
}
|
|
|
|
void Containment::remove()
|
|
diff --git a/shell/scripting/widget.cpp b/shell/scripting/widget.cpp
|
|
index a651c2a..b58822b 100644
|
|
--- a/shell/scripting/widget.cpp
|
|
+++ b/shell/scripting/widget.cpp
|
|
@@ -65,7 +65,7 @@ uint Widget::id() const
|
|
QString Widget::type() const
|
|
{
|
|
if (d->applet) {
|
|
- return d->applet.data()->pluginInfo().pluginName();
|
|
+ return d->applet.data()->pluginMetaData().pluginId();
|
|
}
|
|
|
|
return QString();
|
|
diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp
|
|
index 152ffeb..2c3e734 100644
|
|
--- a/shell/shellcorona.cpp
|
|
+++ b/shell/shellcorona.cpp
|
|
@@ -406,7 +406,7 @@ QByteArray ShellCorona::dumpCurrentLayoutJS() const
|
|
|| cont->location() == Plasma::Types::BottomEdge
|
|
|| cont->location() == Plasma::Types::LeftEdge
|
|
|| cont->location() == Plasma::Types::RightEdge) &&
|
|
- cont->pluginInfo().pluginName() != QStringLiteral("org.kde.plasma.private.systemtray");
|
|
+ cont->pluginMetaData().pluginId() != QStringLiteral("org.kde.plasma.private.systemtray");
|
|
};
|
|
|
|
auto isDesktop = [] (Plasma::Containment *cont) {
|
|
@@ -486,7 +486,7 @@ QByteArray ShellCorona::dumpCurrentLayoutJS() const
|
|
|
|
KConfigGroup appletConfig = applet->config();
|
|
|
|
- appletJson.insert("plugin", applet->pluginInfo().pluginName());
|
|
+ appletJson.insert("plugin", applet->pluginMetaData().pluginId());
|
|
appletJson.insert("config", dumpconfigGroupJS(appletConfig));
|
|
|
|
appletsJsonArray << appletJson;
|
|
@@ -553,7 +553,7 @@ QByteArray ShellCorona::dumpCurrentLayoutJS() const
|
|
QJsonObject appletJson;
|
|
|
|
appletJson.insert("title", applet->title());
|
|
- appletJson.insert("plugin", applet->pluginInfo().pluginName());
|
|
+ appletJson.insert("plugin", applet->pluginMetaData().pluginId());
|
|
|
|
appletJson.insert("geometry.x", geometry.x() / gridUnit);
|
|
appletJson.insert("geometry.y", geometry.y() / gridUnit);
|
|
@@ -1230,11 +1230,11 @@ void ShellCorona::handleContainmentAdded(Plasma::Containment *c)
|
|
|
|
void ShellCorona::executeSetupPlasmoidScript(Plasma::Containment *containment, Plasma::Applet *applet)
|
|
{
|
|
- if (!applet->pluginInfo().isValid() || !containment->pluginInfo().isValid()) {
|
|
+ if (!applet->pluginMetaData().isValid() || !containment->pluginMetaData().isValid()) {
|
|
return;
|
|
}
|
|
|
|
- const QString scriptFile = m_lookAndFeelPackage.filePath("plasmoidsetupscripts", applet->pluginInfo().pluginName() + ".js");
|
|
+ const QString scriptFile = m_lookAndFeelPackage.filePath("plasmoidsetupscripts", applet->pluginMetaData().pluginId() + ".js");
|
|
|
|
if (scriptFile.isEmpty()) {
|
|
return;
|
|
@@ -1533,7 +1533,7 @@ Plasma::Containment *ShellCorona::setContainmentTypeForScreen(int screen, const
|
|
//if creation failed or invalid plugin, give up
|
|
if (!newContainment) {
|
|
return oldContainment;
|
|
- } else if (!newContainment->pluginInfo().isValid()) {
|
|
+ } else if (!newContainment->pluginMetaData().isValid()) {
|
|
newContainment->deleteLater();
|
|
return oldContainment;
|
|
}
|
|
@@ -1966,7 +1966,8 @@ void ShellCorona::activateLauncherMenu()
|
|
for (auto it = m_panelViews.constBegin(), end = m_panelViews.constEnd(); it != end; ++it) {
|
|
const auto applets = it.key()->applets();
|
|
for (auto applet : applets) {
|
|
- if (applet->pluginInfo().property("X-Plasma-Provides").toStringList().contains(QStringLiteral("org.kde.plasma.launchermenu"))) {
|
|
+ const auto provides = KPluginMetaData::readStringList(applet->pluginMetaData().rawData(), QStringLiteral("X-Plasma-Provides"));
|
|
+ if (provides.contains(QLatin1String("org.kde.plasma.launchermenu"))) {
|
|
if (!applet->globalShortcut().isEmpty()) {
|
|
emit applet->activated();
|
|
return;
|
|
--
|
|
2.7.4
|
|
|