2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2013-03-08 15:44:52 +00:00
|
|
|
|
2021-02-09 17:06:54 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
2013-03-08 15:44:52 +00:00
|
|
|
|
|
|
|
QtObject {
|
2019-09-17 16:10:59 +00:00
|
|
|
id: root
|
2013-03-08 15:44:52 +00:00
|
|
|
property real defaultSpacing: 10
|
|
|
|
property SystemPalette palette: SystemPalette { }
|
|
|
|
|
|
|
|
property var controlWindow: Window {
|
2019-09-17 16:10:59 +00:00
|
|
|
width: col.implicitWidth + root.defaultSpacing * 2
|
|
|
|
height: col.implicitHeight + root.defaultSpacing * 2
|
|
|
|
color: root.palette.window
|
2013-03-08 15:44:52 +00:00
|
|
|
title: "Control Window"
|
|
|
|
Column {
|
|
|
|
id: col
|
|
|
|
anchors.fill: parent
|
2019-09-17 16:10:59 +00:00
|
|
|
anchors.margins: root.defaultSpacing
|
|
|
|
spacing: root.defaultSpacing
|
2013-03-08 15:44:52 +00:00
|
|
|
property real cellWidth: col.width / 3 - spacing
|
2021-02-09 17:06:54 +00:00
|
|
|
Label { text: "Control the second window:" }
|
2013-03-08 15:44:52 +00:00
|
|
|
Grid {
|
|
|
|
id: grid
|
|
|
|
columns: 3
|
2019-09-17 16:10:59 +00:00
|
|
|
spacing: root.defaultSpacing
|
2013-03-08 15:44:52 +00:00
|
|
|
width: parent.width
|
2021-02-09 17:06:54 +00:00
|
|
|
Button {
|
2013-03-08 15:44:52 +00:00
|
|
|
id: showButton
|
|
|
|
width: col.cellWidth
|
2019-09-17 16:10:59 +00:00
|
|
|
text: root.testWindow.visible ? "Hide" : "Show"
|
|
|
|
onClicked: root.testWindow.visible = !root.testWindow.visible
|
2013-03-08 15:44:52 +00:00
|
|
|
}
|
|
|
|
//! [windowedCheckbox]
|
2021-02-09 17:06:54 +00:00
|
|
|
CheckBox {
|
2013-03-08 15:44:52 +00:00
|
|
|
text: "Windowed"
|
|
|
|
height: showButton.height
|
|
|
|
width: col.cellWidth
|
2019-09-17 16:10:59 +00:00
|
|
|
Binding on checked { value: root.testWindow.visibility === Window.Windowed }
|
|
|
|
onClicked: root.testWindow.visibility = Window.Windowed
|
2013-03-08 15:44:52 +00:00
|
|
|
}
|
|
|
|
//! [windowedCheckbox]
|
2021-02-09 17:06:54 +00:00
|
|
|
CheckBox {
|
2013-03-08 15:44:52 +00:00
|
|
|
height: showButton.height
|
|
|
|
width: col.cellWidth
|
|
|
|
text: "Full Screen"
|
2019-09-17 16:10:59 +00:00
|
|
|
Binding on checked { value: root.testWindow.visibility === Window.FullScreen }
|
|
|
|
onClicked: root.testWindow.visibility = Window.FullScreen
|
2013-03-08 15:44:52 +00:00
|
|
|
}
|
2021-02-09 17:06:54 +00:00
|
|
|
Button {
|
2013-03-08 15:44:52 +00:00
|
|
|
id: autoButton
|
|
|
|
width: col.cellWidth
|
|
|
|
text: "Automatic"
|
2019-09-17 16:10:59 +00:00
|
|
|
onClicked: root.testWindow.visibility = Window.AutomaticVisibility
|
2013-03-08 15:44:52 +00:00
|
|
|
}
|
2021-02-09 17:06:54 +00:00
|
|
|
CheckBox {
|
2013-03-08 15:44:52 +00:00
|
|
|
height: autoButton.height
|
|
|
|
text: "Minimized"
|
2019-09-17 16:10:59 +00:00
|
|
|
Binding on checked { value: root.testWindow.visibility === Window.Minimized }
|
|
|
|
onClicked: root.testWindow.visibility = Window.Minimized
|
2013-03-08 15:44:52 +00:00
|
|
|
}
|
2021-02-09 17:06:54 +00:00
|
|
|
CheckBox {
|
2013-03-08 15:44:52 +00:00
|
|
|
height: autoButton.height
|
|
|
|
text: "Maximized"
|
2019-09-17 16:10:59 +00:00
|
|
|
Binding on checked { value: root.testWindow.visibility === Window.Maximized }
|
|
|
|
onClicked: root.testWindow.visibility = Window.Maximized
|
2013-03-08 15:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
function visibilityToString(v) {
|
|
|
|
switch (v) {
|
|
|
|
case Window.Windowed:
|
|
|
|
return "windowed";
|
|
|
|
case Window.Minimized:
|
|
|
|
return "minimized";
|
|
|
|
case Window.Maximized:
|
|
|
|
return "maximized";
|
|
|
|
case Window.FullScreen:
|
|
|
|
return "fullscreen";
|
|
|
|
case Window.AutomaticVisibility:
|
|
|
|
return "automatic";
|
|
|
|
case Window.Hidden:
|
|
|
|
return "hidden";
|
|
|
|
}
|
|
|
|
return "unknown";
|
|
|
|
}
|
2021-02-09 17:06:54 +00:00
|
|
|
Label {
|
2013-12-16 09:58:05 +00:00
|
|
|
id: visibilityLabel
|
2019-09-17 16:10:59 +00:00
|
|
|
text: "second window is " + (root.testWindow.visible ? "visible" : "invisible") +
|
|
|
|
" and has visibility " + parent.visibilityToString(root.testWindow.visibility)
|
2013-03-08 15:44:52 +00:00
|
|
|
}
|
|
|
|
Rectangle {
|
2019-09-17 16:10:59 +00:00
|
|
|
color: root.palette.text
|
2013-03-08 15:44:52 +00:00
|
|
|
width: parent.width
|
|
|
|
height: 1
|
|
|
|
}
|
2016-09-22 12:22:26 +00:00
|
|
|
CurrentScreen { }
|
|
|
|
Rectangle {
|
2019-09-17 16:10:59 +00:00
|
|
|
color: root.palette.text
|
2016-09-22 12:22:26 +00:00
|
|
|
width: parent.width
|
|
|
|
height: 1
|
|
|
|
}
|
|
|
|
AllScreens { width: parent.width }
|
2013-03-08 15:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var testWindow: Window {
|
|
|
|
width: 320
|
|
|
|
height: 240
|
|
|
|
color: "#215400"
|
|
|
|
title: "Test Window with color " + color
|
2013-11-15 14:17:57 +00:00
|
|
|
flags: Qt.Window | Qt.WindowFullscreenButtonHint
|
2013-03-08 15:44:52 +00:00
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
2019-09-17 16:10:59 +00:00
|
|
|
anchors.margins: root.defaultSpacing
|
2021-02-09 17:06:54 +00:00
|
|
|
Label {
|
2013-03-08 15:44:52 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
text: "Second Window"
|
|
|
|
}
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2019-09-17 16:10:59 +00:00
|
|
|
onClicked: root.testWindow.color = "#e0c31e"
|
2013-03-08 15:44:52 +00:00
|
|
|
}
|
2021-02-09 17:06:54 +00:00
|
|
|
Button {
|
2013-03-08 15:44:52 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
2019-09-17 16:10:59 +00:00
|
|
|
anchors.margins: root.defaultSpacing
|
|
|
|
text: root.testWindow.visibility === Window.FullScreen ? "exit fullscreen" : "go fullscreen"
|
2013-03-08 15:44:52 +00:00
|
|
|
width: 150
|
|
|
|
onClicked: {
|
2019-09-17 16:10:59 +00:00
|
|
|
if (root.testWindow.visibility === Window.FullScreen)
|
|
|
|
root.testWindow.visibility = Window.AutomaticVisibility
|
2013-03-08 15:44:52 +00:00
|
|
|
else
|
2019-09-17 16:10:59 +00:00
|
|
|
root.testWindow.visibility = Window.FullScreen
|
2013-03-08 15:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-09 17:06:54 +00:00
|
|
|
Button {
|
2013-03-08 15:44:52 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
2019-09-17 16:10:59 +00:00
|
|
|
anchors.margins: root.defaultSpacing
|
2013-03-08 15:44:52 +00:00
|
|
|
text: "X"
|
|
|
|
width: 30
|
2019-09-17 16:10:59 +00:00
|
|
|
onClicked: root.testWindow.close()
|
2013-03-08 15:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-05-29 08:58:38 +00:00
|
|
|
|
|
|
|
property var splashWindow: Splash {
|
2019-09-17 16:10:59 +00:00
|
|
|
onTimeout: root.controlWindow.visible = true
|
2013-05-29 08:58:38 +00:00
|
|
|
}
|
2013-03-08 15:44:52 +00:00
|
|
|
}
|