2022-12-18 04:52:52 +00:00
|
|
|
import QtQuick
|
2023-01-29 10:11:41 +00:00
|
|
|
import QtQuick.Controls
|
2022-12-18 04:52:52 +00:00
|
|
|
|
|
|
|
Flickable {
|
|
|
|
id: root
|
|
|
|
property alias font: textEdit.font
|
|
|
|
property alias text: textEdit.text
|
|
|
|
property alias color: textEdit.color
|
|
|
|
property alias textFormat: textEdit.textFormat
|
|
|
|
|
|
|
|
flickableDirection: Flickable.VerticalFlick
|
|
|
|
contentWidth: textEdit.width
|
|
|
|
contentHeight: textEdit.height
|
|
|
|
clip: true
|
2023-01-29 10:11:41 +00:00
|
|
|
ScrollBar.vertical: ScrollBar {
|
|
|
|
parent: root.parent
|
|
|
|
anchors.top: root.top
|
|
|
|
anchors.right: root.right
|
|
|
|
anchors.bottom: root.bottom
|
|
|
|
}
|
2022-12-18 04:52:52 +00:00
|
|
|
|
|
|
|
TextEdit {
|
|
|
|
id: textEdit
|
|
|
|
|
|
|
|
width: root.width
|
|
|
|
clip: true
|
|
|
|
readOnly: true
|
|
|
|
selectByKeyboard: true
|
|
|
|
selectByMouse: true
|
|
|
|
wrapMode: TextEdit.WrapAnywhere
|
|
|
|
textFormat: TextEdit.RichText
|
2023-02-15 11:54:35 +00:00
|
|
|
font.pixelSize: 16
|
2022-12-18 04:52:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function append(text) {
|
|
|
|
let autoScroll = atYEnd;
|
|
|
|
textEdit.append(text);
|
|
|
|
if (autoScroll && contentHeight > contentY + height) {
|
|
|
|
contentY = contentHeight - height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|