KActionCollection setAssociatedWidget problems

Hamish Rodda rodda at kde.org
Sun Oct 21 15:01:02 BST 2007


Hi,

A while back there was a cleanup of KActionCollection which subtly changed the 
behaviour of setAssociatedWidget(QWidget*).  This function is intended to 
make the actions specific to that widget, and accomplishes this by adding all 
actions to the widget and setting their shortcut context to 
Qt::WidgetShortcut. (It replaces KAccel's widget binding functionality)

The problem is that in the cleanup, the mechanism to ensure any further 
actions were added to the widget was kept, but the mechanism to ensure the 
shortcut context got changed to Qt::WidgetShortcut was deleted.  Now, the 
only shortcuts which have their context changed are those which are already a 
part of the action collection when setAssociatedWidget is called.

This has created a set of serious bugs: when parts are merged together, 
actions' shortcuts step on each other's toes if the setAssociatedWidget call 
was prior to their addition to the action collection.  For instance, 
KDirOperator's delete shortcut (a WindowShortcut) competes with katepart's 
delete shortcut, thus delete doesn't work when you're typing in kate.

While I agree that the magic of changing the shortcut context is not ideal, it 
is the intention (or at least I hope it is) of every use of 
setAssociatedWidget to conveniently have this effect.

I believe the best course of action is to reintroduce this behaviour (one line 
patch attached).  The alternative really is to remove setAssociatedShortcut 
and let the apps do it themselves, but I think this would lead to more 
errors.

Cheers,
Hamish.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kactioncollection.patch
Type: text/x-diff
Size: 500 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20071022/093b006b/attachment.patch>
-------------- 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/20071022/093b006b/attachment.sig>


More information about the kde-core-devel mailing list