fix scroll: use named Timer instead of Timer.singleShot (scope issue)
This commit is contained in:
parent
50c3b5979c
commit
95d6da75f6
26
gui/main.qml
26
gui/main.qml
|
|
@ -59,12 +59,21 @@ ApplicationWindow {
|
|||
palette.disabled.light: theme.lightColor
|
||||
palette.disabled.shadow: theme.shadowColor
|
||||
|
||||
// Deferred scroll timer — fires once after model changes settle
|
||||
Timer {
|
||||
id: scrollTimer
|
||||
interval: 0
|
||||
repeat: false
|
||||
onTriggered: chatView.positionViewAtEnd()
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
var log = ollie.readLog()
|
||||
if (log) {
|
||||
chatModel.appendData(log)
|
||||
chatModel.trimFront(30)
|
||||
}
|
||||
scrollTimer.start()
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
|
@ -76,6 +85,7 @@ ApplicationWindow {
|
|||
chatModel.appendData(log)
|
||||
chatModel.trimFront(30)
|
||||
}
|
||||
scrollTimer.start()
|
||||
}
|
||||
function onStreamingDone() {
|
||||
chatModel.appendData("\n[info]\nsession ended\n")
|
||||
|
|
@ -313,23 +323,15 @@ ApplicationWindow {
|
|||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
||||
onCountChanged: {
|
||||
if (count > 0) {
|
||||
var idx = count - 1
|
||||
Timer.singleShot(0, function() {
|
||||
positionViewAtIndex(idx, ListView.End)
|
||||
})
|
||||
}
|
||||
if (count > 0)
|
||||
scrollTimer.start()
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: chatModel
|
||||
function onDataChanged() {
|
||||
if (chatView.atYEnd && chatView.count > 0) {
|
||||
var idx = chatView.count - 1
|
||||
Timer.singleShot(0, function() {
|
||||
chatView.positionViewAtIndex(idx, ListView.End)
|
||||
})
|
||||
}
|
||||
if (chatView.atYEnd && chatView.count > 0)
|
||||
scrollTimer.start()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in New Issue