Skip to content

Commit

Permalink
first version of actual hotkey dialog highlighting
Browse files Browse the repository at this point in the history
global only so far ... :/
  • Loading branch information
ewerybody committed Mar 14, 2019
1 parent afd9cae commit 6e69e26
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 28 deletions.
35 changes: 32 additions & 3 deletions ui/a2widget/a2hotkey/keyboard_dialog/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -219,23 +220,24 @@ 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()
if not self.checked_modifier:
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'
' %s' % win_no_mods[trigger_key])

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])
Expand Down Expand Up @@ -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]:
Expand Down
1 change: 1 addition & 0 deletions ui/a2widget/a2hotkey/keyboard_dialog/main.css.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
QPushButton {
font-size: %(font_size)ipx;
border: 2px solid "%(color_button)s";
}

QPushButton:checked {
Expand Down
51 changes: 26 additions & 25 deletions ui/a2widget/a2hotkey/keyboard_dialog/standard_windows_keys.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
}
}

0 comments on commit 6e69e26

Please sign in to comment.