Verified Commit b6741c0b authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Port to new KPluginFactory constructor

Also make the base class constructor compatible with KPluginFactory.
This is what is done in the KDE frameworks that provide plugin interfaces too.

Futhermore it sets the plugin metadata for the kpart. This will be useful in
case the plugin wants to access it's own metadata or if KPart will use it inernally.
parent 54adb6a8
......@@ -7,9 +7,11 @@
namespace kt
{
Plugin::Plugin(QObject *parent)
Plugin::Plugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: KParts::Plugin(parent)
{
setMetaData(data);
Q_UNUSED(args)
}
Plugin::~Plugin()
......
......@@ -36,7 +36,7 @@ class KTCORE_EXPORT Plugin : public KParts::Plugin
{
Q_OBJECT
public:
Plugin(QObject *parent);
Plugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~Plugin() override;
/**
......
......@@ -72,12 +72,12 @@ void PluginManager::loadPlugins()
void PluginManager::load(const KPluginMetaData &data, int idx)
{
Q_UNUSED(data)
KPluginLoader loader(data.fileName());
KPluginFactory *factory = loader.factory();
if (!factory)
return;
factory->setMetaData(data);
Plugin *plugin = factory->create<kt::Plugin>();
if (!plugin) {
Out(SYS_GEN | LOG_NOTICE) << QStringLiteral("Creating instance of plugin %1 failed !").arg(pluginsMetaData.at(idx).fileName()) << endl;
......
......@@ -35,12 +35,11 @@ K_PLUGIN_FACTORY_WITH_JSON(ktorrent_bwscheduler, "ktorrent_bwscheduler.json", re
namespace kt
{
BWSchedulerPlugin::BWSchedulerPlugin(QObject *parent, const QVariantList &args)
: Plugin(parent)
BWSchedulerPlugin::BWSchedulerPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: Plugin(parent, data, args)
, m_editor(nullptr)
, m_pref(nullptr)
{
Q_UNUSED(args);
connect(&m_timer, &QTimer::timeout, this, &BWSchedulerPlugin::timerTriggered);
screensaver =
new org::freedesktop::ScreenSaver(QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("/ScreenSaver"), QDBusConnection::sessionBus(), this);
......
......@@ -29,7 +29,7 @@ class BWSchedulerPlugin : public Plugin
{
Q_OBJECT
public:
BWSchedulerPlugin(QObject *parent, const QVariantList &args);
BWSchedulerPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~BWSchedulerPlugin() override;
void load() override;
......
......@@ -25,10 +25,9 @@ using namespace bt;
namespace kt
{
DownloadOrderPlugin::DownloadOrderPlugin(QObject *parent, const QVariantList &args)
: Plugin(parent)
DownloadOrderPlugin::DownloadOrderPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: Plugin(parent, data, args)
{
Q_UNUSED(args);
download_order_action = new QAction(QIcon::fromTheme(QStringLiteral("view-sort-ascending")), i18n("File Download Order"), this);
connect(download_order_action, &QAction::triggered, this, &DownloadOrderPlugin::showDownloadOrderDialog);
actionCollection()->addAction(QStringLiteral("download_order"), download_order_action);
......
......@@ -21,7 +21,7 @@ class DownloadOrderPlugin : public Plugin, public ViewListener
{
Q_OBJECT
public:
DownloadOrderPlugin(QObject *parent, const QVariantList &args);
DownloadOrderPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~DownloadOrderPlugin() override;
void load() override;
......
......@@ -32,8 +32,8 @@ using namespace bt;
namespace kt
{
InfoWidgetPlugin::InfoWidgetPlugin(QObject *parent, const QVariantList &)
: Plugin(parent)
InfoWidgetPlugin::InfoWidgetPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: Plugin(parent, data, args)
{
}
......
......@@ -33,7 +33,7 @@ class InfoWidgetPlugin : public Plugin, public ViewListener
{
Q_OBJECT
public:
InfoWidgetPlugin(QObject *parent, const QVariantList &args);
InfoWidgetPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~InfoWidgetPlugin() override;
void load() override;
......
......@@ -28,10 +28,9 @@ K_PLUGIN_FACTORY_WITH_JSON(ktorrent_ipfilter, "ktorrent_ipfilter.json", register
namespace kt
{
IPFilterPlugin::IPFilterPlugin(QObject *parent, const QVariantList &args)
: Plugin(parent)
IPFilterPlugin::IPFilterPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: Plugin(parent, data, args)
{
Q_UNUSED(args);
connect(&auto_update_timer, &QTimer::timeout, this, &IPFilterPlugin::checkAutoUpdate);
auto_update_timer.setSingleShot(true);
}
......
......@@ -29,7 +29,7 @@ class IPFilterPlugin : public Plugin
{
Q_OBJECT
public:
IPFilterPlugin(QObject *parent, const QVariantList &args);
IPFilterPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~IPFilterPlugin() override;
void load() override;
......
......@@ -26,8 +26,8 @@ K_PLUGIN_FACTORY_WITH_JSON(ktorrent_logviewer, "ktorrent_logviewer.json", regist
namespace kt
{
LogViewerPlugin::LogViewerPlugin(QObject *parent, const QVariantList &)
: Plugin(parent)
LogViewerPlugin::LogViewerPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: Plugin(parent, data, args)
{
}
......
......@@ -30,7 +30,7 @@ class LogViewerPlugin : public Plugin
{
Q_OBJECT
public:
LogViewerPlugin(QObject *parent, const QVariantList &args);
LogViewerPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~LogViewerPlugin() override;
void load() override;
......
......@@ -30,10 +30,9 @@ K_PLUGIN_FACTORY_WITH_JSON(ktorrent_magnetgenerator, "ktorrent_magnetgenerator.j
using namespace bt;
namespace kt
{
MagnetGeneratorPlugin::MagnetGeneratorPlugin(QObject *parent, const QVariantList &args)
: Plugin(parent)
MagnetGeneratorPlugin::MagnetGeneratorPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: Plugin(parent, data, args)
{
Q_UNUSED(args);
pref = nullptr;
generate_magnet_action = new QAction(QIcon::fromTheme(QStringLiteral("kt-magnet")), i18n("Copy Magnet URI"), this);
connect(generate_magnet_action, &QAction::triggered, this, &MagnetGeneratorPlugin::generateMagnet);
......
......@@ -17,7 +17,7 @@ class MagnetGeneratorPlugin : public Plugin, public ViewListener
{
Q_OBJECT
public:
MagnetGeneratorPlugin(QObject *parent, const QVariantList &args);
MagnetGeneratorPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~MagnetGeneratorPlugin() override;
void load() override;
......
......@@ -20,10 +20,9 @@ using namespace bt;
namespace kt
{
MediaPlayerPlugin::MediaPlayerPlugin(QObject *parent, const QVariantList &args)
: Plugin(parent)
MediaPlayerPlugin::MediaPlayerPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: Plugin(parent, data, args)
{
Q_UNUSED(args);
}
MediaPlayerPlugin::~MediaPlayerPlugin()
......
......@@ -22,7 +22,7 @@ class MediaPlayerPlugin : public Plugin
{
Q_OBJECT
public:
MediaPlayerPlugin(QObject *parent, const QVariantList &args);
MediaPlayerPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~MediaPlayerPlugin() override;
void load() override;
......
......@@ -29,10 +29,9 @@ K_PLUGIN_FACTORY_WITH_JSON(ktorrent_scanfolder, "ktorrent_scanfolder.json", regi
namespace kt
{
ScanFolderPlugin::ScanFolderPlugin(QObject *parent, const QVariantList &args)
: Plugin(parent)
ScanFolderPlugin::ScanFolderPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: Plugin(parent, data, args)
{
Q_UNUSED(args);
}
ScanFolderPlugin::~ScanFolderPlugin()
......
......@@ -25,7 +25,7 @@ class ScanFolderPlugin : public Plugin
{
Q_OBJECT
public:
ScanFolderPlugin(QObject *parent, const QVariantList &args);
ScanFolderPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
~ScanFolderPlugin() override;
void load() override;
......
......@@ -26,10 +26,9 @@ K_PLUGIN_FACTORY_WITH_JSON(ktorrent_scanforlostfiles, "ktorrent_scanforlostfiles
namespace kt
{
ScanForLostFilesPlugin::ScanForLostFilesPlugin(QObject *parent, const QVariantList &args)
: Plugin(parent)
ScanForLostFilesPlugin::ScanForLostFilesPlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
: Plugin(parent, data, args)
{
Q_UNUSED(args);
}
ScanForLostFilesPlugin::~ScanForLostFilesPlugin()
......
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