debugConsole: add toggle() conveniance function

This commit is contained in:
miruka 2020-04-01 05:37:44 -04:00
parent f838bdf96d
commit 4602366b9c
3 changed files with 15 additions and 8 deletions

View File

@ -1,7 +1,5 @@
# TODO # TODO
- Fix escape to unselect events
## Refactoring ## Refactoring
- Rewrite account settings using `HTabbedContainer` - Rewrite account settings using `HTabbedContainer`

View File

@ -73,6 +73,18 @@ HDrawer {
readonly property alias commandsView: commandsView readonly property alias commandsView: commandsView
function toggle(targetItem=mainUI, js="", addToHistory=false) {
if (debugConsole.visible) {
debugConsole.visible = false
return
}
debugConsole.visible = true
debugConsole.target = targetItem
if (js) debugConsole.runJS(js, addToHistory)
}
function runJS(input, addToHistory=true) { function runJS(input, addToHistory=true) {
if (addToHistory && history.slice(-1)[0] !== input) { if (addToHistory && history.slice(-1)[0] !== input) {
history.push(input) history.push(input)
@ -119,7 +131,7 @@ HDrawer {
HShortcut { HShortcut {
sequences: settings.keys.toggleDebugConsole sequences: settings.keys.toggleDebugConsole
onActivated: debugConsole.visible = ! debugConsole.visible onActivated: debugConsole.toggle()
} }
HColumnLayout { HColumnLayout {

View File

@ -221,11 +221,8 @@ HColumnLayout {
HMenuItem { HMenuItem {
icon.name: "debug" icon.name: "debug"
text: qsTr("Debug this event") text: qsTr("Debug this event")
onTriggered: { onTriggered:
mainUI.debugConsole.visible = true mainUI.debugConsole.toggle(eventContent, "t.parent.json()")
mainUI.debugConsole.target = eventContent
mainUI.debugConsole.runJS("t.parent.json()", false)
}
} }
HMenuItemPopupSpawner { HMenuItemPopupSpawner {