summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Martin <mart@kde.org>2017-03-21 16:34:48 +0100
committerMarco Martin <notmart@gmail.com>2017-04-03 15:44:52 +0000
commit378bd7b4454a5a049072ae1043981984f30e8329 (patch)
tree44a7cc08ba7b008cae6e6dce5beed320ffb0576e
parentedc24e3cd75eaf02a587f50b14dbd0288447179d (diff)
downloadqtquickcontrols-5.8.tar.gz
Add NOTIFY signals for WheelArea5.8
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 <frederik.gladhorn@qt.io>
-rw-r--r--src/controls/Private/qquickwheelarea.cpp16
-rw-r--r--src/controls/Private/qquickwheelarea_p.h16
-rw-r--r--src/controls/ScrollView.qml12
3 files changed, 38 insertions, 6 deletions
diff --git a/src/controls/Private/qquickwheelarea.cpp b/src/controls/Private/qquickwheelarea.cpp
index 9c0a70a2..bd77ae24 100644
--- a/src/controls/Private/qquickwheelarea.cpp
+++ b/src/controls/Private/qquickwheelarea.cpp
@@ -141,7 +141,11 @@ void QQuickWheelArea1::wheelEvent(QWheelEvent *we)
void QQuickWheelArea1::setHorizontalMinimumValue(qreal value)
{
+ if (value == m_horizontalMinimumValue)
+ return;
+
m_horizontalMinimumValue = value;
+ emit horizontalMinimumValueChanged();
}
qreal QQuickWheelArea1::horizontalMinimumValue() const
@@ -151,7 +155,11 @@ qreal QQuickWheelArea1::horizontalMinimumValue() const
void QQuickWheelArea1::setHorizontalMaximumValue(qreal value)
{
+ if (value == m_horizontalMaximumValue)
+ return;
+
m_horizontalMaximumValue = value;
+ emit horizontalMaximumValueChanged();
}
qreal QQuickWheelArea1::horizontalMaximumValue() const
@@ -161,7 +169,11 @@ qreal QQuickWheelArea1::horizontalMaximumValue() const
void QQuickWheelArea1::setVerticalMinimumValue(qreal value)
{
+ if (value == m_verticalMinimumValue)
+ return;
+
m_verticalMinimumValue = value;
+ emit verticalMinimumValueChanged();
}
qreal QQuickWheelArea1::verticalMinimumValue() const
@@ -171,7 +183,11 @@ qreal QQuickWheelArea1::verticalMinimumValue() const
void QQuickWheelArea1::setVerticalMaximumValue(qreal value)
{
+ if (value == m_verticalMaximumValue)
+ return;
+
m_verticalMaximumValue = value;
+ emit verticalMaximumValueChanged();
}
qreal QQuickWheelArea1::verticalMaximumValue() const
diff --git a/src/controls/Private/qquickwheelarea_p.h b/src/controls/Private/qquickwheelarea_p.h
index 676383bc..a11b78cf 100644
--- a/src/controls/Private/qquickwheelarea_p.h
+++ b/src/controls/Private/qquickwheelarea_p.h
@@ -50,12 +50,12 @@ class QQuickWheelArea1 : public QQuickItem
Q_OBJECT
Q_PROPERTY(qreal verticalDelta READ verticalDelta WRITE setVerticalDelta NOTIFY verticalWheelMoved)
Q_PROPERTY(qreal horizontalDelta READ horizontalDelta WRITE setHorizontalDelta NOTIFY horizontalWheelMoved)
- Q_PROPERTY(qreal horizontalMinimumValue READ horizontalMinimumValue WRITE setHorizontalMinimumValue)
- Q_PROPERTY(qreal horizontalMaximumValue READ horizontalMaximumValue WRITE setHorizontalMaximumValue)
- Q_PROPERTY(qreal verticalMinimumValue READ verticalMinimumValue WRITE setVerticalMinimumValue)
- Q_PROPERTY(qreal verticalMaximumValue READ verticalMaximumValue WRITE setVerticalMaximumValue)
- Q_PROPERTY(qreal horizontalValue READ horizontalValue WRITE setHorizontalValue)
- Q_PROPERTY(qreal verticalValue READ verticalValue WRITE setVerticalValue)
+ Q_PROPERTY(qreal horizontalMinimumValue READ horizontalMinimumValue WRITE setHorizontalMinimumValue NOTIFY horizontalMinimumValueChanged)
+ Q_PROPERTY(qreal horizontalMaximumValue READ horizontalMaximumValue WRITE setHorizontalMaximumValue NOTIFY horizontalMaximumValueChanged)
+ Q_PROPERTY(qreal verticalMinimumValue READ verticalMinimumValue WRITE setVerticalMinimumValue NOTIFY verticalMinimumValueChanged)
+ Q_PROPERTY(qreal verticalMaximumValue READ verticalMaximumValue WRITE setVerticalMaximumValue NOTIFY verticalMaximumValueChanged)
+ Q_PROPERTY(qreal horizontalValue READ horizontalValue WRITE setHorizontalValue NOTIFY horizontalValueChanged)
+ Q_PROPERTY(qreal verticalValue READ verticalValue WRITE setVerticalValue NOTIFY verticalValueChanged)
Q_PROPERTY(qreal scrollSpeed READ scrollSpeed WRITE setScrollSpeed NOTIFY scrollSpeedChanged)
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(bool inverted READ isInverted)
@@ -106,7 +106,11 @@ public:
Q_SIGNALS:
void verticalValueChanged();
+ void verticalMinimumValueChanged();
+ void verticalMaximumValueChanged();
void horizontalValueChanged();
+ void horizontalMinimumValueChanged();
+ void horizontalMaximumValueChanged();
void verticalWheelMoved();
void horizontalWheelMoved();
void scrollSpeedChanged();
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