KIPI::PluginLoader

Search for usage in LXR

#include <KIPI/PluginLoader>

Inheritance diagram for KIPI::PluginLoader:

Classes

class  Info
 

Public Types

typedef QList< Info * > PluginList
 

Signals

void plug (KIPI::PluginLoader::Info *)
 
void replug ()
 
void unplug (KIPI::PluginLoader::Info *)
 

Public Member Functions

 PluginLoader ()
 
 PluginLoader (KXmlGuiWindow *const parent)
 
 ~PluginLoader () override
 
ConfigWidgetconfigWidget (QWidget *const parent) const
 
QStringList disabledPluginActions () const
 
void init ()
 
Interfaceinterface () const
 
QString kipiPluginsVersion () const
 
void loadPlugins ()
 
const PluginListpluginList ()
 
void setDisabledPluginActions (const QStringList &disabledActions)
 
void setIgnoredPluginsList (const QStringList &ignores)
 
void setInterface (Interface *const interface)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static PluginLoaderinstance ()
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

Author
Gilles Caulier
Maintainer: Victor Dodon

This is the class that will help host applications to load plugins.

This is a singleton and host applications should create the PluginLoader just once, and then use the instance() static method to access it.

The host application must create an instance of the plugin loader, and call the method loadPlugins() to get the plugins loaded. To ensure that plugins are correctly removed from menus and toolbars when loaded and unloaded after constructions, the application must connect to either the signals plug() / unplug() or the signal replug(). These signals are emitted when a plugin is to be inserted into the menus.

If your application is using KDE XMLGUI, the easiest(nicest) way to get the plugins inserted into the menus is by adding an item in your application XML ui.rc file looking like this:

<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<gui version="1" name="MyKipiApplication" >
<MenuBar>
<Menu name="Image" ><text>&amp;Image</text>
<DefineGroup name="kipi_image_group" append="kipi_image_group" />
</Menu>
<Menu name="Tools"><text>&amp;Tools</text>
<DefineGroup name="kipi_album_group" append="kipi_album_group" />
<Separator/>
<DefineGroup name="kipi_tool_group" append="kipi_tool_group" />
<Separator/>
<DefineGroup name="kipi_batch_group" append="kipi_batch_group" />
</Menu>
<Merge/>
</MenuBar>
<ToolBar name="mainToolBar">
<text>Main Toolbar</text>
</Toolbar>
<ActionProperties/>
</gui>

Then loading plugins into menus could be done with code similar to this implementation:

class MyKipiApplication : public KXmlGuiWindow
{
public:
MyKipiApplication();
private Q_SLOTS:
void slotKipiPluginPlug();
private:
KIPI::Interface* m_iface;
KIPI::PluginLoader* m_loader;
};
// -------------------------------------------------------------------------------
MyKipiApplication::MyKipiApplication() : KXmlGuiWindow(0)
{
m_iface = new KIPI::Interface(this, "MyKipiApplication_KIPI_interface");
m_loader = new KIPI::PluginLoader(this);
m_loader->setInterface(m_iface);
m_loader->init();
connect(m_loader, SIGNAL(replug()),
this, SLOT(slotKipiPluginPlug()));
m_loader->loadPlugins();
// Do not delete m_loader as long as any of the plugins are in use
}
void MyKipiApplication::slotKipiPluginPlug()
{
QList<QAction*> kipiImageActions, kipiExportActions, kipiToolsActions;
PluginLoader::PluginList list = m_loader->pluginList();
// We need to remove loaded plugins from the gui factory
for (PluginLoader::PluginList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it )
{
Plugin* plugin = (*it)->plugin();
if ( !plugin || !(*it)->shouldLoad() )
continue;
guiFactory()->removeClient(plugin);
}
for (PluginLoader::PluginList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it )
{
Plugin* plugin = (*it)->plugin();
if ( !plugin || !(*it)->shouldLoad() )
continue;
plugin->setup(this);
}
// We add plugins to the factory
for (PluginLoader::PluginList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it )
{
Plugin* plugin = (*it)->plugin();
if ( !plugin || !(*it)->shouldLoad() )
continue;
guiFactory()->addClient(plugin);
}
}

For a implementation sample used to manage Kipi-plugins in host application, look the code of the kxmlkipicmd test application in the "test" folder from libkipi.

To configure which plugins should be loaded, simply call PluginLoader::configWidget(), and insert the widget into your normal configuration dialog.

Definition at line 173 of file pluginloader.h.

Constructor & Destructor Documentation

KIPI::PluginLoader::PluginLoader ( )

Use this constructor if your application does not use KDE XML GUI technology.

Note that the PluginLoader is intended to be a singleton, so you should create only one and then use instance().

Definition at line 216 of file pluginloader.cpp.

KIPI::PluginLoader::PluginLoader ( KXmlGuiWindow *const  parent)

Standard constructor.

You must pass the instance of KDE XML GUI application as argument.

Note that the PluginLoader is intended to be a singleton, so you should create only one and then use instance().

Parameters
parentthe pointer to the KXmlGuiWindow of your application

Definition at line 223 of file pluginloader.cpp.

KIPI::PluginLoader::~PluginLoader ( )
overridedefault

Standard destructor.

Since PluginLoader is a singleton, you should not call this in client code.

Member Function Documentation

ConfigWidget * KIPI::PluginLoader::configWidget ( QWidget *const  parent) const

Return the config widget with list of plugins to manage.

Definition at line 356 of file pluginloader.cpp.

QStringList KIPI::PluginLoader::disabledPluginActions ( ) const

Return the list of disabled plugin actions.

Definition at line 253 of file pluginloader.cpp.

void KIPI::PluginLoader::init ( )

Init plugin loader.

Call this method to parse relevant plugins installed on your system. Before to call this method, you must setup KIPI interface instance. Optionally, setup list of plugins to ignore, the constraint list, and the disabled plugin actions

Definition at line 258 of file pluginloader.cpp.

PluginLoader * KIPI::PluginLoader::instance ( )
static

Returns plugin loader instance.

Definition at line 341 of file pluginloader.cpp.

Interface * KIPI::PluginLoader::interface ( ) const

Return KIPI host interface instance.

Definition at line 351 of file pluginloader.cpp.

QString KIPI::PluginLoader::kipiPluginsVersion ( ) const

Return the kipi-plugins version installed on your computer if it's found through kipiplugins.desktop file.

Definition at line 361 of file pluginloader.cpp.

void KIPI::PluginLoader::loadPlugins ( )

Call this method to load relevant plugins installed on your system to your KIPI host application.

Note
Plugins can be loaded through Info item.

Definition at line 331 of file pluginloader.cpp.

const PluginLoader::PluginList & KIPI::PluginLoader::pluginList ( )

Returns the list of loaded plugins.

Definition at line 336 of file pluginloader.cpp.

void KIPI::PluginLoader::replug ( )
signal
Note
Plugin can be plugged through Info item.
void KIPI::PluginLoader::setDisabledPluginActions ( const QStringList disabledActions)

Set disabled plugin actions that will not be plugged into the gui,.

Definition at line 248 of file pluginloader.cpp.

void KIPI::PluginLoader::setIgnoredPluginsList ( const QStringList ignores)

Set Plugins ignore list, with name of obsoletes plugins to not load through init().

Definition at line 243 of file pluginloader.cpp.

void KIPI::PluginLoader::setInterface ( Interface *const  interface)

Set KIPI interface instance from host application.

Definition at line 237 of file pluginloader.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jan 22 2022 22:32:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.