vcl/qt5/Qt5Widget.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
New commits: commit 5ad289b558c11fcef3dada51b873b5f48b9a2cab Author: Michael Weghorn <[email protected]> AuthorDate: Fri Feb 15 20:41:07 2019 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Feb 15 22:07:53 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 <[email protected]> diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx index 22779464ee37..2baf7a37125a 100644 --- a/vcl/qt5/Qt5Widget.cxx +++ b/vcl/qt5/Qt5Widget.cxx @@ -238,7 +238,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) @@ -247,6 +247,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) @@ -385,7 +390,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; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
