Fix HShortcutHandler not processing shortcuts
This commit is contained in:
parent
8d1c02f44f
commit
28d8721fe2
|
@ -108,7 +108,7 @@ class UISettings(JSONConfigFile):
|
|||
"theme": "Default.qpl",
|
||||
"writeAliases": {},
|
||||
"keys": {
|
||||
"startDebugger": ["Alt+Shift+D"],
|
||||
"startDebugger": "Alt+Shift+D",
|
||||
"reloadConfig": "Alt+Shift+R",
|
||||
|
||||
"scrollUp": ["Alt+Up", "Alt+K"],
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user