KIPI::PluginLoader Class Reference
#include <pluginloader.h>
Collaboration diagram for KIPI::PluginLoader:
[legend]List of all members.
Detailed Description
This is the class that will help host applications to load plugins.
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 XMLGUI, the easiest way to get the plugins inserted into the menus is by adding an item in the ui.rc file looking list this: <ActionList name="image_actions"/>
Then plugin plugins into menus could be done with code similiar to this from KimDaBa:
void slotReplug() {
unplugActionList( QString::fromLatin1("file_actions") );
unplugActionList( QString::fromLatin1("image_actions") );
unplugActionList( QString::fromLatin1("tool_actions") );
QPtrList<KAction> fileActions;
QPtrList<KAction> imageActions;
QPtrList<KAction> toolsActions;
KIPI::PluginLoader::PluginList list = _pluginLoader->pluginList();
for( KIPI::PluginLoader::PluginList::Iterator it = list.begin(); it != list.end(); ++it ) {
KIPI::Plugin* plugin = (*it)->plugin;
if ( !plugin || !(*it)->shouldLoad )
continue;
plugin->setup( this );
QPtrList<KAction>* popup = 0;
if ( plugin->category() == KIPI::IMAGESPLUGIN )
popup = &imageActions;
else if ( plugin->category() == KIPI::EXPORTPLUGIN ||
plugin->category() == KIPI::IMPORTPLUGIN )
popup = &fileActions;
else if ( plugin->category() == KIPI::TOOLSPLUGIN )
popup = &toolsActions;
if ( popup ) {
KActionPtrList actions = plugin->actions();
for( KActionPtrList::Iterator it = actions.begin(); it != actions.end(); ++it ) {
popup->append( *it );
}
}
else {
kdDebug() << "No menu found\n";
}
plugin->actionCollection()->readShortcutSettings();
}
plugActionList( QString::fromLatin1("file_actions"), fileActions );
plugActionList( QString::fromLatin1("image_actions"), imageActions );
plugActionList( QString::fromLatin1("tool_actions"), toolsActions );
}
To configure which plugins should be loaded, simply call PluginLoader::configWidget(), and insert the widget into your normal configuration dialog.
Member Typedef Documentation
Constructor & Destructor Documentation
| KIPI::PluginLoader::PluginLoader |
( |
const QStringList & |
ignores, |
|
|
Interface * |
interface |
|
) |
|
|
| KIPI::PluginLoader::~PluginLoader |
( |
|
) |
[virtual] |
|
Member Function Documentation
| ConfigWidget * KIPI::PluginLoader::configWidget |
( |
QWidget * |
parent |
) |
|
|
| void KIPI::PluginLoader::loadPlugins |
( |
|
) |
|
|
| void KIPI::PluginLoader::replug |
( |
|
) |
[signal] |
|
Friends And Related Function Documentation
The documentation for this class was generated from the following files:
Generated on Tue Sep 13 05:02:15 2005 for libKipi by
1.4.4