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

View File

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

View File

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