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
- Fix escape to unselect events
## Refactoring
- Rewrite account settings using `HTabbedContainer`

View File

@ -73,6 +73,18 @@ HDrawer {
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) {
if (addToHistory && history.slice(-1)[0] !== input) {
history.push(input)
@ -119,7 +131,7 @@ HDrawer {
HShortcut {
sequences: settings.keys.toggleDebugConsole
onActivated: debugConsole.visible = ! debugConsole.visible
onActivated: debugConsole.toggle()
}
HColumnLayout {

View File

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