From 547a1bea492954d828aa0798be93384669812489 Mon Sep 17 00:00:00 2001 From: Jani Honkonen Date: Mon, 6 Aug 2012 12:02:51 +0300 Subject: Fix limitting shortcuts to keypad only The Qt::KeypadModifier modifier is internally masked away from all shortcuts. So it is not possible to set a keypad only shortcut. Changed the implementation so that first a full keysequence match is searched. Then if no match is found the same sequence is tried without the keypad modifer. Added a autotest for this also to cover the basic use cases relating to this. Task-number: QTBUG-20191 Change-Id: Ibe7740c705fd0ab1eece4809b9a0b48882172933 Reviewed-by: Gunnar Sletta Reviewed-by: Stephen Kelly --- src/gui/kernel/qshortcutmap.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index 474fb07566..04a16c57ff 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -381,6 +381,12 @@ QKeySequence::SequenceMatch QShortcutMap::nextState(QKeyEvent *e) d->identicals.resize(0); result = find(e); + if (result == QKeySequence::NoMatch && (e->modifiers() & Qt::KeypadModifier)) { + // Try to find a match without keypad modifier + QKeyEvent event = *e; + event.setModifiers(e->modifiers() & ~Qt::KeypadModifier); + result = find(&event); + } if (result == QKeySequence::NoMatch && e->modifiers() & Qt::ShiftModifier) { // If Shift + Key_Backtab, also try Shift + Qt::Key_Tab if (e->key() == Qt::Key_Backtab) { @@ -570,8 +576,7 @@ void QShortcutMap::createNewSequences(QKeyEvent *e, QVector &ksl) curKsl.setKey(0, 2); curKsl.setKey(0, 3); } - // Filtering keycode here with 0xdfffffff to ignore the Keypad modifier - curKsl.setKey(possibleKeys.at(pkNum) & 0xdfffffff, index); + curKsl.setKey(possibleKeys.at(pkNum), index); } } } -- cgit v1.2.3