summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2019-02-15 20:41:07 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2019-02-15 22:07:53 +0100
commit5ad289b558c11fcef3dada51b873b5f48b9a2cab (patch)
tree481bf0ac907e362b1132f9c4deeff59a20a6444e /vcl
parent61bb90aac5038b5ff051668f7ae86eb61658e4f3 (diff)
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@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qt5/Qt5Widget.cxx9
1 files changed, 7 insertions, 2 deletions
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;