Merge remote-tracking branch 'origin/pr/3742'

This commit is contained in:
Florian Bruhin 2018-03-27 12:01:18 +02:00
commit 9cff0e7367
3 changed files with 14 additions and 2 deletions

View File

@ -58,7 +58,8 @@ def is_special(key, modifiers):
_assert_plain_key(key)
_assert_plain_modifier(modifiers)
return not (_is_printable(key) and
modifiers in [Qt.ShiftModifier, Qt.NoModifier])
modifiers in [Qt.ShiftModifier, Qt.NoModifier,
Qt.KeypadModifier])
def is_modifier_key(key):
@ -303,7 +304,8 @@ class KeyInfo:
key_string = key_string.lower()
# "special" binding
assert is_special(self.key, self.modifiers)
assert (is_special(self.key, self.modifiers) or
self.modifiers == Qt.KeypadModifier)
modifier_string = _modifiers_to_string(modifiers)
return '<{}{}>'.format(modifier_string, key_string)

View File

@ -518,6 +518,8 @@ def test_is_printable(key, printable):
(Qt.Key_Escape, Qt.ControlModifier, True),
(Qt.Key_X, Qt.ControlModifier, True),
(Qt.Key_X, Qt.NoModifier, False),
(Qt.Key_2, Qt.KeypadModifier, False),
(Qt.Key_2, Qt.NoModifier, False),
])
def test_is_special(key, modifiers, special):
assert keyutils.is_special(key, modifiers) == special

View File

@ -96,3 +96,11 @@ class TestHintKeyParser:
assert match == QKeySequence.ExactMatch
keyparser.execute.assert_called_with('follow-hint -s as', None)
def test_numberkey_hint_match(self, keyparser, fake_keyevent):
keyparser.update_bindings(['21', '22'])
match = keyparser.handle(fake_keyevent(Qt.Key_2, Qt.KeypadModifier))
assert match == QKeySequence.PartialMatch
match = keyparser.handle(fake_keyevent(Qt.Key_2, Qt.KeypadModifier))
assert match == QKeySequence.ExactMatch