kate/interfaces/kate
Kate::Plugin Class Reference
Kate plugin interface. More...
#include <plugin.h>

Public Member Functions | |
| Plugin (Application *application=0, const char *name=0) | |
| virtual | ~Plugin () |
| Application * | application () const |
| virtual PluginView * | createView (MainWindow *mainWindow) |
| virtual void | readSessionConfig (KConfigBase *config, const QString &groupPrefix) |
| virtual void | writeSessionConfig (KConfigBase *config, const QString &groupPrefix) |
Detailed Description
Kate plugin interface.
Topics:
Introduction
The Plugin class is the central part of a Kate plugin. It is possible to represent your plugin in the GUI with a subclass of PluginView. Furthermore if the plugin is configurable (and thus has config pages) you have to additionally derive your plugin from PluginConfigPageInterface.
Configuration Management
When Kate loads a session it calls readSessionConfig(), so if you have config settings use this function to load them. To save config settings for a session use writeSessionConfig(), as it will be called whenever a session is saved/closed.
If you want to save config settings which are not bound to a session but valid for all plugin instances you have to create your own KConfig like this:
KConfig* myConfig = new KConfig("katemypluginrc");
Plugin Views
If your plugin needs to be present in the GUI (e.g. menu or toolbar entries) you have to subclass PluginView and return a new instance of your plugin view, like this:
class MyPluginView : public Kate::PluginView { Q_OBJECT public: MyPluginView(MainWindow *mainWindow); // possibilities of gui: // - hook into the menus with KXMLGUIClient // - create a toolView and put a widget into it with MainWindow::createToolView() }; class MyPlugin : public Kate::Plugin { Q_OBJECT public: // other methods etc... PluginView *createView(MainWindow *mainWindow) { return new MyPluginView(mainWindow); } };
The Kate application takes care and deletes all plugin views. Further information can be found in the class documentation of PluginView.
Config Pages
If your plugin is configurable it makes sense to have config pages which appear in Kate's settings dialog. To tell the plugin loader that your plugin supports config pages you have to additionally derive your plugin from the class PluginConfigPageInterface. Read the class documentation for PluginConfigPageInterface to see how to do this right.
- See also:
- PluginView, PluginConfigPageInterface
Definition at line 114 of file plugin.h.
Constructor & Destructor Documentation
| Plugin::Plugin | ( | Application * | application = 0, |
|
| const char * | name = 0 | |||
| ) | [explicit] |
Constructor.
- Parameters:
-
application the Kate application name identifier
Definition at line 58 of file plugin.cpp.
| Plugin::~Plugin | ( | ) | [virtual] |
Virtual destructor.
Definition at line 63 of file plugin.cpp.
Member Function Documentation
| Application * Plugin::application | ( | ) | const |
Accessor to the Kate application.
- Returns:
- the application object
Definition at line 72 of file plugin.cpp.
| PluginView * Plugin::createView | ( | MainWindow * | mainWindow | ) | [virtual] |
Create a new View for this plugin for the given Kate MainWindow This may be called arbitrary often by the application to create as much views as mainwindows are around, the application will take care to delete this views if mainwindows close, you don't need to handle this yourself in the plugin.
The default implementation just doesn't create any view and returns a NULL pointer
- Parameters:
-
mainWindow the MainWindow for which a view should be created
- Returns:
- the new created view or NULL
Definition at line 77 of file plugin.cpp.
| void Plugin::readSessionConfig | ( | KConfigBase * | config, | |
| const QString & | groupPrefix | |||
| ) | [virtual] |
Load session specific settings here.
This function is called whenever a Kate session is loaded. You should use the given config and prefix groupPrefix to store the data. The group prefix exist so that the group does not clash with other applications that use the same config file.
- Parameters:
-
config the KConfig object which is to be used groupPrefix the group prefix which is to be used
- See also:
- writeSessionConfig()
Definition at line 82 of file plugin.cpp.
| void Plugin::writeSessionConfig | ( | KConfigBase * | config, | |
| const QString & | groupPrefix | |||
| ) | [virtual] |
Store session specific settings here.
This function is called whenever a Kate session is saved. You should use the given config and prefix groupPrefix to store the data. The group prefix exists so that the group does not clash with other applications that use the same config file.
- Parameters:
-
config the KConfig object which is to be used groupPrefix the group prefix which is to be used
- See also:
- readSessionConfig()
Definition at line 85 of file plugin.cpp.
The documentation for this class was generated from the following files:
KDE 4.4 API Reference