1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://www.qt.io
**
** This file is part of Qt Enterprise Embedded.
**
** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://www.qt.io
**
****************************************************************************/
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Enterprise.VirtualKeyboard 1.2
import com.qtcompany.B2QtLauncher 1.0
Window {
id: window
visible: true
width: qpa_platform == "wayland" ? 800 : Screen.desktopAvailableWidth
height: qpa_platform == "wayland" ? 600 : Screen.desktopAvailableHeight
color: "white"
property color qtgreen: '#80c342'
Item {
id: root
anchors.centerIn: window.contentItem
property bool portraitMode: Screen.desktopAvailableHeight > Screen.desktopAvailableWidth ? true : false
rotation: portraitMode ? 90 : 0
width: portraitMode ? window.height : window.width
height: portraitMode ? window.width : window.height
property int stateDelay: 400;
property int bootDelay: 1000;
LauncherApplicationsModel {
id: applicationsModel
onReady: {
engine.markApplicationsModelReady();
}
Component.onCompleted: {
//Set the directory to parse for apps
initialize(applicationSettings.appsRoot);
}
}
LauncherEngine {
id: engine
bootAnimationEnabled: applicationSettings.isBootAnimationEnabled
fpsEnabled: applicationSettings.isShowFPSEnabled
}
states: [
State {
name: "booting"
PropertyChanges { target: appGrid; opacity: 0 }
PropertyChanges { target: splashScreen; opacity: 0 }
PropertyChanges { target: url; opacity: 0 }
},
State {
name: "running"
PropertyChanges { target: appGrid; opacity: 1 }
PropertyChanges { target: applicationLoader; opacity: 0 }
PropertyChanges { target: splashScreen; opacity: 0 }
},
State {
name: "app-launching"
PropertyChanges { target: appGrid; opacity: 0 }
PropertyChanges { target: splashScreen; opacity: 1 }
},
State {
name: "app-running"
PropertyChanges { target: applicationLoader; opacity: 1 }
PropertyChanges { target: appGrid; opacity: 0 }
PropertyChanges { target: splashScreen; opacity: 0 }
PropertyChanges { target: url; opacity: 0 }
},
State {
name: "app-closing"
PropertyChanges { target: applicationLoader; opacity: 0 }
PropertyChanges { target: appGrid; opacity: 0 }
PropertyChanges { target: splashScreen; opacity: 0 }
}
]
transitions: [
Transition {
from: "booting"
to: "running"
SequentialAnimation {
ParallelAnimation {
NumberAnimation { target: appGrid; property: "opacity"; duration: root.bootDelay; easing.type: Easing.InOutQuad }
}
ScriptAction { script: bootScreenLoader.sourceComponent = undefined }
}
},
Transition {
NumberAnimation { property: "opacity"; duration: root.stateDelay }
},
Transition {
from: "running"
to: "app-launching"
SequentialAnimation {
NumberAnimation { property: "opacity"; duration: root.stateDelay }
PauseAnimation { duration: 500 }
ScriptAction { script: {
applicationLoader.source = engine.applicationMain;
}
}
}
},
Transition {
from: "app-launching"
to: "running"
SequentialAnimation {
NumberAnimation { target: appGrid; property: "opacity"; duration: root.stateDelay }
ScriptAction { script: {
engine.closeApplication();
applicationLoader.source = "";
}
}
}
},
Transition {
from: "app-launching"
to: "app-running"
NumberAnimation { property: "opacity"; duration: root.stateDelay }
},
Transition {
from: "app-running"
to: "app-closing"
SequentialAnimation {
ParallelAnimation {
NumberAnimation { target: appGrid; property: "opacity"; duration: root.stateDelay }
NumberAnimation { target: applicationLoader; property: "opacity"; duration: root.stateDelay }
NumberAnimation { target: applicationCloseButton; property: "opacity"; duration: root.stateDelay}
}
NumberAnimation { target: applicationLoader; property: "opacity"; duration: root.stateDelay }
ScriptAction { script: {
engine.closeApplication();
applicationLoader.source = "";
}
}
}
}
]
state: engine.state
// onStateChanged: print("---state: " + engine.state);
LaunchScreen {
id: appGrid
visible: opacity > 0
anchors.fill: parent
}
Loader {
id: bootScreenLoader
visible: opacity > 0
anchors.fill: parent
sourceComponent: BootScreen {}
}
Timer {
id: failedAppLaunchTrigger;
interval: 500;
running: false
repeat: false
onTriggered: {
engine.closeApplication()
}
}
Loader {
id: applicationLoader
opacity: 0;
visible: opacity > 0
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: inputPanel.top
asynchronous: false;
onStatusChanged: {
// switch (status) {
// case Loader.Null: print("applicationLoader status: Null"); break;
// case Loader.Ready: print("applicationLoader status: Ready"); break;
// case Loader.Error: print("applicationLoader status: Error"); break;
// case Loader.Loading: print("applicationLoader status: Loading"); break;
// default: print("applicationLoader: unknown status: " + status); break;
// }
if (status == Loader.Error) {
// print("applicationLoader: app failed, reverting to 'running' state");
failedAppLaunchTrigger.running = true;
}
}
onLoaded: {
engine.state = "app-running";
}
Rectangle {
id: applicationCloseButton;
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: parent.width / 4
y: -height / 2;
width: closeLabel.width + engine.centimeter() * 2
height: engine.fontSize() * 3;
radius: height / 2;
gradient: Gradient {
GradientStop { position: 0.5; color: "gray" }
GradientStop { position: 1; color: "black"; }
}
// border.color: "gray"
Text {
id: closeLabel
color: "white"
text: "Close"
anchors.centerIn: parent
anchors.verticalCenterOffset: parent.height / 4;
font.pixelSize: engine.fontSize();
}
enabled: engine.state == "app-running"
MouseArea {
anchors.fill: parent
onClicked: {
engine.state = "app-closing"
}
}
z: 1
}
}
InputPanel {
id: inputPanel
z: 99
y: root.height
anchors.left: root.left
anchors.right: root.right
states: State {
name: "visible"
when: Qt.inputMethod.visible
PropertyChanges {
target: inputPanel
y: root.height - inputPanel.height
}
}
transitions: Transition {
from: ""
to: "visible"
reversible: true
ParallelAnimation {
NumberAnimation {
properties: "y"
duration: 250
easing.type: Easing.InOutQuad
}
}
}
}
Item {
id: splashScreen
visible: opacity > 0
anchors.fill: parent
Text {
id: splashLabel
color: "white"
text: "Loading..."
anchors.centerIn: parent;
anchors.verticalCenterOffset: -height
font.pixelSize: engine.titleFontSize()
}
Image {
source: "images/codeless.png"
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom;
anchors.margins: parent.height * 0.1;
}
}
Item {
id: fps
opacity: engine.fpsEnabled ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 500 } }
anchors.bottom: parent.bottom;
anchors.left: parent.left;
width: fpsLabel.width
height: fpsLabel.height
Rectangle {
color: "black"
opacity: 0.5
anchors.fill: fpsLabel
}
Text {
id: fpsLabel;
color: "white"
text: "FPS: " + engine.fps
font.pixelSize: engine.sensibleButtonSize() * 0.2
}
}
Item {
id: url
anchors.bottom: parent.bottom;
anchors.horizontalCenter: parent.horizontalCenter;
anchors.margins: height/2
width: urlLabel.width
height: urlLabel.height
Text {
id: urlLabel;
text: "http://www.qt.io/qt-for-device-creation"
color: qtgreen
font.pixelSize: engine.sensibleButtonSize() * 0.2
font.bold: true
}
}
}
}
|