diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2016-08-01 11:24:18 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2016-08-02 12:49:59 +0000 |
commit | 1b7b2d7ddb6a02fd2ccd1f29a431005b9e693723 (patch) | |
tree | 8b2835ae856604c7f54d02333f70cbcb35c0f172 /src/quicktemplates2/qquickswipedelegate.cpp | |
parent | e336afdb67d572087dda352b485ac309756639af (diff) |
SwipeDelegate: warn about horizontally anchoring background/contentItem
SwipeDelegate must have control over the x positions of these items in
order to move them during swipes.
Task-number: QTBUG-55040
Change-Id: Ie1e91fa4705cffe7573205279feff9bab048acd5
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickswipedelegate.cpp')
-rw-r--r-- | src/quicktemplates2/qquickswipedelegate.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp index 356054fb..c6c8ebc7 100644 --- a/src/quicktemplates2/qquickswipedelegate.cpp +++ b/src/quicktemplates2/qquickswipedelegate.cpp @@ -706,8 +706,24 @@ bool QQuickSwipeDelegatePrivate::handleMouseReleaseEvent(QQuickItem *, QMouseEve return hadGrabbedMouse; } +static void warnIfHorizontallyAnchored(QQuickItem *item, const QString &itemName) +{ + if (!item) + return; + + QQuickAnchors *anchors = QQuickItemPrivate::get(item)->_anchors; + if (anchors && (anchors->fill() || anchors->centerIn() || anchors->left().item || anchors->right().item) + && !item->property("_q_QQuickSwipeDelegate_warned").toBool()) { + qmlInfo(item) << QString::fromLatin1("SwipeDelegate: cannot use horizontal anchors with %1; unable to layout the item.").arg(itemName); + item->setProperty("_q_QQuickSwipeDelegate_warned", true); + } +} + void QQuickSwipeDelegatePrivate::resizeContent() { + warnIfHorizontallyAnchored(background, QStringLiteral("background")); + warnIfHorizontallyAnchored(contentItem, QStringLiteral("contentItem")); + // If the background and contentItem are repositioned due to a swipe, // we don't want to call QQuickControlPrivate's implementation of this function, // as it repositions the contentItem to be visible. |