[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - vcl/qt5

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Feb 18 08:36:37 UTC 2019


 vcl/qt5/Qt5Widget.cxx |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit a02d1c9705bfd8cb0b03342bb717c8bbe3723461
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Fri Feb 15 20:41:07 2019 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Mon Feb 18 09:36:18 2019 +0100

    tdf#123451 qt5: Detect decimal separator on keypad
    
    'QtKeyEvent::key()' doesn't return a special value for the
    decimal separator key on the keypad ("," or "."), but just returns
    'Qt::Key_Comma' or 'Qt::Key_Period'. However, the 'Qt::KeypadModifier'
    modifier is set in this case, so check for this one in addition
    and return 'KEY_DECIMAL' if those are combined.
    
    Change-Id: Ia80826e2ad5e47a1f49bef450168523d766c1d6a
    Reviewed-on: https://gerrit.libreoffice.org/67886
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
    (cherry picked from commit 5ad289b558c11fcef3dada51b873b5f48b9a2cab)
    Reviewed-on: https://gerrit.libreoffice.org/67888
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 394bcc1029e4..6d44262b38e8 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -237,7 +237,7 @@ void Qt5Widget::closeEvent(QCloseEvent* /*pEvent*/)
     m_pFrame->CallCallback(SalEvent::Close, nullptr);
 }
 
-static sal_uInt16 GetKeyCode(int keyval)
+static sal_uInt16 GetKeyCode(int keyval, Qt::KeyboardModifiers modifiers)
 {
     sal_uInt16 nCode = 0;
     if (keyval >= Qt::Key_0 && keyval <= Qt::Key_9)
@@ -246,6 +246,11 @@ static sal_uInt16 GetKeyCode(int keyval)
         nCode = KEY_A + (keyval - Qt::Key_A);
     else if (keyval >= Qt::Key_F1 && keyval <= Qt::Key_F26)
         nCode = KEY_F1 + (keyval - Qt::Key_F1);
+    else if (modifiers.testFlag(Qt::KeypadModifier)
+             && (keyval == Qt::Key_Period || keyval == Qt::Key_Comma))
+        // Qt doesn't use a special keyval for decimal separator ("," or ".")
+        // on numerical keypad, but sets Qt::KeypadModifier in addition
+        nCode = KEY_DECIMAL;
     else
     {
         switch (keyval)
@@ -384,7 +389,7 @@ bool Qt5Widget::handleKeyEvent(QKeyEvent* pEvent, bool bDown)
 
     aEvent.mnCharCode = (pEvent->text().isEmpty() ? 0 : pEvent->text().at(0).unicode());
     aEvent.mnRepeat = 0;
-    aEvent.mnCode = GetKeyCode(pEvent->key());
+    aEvent.mnCode = GetKeyCode(pEvent->key(), pEvent->modifiers());
     aEvent.mnCode |= GetKeyModCode(pEvent->modifiers());
 
     bool bStopProcessingKey;


More information about the Libreoffice-commits mailing list