diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-11-06 17:00:29 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-11-08 01:26:54 +0000 |
commit | 8e9bd27e2c3b745813ae0a6eb3469ad10beee8a9 (patch) | |
tree | caa2940525ef0f577f6b7179ba02e3826af2944e | |
parent | cdc63b1cbc12bba56c0148ce9a33bd7488ef0b11 (diff) |
QQuickOverlay: don't reset rotation during resize if we don't have to
Overlays on windows that have an explicit content orientation set need
to reset their rotation value when the window's geometry changes, so
that items on the overlay have the correct orientation as well. This
was implemented in f1e139b9ac02313f541ed6749f05e265f4c8bf13.
However, for windows that follow the default screen orientation (i.e.
use Qt::PrimaryOrientation), we don't have to reset the rotation to
0 when the window resizes.
Fixes: QTBUG-118460
Change-Id: I1a65f15000b1d8a6425773adeba127915b944581
Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
(cherry picked from commit d51847e327d6d19c0e984ad65f66d8123d2e56ea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/quicktemplates/qquickoverlay.cpp | 2 | ||||
-rw-r--r-- | tests/auto/quickcontrols/qquickoverlay/tst_qquickoverlay.cpp | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/quicktemplates/qquickoverlay.cpp b/src/quicktemplates/qquickoverlay.cpp index 3d9ac5481a..dde26c8a8b 100644 --- a/src/quicktemplates/qquickoverlay.cpp +++ b/src/quicktemplates/qquickoverlay.cpp @@ -265,6 +265,8 @@ void QQuickOverlayPrivate::updateGeometry() switch (window->contentOrientation()) { case Qt::PrimaryOrientation: + rotation = this->rotation(); + Q_FALLTHROUGH(); case Qt::PortraitOrientation: size = window->size(); break; diff --git a/tests/auto/quickcontrols/qquickoverlay/tst_qquickoverlay.cpp b/tests/auto/quickcontrols/qquickoverlay/tst_qquickoverlay.cpp index 8dfe57920c..beb8d8dfb5 100644 --- a/tests/auto/quickcontrols/qquickoverlay/tst_qquickoverlay.cpp +++ b/tests/auto/quickcontrols/qquickoverlay/tst_qquickoverlay.cpp @@ -18,6 +18,7 @@ public: private slots: void clearGrabbers(); + void retainOrientation(); }; class TestInputHandler : public QQuickPointerDeviceHandler @@ -199,6 +200,24 @@ void tst_QQuickOverlay::clearGrabbers() QVERIFY(testPointerhandler.m_points.isEmpty()); } +void tst_QQuickOverlay::retainOrientation() +{ + QQuickWindow window; + auto *overlay = QQuickOverlay::overlay(&window); + + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + qreal rot = 10; + overlay->setRotation(rot); + const QSizeF sz = overlay->size(); + window.resize(window.size() + QSize(10, 10)); + // wait for the resize event to call QQuickOverlay::updateGeometry + QTRY_COMPARE_NE(overlay->size(), sz); + + QCOMPARE(overlay->rotation(), rot); +} + QTEST_MAIN(tst_QQuickOverlay) #include "tst_qquickoverlay.moc" |