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:
parent
a3d2c4947e
commit
b2efe6ea27
|
|
@ -1306,42 +1306,55 @@ ListView {
|
||||||
del.editingBody = false
|
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.fillWidth: true
|
||||||
Layout.preferredHeight: Math.min(
|
Layout.preferredHeight: Math.min(
|
||||||
Math.max(bodyEditor.contentHeight + 16, outline.baseFontSize * 6),
|
Math.max(bodyEditor.contentHeight + 16, outline.baseFontSize * 6),
|
||||||
outline.baseFontSize * 20)
|
outline.baseFontSize * 20)
|
||||||
clip: true
|
color: theme.baseColor
|
||||||
|
border.color: theme.midColor
|
||||||
|
border.width: 1
|
||||||
|
radius: 3
|
||||||
|
|
||||||
TextArea {
|
Flickable {
|
||||||
id: bodyEditor
|
id: bodyFlick
|
||||||
wrapMode: TextArea.Wrap
|
anchors.fill: parent
|
||||||
font.family: "monospace"
|
anchors.margins: 4
|
||||||
font.pointSize: outline.baseFontSize
|
clip: true
|
||||||
selectByMouse: true
|
contentWidth: width
|
||||||
background: Rectangle {
|
contentHeight: bodyEditor.contentHeight
|
||||||
color: theme.baseColor
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
border.color: theme.midColor
|
ScrollBar.vertical: ScrollBar {}
|
||||||
border.width: 1
|
|
||||||
radius: 3
|
TextArea.flickable: TextArea {
|
||||||
}
|
id: bodyEditor
|
||||||
// Seed from the raw body when the editor opens.
|
wrapMode: TextArea.Wrap
|
||||||
onVisibleChanged: {
|
font.family: "monospace"
|
||||||
if (visible) {
|
font.pointSize: outline.baseFontSize
|
||||||
text = docModel.bodyText(del.index)
|
selectByMouse: true
|
||||||
forceActiveFocus()
|
background: null
|
||||||
cursorPosition = text.length
|
// 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.
|
||||||
// Ctrl+Enter saves; Escape cancels.
|
Keys.onPressed: (ev) => {
|
||||||
Keys.onPressed: (ev) => {
|
if ((ev.key === Qt.Key_Return || ev.key === Qt.Key_Enter)
|
||||||
if ((ev.key === Qt.Key_Return || ev.key === Qt.Key_Enter)
|
&& (ev.modifiers & Qt.ControlModifier)) {
|
||||||
&& (ev.modifiers & Qt.ControlModifier)) {
|
bodyEditColumn.saveBody()
|
||||||
bodyEditColumn.saveBody()
|
ev.accepted = true
|
||||||
ev.accepted = true
|
} else if (ev.key === Qt.Key_Escape) {
|
||||||
} else if (ev.key === Qt.Key_Escape) {
|
del.editingBody = false
|
||||||
del.editingBody = false
|
ev.accepted = true
|
||||||
ev.accepted = true
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue