Improve chat scrolling and minimap bounds
This commit is contained in:
parent
183f30ca23
commit
100572b94e
|
|
@ -5,15 +5,23 @@ import QtQuick.Layouts 1.15
|
||||||
Item {
|
Item {
|
||||||
id: chatPane
|
id: chatPane
|
||||||
property bool sidebarVisible: true
|
property bool sidebarVisible: true
|
||||||
|
property int maxVisibleBlocks: 80
|
||||||
signal toggleSidebar()
|
signal toggleSidebar()
|
||||||
function scrollToBottom() {
|
function scrollToBottom() {
|
||||||
chatView.positionViewAtEnd()
|
chatView.positionViewAtEnd()
|
||||||
}
|
}
|
||||||
|
function trimVisibleBlocks() {
|
||||||
|
if (chatModel.count > chatPane.maxVisibleBlocks)
|
||||||
|
chatModel.trimFront(chatPane.maxVisibleBlocks)
|
||||||
|
}
|
||||||
function loadChat() {
|
function loadChat() {
|
||||||
chatModel.reset()
|
chatModel.reset()
|
||||||
if (ollie.activeSessionId && ollie.activeAgentId) {
|
if (ollie.activeSessionId && ollie.activeAgentId) {
|
||||||
var log = ollie.readLogForSession(ollie.activeSessionId, ollie.activeAgentId)
|
var log = ollie.readLogForSession(ollie.activeSessionId, ollie.activeAgentId)
|
||||||
if (log) { chatModel.appendData(log); chatModel.trimFront(20) }
|
if (log) {
|
||||||
|
chatModel.appendData(log)
|
||||||
|
chatModel.trimFront(chatPane.maxVisibleBlocks)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
scrollToBottom()
|
scrollToBottom()
|
||||||
}
|
}
|
||||||
|
|
@ -124,6 +132,13 @@ Item {
|
||||||
anchors.margins: 4
|
anchors.margins: 4
|
||||||
visible: ollie.daemonConnected && ollie.activeAgentId !== ""
|
visible: ollie.daemonConnected && ollie.activeAgentId !== ""
|
||||||
|
|
||||||
|
onCountChanged: {
|
||||||
|
if (!scrollButton.visible) chatPane.scrollToBottom()
|
||||||
|
}
|
||||||
|
onContentHeightChanged: {
|
||||||
|
if (!scrollButton.visible) chatPane.scrollToBottom()
|
||||||
|
}
|
||||||
|
|
||||||
delegate: ChatBlockDelegate {
|
delegate: ChatBlockDelegate {
|
||||||
width: chatView.width - 8
|
width: chatView.width - 8
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +182,8 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
anchors.right: parent.right
|
id: scrollButton
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.margins: 12
|
anchors.margins: 12
|
||||||
text: "↓"
|
text: "↓"
|
||||||
|
|
@ -272,6 +288,11 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: chatModel
|
||||||
|
function onCountChanged() { chatPane.trimVisibleBlocks() }
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: ollie
|
target: ollie
|
||||||
function onSessionsChanged() { chatPane.loadChat() }
|
function onSessionsChanged() { chatPane.loadChat() }
|
||||||
|
|
|
||||||
Reference in New Issue