From cd87344d801244fa8717c71038c04797915ff249 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Fri, 29 Aug 2014 12:19:08 +0200 Subject: [PATCH] make PackageStructure plugins use the json method as with DataEngines --- src/plasma/packagestructure.h | 7 ++++++- src/plasma/pluginloader.cpp | 21 ++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/plasma/packagestructure.h b/src/plasma/packagestructure.h index fb32c22a6..c746732ba 100644 --- a/src/plasma/packagestructure.h +++ b/src/plasma/packagestructure.h @@ -27,6 +27,7 @@ #include #include #include +#include namespace Plasma { @@ -98,5 +99,9 @@ private: #define K_EXPORT_PLASMA_PACKAGE(libname, classname) \ K_PLUGIN_FACTORY(factory, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) -#endif +#define K_EXPORT_PLASMA_PACKAGE_WITH_JSON(classname, jsonFile) \ + K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ + K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) + +#endif diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp index a81fc72c3..d08104e5f 100644 --- a/src/plasma/pluginloader.cpp +++ b/src/plasma/pluginloader.cpp @@ -53,6 +53,7 @@ public: PluginLoaderPrivate() : isDefaultLoader(false), dataEnginePluginDir("plasma/dataengine"), + packageStructurePluginDir("plasma/packagestructure"), packageRE("[^a-zA-Z0-9\\-_]") { } @@ -64,6 +65,7 @@ public: QHash > structures; bool isDefaultLoader; QString dataEnginePluginDir; + QString packageStructurePluginDir; QRegExp packageRE; }; @@ -443,23 +445,16 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s } // first we check for plugins in sycoca - QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(packageFormat); - KService::List offers = KServiceTypeTrader::self()->query("Plasma/PackageStructure", constraint); - - QVariantList args; - QString error; - foreach (const KService::Ptr &offer, offers) { - structure = qobject_cast(offer->createInstance(0, args, &error)); - - if (structure) { - d->structures.insert(hashkey, structure); - return Package(structure); - } + const QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(packageFormat); + structure = KPluginTrader::createInstanceFromQuery(d->packageStructurePluginDir, "Plasma/PackageStructure", constraint, 0); + if (structure) { + d->structures.insert(hashkey, structure); + return Package(structure); + } #ifndef NDEBUG // qDebug() << "Couldn't load Package for" << packageFormat << "! reason given: " << error; #endif - } return Package(); }