gui: add submit button to prompt input
Add a ▶ button next to the text area for mouse-based submission. Extract shared doSubmit() on the input RowLayout. Button uses focusPolicy: Qt.NoFocus so it doesn't steal focus from the TextArea.
This commit is contained in:
parent
9829498d57
commit
307687542c
|
|
@ -203,10 +203,18 @@ Item {
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
id: inputRow
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.margins: 6
|
Layout.margins: 6
|
||||||
spacing: 4
|
spacing: 4
|
||||||
|
|
||||||
|
function doSubmit() {
|
||||||
|
if (promptInput.text.trim() !== "") {
|
||||||
|
ollie.submit(promptInput.text.trim())
|
||||||
|
promptInput.text = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TextArea in ScrollView for overflow, with context menu overlay
|
// TextArea in ScrollView for overflow, with context menu overlay
|
||||||
Item {
|
Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
@ -246,10 +254,7 @@ Item {
|
||||||
if (event.modifiers & Qt.ShiftModifier) {
|
if (event.modifiers & Qt.ShiftModifier) {
|
||||||
event.accepted = false
|
event.accepted = false
|
||||||
} else {
|
} else {
|
||||||
if (text.trim() !== "") {
|
inputRow.doSubmit()
|
||||||
ollie.submit(text.trim())
|
|
||||||
text = ""
|
|
||||||
}
|
|
||||||
event.accepted = true
|
event.accepted = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -285,6 +290,19 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: "▶"
|
||||||
|
Layout.alignment: Qt.AlignBottom
|
||||||
|
Layout.preferredWidth: 36
|
||||||
|
Layout.preferredHeight: 36
|
||||||
|
focusPolicy: Qt.NoFocus
|
||||||
|
enabled: promptInput.enabled && promptInput.text.trim() !== ""
|
||||||
|
onClicked: inputRow.doSubmit()
|
||||||
|
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
ToolTip.text: "Send (Enter)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue