diff --git a/abstracttoolbox.cpp b/abstracttoolbox.cpp index 6683080a8..14205a352 100644 --- a/abstracttoolbox.cpp +++ b/abstracttoolbox.cpp @@ -76,6 +76,26 @@ AbstractToolBox *AbstractToolBox::load(const QString &name, const QVariantList & } } +KPluginInfo::List AbstractToolBox::listToolBoxInfo(const QString + &parentApp) +{ + KPluginInfo::List list; + + if (parentApp.isEmpty() || parentApp == KGlobal::mainComponent().componentName()) { + list = KPluginInfo::List(); + } + + 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/ToolBox", constraint); + return list + KPluginInfo::fromServices(offers); +} + Containment *AbstractToolBox::containment() const { return d->containment; diff --git a/abstracttoolbox.h b/abstracttoolbox.h index 423d3335f..eb16a5f78 100644 --- a/abstracttoolbox.h +++ b/abstracttoolbox.h @@ -23,6 +23,8 @@ #include #include +#include + #include "plasma/plasma_export.h" class QAction; @@ -66,6 +68,20 @@ public: */ static AbstractToolBox *load(const QString &name, const QVariantList &args=QVariantList(), Plasma::Containment *containment=0); + /** + * Returns a list of all installed ToolBox plugins + * + * @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. + * + * @since 4.6 + */ + static KPluginInfo::List listToolBoxInfo(const QString + &parentApp = QString()); + /** * create a toolbox tool from the given action * @p action the action to associate the tool with