The future of KAction

Christoph Cullmann cullmann at absint.com
Wed Nov 16 09:38:20 GMT 2005


On Tuesday 15 November 2005 18:53, Alexander Dymo wrote:
> On Tuesday 15 November 2005 15:02, Simon Hausmann wrote:
> > GuiEditor editor(this);
> > editor.startMenuBar();
> >   editor.startMenu("file", "&File");
> >     editor.addAction(newDocumentAction);
> >     editor.addAction(fileOpenAction);
> >     editor.addSeparator();
> >     editor.startMenu("printTo", "&Print To");
> >       editor.addActions(KPrinter::printToActions());
> >     editor.menuFinished();
> >     editor.addSeparator();
> >     editor.addAction(quitAction);
> >   editor.menuFinished();
> >    ...
> >    editor.startMenu("settings", "&Settings");
> >      ...
> >      editor.addActionGroup("plugin settings");
> >      ...
> >    editor.menuFinished();
> >    ...
> > editor.menuFinished();
> > editor.startToolBar();
> >   editor.addAction(newDocumentAction);
> >   editor.addSeparator();
> >   editor.addWidget(searchComboBox);
> > editor.show();
>
> That's much better than xml IMHO.
>
> > void Plugin::buildGui()
> > {
> >     GuiEditor editor(this);
> >
> >     editor.startMenuBar();
> >     // .. in case the application doesn't want us to populate
> >     // the settings menu or doesn't provide one in the first place
> >     if (editor.tryToEditMenu("settings")) {
> >         editor.addActionToGroup("plugin settings", mySettingsAction);
>
> Why do we need to call ::tryToEditMenu()? Plugin should never care whether
> the host application wants or doesn't want to add an action. It should
> just call
> 	editor.addActionToGroup("plugin settings", mySettingsAction);
> If you really want to know whether your action was added, you can
> make ::addActionToGroup return bool.
btw., other important thing: it needs to be possible to remove the gui 
elements the plugin/part has added without deleting the plugin/part in a sane 
way, like atm possible with unplugging the xmlguiclient.


cu
Christoph




More information about the kde-core-devel mailing list