add ContainmentActions to PluginLoader
This commit is contained in:
parent
fb3a64ba6c
commit
933e72092a
@ -34,6 +34,7 @@
|
||||
#include "applet.h"
|
||||
#include "abstractrunner.h"
|
||||
#include "containment.h"
|
||||
#include "containmentactions.h"
|
||||
#include "package.h"
|
||||
#include "popupapplet.h"
|
||||
#include "private/applet_p.h"
|
||||
@ -252,9 +253,47 @@ Service *PluginLoader::loadService(const QString &name, const QVariantList &args
|
||||
return service;
|
||||
}
|
||||
|
||||
ContainmentActions *PluginLoader::loadContainmentActions(Containment *parent, const QString &name, const QVariantList &args)
|
||||
{
|
||||
if (name.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ContainmentActions *actions = d->isDefaultLoader ? 0 : internalLoadContainmentActions(parent, name, args);
|
||||
if (actions) {
|
||||
return actions;
|
||||
}
|
||||
|
||||
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name);
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/ContainmentActions", constraint);
|
||||
|
||||
if (offers.isEmpty()) {
|
||||
kDebug() << "offers is empty for " << name;
|
||||
return 0;
|
||||
}
|
||||
|
||||
KService::Ptr offer = offers.first();
|
||||
KPluginLoader plugin(*offer);
|
||||
|
||||
if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
QVariantList allArgs;
|
||||
allArgs << offer->storageId() << args;
|
||||
QString error;
|
||||
actions = offer->createInstance<Plasma::ContainmentActions>(parent, allArgs, &error);
|
||||
|
||||
if (!actions) {
|
||||
kDebug() << "Couldn't load containmentActions \"" << name << "\"! reason given: " << error;
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
Package PluginLoader::loadPackage(const QString &packageFormat, const QString &specialization)
|
||||
{
|
||||
if (!s_isDefaultLoader) {
|
||||
if (!d->isDefaultLoader) {
|
||||
Package p = internalLoadPackage(packageFormat, specialization);
|
||||
if (p.isValid()) {
|
||||
return p;
|
||||
@ -427,6 +466,25 @@ KPluginInfo::List PluginLoader::listRunnerInfo(const QString &parentApp)
|
||||
return list + KPluginInfo::fromServices(offers);
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::listContainmentActionsInfo(const QString &parentApp)
|
||||
{
|
||||
KPluginInfo::List list;
|
||||
|
||||
if (!d->isDefaultLoader && (parentApp.isEmpty() || parentApp == KGlobal::mainComponent().componentName())) {
|
||||
list = internalContainmentActionsInfo();
|
||||
}
|
||||
|
||||
QString constraint;
|
||||
if (parentApp.isEmpty()) {
|
||||
constraint.append("not exist [X-KDE-ParentApp]");
|
||||
} else {
|
||||
constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'");
|
||||
}
|
||||
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/ContainmentActions", constraint);
|
||||
return KPluginInfo::fromServices(offers);
|
||||
}
|
||||
|
||||
Applet* PluginLoader::internalLoadApplet(const QString &name, uint appletId, const QVariantList &args)
|
||||
{
|
||||
Q_UNUSED(name)
|
||||
@ -483,6 +541,11 @@ KPluginInfo::List PluginLoader::internalServiceInfo() const
|
||||
return KPluginInfo::List();
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::internalContainmentActionsInfo() const
|
||||
{
|
||||
return KPluginInfo::List();
|
||||
}
|
||||
|
||||
static KPluginInfo::List standardInternalInfo(const QString &type, const QString &category = QString())
|
||||
{
|
||||
QStringList files = KGlobal::dirs()->findAllResources("appdata",
|
||||
|
@ -26,15 +26,16 @@
|
||||
|
||||
namespace Plasma {
|
||||
|
||||
class AbstractRunner;
|
||||
class Applet;
|
||||
class Containment;
|
||||
class ContainmentActions;
|
||||
class DataEngine;
|
||||
class Service;
|
||||
class AbstractRunner;
|
||||
|
||||
class PluginLoaderPrivate;
|
||||
|
||||
//TODO:
|
||||
// * add support for ContainmentActions plugins
|
||||
// * add KPluginInfo listing support for Containments (already loaded via the applet loading code)
|
||||
|
||||
/**
|
||||
@ -94,6 +95,21 @@ public:
|
||||
**/
|
||||
Service *loadService(const QString &name, const QVariantList &args, QObject *parent = 0);
|
||||
|
||||
/**
|
||||
* Load a ContainmentActions plugin.
|
||||
*
|
||||
* Returns a pointer to the containmentactions if successful.
|
||||
* The caller takes responsibility for the containmentactions, including
|
||||
* deleting it when no longer needed.
|
||||
*
|
||||
* @param parent the parent containment. @since 4.6 null is allowed.
|
||||
* @param name the plugin name, as returned by KPluginInfo::pluginName()
|
||||
* @param args to send the containmentactions extra arguments
|
||||
* @return a ContaimentActions object
|
||||
**/
|
||||
ContainmentActions *loadContainmentActions(Containment *parent, const QString &containmentActionsName,
|
||||
const QVariantList &args = QVariantList());
|
||||
|
||||
/**
|
||||
* Load a Package plugin.
|
||||
*
|
||||
@ -147,6 +163,18 @@ public:
|
||||
**/
|
||||
KPluginInfo::List listRunnerInfo(const QString &parentApp = QString());
|
||||
|
||||
/**
|
||||
* Returns a list of all known ContainmentActions.
|
||||
*
|
||||
* @param parentApp the application to filter applets on. Uses the
|
||||
* X-KDE-ParentApp entry (if any) in the plugin info.
|
||||
* The default value of QString() will result in a
|
||||
* list containing only applets not specifically
|
||||
* registered to an application.
|
||||
* @return list of applets
|
||||
**/
|
||||
KPluginInfo::List listContainmentActionsInfo(const QString &parentApp);
|
||||
|
||||
/**
|
||||
* Set the plugin loader which will be queried for all loads.
|
||||
*
|
||||
@ -216,6 +244,24 @@ protected:
|
||||
**/
|
||||
virtual Service *internalLoadService(const QString &name, const QVariantList &args, QObject *parent = 0);
|
||||
|
||||
/**
|
||||
* A re-implementable method that allows subclasses to override
|
||||
* the default behaviour of loadContainmentActions. If the Containments Action requested is not recognized,
|
||||
* then the implementation should return a NULL pointer. This method is called
|
||||
* by loadService prior to attempting to load a Service using the standard Plasma
|
||||
* plugin mechanisms.
|
||||
*
|
||||
* Returns a pointer to the containmentactions if successful.
|
||||
* The caller takes responsibility for the containmentactions, including
|
||||
* deleting it when no longer needed.
|
||||
*
|
||||
* @param parent the parent containment. @since 4.6 null is allowed.
|
||||
* @param name the plugin name, as returned by KPluginInfo::pluginName()
|
||||
* @param args to send the containmentactions extra arguments
|
||||
* @return a ContaimentActions object
|
||||
**/
|
||||
virtual ContainmentActions *internalLoadContainmentActions(Containment *parent, const QString &containmentActionsName, const QVariantList &args);
|
||||
|
||||
/**
|
||||
* A re-implementable method that allows subclasses to override
|
||||
* the default behaviour of loadPackage. If the service requested is not recognized,
|
||||
@ -254,24 +300,31 @@ protected:
|
||||
* A re-implementable method that allows subclasses to provide additional DataEngines
|
||||
* for DataEngineManager::listDataEngines.
|
||||
*
|
||||
* @return list of DataEngines, or an empty list if none
|
||||
* @return list of DataEngines info, or an empty list if none
|
||||
**/
|
||||
virtual KPluginInfo::List internalDataEngineInfo() const;
|
||||
|
||||
/**
|
||||
* Returns a list of all known Runner implementations
|
||||
*
|
||||
* @return list of AbstractRunners, or an empty list if none
|
||||
* @return list of AbstractRunners info, or an empty list if none
|
||||
*/
|
||||
virtual KPluginInfo::List internalRunnerInfo() const;
|
||||
|
||||
/**
|
||||
* Returns a list of all known Runner implementations
|
||||
*
|
||||
* @return list of AbstractRunners, or an empty list if none
|
||||
* @return list of AbstractRunners info, or an empty list if none
|
||||
*/
|
||||
virtual KPluginInfo::List internalServiceInfo() const;
|
||||
|
||||
/**
|
||||
* Returns a list of all known Runner implementations
|
||||
*
|
||||
* @return list of ContainmentActions info, or an empty list if none
|
||||
*/
|
||||
virtual KPluginInfo::List internalContainmentActionsInfo() const;
|
||||
|
||||
/**
|
||||
* Standardized mechanism for providing internal Applets by install .desktop files
|
||||
* in $APPPDATA/plasma/internal/applets/
|
||||
|
Loading…
Reference in New Issue
Block a user