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-18 23:45:21 +00:00
|
|
|
|
2022-12-18 04:52:52 +00:00
|
|
|
clip: true
|
2023-05-18 23:45:21 +00:00
|
|
|
|
|
|
|
highlight: Rectangle { color: "#EEEEEE"; radius: 5 }
|
|
|
|
highlightMoveDuration: 500
|
|
|
|
|
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
|
2023-05-18 23:45:21 +00:00
|
|
|
selectByMouse: false
|
2022-12-18 04:52:52 +00:00
|
|
|
wrapMode: TextEdit.WrapAnywhere
|
|
|
|
textFormat: TextEdit.RichText
|
2023-02-15 11:54:35 +00:00
|
|
|
font.pixelSize: 16
|
2023-05-18 23:45:21 +00:00
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
onTapped: root.currentIndex = index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
text: "Return to Bottom"
|
|
|
|
visible: root.currentIndex !== logModel.count - 1
|
|
|
|
onClicked: root.currentIndex = logModel.count - 1;
|
2022-12-18 04:52:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function append(text) {
|
2023-06-09 09:23:02 +00:00
|
|
|
const autoScroll = root.currentIndex === logModel.count - 1;
|
2023-05-13 06:16:09 +00:00
|
|
|
logModel.append({ logText: text });
|
2023-05-18 23:45:21 +00:00
|
|
|
if (autoScroll) {
|
|
|
|
root.currentIndex = logModel.count - 1;
|
2022-12-18 04:52:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|