1From 9fada65e1dd8958cbe4b8dc12c9e4814fcff5a6c Mon Sep 17 00:00:00 2001 2From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com> 3Date: Fri, 16 Apr 2021 21:54:16 +0200 4Subject: [PATCH] Revert "Get the scale of the popup item when setting the 5 parent item" 6 7Upgrade 5.14.2 (for us dunfell) -> 5.15.2 introduced a bug: Opening a menu 8for the second+ time, menu moves right and down and parts land outside screen. 9Reported but nobody cares. [1] 10 11[1] https://bugreports.qt.io/browse/QTBUG-86973 12 13Upstream-Status: Pending 14 15This reverts commit 761dba8b23b7e558acc57b3e481648ce319a4397. 16Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> 17--- 18 src/quicktemplates2/qquickpopuppositioner.cpp | 18 +++++++-------- 19 .../qquickpopuppositioner_p_p.h | 1 - 20 tests/auto/controls/data/tst_combobox.qml | 22 ------------------- 21 tests/auto/controls/data/tst_popup.qml | 3 --- 22 4 files changed, 8 insertions(+), 36 deletions(-) 23 24diff --git a/src/quicktemplates2/qquickpopuppositioner.cpp b/src/quicktemplates2/qquickpopuppositioner.cpp 25index 1bfaafbe6..dbe8ac1d5 100644 26--- a/src/quicktemplates2/qquickpopuppositioner.cpp 27+++ b/src/quicktemplates2/qquickpopuppositioner.cpp 28@@ -92,10 +92,7 @@ void QQuickPopupPositioner::setParentItem(QQuickItem *parent) 29 30 QQuickItemPrivate::get(parent)->addItemChangeListener(this, ItemChangeTypes); 31 addAncestorListeners(parent->parentItem()); 32- // Store the scale property so the end result of any transition that could effect the scale 33- // does not influence the top left of the final popup, so it doesn't appear to flip from one 34- // position to another as a result 35- m_popupScale = m_popup->popupItem()->scale(); 36+ 37 if (m_popup->popupItem()->isVisible()) 38 QQuickPopupPrivate::get(m_popup)->reposition(); 39 } 40@@ -111,10 +108,11 @@ void QQuickPopupPositioner::reposition() 41 return; 42 } 43 44- const qreal w = popupItem->width() * m_popupScale; 45- const qreal h = popupItem->height() * m_popupScale; 46- const qreal iw = popupItem->implicitWidth() * m_popupScale; 47- const qreal ih = popupItem->implicitHeight() * m_popupScale; 48+ const qreal scale = popupItem->scale(); 49+ const qreal w = popupItem->width() * scale; 50+ const qreal h = popupItem->height() * scale; 51+ const qreal iw = popupItem->implicitWidth() * scale; 52+ const qreal ih = popupItem->implicitHeight() * scale; 53 54 bool widthAdjusted = false; 55 bool heightAdjusted = false; 56@@ -260,9 +258,9 @@ void QQuickPopupPositioner::reposition() 57 } 58 59 if (!p->hasWidth && widthAdjusted && rect.width() > 0) 60- popupItem->setWidth(rect.width() / m_popupScale); 61+ popupItem->setWidth(rect.width() / scale); 62 if (!p->hasHeight && heightAdjusted && rect.height() > 0) 63- popupItem->setHeight(rect.height() / m_popupScale); 64+ popupItem->setHeight(rect.height() / scale); 65 m_positioning = false; 66 } 67 68diff --git a/src/quicktemplates2/qquickpopuppositioner_p_p.h b/src/quicktemplates2/qquickpopuppositioner_p_p.h 69index 03a2e2fed..64f57a3fa 100644 70--- a/src/quicktemplates2/qquickpopuppositioner_p_p.h 71+++ b/src/quicktemplates2/qquickpopuppositioner_p_p.h 72@@ -79,7 +79,6 @@ protected: 73 bool m_positioning = false; 74 QQuickItem *m_parentItem = nullptr; 75 QQuickPopup *m_popup = nullptr; 76- qreal m_popupScale = 1.0; 77 }; 78 79 QT_END_NAMESPACE 80diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml 81index 1c58372ff..e9156fee5 100644 82--- a/tests/auto/controls/data/tst_combobox.qml 83+++ b/tests/auto/controls/data/tst_combobox.qml 84@@ -911,28 +911,6 @@ TestCase { 85 compare(control.popup.visible, true) 86 verify(control.popup.contentItem.y < control.y) 87 88- 89- // Account for when a transition of a scale from 0.9-1.0 that it is placed above right away and not below 90- // first just because there is room at the 0.9 scale 91- if (control.popup.enter !== null) { 92- // hide 93- mouseClick(control) 94- compare(control.pressed, false) 95- tryCompare(control.popup, "visible", false) 96- control.y = control.Window.height - (control.popup.contentItem.height * 0.99) 97- var popupYSpy = createTemporaryObject(signalSpy, testCase, {target: control.popup, signalName: "yChanged"}) 98- verify(popupYSpy.valid) 99- mousePress(control) 100- compare(control.pressed, true) 101- compare(control.popup.visible, false) 102- mouseRelease(control) 103- compare(control.pressed, false) 104- compare(control.popup.visible, true) 105- tryCompare(control.popup.enter, "running", false) 106- verify(control.popup.contentItem.y < control.y) 107- verify(popupYSpy.count === 1) 108- } 109- 110 // follow the control outside the horizontal window bounds 111 control.x = -control.width / 2 112 compare(control.x, -control.width / 2) 113diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml 114index 57d5ccccf..71d6f2d76 100644 115--- a/tests/auto/controls/data/tst_popup.qml 116+++ b/tests/auto/controls/data/tst_popup.qml 117@@ -1276,9 +1276,6 @@ TestCase { 118 { visible: true, width: 100, height: 100 }) 119 verify(control) 120 verify(control.visible) 121- // If there is a transition then make sure it is finished 122- if (control.enter !== null) 123- tryCompare(control.enter, "running", false) 124 compare(control.parent, control.Overlay.overlay) 125 compare(control.x, 0) 126 compare(control.y, 0) 127-- 1282.26.2 129 130