-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.qml
738 lines (665 loc) · 22.4 KB
/
main.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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
import QtQuick 2.15
import CustomControls 1.0
import QtQuick.Window 2.15
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.5
import "./"
ApplicationWindow {
width: 1920
height: 960
visible: true
title: qsTr("Car DashBoard")
color: "#1E1E1E"
visibility: "FullScreen"
property int nextSpeed: 60
function generateRandom(maxLimit = 70){
let rand = Math.random() * maxLimit;
rand = Math.floor(rand);
return rand;
}
function speedColor(value){
if(value < 60 ){
return "green"
} else if(value > 60 && value < 150){
return "yellow"
}else{
return "Red"
}
}
Timer {
interval: 500
running: true
repeat: true
onTriggered:{
currentTime.text = Qt.formatDateTime(new Date(), "hh:mm")
}
}
Timer{
repeat: true
interval: 3000
running: true
onTriggered: {
nextSpeed = generateRandom()
}
}
Shortcut {
sequence: "Ctrl+Q"
context: Qt.ApplicationShortcut
onActivated: Qt.quit()
}
Image {
id: dashboard
width: parent.width
height: parent.height
anchors.centerIn: parent
source: "qrc:/assets/Dashboard.svg"
/*
Top Bar Of Screen
*/
Image {
id: topBar
width: 1357
source: "qrc:/assets/Vector 70.svg"
anchors{
top: parent.top
topMargin: 26.50
horizontalCenter: parent.horizontalCenter
}
Image {
id: headLight
property bool indicator: false
width: 42.5
height: 38.25
anchors{
top: parent.top
topMargin: 25
leftMargin: 230
left: parent.left
}
source: indicator ? "qrc:/assets/Low beam headlights.svg" : "qrc:/assets/Low_beam_headlights_white.svg"
Behavior on indicator { NumberAnimation { duration: 300 }}
MouseArea{
anchors.fill: parent
onClicked: {
headLight.indicator = !headLight.indicator
}
}
}
Label{
id: currentTime
text: Qt.formatDateTime(new Date(), "hh:mm")
font.pixelSize: 32
font.family: "Inter"
font.bold: Font.DemiBold
color: "#FFFFFF"
anchors.top: parent.top
anchors.topMargin: 25
anchors.horizontalCenter: parent.horizontalCenter
}
Label{
id: currentDate
text: Qt.formatDateTime(new Date(), "dd/MM/yyyy")
font.pixelSize: 32
font.family: "Inter"
font.bold: Font.DemiBold
color: "#FFFFFF"
anchors.right: parent.right
anchors.rightMargin: 230
anchors.top: parent.top
anchors.topMargin: 25
}
}
/*
Speed Label
*/
// Label{
// id:speedLabel
// text: "68"
// font.pixelSize: 134
// font.family: "Inter"
// color: "#01E6DE"
// font.bold: Font.DemiBold
// anchors.top: parent.top
// anchors.topMargin:Math.floor(parent.height * 0.35)
// anchors.horizontalCenter: parent.horizontalCenter
// }
Gauge {
id: speedLabel
width: 450
height: 450
property bool accelerating
value: accelerating ? maximumValue : 0
maximumValue: 250
anchors.top: parent.top
anchors.topMargin:Math.floor(parent.height * 0.25)
anchors.horizontalCenter: parent.horizontalCenter
Component.onCompleted: forceActiveFocus()
Behavior on value { NumberAnimation { duration: 1000 }}
Keys.onSpacePressed: accelerating = true
Keys.onReleased: {
if (event.key === Qt.Key_Space) {
accelerating = false;
event.accepted = true;
}else if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
radialBar.accelerating = false;
event.accepted = true;
}
}
Keys.onEnterPressed: radialBar.accelerating = true
Keys.onReturnPressed: radialBar.accelerating = true
}
// Label{
// text: "MPH"
// font.pixelSize: 46
// font.family: "Inter"
// color: "#01E6DE"
// font.bold: Font.Normal
// anchors.top:speedLabel.bottom
// anchors.horizontalCenter: parent.horizontalCenter
// }
/*
Speed Limit Label
*/
Rectangle{
id:speedLimit
width: 130
height: 130
radius: height/2
color: "#D9D9D9"
border.color: speedColor(maxSpeedlabel.text)
border.width: 10
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 50
Label{
id:maxSpeedlabel
text: getRandomInt(150, speedLabel.maximumValue).toFixed(0)
font.pixelSize: 45
font.family: "Inter"
font.bold: Font.Bold
color: "#01E6DE"
anchors.centerIn: parent
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
}
}
Image {
anchors{
bottom: car.top
bottomMargin: 30
horizontalCenter:car.horizontalCenter
}
source: "qrc:/assets/Model 3.png"
}
Image {
id:car
anchors{
bottom: speedLimit.top
bottomMargin: 30
horizontalCenter:speedLimit.horizontalCenter
}
source: "qrc:/assets/Car.svg"
}
// IMGonline.com.ua ==> Compress Image With
/*
Left Road
*/
Image {
id: leftRoad
width: 127
height: 397
anchors{
left: speedLimit.left
leftMargin: 100
bottom: parent.bottom
bottomMargin: 26.50
}
source: "qrc:/assets/Vector 2.svg"
}
RowLayout{
spacing: 20
anchors{
left: parent.left
leftMargin: 250
bottom: parent.bottom
bottomMargin: 26.50 + 65
}
RowLayout{
spacing: 3
Label{
text: "100.6"
font.pixelSize: 32
font.family: "Inter"
font.bold: Font.Normal
font.capitalization: Font.AllUppercase
color: "#FFFFFF"
}
Label{
text: "°F"
font.pixelSize: 32
font.family: "Inter"
font.bold: Font.Normal
font.capitalization: Font.AllUppercase
opacity: 0.2
color: "#FFFFFF"
}
}
RowLayout{
spacing: 1
Layout.topMargin: 10
Rectangle{
width: 20
height: 15
color: speedLabel.value.toFixed(0) > 31.25 ? speedLabel.speedColor : "#01E6DC"
}
Rectangle{
width: 20
height: 15
color: speedLabel.value.toFixed(0) > 62.5 ? speedLabel.speedColor : "#01E6DC"
}
Rectangle{
width: 20
height: 15
color: speedLabel.value.toFixed(0) > 93.75 ? speedLabel.speedColor : "#01E6DC"
}
Rectangle{
width: 20
height: 15
color: speedLabel.value.toFixed(0) > 125.25 ? speedLabel.speedColor : "#01E6DC"
}
Rectangle{
width: 20
height: 15
color: speedLabel.value.toFixed(0) > 156.5 ? speedLabel.speedColor : "#01E6DC"
}
Rectangle{
width: 20
height: 15
color: speedLabel.value.toFixed(0) > 187.75 ? speedLabel.speedColor : "#01E6DC"
}
Rectangle{
width: 20
height: 15
color: speedLabel.value.toFixed(0) > 219 ? speedLabel.speedColor : "#01E6DC"
}
}
Label{
text: speedLabel.value.toFixed(0) + " MPH "
font.pixelSize: 32
font.family: "Inter"
font.bold: Font.Normal
font.capitalization: Font.AllUppercase
color: "#FFFFFF"
}
}
/*
Right Road
*/
Image {
id: rightRoad
width: 127
height: 397
anchors{
right: speedLimit.right
rightMargin: 100
bottom: parent.bottom
bottomMargin: 26.50
}
source: "qrc:/assets/Vector 1.svg"
}
/*
Right Side gear
*/
RowLayout{
spacing: 20
anchors{
right: parent.right
rightMargin: 350
bottom: parent.bottom
bottomMargin: 26.50 + 65
}
Label{
text: "Ready"
font.pixelSize: 32
font.family: "Inter"
font.bold: Font.Normal
font.capitalization: Font.AllUppercase
color: "#32D74B"
}
Label{
text: "P"
font.pixelSize: 32
font.family: "Inter"
font.bold: Font.Normal
font.capitalization: Font.AllUppercase
color: "#FFFFFF"
}
Label{
text: "R"
font.pixelSize: 32
font.family: "Inter"
font.bold: Font.Normal
font.capitalization: Font.AllUppercase
opacity: 0.2
color: "#FFFFFF"
}
Label{
text: "N"
font.pixelSize: 32
font.family: "Inter"
font.bold: Font.Normal
font.capitalization: Font.AllUppercase
opacity: 0.2
color: "#FFFFFF"
}
Label{
text: "D"
font.pixelSize: 32
font.family: "Inter"
font.bold: Font.Normal
font.capitalization: Font.AllUppercase
opacity: 0.2
color: "#FFFFFF"
}
}
/*Left Side Icons*/
Image {
id:forthLeftIndicator
property bool parkingLightOn: true
width: 72
height: 62
anchors{
left: parent.left
leftMargin: 175
bottom: thirdLeftIndicator.top
bottomMargin: 25
}
Behavior on parkingLightOn { NumberAnimation { duration: 300 }}
source: parkingLightOn ? "qrc:/assets/Parking lights.svg" : "qrc:/assets/Parking_lights_white.svg"
MouseArea{
anchors.fill: parent
onClicked: {
forthLeftIndicator.parkingLightOn = !forthLeftIndicator.parkingLightOn
}
}
}
Image {
id:thirdLeftIndicator
property bool lightOn: true
width: 52
height: 70.2
anchors{
left: parent.left
leftMargin: 145
bottom: secondLeftIndicator.top
bottomMargin: 25
}
source: lightOn ? "qrc:/assets/Lights.svg" : "qrc:/assets/Light_White.svg"
Behavior on lightOn { NumberAnimation { duration: 300 }}
MouseArea{
anchors.fill: parent
onClicked: {
thirdLeftIndicator.lightOn = !thirdLeftIndicator.lightOn
}
}
}
Image {
id:secondLeftIndicator
property bool headLightOn: true
width: 51
height: 51
anchors{
left: parent.left
leftMargin: 125
bottom: firstLeftIndicator.top
bottomMargin: 30
}
Behavior on headLightOn { NumberAnimation { duration: 300 }}
source:headLightOn ? "qrc:/assets/Low beam headlights.svg" : "qrc:/assets/Low_beam_headlights_white.svg"
MouseArea{
anchors.fill: parent
onClicked: {
secondLeftIndicator.headLightOn = !secondLeftIndicator.headLightOn
}
}
}
Image {
id:firstLeftIndicator
property bool rareLightOn: false
width: 51
height: 51
anchors{
left: parent.left
leftMargin: 100
verticalCenter: speedLabel.verticalCenter
}
source: rareLightOn ? "qrc:/assets/Rare_fog_lights_red.svg" : "qrc:/assets/Rare fog lights.svg"
Behavior on rareLightOn { NumberAnimation { duration: 300 }}
MouseArea{
anchors.fill: parent
onClicked: {
firstLeftIndicator.rareLightOn = !firstLeftIndicator.rareLightOn
}
}
}
/*Right Side Icons*/
Image {
id:forthRightIndicator
property bool indicator: true
width: 56.83
height: 36.17
anchors{
right: parent.right
rightMargin: 195
bottom: thirdRightIndicator.top
bottomMargin: 50
}
source: indicator ? "qrc:/assets/FourthRightIcon.svg" : "qrc:/assets/FourthRightIcon_red.svg"
Behavior on indicator { NumberAnimation { duration: 300 }}
MouseArea{
anchors.fill: parent
onClicked: {
forthRightIndicator.indicator = !forthRightIndicator.indicator
}
}
}
Image {
id:thirdRightIndicator
property bool indicator: true
width: 56.83
height: 36.17
anchors{
right: parent.right
rightMargin: 155
bottom: secondRightIndicator.top
bottomMargin: 50
}
source: indicator ? "qrc:/assets/thirdRightIcon.svg" : "qrc:/assets/thirdRightIcon_red.svg"
Behavior on indicator { NumberAnimation { duration: 300 }}
MouseArea{
anchors.fill: parent
onClicked: {
thirdRightIndicator.indicator = !thirdRightIndicator.indicator
}
}
}
Image {
id:secondRightIndicator
property bool indicator: true
width: 56.83
height: 36.17
anchors{
right: parent.right
rightMargin: 125
bottom: firstRightIndicator.top
bottomMargin: 50
}
source: indicator ? "qrc:/assets/SecondRightIcon.svg" : "qrc:/assets/SecondRightIcon_red.svg"
Behavior on indicator { NumberAnimation { duration: 300 }}
MouseArea{
anchors.fill: parent
onClicked: {
secondRightIndicator.indicator = !secondRightIndicator.indicator
}
}
}
Image {
id:firstRightIndicator
property bool sheetBelt: true
width: 36
height: 45
anchors{
right: parent.right
rightMargin: 100
verticalCenter: speedLabel.verticalCenter
}
source: sheetBelt ? "qrc:/assets/FirstRightIcon.svg" : "qrc:/assets/FirstRightIcon_grey.svg"
Behavior on sheetBelt { NumberAnimation { duration: 300 }}
MouseArea{
anchors.fill: parent
onClicked: {
firstRightIndicator.sheetBelt = !firstRightIndicator.sheetBelt
}
}
}
// Progress Bar
RadialBar {
id:radialBar
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: parent.width / 6
}
width: 338
height: 338
penStyle: Qt.RoundCap
dialType: RadialBar.NoDial
progressColor: "#01E4E0"
backgroundColor: "transparent"
dialWidth: 17
startAngle: 270
spanAngle: 3.6 * value
minValue: 0
maxValue: 100
value: accelerating ? maxValue : 65
textFont {
family: "inter"
italic: false
bold: Font.Medium
pixelSize: 60
}
showText: false
suffixText: ""
textColor: "#FFFFFF"
property bool accelerating
Behavior on value { NumberAnimation { duration: 1000 }}
ColumnLayout{
anchors.centerIn: parent
Label{
text: radialBar.value.toFixed(0) + "%"
font.pixelSize: 65
font.family: "Inter"
font.bold: Font.Normal
color: "#FFFFFF"
Layout.alignment: Qt.AlignHCenter
}
Label{
text: "Battery charge"
font.pixelSize: 28
font.family: "Inter"
font.bold: Font.Normal
opacity: 0.8
color: "#FFFFFF"
Layout.alignment: Qt.AlignHCenter
}
}
}
ColumnLayout{
spacing: 40
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: parent.width / 6
}
RowLayout{
spacing: 30
Image {
width: 72
height: 50
source: "qrc:/assets/road.svg"
}
ColumnLayout{
Label{
text: "188 KM"
font.pixelSize: 30
font.family: "Inter"
font.bold: Font.Normal
opacity: 0.8
color: "#FFFFFF"
}
Label{
text: "Distance"
font.pixelSize: 20
font.family: "Inter"
font.bold: Font.Normal
opacity: 0.8
color: "#FFFFFF"
}
}
}
RowLayout{
spacing: 30
Image {
width: 72
height: 78
source: "qrc:/assets/fuel.svg"
}
ColumnLayout{
Label{
text: "34 mpg"
font.pixelSize: 30
font.family: "Inter"
font.bold: Font.Normal
opacity: 0.8
color: "#FFFFFF"
}
Label{
text: "Avg. Fuel Usage"
font.pixelSize: 20
font.family: "Inter"
font.bold: Font.Normal
opacity: 0.8
color: "#FFFFFF"
}
}
}
RowLayout{
spacing: 30
Image {
width: 72
height: 72
source: "qrc:/assets/speedometer.svg"
}
ColumnLayout{
Label{
text: "78 mph"
font.pixelSize: 30
font.family: "Inter"
font.bold: Font.Normal
opacity: 0.8
color: "#FFFFFF"
}
Label{
text: "Avg. Speed"
font.pixelSize: 20
font.family: "Inter"
font.bold: Font.Normal
opacity: 0.8
color: "#FFFFFF"
}
}
}
}
}
}