Commit 82202a24 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Port away from deprecated KPluginLoader

parent 6228921f
......@@ -18,7 +18,7 @@
#include <KIconLoader>
#include <KJobWidgets>
#include <KOverlayIconPlugin>
#include <KPluginLoader>
#include <KPluginMetaData>
#include <KSharedConfig>
#ifdef HAVE_BALOO
......@@ -30,6 +30,7 @@
#include <QApplication>
#include <QIcon>
#include <QPainter>
#include <QPluginLoader>
#include <QElapsedTimer>
#include <QTimer>
......@@ -120,15 +121,16 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result,
this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived);
const auto plugins = KPluginLoader::instantiatePlugins(QStringLiteral("kf5/overlayicon"), nullptr, qApp);
for (QObject *it : plugins) {
auto plugin = qobject_cast<KOverlayIconPlugin*>(it);
const auto plugins = KPluginMetaData::findPlugins(QStringLiteral("kf5/overlayicon"));
for (const KPluginMetaData &data : plugins) {
auto instance = QPluginLoader(data.fileName()).instance();
auto plugin = qobject_cast<KOverlayIconPlugin *>(instance);
if (plugin) {
m_overlayIconsPlugin.append(plugin);
connect(plugin, &KOverlayIconPlugin::overlaysChanged, this, &KFileItemModelRolesUpdater::slotOverlaysChanged);
} else {
// not our/valid plugin, so delete the created object
it->deleteLater();
delete instance;
}
}
}
......
......@@ -15,7 +15,6 @@
#include <KMountPoint>
#include <KParts/ReadOnlyPart>
#include <KPluginFactory>
#include <KPluginLoader>
#include <KProtocolInfo>
#include <KShell>
#include <kde_terminal_interface.h>
......@@ -129,8 +128,7 @@ void TerminalPanel::showEvent(QShowEvent* event)
if (!m_terminal) {
m_clearTerminal = true;
KPluginLoader loader(QStringLiteral("konsolepart"));
KPluginFactory* factory = loader.factory();
KPluginFactory *factory = KPluginFactory::loadFactory(KPluginMetaData(QStringLiteral("konsolepart"))).plugin;
m_konsolePart = factory ? (factory->create<KParts::ReadOnlyPart>(this)) : nullptr;
if (m_konsolePart) {
connect(m_konsolePart, &KParts::ReadOnlyPart::destroyed, this, &TerminalPanel::terminalExited);
......
......@@ -307,7 +307,7 @@ void ContextMenuSettingsPage::loadServices()
#endif
// Load JSON-based plugins that implement the KFileItemActionPlugin interface
const auto jsonPlugins = KPluginLoader::findPlugins(QStringLiteral("kf5/kfileitemaction"));
const auto jsonPlugins = KPluginMetaData::findPlugins(QStringLiteral("kf5/kfileitemaction"));
for (const auto &jsonMetadata : jsonPlugins) {
const QString desktopEntryName = jsonMetadata.pluginId();
......@@ -328,7 +328,7 @@ void ContextMenuSettingsPage::loadVersionControlSystems()
// Create a checkbox for each available version control plugin
QSet<QString> loadedPlugins;
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("dolphin/vcs"));
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("dolphin/vcs"));
for (const auto &plugin : plugins) {
const QString pluginName = plugin.name();
addRow(QStringLiteral("code-class"),
......
......@@ -11,7 +11,7 @@
#include <KIO/ThumbCreator>
#include <KJobWidgets>
#include <KLocalizedString>
#include <KPluginLoader>
#include <QPluginLoader>
#include <QDialogButtonBox>
#include <QPushButton>
......@@ -25,7 +25,7 @@ ConfigurePreviewPluginDialog::ConfigurePreviewPluginDialog(const QString& plugin
QDialog(parent)
{
QSharedPointer<ThumbCreator> previewPlugin;
const QString pluginPath = KPluginLoader::findPlugin(desktopEntryName);
const QString pluginPath = QPluginLoader(desktopEntryName).fileName();
if (!pluginPath.isEmpty()) {
newCreator create = (newCreator)QLibrary::resolve(pluginPath, "new_creator");
if (create) {
......
......@@ -45,7 +45,6 @@ class KFileItem;
* - Add the following lines at the top of fileviewsvnplugin.cpp:
* <code>
* #include <KPluginFactory>
* #include <KPluginLoader>
* K_PLUGIN_CLASS_WITH_JSON(FileViewSvnPlugin, "fileviewsvnplugin.json")
* </code>
*
......
......@@ -14,7 +14,6 @@
#include <KLocalizedString>
#include <KPluginFactory>
#include <KPluginLoader>
#include <KPluginMetaData>
#include <QTimer>
......@@ -280,15 +279,13 @@ void VersionControlObserver::initPlugins()
// all fileview version control plugins and remember them in 'plugins'.
const QStringList enabledPlugins = VersionControlSettings::enabledPlugins();
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("dolphin/vcs"));
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("dolphin/vcs"));
QSet<QString> loadedPlugins;
for (const auto &p : plugins) {
if (enabledPlugins.contains(p.name())) {
KPluginLoader loader(p.fileName());
KPluginFactory *factory = loader.factory();
KVersionControlPlugin *plugin = factory->create<KVersionControlPlugin>();
auto plugin = KPluginFactory::instantiatePlugin<KVersionControlPlugin>(p).plugin;
if (plugin) {
m_plugins.append(plugin);
loadedPlugins += p.name();
......
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