[Konsole-devel] [PATCH] Shortcuts with hidden menu bar

Robert Knight robertknight at gmail.com
Tue Jul 24 17:16:56 UTC 2007


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 <robin at nibor.org> 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 <MenuBar>, but also
> to <MainWindow>. 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
>



More information about the konsole-devel mailing list