Commit d150811a authored by Jonathan Marten's avatar Jonathan Marten
Browse files

Port deprecated KPluginInfo -> KPluginMetaData

parent b26b4a58
Pipeline #170751 passed with stage
in 4 minutes and 26 seconds
......@@ -9,7 +9,6 @@
#include "k3b_export.h"
#include <KPluginFactory>
#include <KPluginMetaData>
#include <KPluginInfo>
#include <QObject>
#define K3B_PLUGIN_SYSTEM_VERSION 5
......@@ -32,7 +31,6 @@ namespace K3b {
explicit Plugin( QObject* parent = 0 );
~Plugin() override;
KPluginInfo pluginInfo() const { return KPluginInfo::fromMetaData(d->metadata); }
KPluginMetaData pluginMetaData() const { return d->metadata; }
/**
......
......@@ -12,9 +12,8 @@
#include "k3b_i18n.h"
#include <KCModuleProxy>
#include <KPluginInfo>
#include <KService>
#include <KPluginLoader>
#include <KPluginFactory>
#include <KPluginMetaData>
#include <KMessageBox>
......@@ -84,15 +83,15 @@ QList<K3b::Plugin*> K3b::PluginManager::plugins( const QString& group ) const
KCModuleProxy* K3b::PluginManager::Private::getModuleProxy( Plugin* plugin ) const
{
foreach( const KService::Ptr& service, plugin->pluginInfo().kcmServices() ) {
if( !service->noDisplay() ) {
KCModuleProxy* moduleProxy = new KCModuleProxy( service );
if( moduleProxy->realModule() ) {
return moduleProxy;
}
else {
delete moduleProxy;
}
const QString kcm = plugin->pluginMetaData().value("X-KDE-ConfigModule");
qDebug() << "for plugin" << plugin->pluginMetaData().pluginId() << "KCM" << kcm;
if (!kcm.isEmpty()) {
KCModuleProxy *moduleProxy = new KCModuleProxy(KPluginMetaData(kcm));
if( moduleProxy->realModule() ) {
return moduleProxy;
}
else {
delete moduleProxy;
}
}
return 0;
......@@ -101,11 +100,11 @@ KCModuleProxy* K3b::PluginManager::Private::getModuleProxy( Plugin* plugin ) con
void K3b::PluginManager::loadAll()
{
const QVector<KPluginMetaData> metadataList = KPluginLoader::findPlugins("k3b_plugins");
const QVector<KPluginMetaData> metadataList = KPluginMetaData::findPlugins("k3b_plugins");
for (const auto &metadata : metadataList) {
KPluginLoader loader(metadata.fileName());
KPluginFactory *factory = loader.factory();
if (auto *plugin = factory->create<K3b::Plugin>()) {
KPluginFactory::Result<K3b::Plugin> result = KPluginFactory::instantiatePlugin<K3b::Plugin>(metadata);
if (result) {
K3b::Plugin *plugin = result.plugin;
plugin->d->metadata = metadata;
qDebug() << "Loaded plugin" << metadata.metaDataFileName();
d->plugins.append(plugin);
......@@ -132,7 +131,7 @@ int K3b::PluginManager::execPluginDialog( Plugin* plugin, QWidget* parent )
{
if( KCModuleProxy* moduleProxy = d->getModuleProxy( plugin ) ) {
QDialog dlg( parent );
dlg.setWindowTitle( plugin->pluginInfo().name() );
dlg.setWindowTitle( plugin->pluginMetaData().name() );
QVBoxLayout* layout = new QVBoxLayout( &dlg );
QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults, &dlg );
layout->addWidget( moduleProxy );
......@@ -156,7 +155,7 @@ int K3b::PluginManager::execPluginDialog( Plugin* plugin, QWidget* parent )
return ret;
}
else {
KMessageBox::sorry( parent, i18n("No settings available for plugin %1.", plugin->pluginInfo().name() ) );
KMessageBox::sorry( parent, i18n("No settings available for plugin %1.", plugin->pluginMetaData().name() ) );
return 0;
}
}
......
......@@ -11,6 +11,7 @@
#include "k3bdoc.h"
#include "k3bplugin.h"
#include <KConfigGroup>
#include <QFlags>
#include <QIcon>
......
......@@ -13,6 +13,7 @@
#include <config-k3b.h>
#include <KConfig>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QDebug>
#include <QTextCodec>
......
......@@ -12,6 +12,7 @@
#include <config-k3b.h>
#include <KConfig>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QDebug>
......
......@@ -17,6 +17,7 @@
#include "k3bplugin_i18n.h"
#include <KConfig>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QDebug>
......
......@@ -532,7 +532,8 @@ void K3b::SystemProblemDialog::checkSystem(QWidget* parent, NotificationLevel le
bool haveMp3Decoder = false;
for( QList<K3b::Plugin*>::const_iterator it = plugins.constBegin();
it != plugins.constEnd(); ++it ) {
if( (*it)->pluginInfo().isValid() && (*it)->pluginInfo().pluginName() == "k3bmaddecoder" ) {
const KPluginMetaData &metaData = (*it)->pluginMetaData();
if (metaData.isValid() && metaData.pluginId() == "k3bmaddecoder" ) {
haveMp3Decoder = true;
break;
}
......
......@@ -11,8 +11,7 @@
#include "k3bcore.h"
#include <KLocalizedString>
#include <KPluginSelector>
#include <KPluginInfo>
#include <KPluginWidget>
#include <QDebug>
#include <QHash>
......@@ -33,7 +32,7 @@ K3b::PluginOptionTab::PluginOptionTab( QWidget* parent )
"<em>KPart Plugins</em> which embed themselves in the K3b menu structure.</p>" ), this );
label->setWordWrap( true );
KPluginSelector* pluginSelector = new KPluginSelector( this );
KPluginWidget * pluginSelector = new KPluginWidget( this );
layout->addWidget( label );
layout->addWidget( pluginSelector );
......@@ -47,16 +46,13 @@ K3b::PluginOptionTab::PluginOptionTab( QWidget* parent )
// add all plugins in each category
foreach( const QString &category, categoryNames.keys() ) {
QList<KPluginInfo> plugins;
QVector<KPluginMetaData> plugins;
foreach( Plugin* plugin, k3bcore->pluginManager()->plugins( category ) ) {
plugins << plugin->pluginInfo();
qDebug() << "Adding plugin" << plugin->pluginInfo().name();
plugins << plugin->pluginMetaData();
qDebug() << "Adding plugin" << plugin->pluginMetaData().pluginId();
}
pluginSelector->addPlugins( plugins,
KPluginSelector::ReadConfigFile,
categoryNames[ category ],
category );
pluginSelector->addPlugins( plugins, categoryNames[ category ] );
}
}
......
......@@ -14,6 +14,7 @@
#include <KComboBox>
#include <KConfig>
#include <KConfigGroup>
#include <KColorScheme>
#include <KLocalizedString>
#include <KDiskFreeSpaceInfo>
......@@ -61,7 +62,7 @@ K3b::AudioEncoder* K3b::AudioConvertingOptionWidget::Private::encoderForIndex( i
QString K3b::AudioConvertingOptionWidget::Private::pluginNameForIndex( int index ) const
{
if( AudioEncoder* encoder = encoderForIndex( index ) )
return encoder->pluginInfo().pluginName();
return encoder->pluginMetaData().pluginId();
else
return QString();
}
......@@ -87,7 +88,7 @@ int K3b::AudioConvertingOptionWidget::Private::indexForFileType( const QString&
for( int i = 0; i < encoders.size(); ++i ) {
AudioEncoder* encoder = encoders.at( i );
if( encoder != 0 &&
encoder->pluginInfo().pluginName() == pluginName &&
encoder->pluginMetaData().pluginId() == pluginName &&
extensions.at( i ) == ext ) {
return i;
}
......@@ -102,7 +103,7 @@ QString K3b::AudioConvertingOptionWidget::Private::defaultPluginName() const
for( int i = 0; i < extensions.size(); ++i ) {
AudioEncoder* encoder = encoders.at( i );
if( extensions.at( i ) == defaultExt && encoder != 0 ) {
return encoder->pluginInfo().pluginName();
return encoder->pluginMetaData().pluginId();
}
}
return QString();
......
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