Multiple main window support, and action-collections

Andreas Pakulat apaku at gmx.de
Sun Jul 26 18:26:34 UTC 2009


On 26.07.09 16:10:36, David Nolden wrote:
> Am Sonntag 26 Juli 2009 15:17:38 schrieb Andreas Pakulat:
> > I don't like this, the plugin implementation shouldn't need to worry about
> > the mainwindows and the xmlgui stuff (except putting the actions into an
> > action collection and setting an xml file).
> >
> > So, how about having:
> >
> > class IPlugin : public QObject
> > {
> >         QList<KAction*> actions();
> >         QString xmlFile();
> > }
> >
> > And then simply do the xmlguiclient-stuff inside sublime and/or shell?
> Ah yeah I've also though about just doing something like "virtual void 
> createActionsForMainWindow(Sublime::MainWindow* window, QString& xmlFile, 
> KActionCollection& actions)".

I don't see why it would need to know about the mainwindow. The actions
of a plugin should be the same in all mainwindows. IMHO two pure virtual
getters for the actions and the xmlfile are enough.

> But then I saw that there is quite a bit more of stuff in KXMLGuiClient, for 
> example management of 'states'. So it probably shouldn't be completely hidden 
> away.

The question is wether all that is really needed. I agree we should also
provide the stateChanged thing, probably as a signal emitted by IPlugin.
Other than that I can't see anything in the KXMLGUIClient API that any
of our plugins uses or would need to use. The usual things done are:

- create a couple of actions and adding them to the collection under a
  certain name
- set the xml file such that the actions show up in the menus/toolbars
- enable/disable actions during runtime, either by calling setEnabled()
  on the action, or by using the state stuff via stateChanged()

One thing I'm not sure right now is wether a given KAction can be added
to multiple clients/action collections. IIRC KActionCollection does a
setParent (don't have the sources at hand), so we'd need need to "clone"
actions...

Andreas
 
-- 
Today's weirdness is tomorrow's reason why.
		-- Hunter S. Thompson




More information about the KDevelop-devel mailing list