Commit 0860f58f authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Port away from deprecated KPluginLoader

parent 6486baa8
Pipeline #95781 passed with stage
in 2 minutes and 49 seconds
......@@ -8,7 +8,7 @@ set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE
project(ark VERSION ${RELEASE_SERVICE_VERSION})
set(QT_MIN_VERSION 5.15.0)
set(KF5_MIN_VERSION 5.82.0)
set(KF5_MIN_VERSION 5.86.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
......
......@@ -27,7 +27,6 @@
#include <KSharedConfig>
#include <KConfigDialog>
#include <KXMLGUIFactory>
#include <KPluginLoader>
#include <KConfigSkeleton>
#include <QApplication>
......@@ -118,9 +117,7 @@ void MainWindow::dragMoveEvent(QDragMoveEvent * event)
bool MainWindow::loadPart()
{
KPluginFactory *factory = KPluginLoader(QStringLiteral("kf5/parts/arkpart")).factory();
m_part = factory ? static_cast<KParts::ReadWritePart*>(factory->create<KParts::ReadWritePart>(this)) : nullptr;
m_part = KPluginFactory::instantiatePlugin<KParts::ReadWritePart>(KPluginMetaData(QStringLiteral("kf5/parts/arkpart"))).plugin;
if (!m_part) {
KMessageBox::error(this, i18n("Unable to find Ark's KPart component, please check your installation."));
......
......@@ -5,7 +5,6 @@
*/
#include "kcoreaddons_version.h"
#include <KPluginLoader>
#include <KPluginMetaData>
#include <QTest>
......@@ -26,11 +25,7 @@ private:
void MetaDataTest::initTestCase()
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
m_plugins = KPluginLoader::findPlugins(QStringLiteral("kerfuffle"));
#else
m_plugins = KPluginMetaData::findPlugins(QStringLiteral("kerfuffle"));
#endif
}
// If a plugin has invalid JSON metadata (e.g. an extra comma somewhere)
......
......@@ -15,7 +15,6 @@
#include "pluginmanager.h"
#include <KPluginFactory>
#include <KPluginLoader>
#include <QMimeDatabase>
#include <QRegularExpression>
......@@ -60,15 +59,9 @@ Archive *Archive::create(const QString &fileName, Plugin *plugin, QObject *paren
qCDebug(ARK) << "Checking plugin" << plugin->metaData().pluginId();
KPluginFactory *factory = KPluginLoader(plugin->metaData().fileName()).factory();
if (!factory) {
qCWarning(ARK) << "Invalid plugin factory for" << plugin->metaData().pluginId();
return new Archive(FailedPlugin, parent);
}
const QVariantList args = {QVariant(QFileInfo(fileName).absoluteFilePath()),
QVariant().fromValue(plugin->metaData())};
ReadOnlyArchiveInterface *iface = factory->create<ReadOnlyArchiveInterface>(nullptr, args);
ReadOnlyArchiveInterface *iface = KPluginFactory::instantiatePlugin<ReadOnlyArchiveInterface>(plugin->metaData(), nullptr, args).plugin;
if (!iface) {
qCWarning(ARK) << "Could not create plugin instance" << plugin->metaData().pluginId();
return new Archive(FailedPlugin, parent);
......
......@@ -9,7 +9,6 @@
#include "settings.h"
#include "kcoreaddons_version.h"
#include <KPluginLoader>
#include <KSharedConfig>
#include <QFileInfo>
......@@ -194,11 +193,7 @@ QVector<Plugin*> PluginManager::filterBy(const QVector<Plugin*> &plugins, const
void PluginManager::loadPlugins()
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("kerfuffle"));
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("kerfuffle"));
#endif
QSet<QString> addedPlugins;
for (const KPluginMetaData &metaData : plugins) {
const auto pluginId = metaData.pluginId();
......
Markdown is supported
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