kactioncollection and associated widget

Thomas Zander zander at kde.org
Tue Nov 20 11:06:54 GMT 2007


I'm reading the sourcecode of kactioncollection and notice that it no longer 
has an associated widget member.

There just is a KActionCollection::associateWidget() method which does it 
work on actions that are currently in the collection.
But this naturally doesn't work for actions that get added later.
Also, IIRC this is a behavioral change from the kde3 method.

Now, the reason why I find this interresting is that we have open bugs 
(151421 etc) on people expecting to be able to hit the actions keyboard 
shortcut when the widget the actioncollection is associated with is on 
screen.
And the change to no longer add the action to that widget means the action 
can only be used when a widget derived from the action is on screen. Like a 
menu. Which is not really enough.

I can suggest several ways to solve this problem;

1) add a QList<QWidget*> to the private. Make associateWidget() add to it 
and make addAction/takeAction do the adding/removing of these widgets to 
the actions.
or
2) add a constructor with a QWidget as the 'owner'.  This makes the 
collection be more a collection-for-a-widget and it makes more sense to 
have any action added to the collection be auto-added to the widget.
or
3) make each and every application call assocateWidget *after* they added 
their actions to the collection. 

nr 1 is the way things were in kde3 times, I don't know why they were 
removed, but I think that should be reverted. Though I like version 2 a bit 
more myself.  Have the parent be a widget makes it behave in a certain way 
seems good.

-- 
Thomas Zander
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20071120/8aaae6c2/attachment.sig>


More information about the kde-core-devel mailing list