Update window example to use QtQuickControls2

Replaces the use of custom made components from the shared directory, with QtQuickControls2 components.

Fixes: QTBUG-90883
Change-Id: I6e659188aa75bfacf8181689f30580783bf280a2
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Oliver Eftevaag 2021-02-09 18:06:54 +01:00
parent a0cb31ba18
commit 454da9f721
4 changed files with 48 additions and 48 deletions

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@ -48,14 +48,14 @@
**
****************************************************************************/
import QtQuick 2.3
import "../shared" as Shared
import QtQuick
import QtQuick.Controls
Column {
id: root
spacing: 8
Shared.Label {
Label {
text: "Total number of screens: " + screenInfo.count
font.bold: true
}
@ -67,7 +67,7 @@ Column {
Repeater {
id: screenInfo
model: Qt.application.screens
Shared.Label {
Label {
required property string name
required property int virtualX
required property int virtualY

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@ -48,8 +48,8 @@
**
****************************************************************************/
import QtQuick 2.3
import "../shared" as Shared
import QtQuick
import QtQuick.Controls
Item {
id: root
@ -80,47 +80,47 @@ Item {
y: spacing
//! [screen]
Shared.Label {
Label {
text: "Screen \"" + Screen.name + "\":"
font.bold: true
}
Item { width: 1; height: 1 } // spacer
Shared.Label { text: "manufacturer" }
Shared.Label { text: Screen.manufacturer ? Screen.manufacturer : "unknown" }
Label { text: "manufacturer" }
Label { text: Screen.manufacturer ? Screen.manufacturer : "unknown" }
Shared.Label { text: "model" }
Shared.Label { text: Screen.model ? Screen.model : "unknown" }
Label { text: "model" }
Label { text: Screen.model ? Screen.model : "unknown" }
Shared.Label { text: "serial number" }
Shared.Label { text: Screen.serialNumber ? Screen.serialNumber : "unknown" }
Label { text: "serial number" }
Label { text: Screen.serialNumber ? Screen.serialNumber : "unknown" }
Shared.Label { text: "dimensions" }
Shared.Label { text: Screen.width + "x" + Screen.height }
Label { text: "dimensions" }
Label { text: Screen.width + "x" + Screen.height }
Shared.Label { text: "pixel density" }
Shared.Label { text: Screen.pixelDensity.toFixed(2) + " dots/mm (" + (Screen.pixelDensity * 25.4).toFixed(2) + " dots/inch)" }
Label { text: "pixel density" }
Label { text: Screen.pixelDensity.toFixed(2) + " dots/mm (" + (Screen.pixelDensity * 25.4).toFixed(2) + " dots/inch)" }
Shared.Label { text: "logical pixel density" }
Shared.Label { text: Screen.logicalPixelDensity.toFixed(2) + " dots/mm (" + (Screen.logicalPixelDensity * 25.4).toFixed(2) + " dots/inch)" }
Label { text: "logical pixel density" }
Label { text: Screen.logicalPixelDensity.toFixed(2) + " dots/mm (" + (Screen.logicalPixelDensity * 25.4).toFixed(2) + " dots/inch)" }
Shared.Label { text: "device pixel ratio" }
Shared.Label { text: Screen.devicePixelRatio.toFixed(2) }
Label { text: "device pixel ratio" }
Label { text: Screen.devicePixelRatio.toFixed(2) }
Shared.Label { text: "available virtual desktop" }
Shared.Label { text: Screen.desktopAvailableWidth + "x" + Screen.desktopAvailableHeight }
Label { text: "available virtual desktop" }
Label { text: Screen.desktopAvailableWidth + "x" + Screen.desktopAvailableHeight }
Shared.Label { text: "position in virtual desktop" }
Shared.Label { text: Screen.virtualX + ", " + Screen.virtualY }
Label { text: "position in virtual desktop" }
Label { text: Screen.virtualX + ", " + Screen.virtualY }
Shared.Label { text: "orientation" }
Shared.Label { text: root.orientationToString(Screen.orientation) + " (" + Screen.orientation + ")" }
Label { text: "orientation" }
Label { text: root.orientationToString(Screen.orientation) + " (" + Screen.orientation + ")" }
Shared.Label { text: "primary orientation" }
Shared.Label { text: root.orientationToString(Screen.primaryOrientation) + " (" + Screen.primaryOrientation + ")" }
Label { text: "primary orientation" }
Label { text: root.orientationToString(Screen.primaryOrientation) + " (" + Screen.primaryOrientation + ")" }
//! [screen]
Shared.Label { text: "10mm rectangle" }
Label { text: "10mm rectangle" }
Rectangle {
color: "red"
width: Screen.pixelDensity * 10

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@ -48,7 +48,7 @@
**
****************************************************************************/
import QtQuick 2.0
import QtQuick
//! [splash-properties]
Window {

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@ -48,8 +48,8 @@
**
****************************************************************************/
import QtQuick 2.0
import "../shared" as Shared
import QtQuick
import QtQuick.Controls
QtObject {
id: root
@ -67,20 +67,20 @@ QtObject {
anchors.margins: root.defaultSpacing
spacing: root.defaultSpacing
property real cellWidth: col.width / 3 - spacing
Shared.Label { text: "Control the second window:" }
Label { text: "Control the second window:" }
Grid {
id: grid
columns: 3
spacing: root.defaultSpacing
width: parent.width
Shared.Button {
Button {
id: showButton
width: col.cellWidth
text: root.testWindow.visible ? "Hide" : "Show"
onClicked: root.testWindow.visible = !root.testWindow.visible
}
//! [windowedCheckbox]
Shared.CheckBox {
CheckBox {
text: "Windowed"
height: showButton.height
width: col.cellWidth
@ -88,26 +88,26 @@ QtObject {
onClicked: root.testWindow.visibility = Window.Windowed
}
//! [windowedCheckbox]
Shared.CheckBox {
CheckBox {
height: showButton.height
width: col.cellWidth
text: "Full Screen"
Binding on checked { value: root.testWindow.visibility === Window.FullScreen }
onClicked: root.testWindow.visibility = Window.FullScreen
}
Shared.Button {
Button {
id: autoButton
width: col.cellWidth
text: "Automatic"
onClicked: root.testWindow.visibility = Window.AutomaticVisibility
}
Shared.CheckBox {
CheckBox {
height: autoButton.height
text: "Minimized"
Binding on checked { value: root.testWindow.visibility === Window.Minimized }
onClicked: root.testWindow.visibility = Window.Minimized
}
Shared.CheckBox {
CheckBox {
height: autoButton.height
text: "Maximized"
Binding on checked { value: root.testWindow.visibility === Window.Maximized }
@ -131,7 +131,7 @@ QtObject {
}
return "unknown";
}
Shared.Label {
Label {
id: visibilityLabel
text: "second window is " + (root.testWindow.visible ? "visible" : "invisible") +
" and has visibility " + parent.visibilityToString(root.testWindow.visibility)
@ -160,7 +160,7 @@ QtObject {
Rectangle {
anchors.fill: parent
anchors.margins: root.defaultSpacing
Shared.Label {
Label {
anchors.centerIn: parent
text: "Second Window"
}
@ -168,7 +168,7 @@ QtObject {
anchors.fill: parent
onClicked: root.testWindow.color = "#e0c31e"
}
Shared.Button {
Button {
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: root.defaultSpacing
@ -181,7 +181,7 @@ QtObject {
root.testWindow.visibility = Window.FullScreen
}
}
Shared.Button {
Button {
anchors.left: parent.left
anchors.top: parent.top
anchors.margins: root.defaultSpacing