diff options
author | Jan Arve Saether <jan-arve.saether@digia.com> | 2014-08-27 09:12:24 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@digia.com> | 2014-08-28 09:39:09 +0200 |
commit | 10f0da6cfb56396a16ec741380556320fba86552 (patch) | |
tree | 1457c86c7659a1995b23865e4a76702a243f7a39 | |
parent | 4648dc566f72454fb49142b9f55929c9b9502853 (diff) | |
download | qtquickcontrols-10f0da6cfb56396a16ec741380556320fba86552.tar.gz |
Do not shrink application window height to 0
The binding was always evaluated to 0 if __noImplicitHeightGiven
was true. The solution is to move the condition to the Binding
element, which will then cause it to not be triggered when it was
previously be evaluated to 0.
Task-number: QTBUG-38469
Change-Id: I6ff80e44069978ee9685ea2fbe52afc52425cbdc
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
-rw-r--r-- | src/controls/ApplicationWindow.qml | 13 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_applicationwindow.qml | 24 |
2 files changed, 33 insertions, 4 deletions
diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index 185f33ef..bc2bf329 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -171,7 +171,7 @@ Window { Binding { target: root property: "__width" - when: root.minimumWidth <= root.maximumWidth + when: (root.minimumWidth <= root.maximumWidth) && !contentArea.__noImplicitWidthGiven value: Math.max(Math.min(root.maximumWidth, contentArea.implicitWidth), root.minimumWidth) } /*! \internal */ @@ -179,11 +179,16 @@ Window { Binding { target: root property: "__height" - when: root.minimumHeight <= root.maximumHeight + when: (root.minimumHeight <= root.maximumHeight) && !contentArea.__noImplicitHeightGiven value: Math.max(Math.min(root.maximumHeight, contentArea.implicitHeight + __topBottomMargins), root.minimumHeight) } - width: contentArea.__noImplicitWidthGiven ? 0 : __width - height: contentArea.__noImplicitHeightGiven ? 0 : __height + /* As soon as an application developer writes + width: 200 + this binding will be broken. This is the reason for this indirection + via __width (and __height) + */ + width: __width + height: __height minimumWidth: contentArea.__noMinimumWidthGiven ? 0 : contentArea.minimumWidth minimumHeight: contentArea.__noMinimumHeightGiven ? 0 : (contentArea.minimumHeight + __topBottomMargins) diff --git a/tests/auto/controls/data/tst_applicationwindow.qml b/tests/auto/controls/data/tst_applicationwindow.qml index a746f276..0289b184 100644 --- a/tests/auto/controls/data/tst_applicationwindow.qml +++ b/tests/auto/controls/data/tst_applicationwindow.qml @@ -292,5 +292,29 @@ TestCase { window.destroy() } + function test_windowHeight2() { + var test_control = 'import QtQuick 2.2; \ + import QtQuick 2.2; \ + import QtQuick.Controls 1.2; \ + ApplicationWindow { \ + Rectangle { \ + anchors.fill: parent; \ + color: "red" \ + } \ + \ + menuBar: MenuBar { \ + Menu { \ + title: qsTr("Menu") \ + } \ + } \ + } ' + + var window = Qt.createQmlObject(test_control, container, '') + window.visible = true + waitForRendering(window.contentItem) + verify(window.height > 0) + window.destroy() + } + } } |