Change the way Space keybindings are handled

Using it as " " in a keystring won't work anymore, but instead <Space> and
<Shift-Space> does.
This commit is contained in:
Florian Bruhin 2018-03-03 23:00:02 +01:00
parent da60d11b24
commit 7f8508a367
2 changed files with 5 additions and 3 deletions

View File

@ -40,7 +40,7 @@ _MODIFIER_MAP = {
def is_printable(key):
return key <= 0xff
return key <= 0xff and key != Qt.Key_Space
def is_modifier_key(key):
@ -221,7 +221,7 @@ class KeyInfo:
modifiers &= ~_MODIFIER_MAP[self.key]
elif is_printable(self.key):
# "normal" binding
assert len(key_string) == 1 or self.key == Qt.Key_Space, key_string
assert len(key_string) == 1, key_string
if self.modifiers == Qt.ShiftModifier:
return key_string.upper()
elif self.modifiers == Qt.NoModifier:

View File

@ -122,6 +122,8 @@ class TestKeyToString:
(Qt.Key_A, Qt.NoModifier, 'a'),
(Qt.Key_A, Qt.ShiftModifier, 'A'),
(Qt.Key_Space, Qt.NoModifier, '<Space>'),
(Qt.Key_Space, Qt.ShiftModifier, '<Shift+Space>'),
(Qt.Key_Tab, Qt.ShiftModifier, '<Shift+Tab>'),
(Qt.Key_A, Qt.ControlModifier, '<Ctrl+a>'),
(Qt.Key_A, Qt.ControlModifier | Qt.ShiftModifier, '<Ctrl+Shift+a>'),
@ -180,9 +182,9 @@ def test_normalize_keystr(orig, normalized):
(Qt.Key_Backspace, False),
(Qt.Key_Return, False),
(Qt.Key_Enter, False),
(Qt.Key_Space, False),
(Qt.Key_X | Qt.ControlModifier, False), # Wrong usage
(Qt.Key_Space, True), # FIXME broken with upper/lower!
(Qt.Key_ydiaeresis, True),
(Qt.Key_X, True),
])