Fix body editor under the Breeze style

The body editor was a TextArea with a custom background inside a
ScrollView. Under the Breeze QML style that raised "Unable to assign
TextArea to QQuickTextInput" (Breeze's TextArea.qml rejects a custom
background in that nesting).

Switch to the Qt-recommended idiom: a Flickable with
TextArea.flickable: TextArea { background: null }, wrapped in a plain
Rectangle that provides the border/background. Keeps monospace wrapping,
seed-on-open, Ctrl+Enter save and Esc cancel; adds a vertical ScrollBar.

GUI builds clean.

(The separate "startDrag() drag must be active" log was the previous
binary; the a3d2c49 fix removes it — relaunch to clear.)
This commit is contained in:
Levi Neely 2026-10-05 09:49:05 +02:00
parent a3d2c4947e
commit b2efe6ea27
1 changed files with 43 additions and 30 deletions

View File

@ -1306,42 +1306,55 @@ ListView {
del.editingBody = false
}
ScrollView {
// Bordered scroll frame holding the editor. Uses the
// Flickable + TextArea.flickable idiom (not ScrollView),
// which the Breeze style accepts; a custom background on a
// styled TextArea trips Breeze's TextArea internals.
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: Math.min(
Math.max(bodyEditor.contentHeight + 16, outline.baseFontSize * 6),
outline.baseFontSize * 20)
clip: true
color: theme.baseColor
border.color: theme.midColor
border.width: 1
radius: 3
TextArea {
id: bodyEditor
wrapMode: TextArea.Wrap
font.family: "monospace"
font.pointSize: outline.baseFontSize
selectByMouse: true
background: Rectangle {
color: theme.baseColor
border.color: theme.midColor
border.width: 1
radius: 3
}
// Seed from the raw body when the editor opens.
onVisibleChanged: {
if (visible) {
text = docModel.bodyText(del.index)
forceActiveFocus()
cursorPosition = text.length
Flickable {
id: bodyFlick
anchors.fill: parent
anchors.margins: 4
clip: true
contentWidth: width
contentHeight: bodyEditor.contentHeight
boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical: ScrollBar {}
TextArea.flickable: TextArea {
id: bodyEditor
wrapMode: TextArea.Wrap
font.family: "monospace"
font.pointSize: outline.baseFontSize
selectByMouse: true
background: null
// Seed from the raw body when the editor opens.
onVisibleChanged: {
if (visible) {
text = docModel.bodyText(del.index)
forceActiveFocus()
cursorPosition = text.length
}
}
}
// Ctrl+Enter saves; Escape cancels.
Keys.onPressed: (ev) => {
if ((ev.key === Qt.Key_Return || ev.key === Qt.Key_Enter)
&& (ev.modifiers & Qt.ControlModifier)) {
bodyEditColumn.saveBody()
ev.accepted = true
} else if (ev.key === Qt.Key_Escape) {
del.editingBody = false
ev.accepted = true
// Ctrl+Enter saves; Escape cancels.
Keys.onPressed: (ev) => {
if ((ev.key === Qt.Key_Return || ev.key === Qt.Key_Enter)
&& (ev.modifiers & Qt.ControlModifier)) {
bodyEditColumn.saveBody()
ev.accepted = true
} else if (ev.key === Qt.Key_Escape) {
del.editingBody = false
ev.accepted = true
}
}
}
}