Fix HShortcutHandler not processing shortcuts
This commit is contained in:
		| @@ -108,8 +108,8 @@ class UISettings(JSONConfigFile): | ||||
|             "theme": "Default.qpl", | ||||
|             "writeAliases": {}, | ||||
|             "keys": { | ||||
|                 "startDebugger":    ["Alt+Shift+D"], | ||||
|                 "reloadConfig":     "Alt+Shift+R", | ||||
|                 "startDebugger": "Alt+Shift+D", | ||||
|                 "reloadConfig":  "Alt+Shift+R", | ||||
|  | ||||
|                 "scrollUp":       ["Alt+Up", "Alt+K"], | ||||
|                 "scrollDown":     ["Alt+Down", "Alt+J"], | ||||
|   | ||||
| @@ -5,7 +5,6 @@ QtObject { | ||||
|     signal held(var event) | ||||
|     signal released(var event) | ||||
|  | ||||
|  | ||||
|     property bool enabled: true | ||||
|     property var sequences: ""  // string or array of strings | ||||
|     property var sequences: ""  // shortcut string array of shortcut strings | ||||
| } | ||||
|   | ||||
| @@ -22,6 +22,25 @@ Item { | ||||
|     }) | ||||
|  | ||||
|  | ||||
|     function match(event) { | ||||
|         for (let i = 0;  i < shortcutHandler.resources.length; i++) { | ||||
|             let shortcut = shortcutHandler.resources[i] | ||||
|  | ||||
|             if (! shortcut.enabled) continue | ||||
|  | ||||
|             if (typeof(shortcut.sequences) == "string") { | ||||
|                 shortcut.sequences = [shortcut.sequences] | ||||
|             } | ||||
|  | ||||
|             for (let i = 0;  i < shortcut.sequences.length; i++) { | ||||
|                 if (sequenceMatches(event, shortcut.sequences[i])) { | ||||
|                     return shortcut | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         return null | ||||
|     } | ||||
|  | ||||
|     function sequenceMatches(event, sequence) { | ||||
|         let [key, ...mods] = sequence.split("+").reverse() | ||||
|  | ||||
| @@ -37,23 +56,4 @@ Item { | ||||
|         return true | ||||
|     } | ||||
|  | ||||
|     function match(event) { | ||||
|         for (let i = 0;  i < shortcutHandler.resources.length; i++) { | ||||
|             let shortcut = shortcutHandler.resources[i] | ||||
|  | ||||
|             if (! shortcut.enabled) continue | ||||
|  | ||||
|             if (typeof(shortcut.sequences) == "string") { | ||||
|                 return sequenceMatches(event, shortcut.sequences) ? | ||||
|                        shortcut : null | ||||
|             } | ||||
|  | ||||
|             for (let i = 0;  i < shortcut.sequences.length; i++) { | ||||
|                 if (sequenceMatches(event, shortcut.sequences[i])) { | ||||
|                     return shortcut | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         return null | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	