KTextEditor
While the KTextEditor framework provides a powerful text editor in itself, further features are available from plugins (KTextEditor::Plugin). At the time of this writing, all known KTextEditor plugins are maintained by the kate project, but most can be used in other hosting applications, as well.
This page is about supporting KTextEditor plugins in your application. For information on developing the plugins themselves, refer to KTextEditor::Plugin.
Loading simple plugins
The steps needed to find and load basic KTextEditor plugins are roughly as follows:
Note, however, that only a few basic plugins will actually be functional with the above, alone. For others, we need to implement several additional functions, as detailed, below.
Implementing full plugin hosting
I order to allow plugins to interact with the hosting application (e.g. creating or activating additional windows/widgets), you need to implement two interfacing classes:
- KTextEditor::Application (singleton)
- KTextEditor::MainWindow
The latter corresponds to top level windows in your application (it's ok, if your application only supports a single toplevel window), with the assumption being that several document- and/or tool-windows can existing in each main window.
The two classes are really just a thin layer to dispatch from API to be used in plugins to the appropiate functionality in your application. For best runtime compatibility even across different version of KTextEditor, this is implemented using Qt slots. E.g. KTextEditor::MainWindow::activeView() is defined as:
I.e. this function (and most others in KTextEditor::MainWindow and KTextEditor::Application) simply invokes a slot by the same name and signature in its parent QObject. This is what you need to provide. The following example should illustrate the idea:
- Note
- Due to the lose coupling via Qt slots, you may not need to implement a dispatch slots for every single member in KTextEditor::Application, and KTextEditor::MainWindow. Naturally, however, plugins will be more likely to work as expected, the more complete the hosting app implements these interfaces.
- Don't forget to integrate the plugin config pages, if desired:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.