aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/quicktemplates2/qquickcontrol_p_p.h2
-rw-r--r--src/quicktemplates2/qquickswipedelegate.cpp27
-rw-r--r--src/quicktemplates2/qquickswipedelegate_p_p.h1
3 files changed, 28 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h
index 15d0ef74..cb2eb419 100644
--- a/src/quicktemplates2/qquickcontrol_p_p.h
+++ b/src/quicktemplates2/qquickcontrol_p_p.h
@@ -122,7 +122,7 @@ public:
void setRightInset(qreal value, bool reset = false);
void setBottomInset(qreal value, bool reset = false);
- void resizeBackground();
+ virtual void resizeBackground();
virtual void resizeContent();
virtual QQuickItem *getContentItem();
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp
index 77acb498..bc34a4ba 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);
@@ -935,13 +958,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());
}
}
diff --git a/src/quicktemplates2/qquickswipedelegate_p_p.h b/src/quicktemplates2/qquickswipedelegate_p_p.h
index 7ed043d6..e45416af 100644
--- a/src/quicktemplates2/qquickswipedelegate_p_p.h
+++ b/src/quicktemplates2/qquickswipedelegate_p_p.h
@@ -67,6 +67,7 @@ public:
bool handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event);
void resizeContent() override;
+ void resizeBackground() override;
QPalette defaultPalette() const override;