diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2013-11-27 17:57:25 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-30 17:56:22 +0100 |
commit | d0644b040eb09e1ed147ff15e7c926c9e318cbca (patch) | |
tree | 2c6d9d08fc521c13c80cbeb300655042a3ef2870 /tests | |
parent | a6348870ee1fc7b0270ceebf0f13dee7e5e54719 (diff) |
Ensure that QML Windows respect the default platform window state
The 'visible' property of a Window would be set on the baseclass QWindow
like any other property during QML component creation, which would cause
create() to be called and the platform window would be created.
This left the 'visibility' of the QML window as Windowed, not respecting
the platform defaults for how windows should be shown. The user would
have to explicitly set "visibility: Window.AutomaticVisibility" for
this default to apply, which doesn't make sense -- it should be the
default.
We solve this by deferring setVisible and setVisibility on the window
until the component is complete and we have a full picture of its state.
We then ask the platform for the default state based on the window flags
(ensuring that eg "flags: Qt.Popup" will not result in maximized
windows on iOS and Android), and apply the deferred visibility.
The deferred visibility may still be 'false', but setting the window
state makes sense anyways, so that a later "visible = true" will
apply the default window state.
Deferring platform window creation until the geometry has been
potentially set from user code also has the benefit that the
platform window can check the geometry and apply a default
geometry if it's null. This was not possible when the 'visible'
property was a regular property, as you could not know if the
user's geometry changes would come after platform window creation.
Task-number: QTBUG-35174
Change-Id: Icf3236187992048a85b2196c059f9b54699041a4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 984881c8da..b09f80a634 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -304,6 +304,7 @@ private slots: void qmlCreation(); void clearColor(); + void defaultState(); void grab_data(); void grab(); @@ -955,6 +956,25 @@ void tst_qquickwindow::clearColor() QCOMPARE(window->color(), QColor(Qt::blue)); } +void tst_qquickwindow::defaultState() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; import QtQuick.Window 2.1; Window { }", QUrl()); + QObject *created = component.create(); + QScopedPointer<QObject> cleanup(created); + QVERIFY(created); + + QQuickWindow *qmlWindow = qobject_cast<QQuickWindow*>(created); + QVERIFY(qmlWindow); + + QQuickWindow cppWindow; + cppWindow.show(); + QTest::qWaitForWindowExposed(&cppWindow); + + QCOMPARE(qmlWindow->windowState(), cppWindow.windowState()); +} + void tst_qquickwindow::grab_data() { QTest::addColumn<bool>("visible"); |