diff options
Diffstat (limited to 'src/quicktemplates2/qquickswipedelegate.cpp')
-rw-r--r-- | src/quicktemplates2/qquickswipedelegate.cpp | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp index c6214243..629bf23d 100644 --- a/src/quicktemplates2/qquickswipedelegate.cpp +++ b/src/quicktemplates2/qquickswipedelegate.cpp @@ -713,6 +713,29 @@ QQuickSwipeDelegatePrivate::QQuickSwipeDelegatePrivate(QQuickSwipeDelegate *cont { } +void QQuickSwipeDelegatePrivate::resizeBackground() +{ + if (!background) + return; + + resizingBackground = true; + + QQuickItemPrivate *p = QQuickItemPrivate::get(background); + const bool extraAllocated = extra.isAllocated(); + // Don't check for or set the x here since it will just be overwritten by reposition(). + if (((!p->widthValid || !extraAllocated || !extra->hasBackgroundWidth)) + || (extraAllocated && (extra->hasLeftInset || extra->hasRightInset))) { + background->setWidth(width - getLeftInset() - getRightInset()); + } + if (((!p->heightValid || !extraAllocated || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y())) + || (extraAllocated && (extra->hasTopInset || extra->hasBottomInset))) { + background->setY(getTopInset()); + background->setHeight(height - getTopInset() - getBottomInset()); + } + + resizingBackground = false; +} + bool QQuickSwipeDelegatePrivate::handleMousePressEvent(QQuickItem *item, QMouseEvent *event) { Q_Q(QQuickSwipeDelegate); @@ -778,9 +801,10 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv const QPointF mappedEventPos = item->mapToItem(q, event->pos()); const qreal distance = (mappedEventPos - pressPoint).x(); if (!q->keepMouseGrab()) { - // Taken from QQuickDrawerPrivate::grabMouse; see comments there. - int threshold = qMax(20, QGuiApplication::styleHints()->startDragDistance() + 5); - const bool overThreshold = QQuickWindowPrivate::dragOverThreshold(distance, Qt::XAxis, event, threshold); + // We used to use the custom threshold that QQuickDrawerPrivate::grabMouse used, + // but since it's larger than what Flickable uses, it results in Flickable + // stealing events from us (QTBUG-50045), so now we use the default. + const bool overThreshold = QQuickWindowPrivate::dragOverThreshold(distance, Qt::XAxis, event); if (window && overThreshold) { QQuickItem *grabber = q->window()->mouseGrabberItem(); if (!grabber || !grabber->keepMouseGrab()) { @@ -935,13 +959,15 @@ void QQuickSwipeDelegatePrivate::resizeContent() // 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. - // However, we still want to resize the control vertically. + // However, we still want to position the contentItem vertically + // and resize it (in case the control was resized while open). QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&swipe); if (!swipePrivate->complete) { QQuickItemDelegatePrivate::resizeContent(); } else if (contentItem) { Q_Q(QQuickSwipeDelegate); contentItem->setY(q->topPadding()); + contentItem->setWidth(q->availableWidth()); contentItem->setHeight(q->availableHeight()); } } @@ -1025,7 +1051,6 @@ QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) */ /*! - \qmlpropertygroup QtQuick.Controls::SwipeDelegate::swipe \qmlproperty real QtQuick.Controls::SwipeDelegate::swipe.position \qmlproperty bool QtQuick.Controls::SwipeDelegate::swipe.complete \qmlproperty bool QtQuick.Controls::SwipeDelegate::swipe.enabled |