perf(qt): virtualize discovery and warm playback

cx
This commit is contained in:
vicrodh committed 2026-08-22 14:35:36 -06:00
1 parent 34d19211d5
commit c6d142ccb4
15 files changed
+841 -357

No files matched your search

+43 -14
View File
@@ -14,9 +14,11 @@ Item {
visible: maxScroll > 0
readonly property real maxScroll: Math.max(0, target.contentHeight - target.height)
readonly property real thumbH: target.contentHeight > 0
? Math.max(48, target.height / target.contentHeight * height)
: height
// ListView/GridView origins are not guaranteed to stay at zero when their
// model or variable-size delegates change. Use the documented Flickable
// coordinate (`contentY - originY`) for both drawing and seeking.
readonly property real scrollY: Math.max(0, Math.min(maxScroll, target.contentY - target.originY))
readonly property real thumbH: target.contentHeight > 0 ? Math.max(48, target.height / target.contentHeight * height) : height
readonly property real travel: Math.max(0, height - thumbH)
// Shown while scrolling, hovering, or dragging (auto-hide).
property bool scrollActive: false
@@ -25,8 +27,8 @@ Item {
Connections {
target: root.target
function onContentYChanged() {
root.scrollActive = true
hideTimer.restart()
root.scrollActive = true;
hideTimer.restart();
}
}
Timer {
@@ -35,6 +37,13 @@ Item {
onTriggered: root.scrollActive = false
}
// One shared input seam for every page that uses the house scrollbar:
// physical-wheel acceleration is Qt's native process policy (main.rs),
// while this observer supplies only a missing touchpad tail.
QbzKineticScroll {
target: root.target
}
// Track.
Rectangle {
width: 6
@@ -43,19 +52,31 @@ Item {
radius: 3
color: "#12ffffff"
opacity: root.shown ? 1.0 : 0.0
Behavior on opacity { NumberAnimation { duration: 160 } }
Behavior on opacity {
NumberAnimation {
duration: 160
}
}
}
// Thumb.
Rectangle {
width: barArea.containsMouse || barArea.pressed ? 10 : 8
x: Math.round((parent.width - width) / 2)
height: root.thumbH
y: root.maxScroll > 0 ? (root.target.contentY / root.maxScroll) * root.travel : 0
y: root.maxScroll > 0 ? (root.scrollY / root.maxScroll) * root.travel : 0
radius: 5
color: barArea.containsMouse || barArea.pressed ? "#77ffffff" : "#44ffffff"
opacity: root.shown ? 1.0 : 0.0
Behavior on width { NumberAnimation { duration: 100 } }
Behavior on opacity { NumberAnimation { duration: 160 } }
Behavior on width {
NumberAnimation {
duration: 100
}
}
Behavior on opacity {
NumberAnimation {
duration: 160
}
}
}
// Drag / click-to-position over the whole gutter.
MouseArea {
@@ -63,12 +84,20 @@ Item {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onPressed: position(mouseY)
onPositionChanged: if (pressed) position(mouseY)
onPressed: {
// Public Flickable semantics already cancel on a contentY write;
// make the takeover explicit so scrollbar drag remains exact even
// if the first pressed position equals the current one.
root.target.cancelFlick();
position(mouseY);
}
onPositionChanged: if (pressed)
position(mouseY)
function position(my) {
if (root.travel <= 0) return
var frac = Math.min(1, Math.max(0, (my - root.thumbH / 2) / root.travel))
root.target.contentY = frac * root.maxScroll
if (root.travel <= 0)
return;
var frac = Math.min(1, Math.max(0, (my - root.thumbH / 2) / root.travel));
root.target.contentY = root.target.originY + frac * root.maxScroll;
}
}
}