[Libreoffice-commits] core.git: vcl/inc vcl/qt5

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 16 21:38:54 UTC 2019


 vcl/inc/qt5/Qt5Widget.hxx |    2 ++
 vcl/qt5/Qt5Widget.cxx     |   16 ++++++++++++++++
 2 files changed, 18 insertions(+)

New commits:
commit 5843e14a4ddc6d2b1e375ca26eec33033bfad455
Author:     Aleksei Nikiforov <darktemplar at basealt.ru>
AuthorDate: Wed Jan 16 14:57:42 2019 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Jan 16 22:38:30 2019 +0100

    tdf#122238 KDE5: disable mechanism of Qt for shortcut activation
    
    When QEvent::KeyPress event is processed, QEvent::ShortcutOverride event is created
    and processed before finishing processing original event.
    
    If it's an active shortcut, and QEvent::ShortcutOverride event is not accepted,
    the shortcut is activated, but QEvent::KeyPress event is omitted.
    If it's an active shortcut, and QEvent::ShortcutOverride event is accepted,
    the shortcut is not activated, and QEvent::KeyPress event is sent as usual.
    
    But it looks like even if shortcut activation is suppressed,
    shortcut is still called somewhere from insides SalEvent::KeyInput
    event processing callback from Qt5Widget::handleKeyEvent function.
    
    Shortcuts are still assigned to menu actions
    since it shows the key combinations used to activate them.
    
    Change-Id: I1ffc63c2530dd61ae67ab66a96ea3efe767218c0
    Reviewed-on: https://gerrit.libreoffice.org/66444
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 26f26c8bf0a3..4337792dfc43 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -45,6 +45,8 @@ class Qt5Widget : public QWidget
     bool handleKeyEvent(QKeyEvent*, bool);
     void handleMouseButtonEvent(QMouseEvent*, bool);
 
+    virtual bool event(QEvent*) override;
+
     virtual void focusInEvent(QFocusEvent*) override;
     virtual void focusOutEvent(QFocusEvent*) override;
     virtual void keyPressEvent(QKeyEvent*) override;
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index e96a1b1904b3..6d75cd60df73 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -395,6 +395,22 @@ bool Qt5Widget::handleKeyEvent(QKeyEvent* pEvent, bool bDown)
     return bStopProcessingKey;
 }
 
+bool Qt5Widget::event(QEvent* pEvent)
+{
+    if (pEvent->type() == QEvent::ShortcutOverride)
+    {
+        // Accepted event disables shortcut activation,
+        // 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();
+    }
+
+    return QWidget::event(pEvent);
+}
+
 void Qt5Widget::keyPressEvent(QKeyEvent* pEvent)
 {
     if (handleKeyEvent(pEvent, true))


More information about the Libreoffice-commits mailing list