diff --git a/src/zanshin/kontact/CMakeLists.txt b/src/zanshin/kontact/CMakeLists.txt --- a/src/zanshin/kontact/CMakeLists.txt +++ b/src/zanshin/kontact/CMakeLists.txt @@ -1,3 +1,12 @@ +# TODO: remove once kontactinterface 5.14.42 is required + +if(NOT CMAKE_VERSION VERSION_LESS "3.10.0") + # CMake 3.9+ warns about automoc on files without Q_OBJECT, and doesn't know about other macros. + # 3.10+ lets us provide more macro names that require automoc. + # KF5 >= 5.42 takes care itself of adding its macros in its cmake config files + list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "EXPORT_KONTACT_PLUGIN_WITH_JSON") +endif() + set(part_SRCS ../app/aboutdata.cpp part.cpp @@ -22,8 +31,9 @@ add_library(kontact_zanshinplugin MODULE ${kontact_SRCS}) target_link_libraries(kontact_zanshinplugin KF5::Parts KF5::KontactInterface) +kcoreaddons_desktop_to_json(kontact_zanshinplugin zanshin_plugin.desktop) -install(TARGETS kontact_zanshinplugin DESTINATION ${KDE_INSTALL_PLUGINDIR}) +install(TARGETS kontact_zanshinplugin DESTINATION ${KDE_INSTALL_PLUGINDIR}/kontact5) install(FILES zanshin_plugin.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}/kontact) install(FILES zanshin_part.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/zanshin) diff --git a/src/zanshin/kontact/kontact_plugin.cpp b/src/zanshin/kontact/kontact_plugin.cpp --- a/src/zanshin/kontact/kontact_plugin.cpp +++ b/src/zanshin/kontact/kontact_plugin.cpp @@ -25,7 +25,25 @@ #include -EXPORT_KONTACT_PLUGIN(Plugin, zanshin) +#if KONTACTINTERFACE_VERSION < QT_VERSION_CHECK(5, 14, 42) +/** + Exports Kontact plugin. + @param pluginclass the class to instanciate (must derive from KontactInterface::Plugin + @param jsonFile filename of the JSON file, generated from a .desktop file + */ +#define EXPORT_KONTACT_PLUGIN_WITH_JSON( pluginclass, jsonFile ) \ + class Instance \ + { \ + public: \ + static QObject *createInstance( QWidget *, QObject *parent, const QVariantList &list ) \ + { return new pluginclass( static_cast( parent ), list ); } \ + }; \ + K_PLUGIN_FACTORY_WITH_JSON( KontactPluginFactory, jsonFile, registerPlugin< pluginclass > \ + ( QString(), Instance::createInstance ); ) \ + K_EXPORT_PLUGIN_VERSION(KONTACT_PLUGIN_VERSION) +#endif + +EXPORT_KONTACT_PLUGIN_WITH_JSON(Plugin, "zanshin_plugin.json") Plugin::Plugin(KontactInterface::Core *core, const QVariantList&) : KontactInterface::Plugin(core, core, "zanshin") diff --git a/src/zanshin/kontact/zanshin_plugin.desktop b/src/zanshin/kontact/zanshin_plugin.desktop --- a/src/zanshin/kontact/zanshin_plugin.desktop +++ b/src/zanshin/kontact/zanshin_plugin.desktop @@ -3,7 +3,7 @@ Icon=zanshin X-KDE-ServiceTypes=Kontact/Plugin,KPluginInfo -X-KDE-Library=kontact_zanshinplugin +X-KDE-Library=kontact5/kontact_zanshinplugin X-KDE-KontactPluginVersion=10 X-KDE-KontactPartLibraryName=zanshin_part X-KDE-KontactPartExecutableName=zanshin