support load by plugin from AbstractToolBox
what stinks is the both support direct creation -and- plugin loading, but has to be BC could be the case to add it to PluginLoader? don't see big use cases CCMAIL:plasma-devel@kde.org svn path=/trunk/KDE/kdelibs/; revision=1157180
This commit is contained in:
parent
87a29d9efc
commit
457cfcb89a
@ -408,6 +408,7 @@ install(FILES
|
||||
data/servicetypes/plasma-packagestructure.desktop
|
||||
data/servicetypes/plasma-runner.desktop
|
||||
data/servicetypes/plasma-scriptengine.desktop
|
||||
data/servicetypes/plasma-toolbox.desktop
|
||||
data/servicetypes/plasma-wallpaper.desktop
|
||||
DESTINATION ${SERVICETYPES_INSTALL_DIR})
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include "containment.h"
|
||||
|
||||
#include <kservicetypetrader.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
@ -40,11 +42,42 @@ AbstractToolBox::AbstractToolBox(Containment *parent)
|
||||
{
|
||||
}
|
||||
|
||||
AbstractToolBox::AbstractToolBox(QObject *parent, const QVariantList &args)
|
||||
: QGraphicsWidget(0),
|
||||
d(new AbstractToolBoxPrivate(qobject_cast<Containment *>(parent)))
|
||||
{
|
||||
Containment *cont = qobject_cast<Containment *>(parent);
|
||||
|
||||
if (cont) {
|
||||
setParentItem(cont);
|
||||
}
|
||||
}
|
||||
|
||||
AbstractToolBox::~AbstractToolBox()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
AbstractToolBox *AbstractToolBox::load(const QString &name, const QVariantList &args, Plasma::Containment *containment)
|
||||
{
|
||||
const QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name);
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/ToolBox", constraint);
|
||||
|
||||
if (!offers.isEmpty()) {
|
||||
KService::Ptr offer = offers.first();
|
||||
|
||||
KPluginLoader plugin(*offer);
|
||||
|
||||
if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return offer->createInstance<AbstractToolBox>(containment, args);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Containment *AbstractToolBox::containment() const
|
||||
{
|
||||
return d->containment;
|
||||
|
@ -51,8 +51,19 @@ public:
|
||||
Q_ENUMS(ToolType)
|
||||
|
||||
explicit AbstractToolBox(Containment *parent);
|
||||
explicit AbstractToolBox(QObject *parent = 0,
|
||||
const QVariantList &args = QVariantList());
|
||||
~AbstractToolBox();
|
||||
|
||||
/**
|
||||
* Create a new AbstractToolBox, loading the proper plugin
|
||||
* @param name the plugin name
|
||||
* @param args the plugin arguments
|
||||
* @param containment the containment parent of the toolbox
|
||||
* @since 4.6
|
||||
*/
|
||||
static AbstractToolBox *load(const QString &name, const QVariantList &args=QVariantList(), Plasma::Containment *containment=0);
|
||||
|
||||
/**
|
||||
* create a toolbox tool from the given action
|
||||
* @p action the action to associate the tool with
|
||||
@ -79,5 +90,14 @@ private:
|
||||
};
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
/**
|
||||
* Register an applet when it is contained in a loadable module
|
||||
*/
|
||||
#define K_EXPORT_PLASMA_TOOLBOX(libname, classname) \
|
||||
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
||||
K_EXPORT_PLUGIN(factory("plasma_toolbox_" #libname)) \
|
||||
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
|
||||
|
||||
#endif // multiple inclusion guard
|
||||
|
||||
|
5
data/servicetypes/plasma-toolbox.desktop
Normal file
5
data/servicetypes/plasma-toolbox.desktop
Normal file
@ -0,0 +1,5 @@
|
||||
[Desktop Entry]
|
||||
Type=ServiceType
|
||||
X-KDE-ServiceType=Plasma/ToolBox
|
||||
|
||||
Comment=Plasma toolbox
|
Loading…
Reference in New Issue
Block a user