Commit 1e0681a0 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Adapt plugin api to allow to build without deprecated methods

parent d21951a8
Pipeline #188056 passed with stage
in 1 minute and 48 seconds
# SPDX-FileCopyrightText: none
# SPDX-License-Identifier: BSD-3-Clause
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(PIM_VERSION "5.20.40")
set(PIM_VERSION "5.20.41")
project(KontactInterface VERSION ${PIM_VERSION})
......
......@@ -53,8 +53,7 @@ public:
bool disabled;
};
//@endcond
Plugin::Plugin(Core *core, QObject *parent, const char *appName, const char *pluginName)
Plugin::Plugin(Core *core, QObject *parent, const KPluginMetaData &, const char *appName, const char *pluginName)
: KXMLGUIClient(core)
, QObject(parent)
, d(new PluginPrivate)
......
......@@ -11,6 +11,7 @@
#pragma once
#include "kontactinterface_export.h"
#include <kcoreaddons_version.h>
#include <KPluginFactory>
#include <KXMLGUIClient>
......@@ -34,23 +35,36 @@ class Part;
/**
Increase this version number whenever you make a change in the API.
*/
#define KONTACT_PLUGIN_VERSION 10
#define KONTACT_PLUGIN_VERSION 11
/**
Exports Kontact plugin.
@param pluginclass the class to instantiate (must derive from KontactInterface::Plugin)
@param jsonFile filename of the JSON file, generated from a .desktop file
*/
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 95, 0)
#define EXPORT_KONTACT_PLUGIN_WITH_JSON(pluginclass, jsonFile) \
class Instance \
{ \
public: \
static QObject *createInstance(QWidget *, QObject *parent, const QVariantList &list) \
static QObject *createInstance(QWidget *, QObject *parent, const KPluginMetaData &data, const QVariantList &list) \
{ \
return new pluginclass(static_cast<KontactInterface::Core *>(parent), list); \
return new pluginclass(static_cast<KontactInterface::Core *>(parent), data, list); \
} \
}; \
K_PLUGIN_FACTORY_WITH_JSON(KontactPluginFactory, jsonFile, registerPlugin<pluginclass>(QString(), Instance::createInstance);)
#else
#define EXPORT_KONTACT_PLUGIN_WITH_JSON(pluginclass, jsonFile) \
class Instance \
{ \
public: \
static QObject *createInstance(QWidget *, QObject *parent, const KPluginMetaData &data, const QVariantList &list) \
{ \
return new pluginclass(static_cast<KontactInterface::Core *>(parent), data, list); \
} \
}; \
K_PLUGIN_FACTORY_WITH_JSON(KontactPluginFactory, jsonFile, registerPlugin<pluginclass>(Instance::createInstance);)
#endif
namespace KontactInterface
{
......@@ -77,8 +91,7 @@ public:
* It's ok to have several plugins using the same application name.
* @param pluginName The unique name of the plugin. Defaults to appName if not set.
*/
Plugin(Core *core, QObject *parent, const char *appName, const char *pluginName = nullptr);
Plugin(Core *core, QObject *parent, const KPluginMetaData &data, const char *appName, const char *pluginName = nullptr);
/**
* Destroys the plugin.
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment