From konsole-devel Tue Jul 24 15:47:00 2007 From: Robin Stocker Date: Tue, 24 Jul 2007 15:47:00 +0000 To: konsole-devel Subject: [Konsole-devel] [PATCH] Shortcuts with hidden menu bar Message-Id: <46A61EF4.9070207 () nibor ! org> X-MARC-Message: https://marc.info/?l=konsole-devel&m=118529209602516 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------050401080201090608070804" This is a multi-part message in MIME format. --------------050401080201090608070804 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 --------------050401080201090608070804 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="shortcuts-with-hidden-menubar.diff" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="shortcuts-with-hidden-menubar.diff" SW5kZXg6IFRPRE8KPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gVE9ETwkocmV2aXNpb24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igp LT5hY3Rpb25zKCkpOworCiAgICAgc2V0SWRlbnRpZmllcihfc2Vzc2lvbi0+c2Vzc2lvbklk KCkpOwogICAgIHNlc3Npb25UaXRsZUNoYW5nZWQoKTsKICAgICAKSW5kZXg6IHNyYy9NYWlu V2luZG93LmNwcAo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBzcmMvTWFpbldpbmRvdy5jcHAJKHJldmlz aW9uIDY5MTg5MykKKysrIHNyYy9NYWluV2luZG93LmNwcAkod29ya2luZyBjb3B5KQpAQCAt ODEsNiArODEsMTAgQEAgTWFpbldpbmRvdzo6TWFpbldpbmRvdygpCiAgICAgLy8gcmVwbGFj ZSBzdGFuZGFyZCBzaG9ydGN1dHMgd2hpY2ggY2Fubm90IGJlIHVzZWQgaW4gYSB0ZXJtaW5h bAogICAgIC8vIChhcyB0aGV5IGFyZSByZXNlcnZlZCBmb3IgdXNlIGJ5IHRlcm1pbmFsIHBy b2dyYW1zKQogICAgIGNvcnJlY3RTaG9ydGN1dHMoKTsKKworICAgIC8vIGFkZCBhbGwgYWN0 aW9ucyB0byB0aGlzIHdpbmRvdywgc28gdGhhdCB0aGUga2V5Ym9hcmQgc2hvcnRjdXRzIGNh biBiZQorICAgIC8vIHVzZWQgZXZlbiB3aGVuIHRoZSBtZW51IGlzIGhpZGRlbgorICAgIGFk ZEFjdGlvbnMoYWN0aW9uQ29sbGVjdGlvbigpLT5hY3Rpb25zKCkpOwogfQogCiB2b2lkIE1h aW5XaW5kb3c6OmNvcnJlY3RTaG9ydGN1dHMoKQo= --------------050401080201090608070804 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ konsole-devel mailing list konsole-devel@kde.org https://mail.kde.org/mailman/listinfo/konsole-devel --------------050401080201090608070804--