Commit d5f255df authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Port from KPluginSelector to KPluginWidget

Task: https://phabricator.kde.org/T12265
parent 36039abc
......@@ -53,7 +53,6 @@ find_package(KF5 ${KF5_VERSION} REQUIRED
Notifications
NotifyConfig
Parts
Service
TextWidgets
Wallet
WidgetsAddons
......@@ -247,7 +246,6 @@ target_link_libraries(kgetcore
KF5::KIOCore
KF5::KIOWidgets
KF5::Notifications
KF5::Service
KF5::XmlGui
Qt::Core
Qt::Widgets
......
......@@ -12,20 +12,17 @@
#include "core/kget.h"
#include <KLocalizedString>
#include <KPluginInfo>
#include <KSharedConfig>
#include <QDialog>
#include <KSharedConfig>
#include <KConfigGroup>
PluginSelector::PluginSelector(QDialog * parent)
: KPluginSelector(parent)
: KPluginWidget(parent)
{
KPluginInfo::List offers = KGet::self()->pluginInfos();
addPlugins(offers, KPluginSelector::ReadConfigFile, i18n("Plugins"), "Service", KSharedConfig::openConfig());
load();
setConfig(KConfigGroup(KSharedConfig::openConfig(), "Plugins"));
addPlugins(KGet::self()->plugins(), i18n("Plugins"));
connect(parent, &QDialog::accepted, this, &PluginSelector::saveState);
connect(parent, &QDialog::rejected, this, &PluginSelector::loadDefaults);
......
......@@ -10,11 +10,11 @@
#ifndef PLUGINSELECTOR_H
#define PLUGINSELECTOR_H
#include <KPluginSelector>
#include <KPluginWidget>
class QDialog;
class PluginSelector : public KPluginSelector
class PluginSelector : public KPluginWidget
{
Q_OBJECT
public:
......
......@@ -41,7 +41,6 @@
#include <KIO/RenameDialog>
#include <KIO/DeleteJob>
#include <KSharedConfig>
#include <KPluginInfo>
#include <KConfigDialog>
#include <KPluginMetaData>
......@@ -629,9 +628,9 @@ QList<TransferFactory*> KGet::factories()
return m_transferFactories;
}
KPluginInfo::List KGet::pluginInfos()
QVector<KPluginMetaData> KGet::plugins()
{
return m_pluginInfoList;
return m_pluginList;
}
TransferFactory * KGet::factory(TransferHandler * transfer)
......@@ -814,8 +813,8 @@ void KGet::calculateGlobalUploadLimit()
// ------ STATIC MEMBERS INITIALIZATION ------
TransferTreeModel * KGet::m_transferTreeModel;
TransferTreeSelectionModel * KGet::m_selectionModel;
QVector<KPluginMetaData> KGet::m_pluginList;
QList<TransferFactory *> KGet::m_transferFactories;
KPluginInfo::List KGet::m_pluginInfoList;
TransferGroupScheduler * KGet::m_scheduler = nullptr;
MainWindow * KGet::m_mainWindow = nullptr;
KUiServerJobs * KGet::m_jobManager = nullptr;
......@@ -1144,7 +1143,7 @@ QUrl KGet::getValidDestUrl(const QUrl& destDir, const QUrl &srcUrl)
void KGet::loadPlugins()
{
m_transferFactories.clear();
m_pluginInfoList.clear();
m_pluginList.clear();
// TransferFactory plugins
const QVector<KPluginMetaData> offers = KPluginLoader::findPlugins(QStringLiteral("kget"), [](const KPluginMetaData& md) {
......@@ -1175,11 +1174,8 @@ void KGet::loadPlugins()
for (const KPluginMetaData& md : qAsConst(sortedOffers))
{
KPluginInfo info(md);
info.load(plugins);
m_pluginInfoList.prepend(info);
if (!info.isPluginEnabled())
m_pluginList.prepend(md);
if (!plugins.readEntry(md.pluginId() + QLatin1String("Enabled"), md.isEnabledByDefault()))
{
qCDebug(KGET_DEBUG) << "TransferFactory plugin (" << md.fileName()
<< ") found, but not enabled";
......@@ -1189,7 +1185,7 @@ void KGet::loadPlugins()
KGetPlugin* plugin = loadPlugin(md);
if (plugin != nullptr)
{
const QString pluginName = info.name();
const QString pluginName = md.name();
pluginList.prepend(plugin);
qCDebug(KGET_DEBUG) << "TransferFactory plugin (" << md.fileName()
......
......@@ -18,11 +18,11 @@
#ifndef KGET_H
#define KGET_H
#include <KService>
#include <KActionCollection>
#include <KNotification>
#include <KLocalizedString>
#include <KPluginInfo>
#include <KPluginLoader>
#include <KPluginFactory>
#include <QNetworkConfigurationManager>
#include <QDomElement>
......@@ -235,7 +235,7 @@ class KGET_EXPORT KGet
/**
* @returns a list of pluginInfos associated with all transferFactories
*/
static KPluginInfo::List pluginInfos();
static QVector<KPluginMetaData> plugins();
/**
* @returns The factory of a given transfer
......@@ -432,7 +432,7 @@ class KGET_EXPORT KGet
static TransferTreeSelectionModel * m_selectionModel;
//Lists of available plugins
static KPluginInfo::List m_pluginInfoList;
static QVector<KPluginMetaData> m_pluginList;
static QList<TransferFactory *> m_transferFactories;
//pointer to the Main window
......
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