Multiple main window support, and action-collections

Andreas Pakulat apaku at gmx.de
Sun Jul 26 21:44:09 UTC 2009


On 26.07.09 22:26:05, David Nolden wrote:
> Am Sonntag 26 Juli 2009 21:52:50 schrieb David Nolden:
> > Am Sonntag 26 Juli 2009 20:26:34 schrieb Andreas Pakulat:
> > > 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...
> >
> > No they cannot. That's exactly the problem I'm talking about. There is no
> > way around creating new actions for each mainwindow as it seems. That
> > mainwindow argument is not exactly needed while creating those actions, but
> > I think it's consistent giving it when a method is called
> > "createActionsForMainWindow".
> Just tested it, no it's not possible to add the same action to the action 
> collections of two mainwindows. It has no effect in the second one.
> 
> And since KAction is a normal QObject with connections etc., and may have a 
> set defaultWidget(), I guess it's not possible to just clone both, including 
> all their active connections.

I don't think defaultWidget() will be a problem, the plugins actions
won't have one as those are generally not bound to a widget. The only
widget a plugin can provide is a toolview and there can be multiple of
that. Hence having a default widget on the action doesn't make much
sense.

Signal/Slot connections should be handleable by simply doing a bit of

if( isKAction(a) )
{
   KAction* newAction = new KAction();
   connect(newAction, SIGNAL(triggered()), a, SIGNAL(triggered()));
} else if( isKSelectAction(a) )
{
   KSelectionAction* newAction = new KSelectionAction();
   // connect all KSelectAction-relevant signals
}

Obviously that won't work for custom subclasses, but I'm not sure how
many use-cases there exist for that. One way or the other we'll have to
limit the possible use-cases anyway (or replace xmlgui). 

Another possible but not very nice option would be creating multiple
instances of a plugin and binding them to the mainwindow....

Andreas

-- 
Today is the tomorrow you worried about yesterday.




More information about the KDevelop-devel mailing list