From 378bd7b4454a5a049072ae1043981984f30e8329 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 21 Mar 2017 16:34:48 +0100 Subject: Add NOTIFY signals for WheelArea the private WheelArea component didn't have any notify signals in its horizontalValue/verticalValue or minimum/maximum values as well. this caused old values to be used in ScrollView.qml. If we want to have a listView that starts scrolled right when instanced, verticalMaximumValue won't be updated when the list is populated. Also, the wheelArea.verticalValue that's assigned at the beginning will be constrained by the wrong verticalMaximumValue, causing it to go out of sync with contentY. At this point the first time the mouse wheel is moved, the list will jump back at the top. Change-Id: I4605000636be7975ba9a58e2c79e8c2351e5a292 Task-number: QTBUG-59633 Reviewed-by: Frederik Gladhorn --- src/controls/ScrollView.qml | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/controls/ScrollView.qml') diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml index 183991ac..3a7b031f 100644 --- a/src/controls/ScrollView.qml +++ b/src/controls/ScrollView.qml @@ -281,9 +281,21 @@ FocusScope { horizontalMinimumValue: 0 horizontalMaximumValue: flickableItem ? flickableItem.contentWidth - viewport.width : 0 + onHorizontalMaximumValueChanged: { + wheelArea.horizontalRecursionGuard = true + //if horizontalMaximumValue changed, horizontalValue may be actually synced with + wheelArea.horizontalValue = flickableItem.contentX - flickableItem.originX; + wheelArea.horizontalRecursionGuard = false + } verticalMinimumValue: 0 verticalMaximumValue: flickableItem ? flickableItem.contentHeight - viewport.height + __viewTopMargin : 0 + onVerticalMaximumValueChanged: { + wheelArea.verticalRecursionGuard = true + //if verticalMaximumValue changed, verticalValue may be actually synced with + wheelArea.verticalValue = flickableItem.contentY - flickableItem.originY; + wheelArea.verticalRecursionGuard = false + } // The default scroll speed for typical angle-based mouse wheels. The value // comes originally from QTextEdit, which sets 20px steps by default, as well as -- cgit v1.2.1