2023-04-09 05:35:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
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
|
|
|
|
2023-05-13 06:16:09 +00:00
|
|
|
ListView {
|
2022-12-18 04:52:52 +00:00
|
|
|
id: root
|
2023-05-13 06:16:09 +00:00
|
|
|
//property alias font: textEdit.font
|
|
|
|
//property alias text: textEdit.text
|
|
|
|
//property alias color: textEdit.color
|
|
|
|
//property alias textFormat: textEdit.textFormat
|
2022-12-18 04:52:52 +00:00
|
|
|
|
2023-05-13 06:16:09 +00:00
|
|
|
//flickableDirection: Flickable.VerticalFlick
|
|
|
|
//contentWidth: textEdit.width
|
|
|
|
//contentHeight: textEdit.height
|
2022-12-18 04:52:52 +00:00
|
|
|
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
|
|
|
|
2023-05-13 06:16:09 +00:00
|
|
|
model: ListModel { id: logModel }
|
|
|
|
delegate: TextEdit {
|
2022-12-18 04:52:52 +00:00
|
|
|
id: textEdit
|
|
|
|
|
2023-05-13 06:16:09 +00:00
|
|
|
text: logText
|
2022-12-18 04:52:52 +00:00
|
|
|
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;
|
2023-05-13 06:16:09 +00:00
|
|
|
logModel.append({ logText: text });
|
2022-12-18 04:52:52 +00:00
|
|
|
if (autoScroll && contentHeight > contentY + height) {
|
|
|
|
contentY = contentHeight - height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|