diff options
author | Nicolas Fella <nicolas.fella@kdab.com> | 2020-05-13 23:12:54 +0200 |
---|---|---|
committer | Nicolas Fella <nicolas.fella@kdab.com> | 2020-05-25 18:38:32 +0200 |
commit | 583a99ae6688f526bb4f1877d2f253523903c9ad (patch) | |
tree | 0d131695fbafa6b87e4a0eb9f9cbb07b156b968e /src | |
parent | 22d5156d9950eb79f13cad0f99fbfa683dbd26e1 (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
Pick-to: 5.15
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>
Diffstat (limited to 'src')
-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 fed4bbec5e..979548e737 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -2320,20 +2320,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; } |