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 {
|
2023-12-12 11:22:18 +00:00
|
|
|
// acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.NoButton
|
|
|
|
// gesturePolicy: TapHandler.WithinBounds
|
2023-05-18 23:45:21 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-12-10 10:55:16 +00:00
|
|
|
function append(data) {
|
2023-06-09 09:23:02 +00:00
|
|
|
const autoScroll = root.currentIndex === logModel.count - 1;
|
2023-12-10 10:55:16 +00:00
|
|
|
logModel.append(data);
|
2023-05-18 23:45:21 +00:00
|
|
|
if (autoScroll) {
|
|
|
|
root.currentIndex = logModel.count - 1;
|
2022-12-18 04:52:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|