예제 #1
0
def test_shortcuts():
    shortcuts = Shortcuts()

    assert shortcuts["new"] == shortcuts[0]
    assert shortcuts["new"] == QKeySequence.fromString("Ctrl+N")
    shortcuts["new"] = QKeySequence.fromString("Ctrl+Shift+N")
    assert shortcuts["new"] == QKeySequence.fromString("Ctrl+Shift+N")
    assert list(shortcuts[0:2].keys()) == ["new", "open"]
예제 #2
0
 def load(cls, settings: QSettings):
     return cls(close_to_systray=settings.value("close_to_systray", True,
                                                bool),
                use_global_hotkey=settings.value("use_global_hotkey", False,
                                                 bool),
                global_hotkey=QKeySequence.fromString(
                    settings.value("global_hotkey", "", str)),
                external_editor=settings.value("external_editor", ""))
예제 #3
0
    def _process_shortcut_dict(self, shortcuts: dict) -> dict:
        for action in shortcuts.keys():

            # Ignore shortcuts which aren't in currently supported list
            if action not in self._names:
                continue

            # Use "" if there's no shortcut set
            key_string = shortcuts.get(action, None)
            key_string = "" if key_string is None else key_string

            if not key_string.strip():
                shortcuts[action] = ""
                continue

            try:
                shortcuts[action] = eval(key_string)
            except:
                shortcuts[action] = QKeySequence.fromString(key_string)
        return shortcuts
예제 #4
0
def get_keycode(keycomb: str):
    keyseq = QKeySequence.fromString(keycomb)
    return keyseq[0]