gui: wrap prompt input in ScrollView for scrollable multi-line text area
- TextArea grows from 5 rows up to 200px as content increases - Auto-scrolls to bottom on text change - Uses Math.min(contentHeight, max) to avoid unnecessary space
This commit is contained in:
parent
24edd5941a
commit
a0f71a01c2
38
gui/main.qml
38
gui/main.qml
|
|
@ -444,22 +444,32 @@ ApplicationWindow {
|
||||||
Layout.margins: 6
|
Layout.margins: 6
|
||||||
spacing: 4
|
spacing: 4
|
||||||
|
|
||||||
TextArea {
|
ScrollView {
|
||||||
id: promptInput
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: font.pointSize * 5 + 16
|
Layout.maximumHeight: 200
|
||||||
placeholderText: ollie.activeSessionId ? "Message..." : "No session"
|
Layout.preferredHeight: Math.min(promptInput.contentHeight + 16, 200)
|
||||||
enabled: ollie.activeSessionId !== ""
|
clip: true
|
||||||
wrapMode: TextEdit.Wrap
|
|
||||||
Keys.onReturnPressed: {
|
TextArea {
|
||||||
if (event.modifiers & Qt.ShiftModifier) {
|
id: promptInput
|
||||||
event.accepted = false
|
Layout.fillWidth: true
|
||||||
} else {
|
placeholderText: ollie.activeSessionId ? "Message..." : "No session"
|
||||||
if (text.trim() !== "") {
|
enabled: ollie.activeSessionId !== ""
|
||||||
ollie.submit(text.trim())
|
wrapMode: TextEdit.Wrap
|
||||||
text = ""
|
onTextChanged: {
|
||||||
|
// Auto-scroll to bottom as content grows
|
||||||
|
textCursor.position = text.length
|
||||||
|
}
|
||||||
|
Keys.onReturnPressed: {
|
||||||
|
if (event.modifiers & Qt.ShiftModifier) {
|
||||||
|
event.accepted = false
|
||||||
|
} else {
|
||||||
|
if (text.trim() !== "") {
|
||||||
|
ollie.submit(text.trim())
|
||||||
|
text = ""
|
||||||
|
}
|
||||||
|
event.accepted = true
|
||||||
}
|
}
|
||||||
event.accepted = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in New Issue