You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
2.6 KiB
102 lines
2.6 KiB
import QtQuick 2.0
|
|
import QtQuick.Controls 2.3
|
|
import QtQuick.Layouts 1.0
|
|
|
|
import "." as Components
|
|
|
|
Rectangle {
|
|
id: chatRoot
|
|
visible: true
|
|
color: "grey"
|
|
|
|
property var chatList
|
|
signal scrollToBottom()
|
|
signal fetchHistory()
|
|
|
|
onScrollToBottom: scrollBottomTimer.start()
|
|
|
|
Components.ChatScrollToBottomButton {
|
|
z: parent.z + 1
|
|
visible: !chatList.atBottom
|
|
anchors.bottom: parent.bottom
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: 60
|
|
anchors.bottomMargin: 60
|
|
onClicked: scrollBottomTimer.start();
|
|
}
|
|
|
|
Item {
|
|
visible: chatList.atTop && !chatModel.exhausted
|
|
onVisibleChanged: {
|
|
if(!chatModel.exhausted && chatList.atTop && visible && chatListView.count >= chatModel.limit)
|
|
fetchHistory();
|
|
}
|
|
}
|
|
|
|
ColumnLayout {
|
|
// debugBar
|
|
z: parent.z + 1
|
|
visible: ctx.isDebug
|
|
anchors.top: parent.top
|
|
anchors.left: parent.left
|
|
anchors.leftMargin: 60
|
|
anchors.topMargin: 60
|
|
property int pointSize: 16
|
|
|
|
Text {
|
|
color: "lime"
|
|
text: "Messages: " + chatList.count + " (limit: " + chatModel.limit + " offset: " + chatModel.offset + " exhausted: " + chatModel.exhausted + ")"
|
|
font.pointSize: parent.pointSize
|
|
}
|
|
|
|
Text {
|
|
color: "lime"
|
|
text: "mayAutoScroll: " + chatList.mayAutoScroll
|
|
font.pointSize: parent.pointSize
|
|
}
|
|
|
|
Text {
|
|
color: "lime"
|
|
text: "atBottom: " + chatList.atBottom
|
|
font.pointSize: parent.pointSize
|
|
}
|
|
|
|
Text {
|
|
color: "lime"
|
|
text: "atTop: " + chatList.atTop
|
|
font.pointSize: parent.pointSize
|
|
}
|
|
|
|
Text {
|
|
color: "lime"
|
|
text: "rootHeight: " + chatRoot.height
|
|
font.pointSize: parent.pointSize
|
|
}
|
|
|
|
Text {
|
|
color: "lime"
|
|
text: "chatList.cRect.height: " + chatList.childrenRect.height
|
|
font.pointSize: parent.pointSize
|
|
}
|
|
|
|
Text {
|
|
color: "lime"
|
|
text: "scrollPosition: " + chatList.chatScroll.position.toFixed(4)
|
|
font.pointSize: parent.pointSize
|
|
}
|
|
|
|
Text {
|
|
color: "lime"
|
|
text: "scaling: " + ctx.scaleFactor
|
|
font.pointSize: parent.pointSize
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
id: scrollBottomTimer
|
|
interval: 10
|
|
repeat: false
|
|
running: false
|
|
onTriggered: chatList.positionViewAtEnd();
|
|
}
|
|
} |