Debian Codegraph @

tests/manual/quickwindow-switch/main.qml

raw
1 // Copyright (C) 2020 The Qt Company.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 import QtQuick 2.2
5 import QtQuick.Window 2.12 as Win
6 import Qt3D.Core 2.0
7 import Qt3D.Render 2.0
8 import Qt3D.Input 2.0
9 import Qt3D.Extras 2.0
10
11 import QtQuick.Scene3D 2.0
12
13 Win.Window {
14 id: win
15 width: 300
16 height: 350
17 visible: true
18 x: Win.Screen.width / 2 - width / 2
19 y: Win.Screen.height / 2 - height / 2
20 Item {
21 id: mioitem
22 width: 300
23 height: 300
24 Scene3D {
25 id: scene3d
26 anchors.fill: parent
27 Entity {
28 id: sceneRoot
29
30 Camera {
31 id: camera
32 projectionType: CameraLens.PerspectiveProjection
33 fieldOfView: 45
34 aspectRatio: 16/9
35 nearPlane : 0.1
36 farPlane : 1000.0
37 position: Qt.vector3d( 0.0, 0.0, -40.0 )
38 upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
39 viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
40 }
41
42 OrbitCameraController {
43 camera: camera
44 }
45
46 components: [
47 RenderSettings {
48 activeFrameGraph: ForwardRenderer {
49 clearColor: Qt.rgba(0, 0.5, 1, 1)
50 camera: camera
51 }
52 },
53 // Event Source will be set by the Qt3DQuickWindow
54 InputSettings { }
55 ]
56
57 PhongMaterial {
58 id: material
59 }
60
61 TorusMesh {
62 id: torusMesh
63 radius: 5
64 minorRadius: 1
65 rings: 100
66 slices: 20
67 }
68
69 Transform {
70 id: torusTransform
71 scale3D: Qt.vector3d(1.5, 1, 0.5)
72 rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
73 }
74
75 Entity {
76 id: torusEntity
77 components: [ torusMesh, material, torusTransform ]
78 }
79
80 SphereMesh {
81 id: sphereMesh
82 radius: 3
83 }
84
85 Transform {
86 id: sphereTransform
87 property real userAngle: 0.0
88 matrix: {
89 var m = Qt.matrix4x4();
90 m.rotate(userAngle, Qt.vector3d(0, 1, 0));
91 m.translate(Qt.vector3d(20, 0, 0));
92 return m;
93 }
94 }
95
96 NumberAnimation {
97 target: sphereTransform
98 property: "userAngle"
99 duration: 10000
100 from: 0
101 to: 360
102
103 loops: Animation.Infinite
104 running: true
105 }
106
107 Entity {
108 id: sphereEntity
109 components: [ sphereMesh, material, sphereTransform ]
110 }
111 }
112 }
113 }
114 Rectangle {
115 height: 50
116 anchors.left: parent.left
117 anchors.right: parent.right
118 anchors.bottom: parent.bottom
119 color: "yellow"
120 MouseArea {
121 anchors.fill: parent
122 z: 5
123 onClicked: {
124 win.screen = (win.screen === Qt.application.screens[0] ? Qt.application.screens[1] : Qt.application.screens[0])
125 }
126 }
127 Text {
128 anchors.centerIn: parent
129 minimumPointSize: 12
130 fontSizeMode: Text.Fit
131 text: "Move to the other screen"
132 }
133 }
134 }