debugConsole: add toggle() conveniance function
This commit is contained in:
parent
f838bdf96d
commit
4602366b9c
2
TODO.md
2
TODO.md
|
@ -1,7 +1,5 @@
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
- Fix escape to unselect events
|
|
||||||
|
|
||||||
## Refactoring
|
## Refactoring
|
||||||
|
|
||||||
- Rewrite account settings using `HTabbedContainer`
|
- Rewrite account settings using `HTabbedContainer`
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user