-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.qml
333 lines (278 loc) · 8.85 KB
/
app.qml
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
import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.10
import Qb 1.0
import Qb.Core 1.0
import Qb.Android 1.0
QbApp{
id: objMainAppUi
changeWindowPosition: true;
minimumHeight: 500
minimumWidth: 450
property int gridWidth: 100
property int gridHeight: 100
property int gridSpacing: 10
property string dataDir: ""
property bool androidFullScreen: false;
property bool showTopBar: false;
property bool showLoadingScreen: objMainStack.busy;
Keys.onReleased: {
if (event.key === Qt.Key_Escape || event.key === Qt.Key_Back)
{
if(Qt.inputMethod.visible)
{
Qt.inputMethod.hide();
objMainStack.currentItem.forceActiveFocus();
objMainAppUi.resetAndroidFullScreenState();
}
else
{
if(objMainStack.depth === 1)
{
if(objExitDialog.visible)
{
objExitDialog.close();
}
else
{
objExitDialog.open();
}
}
else
{
objMainStack.pop();
}
}
event.accepted = true;
}
}
QbSettings{
id: objSettings
name: "vLibQB"
property alias windowWidth: objMainAppUi.windowWidth
property alias windowHeight: objMainAppUi.windowHeight
property alias windowX: objMainAppUi.windowX
property alias windowY: objMainAppUi.windowY
property alias gridWidth: objMainAppUi.gridWidth
property alias gridHeight: objMainAppUi.gridHeight
property alias gridSpacing: objMainAppUi.gridSpacing
property alias dataDir: objMainAppUi.dataDir
}
QbMetaTheme{
id: objMetaTheme
}
/*Desktop MenuBar*/
Loader{
id: objMenuBarLoader
Component.onCompleted: {
if (!QbCoreOne.isMobilePlatform() && !QbCoreOne.isWebglPlatofrm() && !QbCoreOne.isBuiltForRaspberryPi())
{
objMenuBarLoader.source = objMainAppUi.absoluteURL("/ui/desktop/DesktopMenuBar.qml");
}
}
}
/*Desktop MenuBar End*/
/** Android related things **/
QbAndroidExtras{
id: objAndroidExtras
}
function dpscale(num){
return QbCoreOne.scale(num);
}
function showAndroidStatusBar()
{
if(Qt.platform.os !== "android") return;
objMainAppUi.showTopBar = true;
objAndroidExtras.showSystemUi();
}
function hideAndroidStatusBar()
{
if(Qt.platform.os !== "android") return;
objAndroidExtras.hideSystemUi();
objMainAppUi.showTopBar = false;
}
function enableAndroidFullScreen()
{
if(Qt.platform.os !== "android") return;
objAndroidExtras.enableFullScreen();
objMainAppUi.showTopBar = false;
}
function disableAndroidFullScreen()
{
if(Qt.platform.os !== "android") return;
objAndroidExtras.disableFullScreen();
objMainAppUi.showTopBar = true;
}
function resetAndroidFullScreenState()
{
if(objMainAppUi.androidFullScreen)
{
objMainAppUi.enableAndroidFullScreen();
}
else
{
objMainAppUi.disableAndroidFullScreen();
}
}
/**/
Pane{
anchors.fill: parent
Material.theme: Material.Light
Material.accent: objMetaTheme.accent
Material.foreground: objMetaTheme.foreground
Material.background: objMetaTheme.background
Material.primary: objMetaTheme.primary
topPadding: 0
bottomPadding: 0
rightPadding: 0
leftPadding: 0
StackView{
id: objMainStack
anchors.fill: parent
property string appId: objMainAppUi.appId
}
/* Loading Screen */
Rectangle{
visible: objMainAppUi.showLoadingScreen
anchors.fill: parent
color: objMetaTheme.changeTransparency("black",150)
z: 99999999999
Text{
id: objBusyIndicator
width: 50
height: 50
anchors.centerIn: parent
text: QbFA.icon("fa-spinner")
color: objMetaTheme.textColor(parent.color)
font.pixelSize: 25
font.family: QbFA.family
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
RotationAnimation on rotation {
loops: Animation.Infinite
from: 0
to: 360
direction: RotationAnimation.Clockwise
duration: 1000
}
}
MouseArea{
anchors.fill: parent
preventStealing: true
onClicked: {
}
onDoubleClicked: {
}
onPressed: {
}
}
}
Dialog{
id: objExitDialog
width: Math.min(400,parent.width*0.90)
height: Math.min(300,parent.height*0.90)
x: (parent.width - width)/2.0
y: (parent.height - height)/2.0
modal: true
title: "Quit vLibQB?"
standardButtons: Dialog.Ok | Dialog.Cancel
Label{
id: objExitDialogLabel
anchors.fill: parent
horizontalAlignment: Label.AlignHCenter
verticalAlignment: Label.AlignVCenter
text: "Do you really want to quit?"
wrapMode: Label.WordWrap
Keys.onPressed: {
event.accepted = true;
}
Keys.onReleased: {
event.accepted = true
if (event.key === Qt.Key_Escape || event.key === Qt.Key_Back)
{
objExitDialog.close();
}
}
}
onOpened: {
objExitDialog.forceActiveFocus();
}
onClosed: {
objMainStack.currentItem.forceActiveFocus();
if(Qt.inputMethod.visible)
{
Qt.inputMethod.hide();
}
}
onAccepted: {
objMainAppUi.close();
}
onRejected: {
objMainStack.currentItem.forceActiveFocus();
}
}
}
onWindowReady: {
}
onAppStarted: {
console.log("vLibQB app started.");
QbUtil.addAppObject(objMainAppUi.appId,"mainStack",objMainStack);
QbUtil.addAppObject(objMainAppUi.appId,"mainAppUi",objMainAppUi);
var theme = {};
theme["primary"] = String(Material.color(Material.BlueGrey));
theme["accent"] = String(Material.color(Material.Teal));
theme["secondary"] = String(Material.color(Material.Brown));
theme["error"] = String(Material.color(Material.Red));
theme["background"] = "lightgrey";
theme["foreground"] = "black";
objMetaTheme.setThemeFromJsonData(JSON.stringify(theme));
objMainAppUi.resetAndroidFullScreenState();
if(QbCoreOne.isCurrentDeviceWindows())
{
}
else if(QbCoreOne.isCurrentDeviceLinux())
{
}
else if(QbCoreOne.isCurrentDeviceMac())
{
}
else
{
}
if( QbApplicationBuildNumber<objMainAppUi.getAppManifest()["minQbBuildNumber"])
{
objMainStack.push(objMainAppUi.absoluteURL("/ui/VersionError.qml"))
}
else
{
objMainStack.push(objMainAppUi.absoluteURL("/ui/ContentUi.qml"),
{
"gridWidth": objMainAppUi.gridWidth,
"gridHeight": objMainAppUi.gridHeight,
"gridSpacing": objMainAppUi.gridSpacing,
"dataDir": objMainAppUi.dataDir,
"showSettings": objMainAppUi.dataDir === ""
});
}
}
onAppVisible: {
objMainAppUi.resetAndroidFullScreenState();
}
onAppClosing: {
QbUtil.cleanAppObject(objMainAppUi.appId);
console.log("vLibQB app closing.");
}
/*JS Methods*/
function pushPage(qmlPath){
objMainStack.push(qmlPath,{"appId":objMainAppUi.appId});
}
function pushPageWithData(qmlPath,data){
data["appId"] = objMainAppUi.appId;
objMainStack.push(qmlPath,data);
}
function popPage(){
objMainStack.pop();
}
/*End JS Methods*/
}