gui: add native scrollbar + lazy-load on scroll-up

- Add ScrollBar.vertical to the chat Flickable (both KF5/KF6)
- Remove interactive:false so native flick gestures work
- Trigger paneModel.loadEarlier() when scrolled near top
- Preserve scroll position when prepending older blocks
- Reduce column width by 12px for scrollbar clearance
This commit is contained in:
Levi Neely 2026-07-27 09:17:28 +02:00
parent 756e4086b3
commit 2b17e861be
2 changed files with 31 additions and 4 deletions

View File

@ -179,7 +179,6 @@ Item {
contentWidth: width
contentHeight: paneColumn.implicitHeight
boundsBehavior: Flickable.StopAtBounds
interactive: false // scroll via wheel MouseArea; enables text selection
property bool _settingY: false
@ -187,6 +186,17 @@ Item {
if (_settingY) return
let bottom = contentHeight - height
parent.atBottom = (bottom <= 0 || contentY >= bottom - 4)
// Lazy-load earlier blocks when near top
if (contentY < 80 && contentY >= 0 && !_settingY) {
let oldHeight = contentHeight
if (paneModel.loadEarlier()) {
// Preserve scroll position
_settingY = true
contentY += (contentHeight - oldHeight)
_settingY = false
}
}
}
onContentHeightChanged: {
@ -197,6 +207,10 @@ Item {
}
}
ScrollBar.vertical: ScrollBar {
policy: ScrollBar.AsNeeded
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
@ -214,7 +228,7 @@ Item {
Column {
id: paneColumn
width: paneFlick.width
width: paneFlick.width - 12 // leave room for scrollbar
spacing: 8
Label {

View File

@ -978,7 +978,6 @@ ApplicationWindow {
contentWidth: width
contentHeight: paneColumn.implicitHeight
boundsBehavior: Flickable.StopAtBounds
interactive: false // scroll via wheel; text not selectable in Qt5 Text
property bool _settingY: false
@ -986,6 +985,16 @@ ApplicationWindow {
if (_settingY) return
var bottom = contentHeight - height
parent.atBottom = (bottom <= 0 || contentY >= bottom - 4)
// Lazy-load earlier blocks when near top
if (contentY < 80 && contentY >= 0 && !_settingY) {
var oldHeight = contentHeight
if (paneRoot.paneModel.loadEarlier()) {
_settingY = true
contentY += (contentHeight - oldHeight)
_settingY = false
}
}
}
onContentHeightChanged: {
@ -996,6 +1005,10 @@ ApplicationWindow {
}
}
ScrollBar.vertical: ScrollBar {
policy: ScrollBar.AsNeeded
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
@ -1012,7 +1025,7 @@ ApplicationWindow {
Column {
id: paneColumn
width: paneFlick.width
width: paneFlick.width - 12 // leave room for scrollbar
spacing: 8
Label {