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 <Thorsten.Behrens@CIB.de>
(cherry picked from commit 1a5340788639ba71725338ddc5d340b2b304f4c2)
Reviewed-on: https://gerrit.libreoffice.org/66991
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 4337792..731498f 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -49,7 +49,6 @@ class Qt5Widget : public QWidget
virtual void focusInEvent(QFocusEvent*) override;
virtual void focusOutEvent(QFocusEvent*) override;
virtual void keyPressEvent(QKeyEvent*) override;
virtual void keyReleaseEvent(QKeyEvent*) override;
virtual void mouseMoveEvent(QMouseEvent*) override;
virtual void mousePressEvent(QMouseEvent*) override;
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 26e89a7..69ca329 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -402,20 +402,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<QKeyEvent*>(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))