aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quicktemplates2/qquickpopup.cpp1
-rw-r--r--src/quicktemplates2/qquickpopuppositioner.cpp14
-rw-r--r--tests/auto/controls/data/tst_popup.qml17
3 files changed, 17 insertions, 15 deletions
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index ecb2568e..d108420e 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -471,6 +471,7 @@ void QQuickPopupPrivate::finalizeEnterTransition()
if (focus)
popupItem->setFocus(true);
transitionState = NoTransition;
+ getPositioner()->reposition();
emit q->openedChanged();
emit q->opened();
}
diff --git a/src/quicktemplates2/qquickpopuppositioner.cpp b/src/quicktemplates2/qquickpopuppositioner.cpp
index ebd8ff29..dbe8ac1d 100644
--- a/src/quicktemplates2/qquickpopuppositioner.cpp
+++ b/src/quicktemplates2/qquickpopuppositioner.cpp
@@ -108,10 +108,11 @@ void QQuickPopupPositioner::reposition()
return;
}
- const qreal w = popupItem->width();
- const qreal h = popupItem->height();
- const qreal iw = popupItem->implicitWidth();
- const qreal ih = popupItem->implicitHeight();
+ const qreal scale = popupItem->scale();
+ const qreal w = popupItem->width() * scale;
+ const qreal h = popupItem->height() * scale;
+ const qreal iw = popupItem->implicitWidth() * scale;
+ const qreal ih = popupItem->implicitHeight() * scale;
bool widthAdjusted = false;
bool heightAdjusted = false;
@@ -257,10 +258,9 @@ void QQuickPopupPositioner::reposition()
}
if (!p->hasWidth && widthAdjusted && rect.width() > 0)
- popupItem->setWidth(rect.width());
+ popupItem->setWidth(rect.width() / scale);
if (!p->hasHeight && heightAdjusted && rect.height() > 0)
- popupItem->setHeight(rect.height());
-
+ popupItem->setHeight(rect.height() / scale);
m_positioning = false;
}
diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml
index 27043d1c..71d6f2d7 100644
--- a/tests/auto/controls/data/tst_popup.qml
+++ b/tests/auto/controls/data/tst_popup.qml
@@ -326,6 +326,7 @@ TestCase {
var control = createTemporaryObject(popupControl, testCase, {visible: true, margins: 0})
verify(control)
+ control.scale = 1.0
control.width = control.implicitWidth = testCase.width + 10
control.height = control.implicitHeight = testCase.height + 10
@@ -1293,8 +1294,8 @@ TestCase {
// Center the popup in the window via the overlay.
control.anchors.centerIn = Qt.binding(function() { return control.parent; })
compare(centerInSpy.count, 1)
- compare(control.x, (overlay.width - control.width) / 2)
- compare(control.y, (overlay.height - control.height) / 2)
+ compare(control.x, (overlay.width - (control.width * control.scale)) / 2)
+ compare(control.y, (overlay.height - (control.width * control.scale)) / 2)
// Ensure that it warns when trying to set it to an item that's not its parent.
var anotherItem = createTemporaryObject(rect, applicationWindow.contentItem, { x: 100, y: 100, width: 50, height: 50 })
@@ -1317,14 +1318,14 @@ TestCase {
compare(control.parent, anotherItem)
compare(control.anchors.centerIn, anotherItem)
compare(centerInSpy.count, 4)
- compare(control.x, (anotherItem.width - control.width) / 2)
- compare(control.y, (anotherItem.height - control.height) / 2)
+ compare(control.x, (anotherItem.width - (control.width * control.scale)) / 2)
+ compare(control.y, (anotherItem.height - (control.height * control.scale)) / 2)
// Check that anchors.centerIn beats x and y coordinates as it does in QQuickItem.
control.x = 33;
control.y = 44;
- compare(control.x, (anotherItem.width - control.width) / 2)
- compare(control.y, (anotherItem.height - control.height) / 2)
+ compare(control.x, (anotherItem.width - (control.width * control.scale)) / 2)
+ compare(control.y, (anotherItem.height - (control.height * control.scale)) / 2)
// Check that the popup's x and y coordinates are restored when it's no longer centered.
control.anchors.centerIn = undefined
@@ -1335,8 +1336,8 @@ TestCase {
// Test centering in the overlay while having a different parent (anotherItem).
control.anchors.centerIn = overlay
compare(centerInSpy.count, 6)
- compare(control.x, (overlay.width - control.width) / 2)
- compare(control.y, (overlay.height - control.height) / 2)
+ compare(control.x, (overlay.width - (control.width * control.scale)) / 2)
+ compare(control.y, (overlay.height - (control.height * control.scale)) / 2)
// TODO: do this properly by creating a component or something
applicationWindow.visible = false