-
Notifications
You must be signed in to change notification settings - Fork 15
/
TimerWindow.qml
1145 lines (975 loc) · 39.7 KB
/
TimerWindow.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
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import QtQuick 1.1
import "Storage.js" as Storage
import "Czas.js" as Czas
Rectangle {
id: timer_root
property alias timerer: timer_root
property alias ttext: timerdigital.text
property alias timerstate: timer_root.state
property alias favlistmodel: favlistmodel
property alias favlistview: favlistview
property alias repeat_alarm_setting: settings_timer.repeat_alarm_setting
/* ================== Counting Time ================= */
function timerCount()
{
if (timerhandsec.rotation > 0) {
timerhandsec.rotation = timerhandsec.rotation - 6
}
else if (timerhandsec.rotation === 0 && timerhandmin.rotation > 0) {
timerhandsec.rotation = 354;
timerhandmin.rotation = timerhandmin.rotation - 6;
}
else if (timerhandmin.rotation === 0 && timerhandhour.rotation > 0) {
timerhandsec.rotation = 354;
timerhandmin.rotation = 354;
timerhandhour.rotation = timerhandhour.rotation - 6;
}
else if (timerdigital.text === "00:00:00"){
alarmtimer.start();
counttimer.stop();
trayicon.onTimerStopFromQML()
}
}
/* ================== Time Progress for Unity Launcher Progress Bar ================= */
function timerProgress()
{
var hour = timerdigital.hour
var minute = timerdigital.minute
var second = timerdigital.second
var temphours = Number(timer.tempstarttime.slice(0, 2))
var tempminutes = Number(timer.tempstarttime.slice(3, 5))
var tempsecs = Number(timer.tempstarttime.slice(6))
var temptimeinseconds = temphours * 3600 + tempminutes * 60 + tempsecs
var timeinseconds = Number(Czas.unitsdisplay(hour)*3600) + Number(Czas.unitsdisplay(minute)* 60) + Number(Czas.unitsdisplay(second))
var ratio = timeinseconds/temptimeinseconds
launcher.getTimerProgress(ratio.toFixed(2)) // Show Progress in Unity launcher via python file
}
/* ================== Alarming About Time End ================= */
function timerAlarm()
{
timer_root.state = "Alarm"
notification.somethingFinished("Time's Up!", "Timer " + timer.timername + " (" + timer.tempstarttime + ")" + " finished ","./sounds/timerfinished.wav") // signal from zeegaree.py
launcher.setUrgent("True") // Setting urgent icon in launcher via signal from pomodoro.py
countsincealarm.start()
if (repeat_alarm_setting.isSelected){
alarmrepeater.start()
}
}
/* ================== Reapeat Alarm About Time End If Not Cleared ================= */
function repeatAlarm() {
notification.somethingFinished("Time's Up!", sincealarmpassed.text,"./sounds/timerfinished.wav") // signal from zeegaree.py
launcher.setUrgent("True") // Setting urgent icon in launcher via signal from pomodoro.py
}
/* ================== Counting Time Up Since Alarm Went Off ================= */
function countUpSinceAlarm()
{
var m1 = Number(sincealarmpassed.alarmpassedago.charAt(0))
var m2 = Number(sincealarmpassed.alarmpassedago.charAt(1))
var s1 = Number(sincealarmpassed.alarmpassedago.charAt(3))
var s2 = Number(sincealarmpassed.alarmpassedago.charAt(4))
if (s2 == 9){
s2 = 0;
s1 += 1
if (s1 > 5){
s1 = 0;
m2 += 1;
if (m2 > 9){
m2 = 0;
m1 += 1;
}
}
}
else{
s2 += 1;
}
return sincealarmpassed.alarmpassedago =""+m1 + m2 + "m" + s1 + s2 + "s"
}
/* ======================== Reseting Alarm Notification =============== */
function resetAlarmFlag()
{
alarmtimer.stop();
countsincealarm.stop();
alarmrepeater.stop();
timer.timername = ""
sincealarmpassed.alarmpassedago = "00m00s"
launcher.setUrgent(""); // Setting urgent icon to False (empty string) in launcher via signal from zeegaree.py
trayicon.onTimerStopFromQML()
}
/* ======================== Start Timer =============== */
function startTimer()
{
counttimer.start();
trayicon.onTimerStartFromQML()
if (timerdigital.text === "31:41:59"){
timer_root.state = "PieEgg";
}
}
/* ======================== Stopping Timer =============== */
function stopTimer()
{
counttimer.stop();
timer.timername = ""
launcher.getTimerProgress(0)
trayicon.onTimerStopFromQML()
}
/* ======================== Reseting Timer to 00:00:00 =============== */
function resetTimer()
{
timerhandhour.rotation = 0
timerhandmin.rotation = 0
timerhandsec.rotation = 0
timer.timername = ""
counttimer.stop()
launcher.getTimerProgress(0) // Clear Unity Launcher progress via python file
trayicon.onTimerStopFromQML()
}
/* ======================== Rotation of hands for favourites =============== */
function favhandrotation(start, finish)
{
return Number(favlistmodel.get(favlistview.currentIndex).timeoffav.slice(start, finish)) * 6
}
color: styl.back_color_primary
width: parent.width
height: parent.height
Component.onCompleted: {
Storage.getSettingTimer()
Storage.getFavs(favlistmodel)
console.log("timer completed")
}
Timer {
id: counttimer
interval: 1000
repeat: true
onTriggered: [timerCount(), timerProgress()]
}
Timer {
id: alarmtimer
interval: 100
onTriggered: timerAlarm()
}
Timer {
id: countsincealarm
interval: 1000
repeat: true
onTriggered: countUpSinceAlarm()
}
Timer {
id: alarmrepeater
interval: 30000
repeat: true
onTriggered: repeatAlarm()
}
Pie {
id: pie
}
Item {
id: timer
property string tempstarttime: "" // Temporary Start Time for Unity Launcher Progress
property string timername // Favname when timer ends
width: parent.width
anchors {
top: parent.top
bottom: toolbarbottom1.top
}
ToolbarTop {
id: toolbartop
width: parent.width
anchors {
top: parent.top
right: parent.right
}
toolbarText: "Timer"
CloseButton {
id: closebutton1
anchors {
top: parent.top
topMargin: 5
right: parent.right
rightMargin: 5
}
MouseArea {
anchors.fill: parent
onClicked: {
countsincealarm.running ? resetAlarmFlag() : ""
main_file.state = ""
}
}
}
}
/* ================================== Analog Timer ======================*/
Item {
id: timeranalog
visible: !lite_mode_edit.isSelected
width: Math.min(400, parent.width/2, parent.height/2)
height: lite_mode_edit.isSelected ? 0 : width
x: (parent.width - width)/2
anchors {
top: toolbartop.bottom
topMargin: 20
}
/* =================== Analog Timer Background Image ======================*/
Image {
id: timerback
source: "images/secback.png"
fillMode: Image.PreserveAspectFit
smooth: true
width: parent.width
anchors.centerIn: parent
MouseArea {
id: timerbackmousearea
property real truex: mouseX-timerback.width/2
property real truey: timerback.height/2-mouseY
property real angle: Math.atan2(truex, truey)
property real strictangle: Number(angle * 180 / Math.PI)
property real modulo: strictangle % 6
enabled: !counttimer.running
anchors.fill: parent
onPositionChanged: {
if (timerbackmousearea.angle < 0){
timerhandsec.rotation = (strictangle - modulo) + 360;
}
else {
timerhandsec.rotation = (strictangle - modulo) + 6;
}
}
}
/* =================== Analog Timer Second Hand ======================*/
Image {
id: timerhandsec
source: "images/sechand.png"
fillMode: Image.PreserveAspectFit
smooth: true
rotation: 0
height: timerback.height * 9 / 10
anchors.centerIn: parent
Behavior on rotation {
RotationAnimation { duration: 100; direction: RotationAnimation.Shortest }
}
}
/* =================== Analog Timer Minute Background ======================*/
Item {
id: lightcircle
width: timerhandmin.height
height: width
anchors.centerIn: parent
MouseArea {
id: minmousearea
property real truex: mouseX-width/2
property real truey: height/2-mouseY
property real angle: Math.atan2(truex, truey)
property real strictangle: Number(angle * 180 / Math.PI)
property real modulo: strictangle % 6
enabled: !counttimer.running
anchors.fill: parent
onPositionChanged: if (angle < 0) {
timerhandmin.rotation = strictangle - modulo + 360;
}
else {
timerhandmin.rotation = strictangle - modulo + 6;
}
}
/* =================== Analog Timer Minute Hand ======================*/
Image {
id: timerhandmin
source: "images/minhand.png"
fillMode: Image.PreserveAspectFit
rotation: 0
smooth: true
width: timerhandhour.width
anchors.centerIn: parent
Behavior on rotation {
RotationAnimation { duration: 100; direction: RotationAnimation.Shortest }
}
}
/* =================== Analog Timer Hour Backgroud ======================*/
Image {
id: hourhandbackground
source: "images/hourhandback.png"
fillMode: Image.PreserveAspectFit
smooth: true
width: timerback.width/2.5
anchors.centerIn: parent
MouseArea {
id: hourmousearea
enabled: !counttimer.running
property real truex: mouseX-width/2
property real truey: height/2-mouseY
property real angle: Math.atan2(truex, truey)
property real strictangle: Number(angle * 180 / Math.PI)
property real modulo: strictangle % 6
width: timerhandhour.height
height: width
anchors.centerIn: parent
onPositionChanged: if (angle < 0) {
timerhandhour.rotation = strictangle - modulo + 360;
}
else {
timerhandhour.rotation = strictangle - modulo + 6;
}
}
/* =================== Analog Timer Hour Hand ======================*/
Image {
id: timerhandhour
source: "images/hourhand.png"
fillMode: Image.PreserveAspectFit
smooth: true
height: parent.height * 7.5/10
anchors.centerIn: parent
Behavior on rotation {
RotationAnimation { duration: 100; direction: RotationAnimation.Shortest }
}
}
/* =================== Small Reset Circle ======================*/
Rectangle {
id: smallresetbutton
color: "#eee"
width: timerhandhour.width *3/2
height: width
radius: width/2
anchors.centerIn: timerhandhour
MouseArea {
id: resetredmouse
anchors.fill: parent
hoverEnabled: true
onEntered: smallresetbutton.color = styl.button_back_color_notok/*"#C0292F"*/ // czerwony
onExited: smallresetbutton.color = "#eee"
onClicked: timer_root.resetTimer()
}
}
}
}
}
}
/* ================================== Digital Timer ======================*/
Text {
id: timerdigital
property int hour: Number(timerhandhour.rotation/6)
property int minute: Number(timerhandmin.rotation/6)
property int second: Number(timerhandsec.rotation/6)
color: styl.text_color_primary
x: (parent.width - width)/2
anchors {
top: timeranalog.bottom
topMargin: 10
}
text: Czas.unitsdisplay(hour) + ":" + Czas.unitsdisplay(minute) + ":" + Czas.unitsdisplay(second)
font.pixelSize: lite_mode_edit.isSelected ? Math.min(parent.width/5, parent.height/3) : timeranalog.width/6
}
/*================================ RESET BUTTON ========================== */
Button {
id: reset_button
visible: timerdigital.text != "00:00:00"
buttoncolor: styl.button_back_color_notok
anchors {
verticalCenter: timerdigital.verticalCenter
left: timerdigital.right
leftMargin: 12
}
buttonimage.source: isActive ? "images/reset_eee.png" : "images/reset_3d3d3d.png"
button_ma.onClicked: {
timer_root.resetTimer()
}
}
/* ======================= Start Button ============================= */
StartButton {
id: startbutton1
x: (parent.width - width)/2
anchors {
bottom: parent.bottom
bottomMargin: 40
}
start_button_text:
if (timerdigital.text == "00:00:00" && !counttimer.running) {
return qsTr("Set")
}
else if (timerdigital.text != "00:00:00" && !counttimer.running) {
return qsTr("Start")
}
else {
return qsTr("Stop")
}
color:
if (timerdigital.text == "00:00:00" && !counttimer.running) {
return styl.info_text_color/*"#2980b9"*/ // blue
}
else if (timerdigital.text != "00:00:00" && !counttimer.running) {
return styl.button_back_color_ok/*"#2ecc71"*/ // green
}
else {
return styl.button_back_color_notok/*"#e74c3c"*/ // red
}
start_button_ma.onClicked: {
if (startbutton1.start_button_text == "Set"){
favTimer.state = "SetTimerWindowVisible";
counttimer.stop()
settimerwindow.h1.focus = true
settimerwindow.h1.current_digit = 5 - timerdigital.text.charAt(0)
settimerwindow.h2.current_digit = 9 - timerdigital.text.charAt(1)
settimerwindow.m1.current_digit = 5 - timerdigital.text.charAt(3)
settimerwindow.m2.current_digit = 9 - timerdigital.text.charAt(4)
settimerwindow.s1.current_digit = 5 - timerdigital.text.charAt(6)
settimerwindow.s2.current_digit = 9 - timerdigital.text.charAt(7)
}
else if (startbutton1.start_button_text == "Start") {
timer.tempstarttime = timerdigital.text; // store start time in temporary text
startTimer()
}
else {
stopTimer()
}
}
}
/* ======================= Alarm! ============================= */
Rectangle {
id: alarmrect
color: styl.tooltip_back_color
width: parent.width - 80
height: parent.height - 80
radius: 4
x: 40
y: - parent.height + 20
MouseArea {
anchors.fill: parent
onClicked: {
timer_root.state = "";
resetAlarmFlag()
}
}
Text {
id: alarmtext
color: styl.tooltip_text_color
anchors {
centerIn: parent
verticalCenterOffset: -parent.height/6
}
text: qsTr("Time's Up!")
font {
family: "Ubuntu Light"
pixelSize: parent.width/10
}
}
Text {
id: sincealarmpassed
property string alarmpassedago: "00m00s"
color: styl.tooltip_text_color
width: parent.width - 24
anchors {
top: alarmtext.bottom
topMargin: 20
horizontalCenter: parent.horizontalCenter
}
font {
family: "Ubuntu Light"
pixelSize: parent.width/20
}
text: timer.timername === "" ? "Timer " + "(" + timer.tempstarttime + ")" + " finished " + alarmpassedago + " ago" :
"Timer “" + timer.timername + "” (" + timer.tempstarttime + ")" + " finished " + alarmpassedago + " ago" // Time since timer finished
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
horizontalAlignment: Text.AlignHCenter
}
}
}
Rectangle {
id: overlay
color: "#bb000000"
z: toolbarbottom1.z + 1
width: timer_root.width
height: timer_root.height
scale: 0
MouseArea {
anchors.fill: parent
hoverEnabled: true
preventStealing: true
}
}
/* ================== Setting time of timer ================= */
EditFavWindow {
id: settimerwindow
scale: 0
z: overlay.z + 1
anchors.centerIn: overlay
favname: ""
favname_back.visible: false
fav.visible: false
okmouse {
onClicked: {
var H1 = (5 - h1.current_digit).toString()
var H2 = (9 - h2.current_digit).toString()
var M1 = (5 - m1.current_digit).toString()
var M2 = (9 - m2.current_digit).toString()
var S1 = (5 - s1.current_digit).toString()
var S2 = (9 - s2.current_digit).toString()
timerhandhour.rotation = Number(H1 + H2) * 6
timerhandmin.rotation = Number(M1 + M2) * 6
timerhandsec.rotation = Number(S1 + S2) * 6
favTimer.state = ""
startbutton1.focus = true
}
}
}
/* ================== Adding favorites ================= */
EditFavWindow {
id: addfavwindow
scale: 0
z: overlay.z + 1
anchors.centerIn: overlay
favname: "new favorite"
okmouse {
onClicked: {
var H1 = (5 - h1.current_digit).toString()
var H2 = (9 - h2.current_digit).toString()
var M1 = (5 - m1.current_digit).toString()
var M2 = (9 - m2.current_digit).toString()
var S1 = (5 - s1.current_digit).toString()
var S2 = (9 - s2.current_digit).toString()
var favtime = H1+H2+":"+M1+M2+":"+S1+S2;
var favtimestamp = Qt.formatDateTime(new Date(), "yyMMddhhmmss");
Storage.saveFavs(favname, favtime, favtimestamp)
favlistmodel.append ({"nameoffav": favname, "timeoffav": favtime, "favtimestamp": favtimestamp});
favlistview.positionViewAtEnd();
favTimer.state = "";
timer_root.focus = true
}
}
}
/* ================== Editing favorites ================= */
EditFavWindow {
id: editfavwindow
scale: 0
z: overlay.z + 1
anchors.centerIn: overlay
okmouse {
onClicked: {
var H1 = (5 - h1.current_digit).toString()
var H2 = (9 - h2.current_digit).toString()
var M1 = (5 - m1.current_digit).toString()
var M2 = (9 - m2.current_digit).toString()
var S1 = (5 - s1.current_digit).toString()
var S2 = (9 - s2.current_digit).toString()
var favtimestamp = Qt.formatDateTime(new Date(), "yyMMddhhmmss")
var favtime = H1+H2+":"+M1+M2+":"+S1+S2;
var currentstamp = favlistmodel.get(favlistview.currentIndex).favtimestamp;
var currentname = favlistmodel.get(favlistview.currentIndex).nameoffav;
var currenttime = favlistmodel.get(favlistview.currentIndex).timeoffav;
Storage.updateFavs(favname, favtime, currentstamp)
favlistmodel.set(favlistview.currentIndex, {"nameoffav": favname, "timeoffav": favtime, "favtimestamp": currentstamp});
favTimer.state = ""
timer_root.focus = true
}
}
}
/* ================== Delete confirmation ================= */
ConfirmationWindow {
id: confirmationwindow1
scale: 0
z: overlay.z + 1
anchors.centerIn: overlay
textofnote: "Do you realy want to delete this favourite?"
canceltext: "Cancel"
oktext: "Delete"
okbutton_ma.onClicked: {
var currentstamp = favlistmodel.get(favlistview.currentIndex).favtimestamp;
Storage.deleteFavs(currentstamp)
favlistmodel.remove(favlistview.currentIndex);
favTimer.state = "";
timer_root.focus = true;
}
cancelbutton_ma.onClicked: { // Canceling deleting Favorites from Timer
if (favTimer.state == "ConfirmationVisible") {
favTimer.state = ""
}
}
}
/* ================== Favorites Panel ================= */
Panel {
id: favTimer
Text {
id: favheader
color: styl.text_color_primary
y: 5
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Favorites")
font {family: "Ubuntu Light"; pixelSize: 24}
}
DividerBigHor {
id: divider_big
width: parent.width
anchors {
top: favheader.bottom
topMargin: 6
}
}
Button {
id: newfav
width: parent.width - 10
anchors {
horizontalCenter: parent.horizontalCenter
bottom: favTimer.bottom
bottomMargin: 42
}
buttontext: "New favorite"
MouseArea {
anchors.fill: parent
onClicked: {
favTimer.state = "AddFav"
addfavwindow.fav.forceActiveFocus()
addfavwindow.fav.selectAll()
addfavwindow.h1.current_digit = 5 - timerdigital.text.charAt(0)
addfavwindow.h2.current_digit = 9 - timerdigital.text.charAt(1)
addfavwindow.m1.current_digit = 5 - timerdigital.text.charAt(3)
addfavwindow.m2.current_digit = 9 - timerdigital.text.charAt(4)
addfavwindow.s1.current_digit = 5 - timerdigital.text.charAt(6)
addfavwindow.s2.current_digit = 9 - timerdigital.text.charAt(7)
}
}
}
ListView {
id: favlistview
width: newfav.width + 10
height: parent.height - favheader.height - newfav.height - toolbarbottom1.height - 26
anchors {
top: divider_big.bottom
}
keyNavigationWraps: true
clip: true
delegate:
Item {
id: fav_item
width: parent.width
height: rowrectangle.height + divider_small.height
Behavior on height {
NumberAnimation { duration: 100 }
}
ControlsTimerFav {
id: fav_controls
opacity: 0
anchors.top: parent.top
set_fav_ma.onClicked: {
favlistview.currentIndex = index
timer_root.stopTimer()
timerhandhour.rotation = favhandrotation(0, 2)
timerhandmin.rotation = favhandrotation(3, 5)
timerhandsec.rotation = favhandrotation(6)
timer.timername = favname.text
}
set_and_start_fav_ma.onClicked: {
favlistview.currentIndex = index
timer_root.stopTimer()
timerhandhour.rotation = favhandrotation(0, 2)
timerhandmin.rotation = favhandrotation(3, 5)
timerhandsec.rotation = favhandrotation(6)
timer.tempstarttime = favtime.text
timer.timername = favname.text
startTimer()
}
edit_fav_ma.onClicked: {
favlistview.currentIndex = index;
favTimer.state = "EditFav"
editfavwindow.favname = favlistmodel.get(favlistview.currentIndex).nameoffav
editfavwindow.h1.current_digit = 5 - favlistmodel.get(favlistview.currentIndex).timeoffav.charAt(0)
editfavwindow.h2.current_digit = 9 - favlistmodel.get(favlistview.currentIndex).timeoffav.charAt(1)
editfavwindow.m1.current_digit = 5 - favlistmodel.get(favlistview.currentIndex).timeoffav.charAt(3)
editfavwindow.m2.current_digit = 9 - favlistmodel.get(favlistview.currentIndex).timeoffav.charAt(4)
editfavwindow.s1.current_digit = 5 - favlistmodel.get(favlistview.currentIndex).timeoffav.charAt(6)
editfavwindow.s2.current_digit = 9 - favlistmodel.get(favlistview.currentIndex).timeoffav.charAt(7)
editfavwindow.fav.forceActiveFocus()
editfavwindow.fav.selectAll()
}
delete_fav_ma.onClicked: {
favlistview.currentIndex = index;
favTimer.state = "ConfirmationVisible"
}
}
Rectangle {
id: rowrectangle
property variant favtimestamp_text: favtimestamp
color: styl.panel_back_color
width: newfav.width + 10
height: favname.height + favtime.height + 18
anchors.top: fav_controls.bottom
MouseArea {
anchors.fill: parent
onClicked: {
timer_root.stopTimer()
favlistview.currentIndex = index
timerhandhour.rotation = favhandrotation(0, 2)
timerhandmin.rotation = favhandrotation(3, 5)
timerhandsec.rotation = favhandrotation(6)
timer.timername = favname.text
}
}
}
Text {
id: favname
color: styl.text_color_primary
width: parent.width - fav_menu.width - 24
x: 12
anchors {
top: fav_controls.bottom
topMargin: 6
}
text: nameoffav
elide: Text.ElideRight
font {family: "Ubuntu"; pixelSize: 14}
wrapMode: Text.Wrap
}
Text {
id: favtime
color: styl.text_color_secondary
x: 12
anchors {
horizontalCenter: parent.horizontalCenter
top: favname.bottom
topMargin: 6
}
text: timeoffav
font {family: "Ubuntu"; pixelSize: 16}
}
MenuButton {
id: fav_menu
anchors {
top: parent.top
topMargin: 6
right: parent.right
rightMargin: 6
}
buttonma.onClicked: {
if (fav_controls.opacity === 0){
fav_menu.isActive = true
fav_controls.opacity = 1;
fav_controls.height = fav_controls.set_and_start_fav_ma.height + fav_controls.set_fav_ma.height + 24;
fav_item.height = fav_item.height + fav_controls.height
}
else {
fav_menu.isActive = false
fav_item.height = fav_item.height - fav_controls.height
fav_controls.height = 0
fav_controls.opacity = 0
}
}
}
DividerSmallHor {
id: divider_small
width: favTimer.width
anchors.bottom: parent.bottom
}
ListView.onAdd: SequentialAnimation {
PropertyAction { target: fav_item; property: "scale"; value: 0 }
NumberAnimation { target: fav_item; property: "scale"; to: 1; duration: 200; }
}
ListView.onRemove: SequentialAnimation {
PropertyAction { target: fav_item; property: "ListView.delayRemove"; value: true }
NumberAnimation { target: fav_item; property: "scale"; to: 0; duration: 200; }
PropertyAction { target: fav_item; property: "ListView.delayRemove"; value: false }
}
}
model: ListModel {
id: favlistmodel
}
}
states: [
State {
name: "AddFav"
PropertyChanges { target: overlay; scale: 1 }
PropertyChanges { target: addfavwindow; scale: 1}
},
State {
name: "EditFav"
PropertyChanges { target: overlay; scale: 1 }
PropertyChanges { target: editfavwindow; scale: 1 }
},
State {
name: "ConfirmationVisible"
PropertyChanges { target: overlay; scale: 1 }
PropertyChanges { target: confirmationwindow1; scale: 1 }
PropertyChanges { target: confirmationwindow1; thing_to_delete: favlistmodel.get(favlistview.currentIndex).nameoffav}
PropertyChanges { target: confirmationwindow1.cancel_button; focus: true }
},
State {
name: "SetTimerWindowVisible"
PropertyChanges { target: overlay; scale: 1 }
PropertyChanges { target: settimerwindow; scale: 1 }
}
]
}
/* ====================== Settings Panel ===================== */
Panel {
id: settings_timer_panel
Text {
id: settingsheader
color: styl.text_color_primary
y: 5
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Settings")
font {family: "Ubuntu Light"; pixelSize: 24}
}
SettingsTimer {
id: settings_timer
width: parent.width
anchors {
top: settingsheader.bottom
topMargin: 6
}
}
}
ToolbarBottom {
id: toolbarbottom1
height: 36
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
Rectangle {
id: favs
color: "#00000000"
width: 26
height: 26
radius: 4
anchors {
left: parent.left
leftMargin: 5
verticalCenter: parent.verticalCenter
}
Image {
id: imagefav
source: "images/heart_dark.png"
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
countsincealarm.running ? resetAlarmFlag() : ""
timer_root.state !== "Fav" ? timer_root.state = "Fav" : timer_root.state = ""
}
}
}
Rectangle {
id: settings