diff options
author | Nicolas Fella <nicolas.fella@kdab.com> | 2020-05-13 23:12:54 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-06-10 12:49:24 +0000 |
commit | 97cc020b720723397925c6c95739a48bff9b9ca0 (patch) | |
tree | 5765b6189b9d5f9e78da137e9b1e5e8f77ce25eb /src/quick | |
parent | 79eb26ddf76b8e74467a5930ec8269be823921eb (diff) |
Consider margins in xflick/yflick
AutoFlickDirection and AutoFlickIfNeeded compare the size of the
flickable with the size of the content item. We need to take margins
into account since they might cause the need for scrolling when the
content would otherwise fit.
Fixes: QTBUG-31905
Change-Id: I18d073af4c6ffb1b703f5e2b33f616b61e816e56
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Marco Martin <mart@kde.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 583a99ae6688f526bb4f1877d2f253523903c9ad)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index 8228db87cf..f222a4a32e 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -2321,20 +2321,22 @@ qreal QQuickFlickable::vHeight() const bool QQuickFlickable::xflick() const { Q_D(const QQuickFlickable); - if ((d->flickableDirection & QQuickFlickable::AutoFlickIfNeeded) && (vWidth() > width())) + const int contentWidthWithMargins = d->contentItem->width() + d->hData.startMargin + d->hData.endMargin; + if ((d->flickableDirection & QQuickFlickable::AutoFlickIfNeeded) && (contentWidthWithMargins > width())) return true; if (d->flickableDirection == QQuickFlickable::AutoFlickDirection) - return std::floor(qAbs(vWidth() - width())); + return std::floor(qAbs(contentWidthWithMargins - width())); return d->flickableDirection & QQuickFlickable::HorizontalFlick; } bool QQuickFlickable::yflick() const { Q_D(const QQuickFlickable); - if ((d->flickableDirection & QQuickFlickable::AutoFlickIfNeeded) && (vHeight() > height())) + const int contentHeightWithMargins = d->contentItem->height() + d->vData.startMargin + d->vData.endMargin; + if ((d->flickableDirection & QQuickFlickable::AutoFlickIfNeeded) && (contentHeightWithMargins > height())) return true; if (d->flickableDirection == QQuickFlickable::AutoFlickDirection) - return std::floor(qAbs(vHeight() - height())); + return std::floor(qAbs(contentHeightWithMargins - height())); return d->flickableDirection & QQuickFlickable::VerticalFlick; } |