#include <pluginloader.h>
Public Types | |
| typedef QValueList< Info * > | PluginList |
Signals | |
| void | plug (KIPI::PluginLoader::Info *) |
| void | unplug (KIPI::PluginLoader::Info *) |
| void | replug () |
Public Member Functions | |
| PluginLoader (const QStringList &ignores, Interface *interface) | |
| virtual | ~PluginLoader () |
| void | loadPlugins () |
| ConfigWidget * | configWidget (QWidget *parent) |
| const PluginList & | pluginList () |
| void | loadPlugin (Info *) |
Static Public Member Functions | |
| static PluginLoader * | instance () |
Friends | |
| class | ConfigWidget |
| class | PluginCheckBox |
Classes | |
| class | Info |
| struct | Private |
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 similar to this from KPhotoAlbum:
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(); } // For this to work I need to pass false as second arg for createGUI 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.
| typedef QValueList<Info*> KIPI::PluginLoader::PluginList |
| KIPI::PluginLoader::PluginLoader | ( | const QStringList & | ignores, | |
| Interface * | interface | |||
| ) |
References endl(), KIPI::Interface::hasFeature(), KIPI::PluginLoader::Private::m_ignores, KIPI::PluginLoader::Private::m_interface, and KIPI::PluginLoader::Private::m_pluginList.
| KIPI::PluginLoader::~PluginLoader | ( | ) | [virtual] |
| void KIPI::PluginLoader::loadPlugins | ( | ) |
References loadPlugin(), KIPI::PluginLoader::Private::m_pluginList, and replug().
| PluginLoader * KIPI::PluginLoader::instance | ( | ) | [static] |
Referenced by KIPI::ConfigWidget::apply(), KIPI::ConfigWidget::ConfigWidget(), and loadPlugin().
| ConfigWidget * KIPI::PluginLoader::configWidget | ( | QWidget * | parent | ) |
References ConfigWidget.
| const PluginLoader::PluginList & KIPI::PluginLoader::pluginList | ( | ) |
References KIPI::PluginLoader::Private::m_pluginList.
| void KIPI::PluginLoader::loadPlugin | ( | Info * | info | ) |
References endl(), instance(), KIPI::PluginLoader::Info::library(), KIPI::PluginLoader::Private::m_interface, KIPI::PluginLoader::Info::name(), plug(), KIPI::PluginLoader::Info::plugin(), KIPI::PluginLoader::Info::setPlugin(), and KIPI::PluginLoader::Info::shouldLoad().
Referenced by KIPI::ConfigWidget::apply(), and loadPlugins().
| void KIPI::PluginLoader::plug | ( | KIPI::PluginLoader::Info * | ) | [signal] |
Referenced by loadPlugin().
| void KIPI::PluginLoader::unplug | ( | KIPI::PluginLoader::Info * | ) | [signal] |
Referenced by KIPI::ConfigWidget::apply().
| void KIPI::PluginLoader::replug | ( | ) | [signal] |
Referenced by KIPI::ConfigWidget::apply(), and loadPlugins().
friend class ConfigWidget [friend] |
Referenced by configWidget().
friend class PluginCheckBox [friend] |
1.5.5