aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-20 17:23:16 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-21 21:39:31 +0000
commit3ed4944a7e21191ee726ca31c4e50bd055f9d25b (patch)
tree32a6d49e881413b6c5758078fb039468abc4ebdf
parent8a4af9e87704f7b8ed269114d3ab75430bd61998 (diff)
Fix QQuickPopup::resetWidth/Height()
When reseting the explicit size of a popup, the popup items geometry does not necessarily change. However, it affects the positioning of the popup whether it has explicit size or not. For that reason we must ensure that the popup gets repositioned as appropriate. Change-Id: I2dcd895eb7a1adc9c6a804bed4731edac1d550ec Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quicktemplates2/qquickpopup.cpp10
-rw-r--r--tests/auto/controls/data/tst_popup.qml18
2 files changed, 28 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 2a48473a..22b399b1 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -929,8 +929,13 @@ void QQuickPopup::setWidth(qreal width)
void QQuickPopup::resetWidth()
{
Q_D(QQuickPopup);
+ if (!d->hasWidth)
+ return;
+
d->hasWidth = false;
d->popupItem->resetWidth();
+ if (d->popupItem->isVisible())
+ d->reposition();
}
/*!
@@ -954,8 +959,13 @@ void QQuickPopup::setHeight(qreal height)
void QQuickPopup::resetHeight()
{
Q_D(QQuickPopup);
+ if (!d->hasHeight)
+ return;
+
d->hasHeight = false;
d->popupItem->resetHeight();
+ if (d->popupItem->isVisible())
+ d->reposition();
}
/*!
diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml
index ae1c7185..8d8f94b7 100644
--- a/tests/auto/controls/data/tst_popup.qml
+++ b/tests/auto/controls/data/tst_popup.qml
@@ -355,6 +355,24 @@ TestCase {
control.destroy()
}
+ function test_resetSize() {
+ var control = popupControl.createObject(testCase, {visible: true, margins: 0})
+ verify(control)
+
+ control.width = control.implicitWidth = testCase.width + 10
+ control.height = control.implicitHeight = testCase.height + 10
+
+ compare(control.width, testCase.width + 10)
+ compare(control.height, testCase.height + 10)
+
+ control.width = undefined
+ control.height = undefined
+ compare(control.width, testCase.width)
+ compare(control.height, testCase.height)
+
+ control.destroy()
+ }
+
function test_negativeMargins() {
var control = popupControl.createObject(testCase, {implicitWidth: testCase.width, implicitHeight: testCase.height})
verify(control)