From kde-core-devel Tue Jul 24 17:16:56 2007 From: "Robert Knight" Date: Tue, 24 Jul 2007 17:16:56 +0000 To: kde-core-devel Subject: Re: [Konsole-devel] [PATCH] Shortcuts with hidden menu bar Message-Id: <13ed09c00707241016s51ec7f6fr429c60fb2770e9ef () mail ! gmail ! com> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=118529746920463 Hi Robin, Thanks for patch, it is greatly appreciated. I have checked and committed it. This behaviour affects other KDE applications which also provide the option to hide the menu bar, Konqueror for example. I am not sure about the action classes in kdelibs, I am CCing kde-core-devel in the hope that someone might have suggestions. Regards, Robert. On 24/07/07, Robin Stocker wrote: > Hi, > > As Konsole is probably the application I use the most, I thought I might > help a little with the development of the interesting KDE 4 version. > > The attached patch makes the action shortcuts work with a hidden menu > bar. It applies to trunk/KDE/kdebase/apps/konsole. > > The problem was: In Qt4, invisible widgets don't get events anymore, > because that's usually how you want it to behave. Because the actions > are added to the menu and the menu is hidden, the shortcuts do not work. > > > There are several solutions: > > - In the *ui.rc files, add each action not only to , but also > to . Not good. > > - Add all actions of actionCollection to the main window after they are > all added. I grepped for takeAction, to see if any actions are removed, > but found nothing. This is the method I implemented in the patch. > > - actionCollection provides the signal inserted(QAction *). Connect the > signal to a new slot in MainWindow which adds the action. One would also > have to provide a new method for the signal removed, so this would > amount to four slots in two classes. > > > The best solution would be to use KActionCollection.addAssociatedWidget, > but in line 238 of kdelibs/kdeui/actions/kactioncollection.cpp, before > the action is added to the specified widget, it does this: > > action->setShortcutContext(Qt::WidgetShortcut); > > Because of this, the shortcut will only get triggered when the main > window widget is directly focussed, but that's never the case. > > I don't know where actionCollection is used, but maybe this code could > be changed; maybe add a method setAssociatedWidgetShortcutContext or > something like it. Because then, this would be the cleanest solution. > > > Cheers, > Robin Stocker >