Kaydet (Commit) 5ad289b5 authored tarafından Michael Weghorn's avatar Michael Weghorn

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: 's avatarMichael Weghorn <m.weghorn@posteo.de>
üst 61bb90aa
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment