diff options
author | Shawn Rutledge <shawn.rutledge@theqtcompany.com> | 2016-02-25 13:48:08 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@theqtcompany.com> | 2016-05-13 18:37:58 +0000 |
commit | b9e4a4df577959579b2322fb6077bde82d9ffce3 (patch) | |
tree | 5d95304cd8d143c510e5d9a1ca5c38e6ad542299 /src | |
parent | f5ae7e4f8109a37c5bfab912ba0859f91ecac608 (diff) |
Flickable: add AutoFlickIfNeeded as an option for flickableDirection
If you want to disable all movement when the user tries to flick or
drag, you previously had to set interactive: false. Maybe you need to
bind that to some calculation to determine whether the content fits
completely inside the Flickable or not. This way is easier.
BTW the AutoFlickIfNeeded can be ORed with HorizontalFlick or
VerticalFlick, but we don't document it because AutoFlickDirection=0,
so it's not useful to OR that with anything.
Task-number: QTBUG-31121
Change-Id: Ib03b0f223cb40f0338510c318aa37e70ce71514d
Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 8 | ||||
-rw-r--r-- | src/quick/items/qquickflickable_p.h | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index b0245f402b..ae138d7ceb 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -881,6 +881,10 @@ QQuickFlickableVisibleArea *QQuickFlickable::visibleArea() \e contentHeight is not equal to the \e height of the Flickable. Allows flicking horizontally if the \e contentWidth is not equal to the \e width of the Flickable. + \li Flickable.AutoFlickIfNeeded - allows flicking vertically if the + \e contentHeight is greater than the \e height of the Flickable. + Allows flicking horizontally if the \e contentWidth is greater than + to the \e width of the Flickable. \li Flickable.HorizontalFlick - allows flicking horizontally. \li Flickable.VerticalFlick - allows flicking vertically. \li Flickable.HorizontalAndVerticalFlick - allows flicking in both directions. @@ -2167,6 +2171,8 @@ qreal QQuickFlickable::vHeight() const bool QQuickFlickable::xflick() const { Q_D(const QQuickFlickable); + if ((d->flickableDirection & QQuickFlickable::AutoFlickIfNeeded) && (vWidth() > width())) + return true; if (d->flickableDirection == QQuickFlickable::AutoFlickDirection) return std::floor(qAbs(vWidth() - width())); return d->flickableDirection & QQuickFlickable::HorizontalFlick; @@ -2175,6 +2181,8 @@ bool QQuickFlickable::xflick() const bool QQuickFlickable::yflick() const { Q_D(const QQuickFlickable); + if ((d->flickableDirection & QQuickFlickable::AutoFlickIfNeeded) && (vHeight() > height())) + return true; if (d->flickableDirection == QQuickFlickable::AutoFlickDirection) return std::floor(qAbs(vHeight() - height())); return d->flickableDirection & QQuickFlickable::VerticalFlick; diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h index 6cf78dcf63..318b8ce473 100644 --- a/src/quick/items/qquickflickable_p.h +++ b/src/quick/items/qquickflickable_p.h @@ -192,7 +192,8 @@ public: QQuickItem *contentItem(); - enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 }; + enum FlickableDirection { AutoFlickDirection=0x0, HorizontalFlick=0x1, VerticalFlick=0x2, HorizontalAndVerticalFlick=0x3, + AutoFlickIfNeeded=0xc }; Q_ENUM(FlickableDirection) FlickableDirection flickableDirection() const; void setFlickableDirection(FlickableDirection); |