diff options
author | Jan Arve Saether <jan-arve.saether@digia.com> | 2013-10-16 14:02:02 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-25 15:07:33 +0200 |
commit | 3fdea4f160cbcf9a5c906c8ee05e8361f111a7ec (patch) | |
tree | 4d8720a54b73c7e4e8b2688c0a0e2e89cf69473e | |
parent | 2f77a972eafacebcc5a44204dbf577258de1c4a1 (diff) | |
download | qtquickcontrols-3fdea4f160cbcf9a5c906c8ee05e8361f111a7ec.tar.gz |
Adjust height if the ToolBar or StatusBar is dynamically hidden
Triggered by a manual test I'm working on
Change-Id: I8d49a7d19ac7daebda388df8e2d8595607fdd52c
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
-rw-r--r-- | src/controls/ApplicationWindow.qml | 6 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_applicationwindow.qml | 98 |
2 files changed, 102 insertions, 2 deletions
diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index 43bc9889..564e8d2a 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -145,7 +145,8 @@ Window { anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right - height: childrenRect.height + implicitHeight: childrenRect.height + height: visibleChildren.length > 0 ? implicitHeight: 0 } Item { @@ -153,7 +154,8 @@ Window { anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right - height: childrenRect.height + implicitHeight: childrenRect.height + height: visibleChildren.length > 0 ? implicitHeight: 0 } onVisibleChanged: if (visible && menuBar) menuBar.__parentWindow = root diff --git a/tests/auto/controls/data/tst_applicationwindow.qml b/tests/auto/controls/data/tst_applicationwindow.qml new file mode 100644 index 00000000..e424cc2d --- /dev/null +++ b/tests/auto/controls/data/tst_applicationwindow.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import QtTest 1.0 +import QtQuickControlsTests 1.0 + +Item { + id: container + width: 400 + height: 400 + +TestCase { + id: testCase + name: "Tests_ApplicationWindow" + when:windowShown + width:400 + height:400 + + function test_minimumHeight() { + var test_control = 'import QtQuick 2.1; \ + import QtQuick.Controls 1.1; \ + ApplicationWindow { \ + width: 100; height: 100; \ + property alias contentArea: rect; \ + statusBar: StatusBar { \ + visible: false; \ + Label { \ + text: "Ready"; \ + } \ + } \ + \ + toolBar: ToolBar { \ + visible: false; \ + ToolButton { \ + text: "One"; \ + } \ + } \ + Rectangle { \ + id: rect; \ + anchors.fill: parent; \ + } \ + } ' + + var window = Qt.createQmlObject(test_control, container, '') + wait(0) + var contentArea = window.contentArea + var oldHeight = contentArea.height + compare(contentArea.height, 100) + window.statusBar.visible = true + wait(0) + verify(contentArea.height < oldHeight) + + oldHeight = contentArea.height; + window.toolBar.visible = true + wait(0) + verify(contentArea.height < oldHeight) + window.destroy() + } +} +} |