1/**************************************************************************** 2** 3** Copyright (C) 2017 The Qt Company Ltd. 4** Contact: https://www.qt.io/licensing/ 5** 6** This file is part of the examples of the Qt Toolkit. 7** 8** $QT_BEGIN_LICENSE:BSD$ 9** Commercial License Usage 10** Licensees holding valid commercial Qt licenses may use this file in 11** accordance with the commercial license agreement provided with the 12** Software or, alternatively, in accordance with the terms contained in 13** a written agreement between you and The Qt Company. For licensing terms 14** and conditions see https://www.qt.io/terms-conditions. For further 15** information use the contact form at https://www.qt.io/contact-us. 16** 17** BSD License Usage 18** Alternatively, you may use this file under the terms of the BSD license 19** as follows: 20** 21** "Redistribution and use in source and binary forms, with or without 22** modification, are permitted provided that the following conditions are 23** met: 24** * Redistributions of source code must retain the above copyright 25** notice, this list of conditions and the following disclaimer. 26** * Redistributions in binary form must reproduce the above copyright 27** notice, this list of conditions and the following disclaimer in 28** the documentation and/or other materials provided with the 29** distribution. 30** * Neither the name of The Qt Company Ltd nor the names of its 31** contributors may be used to endorse or promote products derived 32** from this software without specific prior written permission. 33** 34** 35** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 36** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 37** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 38** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 39** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 42** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 43** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 44** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 45** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 46** 47** $QT_END_LICENSE$ 48** 49****************************************************************************/ 50 51import QtQuick 2.0 52import QtQuick.Window 2.3 53import "../shared" as Shared 54 55QtObject { 56 id: root 57 property real defaultSpacing: 10 58 property SystemPalette palette: SystemPalette { } 59 60 property var controlWindow: Window { 61 width: col.implicitWidth + root.defaultSpacing * 2 62 height: col.implicitHeight + root.defaultSpacing * 2 63 color: root.palette.window 64 title: "Control Window" 65 Column { 66 id: col 67 anchors.fill: parent 68 anchors.margins: root.defaultSpacing 69 spacing: root.defaultSpacing 70 property real cellWidth: col.width / 3 - spacing 71 Shared.Label { text: "Control the second window:" } 72 Grid { 73 id: grid 74 columns: 3 75 spacing: root.defaultSpacing 76 width: parent.width 77 Shared.Button { 78 id: showButton 79 width: col.cellWidth 80 text: root.testWindow.visible ? "Hide" : "Show" 81 onClicked: root.testWindow.visible = !root.testWindow.visible 82 } 83 //! [windowedCheckbox] 84 Shared.CheckBox { 85 text: "Windowed" 86 height: showButton.height 87 width: col.cellWidth 88 Binding on checked { value: root.testWindow.visibility === Window.Windowed } 89 onClicked: root.testWindow.visibility = Window.Windowed 90 } 91 //! [windowedCheckbox] 92 Shared.CheckBox { 93 height: showButton.height 94 width: col.cellWidth 95 text: "Full Screen" 96 Binding on checked { value: root.testWindow.visibility === Window.FullScreen } 97 onClicked: root.testWindow.visibility = Window.FullScreen 98 } 99 Shared.Button { 100 id: autoButton 101 width: col.cellWidth 102 text: "Automatic" 103 onClicked: root.testWindow.visibility = Window.AutomaticVisibility 104 } 105 Shared.CheckBox { 106 height: autoButton.height 107 text: "Minimized" 108 Binding on checked { value: root.testWindow.visibility === Window.Minimized } 109 onClicked: root.testWindow.visibility = Window.Minimized 110 } 111 Shared.CheckBox { 112 height: autoButton.height 113 text: "Maximized" 114 Binding on checked { value: root.testWindow.visibility === Window.Maximized } 115 onClicked: root.testWindow.visibility = Window.Maximized 116 } 117 } 118 function visibilityToString(v) { 119 switch (v) { 120 case Window.Windowed: 121 return "windowed"; 122 case Window.Minimized: 123 return "minimized"; 124 case Window.Maximized: 125 return "maximized"; 126 case Window.FullScreen: 127 return "fullscreen"; 128 case Window.AutomaticVisibility: 129 return "automatic"; 130 case Window.Hidden: 131 return "hidden"; 132 } 133 return "unknown"; 134 } 135 Shared.Label { 136 id: visibilityLabel 137 text: "second window is " + (root.testWindow.visible ? "visible" : "invisible") + 138 " and has visibility " + parent.visibilityToString(root.testWindow.visibility) 139 } 140 Rectangle { 141 color: root.palette.text 142 width: parent.width 143 height: 1 144 } 145 CurrentScreen { } 146 Rectangle { 147 color: root.palette.text 148 width: parent.width 149 height: 1 150 } 151 AllScreens { width: parent.width } 152 } 153 } 154 155 property var testWindow: Window { 156 width: 320 157 height: 240 158 color: "#215400" 159 title: "Test Window with color " + color 160 flags: Qt.Window | Qt.WindowFullscreenButtonHint 161 Rectangle { 162 anchors.fill: parent 163 anchors.margins: root.defaultSpacing 164 Shared.Label { 165 anchors.centerIn: parent 166 text: "Second Window" 167 } 168 MouseArea { 169 anchors.fill: parent 170 onClicked: root.testWindow.color = "#e0c31e" 171 } 172 Shared.Button { 173 anchors.right: parent.right 174 anchors.top: parent.top 175 anchors.margins: root.defaultSpacing 176 text: root.testWindow.visibility === Window.FullScreen ? "exit fullscreen" : "go fullscreen" 177 width: 150 178 onClicked: { 179 if (root.testWindow.visibility === Window.FullScreen) 180 root.testWindow.visibility = Window.AutomaticVisibility 181 else 182 root.testWindow.visibility = Window.FullScreen 183 } 184 } 185 Shared.Button { 186 anchors.left: parent.left 187 anchors.top: parent.top 188 anchors.margins: root.defaultSpacing 189 text: "X" 190 width: 30 191 onClicked: root.testWindow.close() 192 } 193 } 194 } 195 196 property var splashWindow: Splash { 197 onTimeout: root.controlWindow.visible = true 198 } 199} 200