Add option to target message for debug console

This commit is contained in:
miruka 2019-09-05 16:09:04 -04:00
parent 01f8bc3d6c
commit ddce551360
2 changed files with 29 additions and 2 deletions

View File

@ -106,5 +106,14 @@ Column {
onTriggered: onTriggered:
Utils.copyToClipboard(selectableLabelContainer.joinedSelection) Utils.copyToClipboard(selectableLabelContainer.joinedSelection)
} }
HMenuItem {
icon.name: "settings"
text: qsTr("Set as debug console target")
visible: debugMode
onTriggered: {
mainUI.debugConsole.target = [eventDelegate, eventContent]
}
}
} }
} }

View File

@ -13,6 +13,20 @@ Window {
color: "transparent" color: "transparent"
property var target: null
property alias t: debugConsole.target
onTargetChanged: {
commandsView.model.insert(0, {
input: "t = " + String(target),
output: "",
error: false,
})
visible = true
}
function runJS(input) { function runJS(input) {
let error = false let error = false
@ -40,7 +54,7 @@ Window {
topMargin: theme.spacing topMargin: theme.spacing
bottomMargin: topMargin bottomMargin: topMargin
leftMargin: theme.spacing leftMargin: theme.spacing
rightMargin: rightMargin rightMargin: leftMargin
clip: true clip: true
verticalLayoutDirection: ListView.BottomToTop verticalLayoutDirection: ListView.BottomToTop
@ -50,12 +64,14 @@ Window {
model: ListModel {} model: ListModel {}
delegate: HColumnLayout { delegate: HColumnLayout {
width: commandsView.width width: commandsView.width -
commandsView.leftMargin - commandsView.rightMargin
HLabel { HLabel {
text: "> " + model.input text: "> " + model.input
wrapMode: Text.Wrap wrapMode: Text.Wrap
color: theme.chat.message.quote color: theme.chat.message.quote
font.family: theme.fontFamily.mono
visible: model.input visible: model.input
Layout.fillWidth: true Layout.fillWidth: true
@ -66,6 +82,7 @@ Window {
wrapMode: Text.Wrap wrapMode: Text.Wrap
color: model.error ? color: model.error ?
theme.colors.errorText : theme.colors.text theme.colors.errorText : theme.colors.text
font.family: theme.fontFamily.mono
visible: model.output visible: model.output
Layout.fillWidth: true Layout.fillWidth: true
@ -85,6 +102,7 @@ Window {
backgroundColor: Qt.hsla(0, 0, 0, 0.85) backgroundColor: Qt.hsla(0, 0, 0, 0.85)
bordered: false bordered: false
placeholderText: qsTr("Type some JavaScript...") placeholderText: qsTr("Type some JavaScript...")
font.family: theme.fontFamily.mono
Layout.fillWidth: true Layout.fillWidth: true