From 6e69e263e187aedd0aba2c8a20fc0175bc1041a9 Mon Sep 17 00:00:00 2001 From: Eric Werner Date: Thu, 14 Mar 2019 23:36:15 +0100 Subject: [PATCH] first version of actual hotkey dialog highlighting global only so far ... :/ --- ui/a2widget/a2hotkey/keyboard_dialog/base.py | 35 +++++++++++-- .../keyboard_dialog/main.css.template | 1 + .../standard_windows_keys.json | 51 ++++++++++--------- 3 files changed, 59 insertions(+), 28 deletions(-) diff --git a/ui/a2widget/a2hotkey/keyboard_dialog/base.py b/ui/a2widget/a2hotkey/keyboard_dialog/base.py index c69e4e5d..e9a09ac5 100644 --- a/ui/a2widget/a2hotkey/keyboard_dialog/base.py +++ b/ui/a2widget/a2hotkey/keyboard_dialog/base.py @@ -94,6 +94,7 @@ def set_key(self): self._check_key(button) self.ui.key_field.setText(self.key) + self.update_ui() def _setup_ui(self): # css debug shortcut @@ -219,6 +220,7 @@ def update_ui(self): # TODO this might be kicked of delayed after dialog popup global_hks, include_hks, exclude_hks = get_current_hotkeys() parent_modifier = hotkey_common.parent_modifier_string(modifier_string) + win_shortcuts, a2_shortcuts = {}, {} if self.scope.is_global: win_globals = win_standard_keys() @@ -226,7 +228,7 @@ def update_ui(self): win_no_mods, a2_no_mods = win_globals.get(''), global_hks.get('') if win_no_mods: print('Possible collisions with Windows Shortcuts:') - for key, op in win_no_mods: + for key, op in win_no_mods.items(): print(' %s: %s' % (key, op)) if trigger_key in win_no_mods: print('Actual collisions with Windows Shortcut:\n' @@ -234,8 +236,8 @@ def update_ui(self): if a2_no_mods: print('Possible collisions with a2 Hotkeys:') - for key, ops in a2_no_mods: - print(' %s: %s' % (key, ';'.join(ops))) + for key, ops in a2_no_mods.items(): + print(' %s: %s' % (key, ';'.join([str(o) for o in ops]))) if trigger_key in a2_no_mods: print('Actual collisions with a2 Hoykeys:\n' ' %s' % a2_no_mods[trigger_key]) @@ -287,6 +289,33 @@ def update_ui(self): else: self.scope._scope_data + self._highlight_keys(win_shortcuts, a2_shortcuts, trigger_key) + + def _highlight_keys(self, win_shortcuts, a2_shortcuts, trigger_key): + for name, button in self.key_dict.items(): + if button in self.modifier.values(): + continue + + name = name.lower() + a2_shortcuts = dict([(k.lower(), v) for k, v in a2_shortcuts.items()]) + tooltip = [] + style_sheet = 'border: 2px solid "#CCC";' + + if name in win_shortcuts: + style_sheet = 'border: 2px solid "#43B6FF";' + tooltip.append('Windows Shortcut: %s' % win_shortcuts[name]) + + if name in a2_shortcuts: + style_sheet = 'border: 2px solid "#FFC23E";' + for command, module in a2_shortcuts[name]: + if module is None: + tooltip.append('a2: %s' % command) + else: + tooltip.append('%s: %s' % (module.name, command)) + + button.setStyleSheet(style_sheet) + button.setToolTip('\n'.join(tooltip)) + def _fill_key_dict(self): for modkeyname in BASE_MODIFIERS: for i in [0, 1]: diff --git a/ui/a2widget/a2hotkey/keyboard_dialog/main.css.template b/ui/a2widget/a2hotkey/keyboard_dialog/main.css.template index 856a3e3f..a1d200ee 100644 --- a/ui/a2widget/a2hotkey/keyboard_dialog/main.css.template +++ b/ui/a2widget/a2hotkey/keyboard_dialog/main.css.template @@ -1,5 +1,6 @@ QPushButton { font-size: %(font_size)ipx; + border: 2px solid "%(color_button)s"; } QPushButton:checked { diff --git a/ui/a2widget/a2hotkey/keyboard_dialog/standard_windows_keys.json b/ui/a2widget/a2hotkey/keyboard_dialog/standard_windows_keys.json index bae76b52..d85a332b 100644 --- a/ui/a2widget/a2hotkey/keyboard_dialog/standard_windows_keys.json +++ b/ui/a2widget/a2hotkey/keyboard_dialog/standard_windows_keys.json @@ -1,22 +1,22 @@ { "Win": { - "D": "Show Desktop", - "M": "Minimize all", - "A": "Show Sidebar", - "F": "Open Feedback Hub", - "X": "Start Button Context Menu", - "S": "Windows Search", - "G": "Game Capturing", - "H": "Start Speech Recognition", - "K": "Windows Connect Assistant", - "L": "Logoff", - "P": "Windows Project Assistant", - "I": "Windows Settings", - "U": "Windows Display Settings", - "T": "Focus Taskbar", - "R": "Open Run Dialog", - "E": "Open Explorer", - "W": "Windows Ink Workspace", + "d": "Show Desktop", + "m": "Minimize all", + "a": "Show Sidebar", + "f": "Open Feedback Hub", + "x": "Start Button Context Menu", + "s": "Windows Search", + "g": "Game Capturing", + "h": "Start Speech Recognition", + "k": "Windows Connect Assistant", + "l": "Logoff", + "p": "Windows Project Assistant", + "i": "Windows Settings", + "u": "Windows Display Settings", + "t": "Focus Taskbar", + "r": "Open Run Dialog", + "e": "Open Explorer", + "w": "Windows Ink Workspace", "1": "App 1 on Taskbar", "2": "App 2 on Taskbar", "3": "App 3 on Taskbar", @@ -26,29 +26,30 @@ "7": "App 7 on Taskbar", "8": "App 8 on Taskbar", "9": "App 9 on Taskbar", - "B": "Focus Tray Icons", + "0": "App 10 on Taskbar", + "b": "Focus Tray Icons", ";": "Emoji Tool", ".": "Emoji Tool", "+": "Magnifier Zoom In", "-": "Magnifier Zoom Out" }, "Ctrl": { - "W": "Close Current Tab/Window" + "w": "Close Current Tab/Window" }, "Ctrl+Shift": { - "Esc": "Task Manager" + "esc": "Task Manager" }, "Ctrl+Alt": { - "Del": "Windows Session Tools" + "del": "Windows Session Tools" }, "Alt": { - "F4": "Close Current Application", - "Tab": "Switch Application" + "f4": "Close Current Application", + "tab": "Switch Application" }, "Alt+Shift": { - "Tab": "Switch Application backwards" + "tab": "Switch Application backwards" }, "": { - "F11": "Toggle Fullscreen" + "f11": "Toggle Fullscreen" } }