Skip to content

Commit

Permalink
Merge pull request #846 from karlch/fix-bind-semicolon
Browse files Browse the repository at this point in the history
Fix binding of configparser comment chars
  • Loading branch information
karlch authored Jul 26, 2024
2 parents af7692b + 40ef974 commit cbce18b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions tests/unit/gui/test_eventhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_temp_key_storage_clears_text(storage, qtbot):
),
(Qt.Key.Key_Colon, Qt.KeyboardModifier.NoModifier, ":", ("<colon>",)),
(Qt.Key.Key_Equal, Qt.KeyboardModifier.NoModifier, "=", ("<equal>",)),
(Qt.Key.Key_Semicolon, Qt.KeyboardModifier.NoModifier, ";", ("<semicolon>",)),
],
)
def test_keyevent_to_sequence(qtkey, modifier, keyname, expected):
Expand Down
8 changes: 5 additions & 3 deletions vimiv/gui/eventhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,20 @@ def _get_base_keysequence(event: QKeyEvent) -> SequenceT:
Qt.Key.Key_PageDown: "<page-down>",
Qt.Key.Key_Delete: "<delete>",
}
separator_keys = {
configparser_keys = {
Qt.Key.Key_Colon: "<colon>",
Qt.Key.Key_Equal: "<equal>",
Qt.Key.Key_Semicolon: "<semicolon>",
Qt.Key.Key_NumberSign: "<number>",
}
if event.key() in special_keys:
# Parse shift here as the key does not support it otherwise
text = special_keys[event.key()] # type: ignore
if event.modifiers() & Qt.KeyboardModifier.ShiftModifier:
return "<shift>", text
return (text,)
if event.key() in separator_keys: # Required as configparser crashes otherwise
return (separator_keys[event.key()],) # type: ignore
if event.key() in configparser_keys: # Required as configparser crashes otherwise
return (configparser_keys[event.key()],) # type: ignore
if event.text().isprintable():
return (event.text(),)
return (QKeySequence(event.key()).toString().lower(),)

0 comments on commit cbce18b

Please sign in to comment.