kactioncollection and associated widget

Hamish Rodda rodda at kde.org
Tue Nov 20 13:41:45 GMT 2007

On Tue, 20 Nov 2007 10:57:07 pm Thomas Zander wrote:
> On Tuesday 20 November 2007 12:21:15 Andreas Pakulat wrote:
> > Please search the archive of this list, this change was done on purpose
> > for a reason (which unfortuantely I don't recall right now).
> I read the thread back then, I just didn't make the conclusion that this is
> actually going to break most kde apps.  Like it does right now.

No, this feature was never used to fix the bugs you are referring to.  See the 
end of the email.

> The whole point of the actionCollection behaving like a dump collection
> still holds, what I and I'm sure others meant with that is the point that
> adding the action should not alter the context automatically.
> The adding of the action to the parent widget still makes a lot of sense to
> me, especially since that doesn't change the action and thus doesn't break
> the concept of "just a collection".

Well, I tried to fix the automatic addition when it was broken / partially 
removed, and I was told that it was too "magic" and violated the concept of a 
collection because it changed the actions (changed their shortcut context to 

So, as a compromise, I switched everything to associateWidget(), which should 
be called after all actions are added to the action collection, and after any 
new actions are added.

> Bottom line; right now the action collection no longer is usable as a
> collection of actions *for*a*widget* and that means a lot of the usecases
> for the collection no longer automatically work.

It works every where else where it is used.

> Notice, btw, that if you do a associateWidget() and later add an action I
> would expect that action to also be associated.  And I'm sure many others
> would too. If this is not the intention, then the method is called
> incorrectly.

Perhaps it is named poorly, but what alternative would you suggest - 
associateWidgetNowOnly() ?

BTW, the bug you refer to is not created by this change.  The bug is actually 
because it never worked with Qt 4 without adding all actions to the main 
window, and in fact you need to keep Qt::WindowShortcut, so you specifically 
_don't_ want associateWidget().  I thought that actually it shouldn't matter 
if it is not plugged into a shown widget if it is a _window_ shortcut, but 
Trolltech disagrees 
I think the best fix is to change their mind, even if just for the specific 
case where a window level shortcut is plugged into a hidden menu bar.

Alternatively, we need to iterate the menu bar when it is shown, and 
temporarily add the actions to the main window (or some other widget).  This 
is a fairly abhorrent hack, because if any programs rely on adding actions to 
the main widget, it could introduce subtle bugs.  However, it would work.

So, we just need to decide, the coding part should be fairly trivial.

-------------- 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/20071121/2570f0f8/attachment.sig>

More information about the kde-core-devel mailing list