K_PLUGIN_FACTORY changes explained
Boudewijn Rempt
boud at valdyas.org
Fri Aug 30 15:36:20 UTC 2013
On Friday 30 August 2013 Aug 14:11:59 David Faure wrote:
> On Friday 23 August 2013 14:21:02 Sebastian Kügler wrote:
> > Hey,
> >
> > I've written a somewhat lengthy and detailed article about the changes to
> > our plugin system:
> >
> > http://vizzzion.org/blog/2013/08/kde-frameworks-5-plugin-factory-guts/
> >
> > Thought it might be interesting for many people here. :)
>
> Good writeup, thanks.
> You could link to it from KDE5PORTING.html?
>
> One thing it doesn't detail (because you didn't directly work on that) is
> differences in where plugins get installed (the install dir changed), and how
> they are found ($QT_PLUGIN_PATH).
>
> And one of the porting ideas is: if you don't need the trader to find your
> plugins, don't use it anymore. E.g. if you can put all your plugins into a
> subdir of the plugin dir, and you don't need any filtering (you just want to
> load them all), iterate over that, no servicetype and no trader needed.
> We still have to solve the use case of filtering/querying though, ideally in
> Qt (so that the json metadata can actually be useful).
>
Maybe useful, maybe not, but this is how we've solved it for Calligra, where the requirements are pretty simple: a calliga app only ever loads a calligra plugin, and a calligra plugin is only ever useful to a calligra app.
I'm also not sure whether this still works with current e-c-m, but first we set the plugin_install_dir:
find_package(KF5 REQUIRED MODULE COMPONENTS CMake Compiler InstallDirs)
set(kdelibs_SOURCE_DIR TRUE)
# override the kf5 plugin installdir
set(PLUGIN_INSTALL_DIR ${LIB_INSTALL_DIR}/calligra)
Then we've got the KoJsonTrader class that tries to figure out in as generic as possible a way where that is -- maybe there's an easier way, but this seems to work. We're only interested in the type of the plugin, for now, so that's the only thing we check.
https://projects.kde.org/projects/calligra/repository/revisions/calligra-qt5-rempt/entry/libs/koplugin/KoJsonTrader.cpp
It's simple, and we don't need the trader classes (well, those are cool) anymore and especially not the sycoca, which is always trouble on the mobile or windows platforms.
--
Boudewijn Rempt
http://www.valdyas.org, http://www.krita.org, http://www.boudewijnrempt.nl
More information about the Kde-frameworks-devel
mailing list