From 1a5340788639ba71725338ddc5d340b2b304f4c2 Mon Sep 17 00:00:00 2001 From: Aleksei Nikiforov Date: Mon, 21 Jan 2019 12:16:13 +0300 Subject: tdf#122814 KDE5: conditional disable of Qt shortcuts Change-Id: I5375f0b555e483b2c108550d319e64d781b96f75 Reviewed-on: https://gerrit.libreoffice.org/66673 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- vcl/qt5/Qt5Widget.cxx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'vcl/qt5') diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx index 6d75cd60df73..4ce56523d58e 100644 --- a/vcl/qt5/Qt5Widget.cxx +++ b/vcl/qt5/Qt5Widget.cxx @@ -403,20 +403,18 @@ bool Qt5Widget::event(QEvent* pEvent) // but enables keypress event. // If event is not accepted and shortcut is successfully activated, // KeyPress event is omitted. - // It looks like handleKeyEvent function still activates the shortcut on KeyPress event, - // so there's no harm in disabling shortcut activation via Qt mechanisms. - pEvent->accept(); + // + // Instead of processing keyPressEvent, handle ShortcutOverride event, + // and if it's handled - disable the shortcut, it should have been activated. + // Don't process keyPressEvent generated after disabling shortcut since it was handled here. + // If event is not handled, don't accept it and let Qt activate related shortcut. + if (handleKeyEvent(static_cast(pEvent), true)) + pEvent->accept(); } return QWidget::event(pEvent); } -void Qt5Widget::keyPressEvent(QKeyEvent* pEvent) -{ - if (handleKeyEvent(pEvent, true)) - pEvent->accept(); -} - void Qt5Widget::keyReleaseEvent(QKeyEvent* pEvent) { if (handleKeyEvent(pEvent, false)) -- cgit