From 2b17e861be431b48b40f88e3fe1bbfa47ee25305 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Mon, 27 Jul 2026 09:17:28 +0200 Subject: [PATCH] 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 --- gui/ChatPane.qml | 18 ++++++++++++++++-- gui/main-kf5.qml | 17 +++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/gui/ChatPane.qml b/gui/ChatPane.qml index 8e25e19..1afd68c 100644 --- a/gui/ChatPane.qml +++ b/gui/ChatPane.qml @@ -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 { diff --git a/gui/main-kf5.qml b/gui/main-kf5.qml index d7aa7e9..e7731f7 100644 --- a/gui/main-kf5.qml +++ b/gui/main-kf5.qml @@ -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 {