ContainmentAction: Fix loading from KPlugin

Summary: At the moment it was enabled in the PluginLoader but we were not using it anywhere.

Test Plan: See patch in plasma-workspace.

Reviewers: #plasma, #frameworks, mart

Reviewed By: #plasma, mart

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D22267
This commit is contained in:
Aleix Pol 2019-07-05 01:03:51 +02:00
parent 35862c093d
commit 46f0da45c6
3 changed files with 9 additions and 9 deletions

View File

@ -37,14 +37,13 @@ namespace Plasma
{ {
ContainmentActions::ContainmentActions(QObject *parentObject) ContainmentActions::ContainmentActions(QObject *parentObject)
: d(new ContainmentActionsPrivate(KService::serviceByStorageId(QString()), this)) : d(new ContainmentActionsPrivate({}, this))
{ {
setParent(parentObject); setParent(parentObject);
} }
ContainmentActions::ContainmentActions(QObject *parentObject, const QVariantList &args) ContainmentActions::ContainmentActions(QObject *parentObject, const QVariantList &args)
: d(new ContainmentActionsPrivate(KService::serviceByStorageId(args.count() > 0 ? : d(new ContainmentActionsPrivate(args.value(0), this))
args[0].toString() : QString()), this))
{ {
setParent(parentObject); setParent(parentObject);
@ -64,7 +63,7 @@ ContainmentActions::~ContainmentActions()
KPluginInfo ContainmentActions::pluginInfo() const KPluginInfo ContainmentActions::pluginInfo() const
{ {
return d->containmentActionsDescription; return KPluginInfo(d->containmentActionsDescription);
} }
Containment *ContainmentActions::containment() Containment *ContainmentActions::containment()

View File

@ -416,10 +416,9 @@ ContainmentActions *PluginLoader::loadContainmentActions(Containment *parent, co
if (!plugins.isEmpty()) { if (!plugins.isEmpty()) {
KPluginLoader loader(plugins.first().fileName()); KPluginLoader loader(plugins.first().fileName());
const QVariantList argsWithMetaData = QVariantList() << loader.metaData().toVariantMap();
KPluginFactory *factory = loader.factory(); KPluginFactory *factory = loader.factory();
if (factory) { if (factory) {
actions = factory->create<Plasma::ContainmentActions>(nullptr, argsWithMetaData); actions = factory->create<Plasma::ContainmentActions>(nullptr, {QVariant::fromValue(plugins.first())});
} }
} }
if (actions) { if (actions) {

View File

@ -20,15 +20,17 @@
#ifndef PLASMA_CONTAINMENTACTIONSPRIVATE_H #ifndef PLASMA_CONTAINMENTACTIONSPRIVATE_H
#define PLASMA_CONTAINMENTACTIONSPRIVATE_H #define PLASMA_CONTAINMENTACTIONSPRIVATE_H
#include <KPluginMetaData>
namespace Plasma namespace Plasma
{ {
class ContainmentActionsPrivate class ContainmentActionsPrivate
{ {
public: public:
ContainmentActionsPrivate(KService::Ptr service, ContainmentActions *containmentActions) : ContainmentActionsPrivate(const QVariant& arg, ContainmentActions *containmentActions) :
q(containmentActions), q(containmentActions),
containmentActionsDescription(service), containmentActionsDescription(arg.canConvert<KPluginMetaData>() ? arg.value<KPluginMetaData>() : KPluginInfo(KService::serviceByStorageId(arg.toString())).toMetaData()),
package(nullptr), package(nullptr),
containment(nullptr) containment(nullptr)
{ {
@ -37,7 +39,7 @@ public:
ContainmentActions *q; ContainmentActions *q;
QString currentTrigger; QString currentTrigger;
KPluginInfo containmentActionsDescription; const KPluginMetaData containmentActionsDescription;
Package *package; Package *package;
KServiceAction mode; KServiceAction mode;
Containment *containment; Containment *containment;