guiFactory() in KTextEditor::MainWindow
christoph at cullmann.io
Mon Jan 6 18:50:17 GMT 2020
On 2020-01-06 16:17, Thomas Friedrichsmeier wrote:
> I'm currently in the process (long overdue) of getting kate plugins to
> work in RKWard. One thing that is causing me a mild headache in this
> context is the presence of
> KXMLGUIFactory* guiFactory()
> in the KTextEditor::MainWindow interface. The problem here is, that I
> would like to keep a bit more control about when an where plugins plug
> their actions. E.g. right now, all views (including tool views) in
> RKWard can be detached as separate windows, and re-attached to the main
> window. Further, the menu actions of inactive views are hidden (client
> is removed from the KXMLGUIFactory), and re-enabled when activated.
> I'm not claiming either is the one-and-only right way to go, but I'd
> certainly like to keep these features. That is a bit difficult if
> plugins start modifying the UI, directly.
> Now I am not entirely sure that I have found all uses of
> KTextEditor::MainWindow::guiFactory(), but _almost_ all are either:
> The odd one out appears to be the externaltoolsplugin, which uses
> guiFactory() to get a pointer to the "file_save_all"-action. This last
> one looks a bit hackish to me in the first place, and could probably be
> rewritten to use findChild<KActionCollection*>() on the top-level
> window, instead.
> For the regular usage, I would like to suggest to
> 1) Deprecate KTextEditor::MainWindow::guiFactory()
> 2) Add new interface functions
> KTextEditor::MainWindow::addClient(KXMLGUIClient *);
> KTextEditor::MainWindow::removeClient(KXMLGUIClient *);
> With these, the embedding application would have the choice of either
> passing to the KXMLGUIFactory as before, saving pointer to the clients
> for later, adding them as children to other KXMLGUIClients (for
> example), and possibly doing other fancy stuff such as modifying their
> menu layout and shortcuts.
> Long story, short question: If I were to create a patch / review
> request for the above suggestion, would it stand any chance of being
> accepted, or am I overlooking something.
first off: cool that you work on integrating the KTextEditor plugin
For KF6, we might want to improve the interfaces more e.g. to easier
to expose stuff like projects to the plugins. Perhaps that might be an
place to cooperate.
For the proposed extension/change: Perhaps we should do it the other way
1) Deprecate KTextEditor::MainWindow::guiFactory()
2) Let the host application add the plugin views to it's GUI by
"requiring" that they
inherit from the KXMLGUIClient
That would give you flexibility and would move the tedious task of plug
in/out the UI
to the host application away from all plugins.
Ignorance is bliss...
https://cullmann.io | https://kate-editor.org
More information about the KWrite-Devel