Try to port backend loading away from KAboutData.
This commit is contained in:
parent
79f7ef6494
commit
aa132e1cdb
|
@ -38,7 +38,6 @@ class CoreBackend::CoreBackendPrivate
|
|||
};
|
||||
|
||||
CoreBackend::CoreBackend() :
|
||||
m_AboutData(NULL),
|
||||
d(new CoreBackendPrivate(*this))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -31,8 +31,6 @@ class CoreBackendDevice;
|
|||
class Device;
|
||||
class PartitionTable;
|
||||
|
||||
class KAboutData;
|
||||
|
||||
class QString;
|
||||
|
||||
/**
|
||||
|
@ -66,11 +64,11 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT CoreBackend : public QObject
|
|||
void scanProgress(const QString& device_node, int i);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the plugin's KAboutData
|
||||
* @return the plugin's KAboutData
|
||||
*/
|
||||
virtual const KAboutData& about() const { return *m_AboutData; }
|
||||
/**
|
||||
* Return the plugin's unique Id from JSON metadata
|
||||
* @return the plugin's unique Id from JSON metadata
|
||||
*/
|
||||
QString id() { return m_id; }
|
||||
|
||||
/**
|
||||
* Initialize the plugin's FileSystem support
|
||||
|
@ -140,11 +138,11 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT CoreBackend : public QObject
|
|||
static void setPartitionTableForDevice(Device& d, PartitionTable* p);
|
||||
static void setPartitionTableMaxPrimaries(PartitionTable& p, qint32 max_primaries);
|
||||
|
||||
private:
|
||||
void setAboutData(const KAboutData* a) { m_AboutData = a; }
|
||||
private:
|
||||
void setId(const QString& id) { m_id = id; }
|
||||
|
||||
private:
|
||||
const KAboutData* m_AboutData;
|
||||
QString m_id;
|
||||
|
||||
class CoreBackendPrivate;
|
||||
CoreBackendPrivate* d;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de *
|
||||
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2015 by Teo Mrnjavac <teo@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
|
@ -24,7 +25,6 @@
|
|||
#include <QStringList>
|
||||
#include <QString>
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KLocalizedString>
|
||||
#include <KPluginLoader>
|
||||
#include <KServiceTypeTrader>
|
||||
|
@ -48,7 +48,8 @@ CoreBackendManager* CoreBackendManager::self()
|
|||
|
||||
KService::List CoreBackendManager::list() const
|
||||
{
|
||||
return KServiceTypeTrader::self()->query(QStringLiteral("PartitionManager/Plugin"), QStringLiteral("[X-KDE-PluginInfo-Category] == 'BackendPlugin'"));
|
||||
return KServiceTypeTrader::self()->query(QStringLiteral("PartitionManager/Plugin"),
|
||||
QStringLiteral("[X-KDE-PluginInfo-Category] == 'BackendPlugin'"));
|
||||
}
|
||||
|
||||
bool CoreBackendManager::load(const QString& name)
|
||||
|
@ -58,14 +59,19 @@ bool CoreBackendManager::load(const QString& name)
|
|||
|
||||
KPluginLoader loader(name);
|
||||
|
||||
KPluginFactory* factory = loader.factory();
|
||||
KPluginFactory* factory = loader.factory();
|
||||
|
||||
if (factory != NULL)
|
||||
{
|
||||
m_Backend = factory->create<CoreBackend>(NULL);
|
||||
// FIXME: port KF5
|
||||
// backend()->setAboutData(factory->componentData().aboutData());
|
||||
// qDebug() << "Loaded backend plugin: " << backend()->about().displayName() << ", " << backend()->about().version();
|
||||
m_Backend = factory->create<CoreBackend>(NULL);
|
||||
|
||||
QString id = loader.metaData().toVariantMap().value(QStringLiteral("KPlugin"))
|
||||
.toMap().value(QStringLiteral("Id")).toString();
|
||||
if ( id.isEmpty() )
|
||||
return false;
|
||||
|
||||
backend()->setId( id );
|
||||
qDebug() << "Loaded backend plugin: " << backend()->id();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -942,7 +942,7 @@ void MainWindow::onFileSystemSupport()
|
|||
void MainWindow::onSettingsChanged()
|
||||
{
|
||||
// FIXME: port KF5
|
||||
if (CoreBackendManager::self()->backend()->about().productName() != Config::backend())
|
||||
if (CoreBackendManager::self()->backend()->id() != Config::backend())
|
||||
{
|
||||
CoreBackendManager::self()->unload();
|
||||
// FIXME: if loadBackend() fails to load the configured backend and loads the default
|
||||
|
|
|
@ -19,8 +19,9 @@ file (GLOB pmdummybackendplugin_SRCS *.cpp)
|
|||
|
||||
add_library(pmdummybackendplugin SHARED ${pmdummybackendplugin_SRCS})
|
||||
|
||||
target_link_libraries(pmdummybackendplugin partitionmanagerprivate ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${LIBPARTED_LIBS} ${BLKID_LIBRARIES} ${KDE4_SOLID_LIBS})
|
||||
target_link_libraries(pmdummybackendplugin partitionmanagerprivate KF5::KIOCore ${LIBPARTED_LIBS} ${BLKID_LIBRARIES} KF5::Solid)
|
||||
|
||||
install(TARGETS pmdummybackendplugin DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
install(FILES pmdummybackendplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
kservice_desktop_to_json(pmdummybackendplugin pmdummybackendplugin.desktop)
|
||||
install(FILES pmdummybackendplugin.json DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
|
||||
|
|
|
@ -34,25 +34,9 @@
|
|||
|
||||
#include <KLocalizedString>
|
||||
#include <KPluginFactory>
|
||||
#include <KAboutData>
|
||||
|
||||
K_PLUGIN_FACTORY(DummyBackendFactory, registerPlugin<DummyBackend>(); )
|
||||
K_PLUGIN_FACTORY_WITH_JSON(DummyBackendFactory, "pmdummybackendplugin.json", registerPlugin<DummyBackend>(); )
|
||||
|
||||
static KAboutData createPluginAboutData()
|
||||
{
|
||||
KAboutData about(
|
||||
QStringLiteral("pmdummybackendplugin"),
|
||||
i18nc("@title", "Dummy Backend Plugin"),
|
||||
QString::fromLatin1(VERSION),
|
||||
i18n("KDE Partition Manager dummy backend."),
|
||||
KAboutLicense::GPL,
|
||||
i18n("Copyright 2010 Volker Lanz"));
|
||||
|
||||
about.addAuthor(i18nc("@info:credit", "Volker Lanz"), i18nc("@info:credit", "Former maintainer"));
|
||||
about.setHomepage(QStringLiteral("http://www.partitionmanager.org"));
|
||||
|
||||
return about;
|
||||
}
|
||||
|
||||
DummyBackend::DummyBackend(QObject*, const QList<QVariant>&) :
|
||||
CoreBackend()
|
||||
|
|
|
@ -34,4 +34,5 @@ add_library(pmlibpartedbackendplugin SHARED ${pmlibpartedbackendplugin_SRCS})
|
|||
target_link_libraries(pmlibpartedbackendplugin partitionmanagerprivate ${LIBPARTED_LIBS} ${BLKID_LIBRARIES} KF5::KIOCore)
|
||||
|
||||
install(TARGETS pmlibpartedbackendplugin DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
install(FILES pmlibpartedbackendplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
kservice_desktop_to_json(pmlibpartedbackendplugin pmlibpartedbackendplugin.desktop)
|
||||
install(FILES pmlibpartedbackendplugin.json DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
|
|
|
@ -47,29 +47,12 @@
|
|||
#include <KIOCore/KMountPoint>
|
||||
#include <KIOCore/KDiskFreeSpaceInfo>
|
||||
#include <KPluginFactory>
|
||||
#include <KAboutData>
|
||||
|
||||
#include <parted/parted.h>
|
||||
#include <unistd.h>
|
||||
#include <blkid/blkid.h>
|
||||
|
||||
K_PLUGIN_FACTORY(LibPartedBackendFactory, registerPlugin<LibPartedBackend>(); )
|
||||
|
||||
static KAboutData createPluginAboutData()
|
||||
{
|
||||
KAboutData about(
|
||||
QStringLiteral("pmlibpartedbackendplugin"),
|
||||
i18nc("@title", "LibParted Backend Plugin"),
|
||||
QStringLiteral("%1, libparted version: %2").arg(QString::fromLatin1(VERSION)).arg(QString::fromLatin1(ped_get_version())),
|
||||
i18n("KDE Partition Manager backend for libparted."),
|
||||
KAboutLicense::GPL,
|
||||
i18n("Copyright 2008,2009,2010 Volker Lanz"));
|
||||
|
||||
about.addAuthor(i18nc("@info:credit", "Volker Lanz"), i18nc("@info:credit", "Former maintainer"));
|
||||
about.setHomepage(QStringLiteral("http://www.partitionmanager.org"));
|
||||
|
||||
return about;
|
||||
}
|
||||
K_PLUGIN_FACTORY_WITH_JSON(LibPartedBackendFactory, "pmlibpartedbackendplugin.json", registerPlugin<LibPartedBackend>();)
|
||||
|
||||
static struct
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue