-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathPomodoroWindow.qml
1491 lines (1272 loc) · 56.1 KB
/
PomodoroWindow.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: wp_root
property string pomonumvar: "0"
property string worktimevariable: ""
property string startclicktime: ""
property string breakstarttime: ""
property string workmiliduration: "0"
property string workduration: Czas.milisecToHoursMinutes(wp_root.workmiliduration)
property string workpauseduration: "0"
property string timevariable: "" // Store time when pause button clicked or break starts
property string pausemiliduration: "0"
property string pauseduration: Czas.milisecToHoursMinutes(wp_root.pausemiliduration)
property string breakmiliduration: "0"
property string breakduration: Czas.milisecToHoursMinutes(wp_root.breakmiliduration)
property alias pomodoroer: pomodoro
property alias pomodorotime: wp_time_text.text
property alias buttontext: wp_start_button.start_button_text
property alias statustext: wp_state.text
property alias statustext2: wp_state2.text
property alias wmtime: wp_root.workmiliduration
property alias bmtime: wp_root.breakmiliduration
property alias pmtime: wp_root.pausemiliduration
property alias pnumb: wp_root.pomonumvar
property alias ticking_sound_setting: settings_wp.ticking_sound_setting
property alias auto_work_setting: settings_wp.auto_work_setting
property alias auto_break_setting: settings_wp.auto_break_setting
property alias work_duration_setting: settings_wp.work_duration_setting
property alias short_break_duration_setting: settings_wp.short_break_duration_setting
property alias long_break_duration_setting: settings_wp.long_break_duration_setting
property alias long_break_after_setting: settings_wp.long_break_after_setting
property alias bounce_animation: settings_wp.bounce_animation
property alias todo_list_timestamp: todo_list_name.todo_list_timestamp
property alias todo_list_name: todo_list_name
property alias todo_listmodel: tasklist.todo_listmodel
property alias todo_listview: tasklist.todo_listview
property alias save_day_note_button: add_day_note.save_note_button
property alias controls_tasks_gen: controls_tasks_gen
function workViewTextNew(thismonth, thisday, thisyear) // append times to stats for day in month
{
var monthinheader = calendar_view.month_name_header.monthNumber;
var yearinheader = calendar_view.year_header.text;
var dayinheader = work_view_text.header.text.charAt(1) == " " ? work_view_text.header.text.charAt(0) : work_view_text.header.text.charAt(0) + work_view_text.header.text.charAt(1);
if (Qt.formatDateTime(new Date(), "d.M.yyyy") == dayinheader + "." + monthinheader + "." + yearinheader) {
work_view_text.day_stats.visible = true
work_view_text.work_u.text = wp_root.pomonumvar
work_view_text.work_d.text = wp_root.workduration
work_view_text.break_d.text = wp_root.breakduration
work_view_text.pause_d.text = wp_root.pauseduration
}
}
function workViewTextUpdate() // updat stats in the work_view_text
{
var monthinheader = calendar_view.month_name_header.monthNumber;
var yearinheader = calendar_view.year_header.text;
var dayinheader = work_view_text.header.text.charAt(1) == " " ? work_view_text.header.text.charAt(0) : work_view_text.header.text.charAt(0) + work_view_text.header.text.charAt(1);
if (Qt.formatDateTime(new Date(), "d.M.yyyy") == dayinheader + "." + monthinheader + "." + yearinheader) {
var wmtime = parseInt(wp_root.workmiliduration, 10)
var bmtime = parseInt(wp_root.breakmiliduration, 10)
var pmtime = parseInt(wp_root.pausemiliduration, 10)
work_view_text.day_stats.visible = true
work_view_text.work_u.text = wp_root.pomonumvar
work_view_text.work_d.text = wp_root.workduration
work_view_text.break_d.text = wp_root.breakduration
work_view_text.pause_d.text = wp_root.pauseduration
work_view_text.work_d_p.work_d_p_mnoznik = wmtime / (wmtime + bmtime + pmtime);
work_view_text.break_d_p.break_d_p_mnoznik = bmtime / (wmtime + bmtime + pmtime);
work_view_text.pause_d_p.pause_d_p_mnoznik = pmtime / (wmtime + bmtime + pmtime);
}
}
color: styl.back_color_primary
width: parent.width
height: parent.height
Keys.onPressed: {
if ((event.key == Qt.Key_N) && (event.modifiers & Qt.ControlModifier) && wp_root.state === "Todo" && todo_header.text == qsTr("Tasks")){
tasklist.new_task_button.button_ma.clicked(true)
}
else if ((event.key == Qt.Key_N) && (event.modifiers & Qt.ControlModifier) && wp_root.state === "Todo" && todo_header.text == qsTr("Lists")){
listoftasks.new_task_list_button.button_ma.clicked(true);
}
}
Component.onCompleted: {
Storage.getSettingWP()
Storage.countTrackedTasks()
console.log("wp completed")
}
Item {
id: pomodoro
signal breakStarted
function stuffToRunWhenNextWorkStarts()
{
trayicon.onWorkplayStartFromQML()
var thisday = Qt.formatDateTime(new Date(), "d");
var thismonth = Qt.formatDateTime(new Date(), "M");
var thisyear = Qt.formatDateTime(new Date(), "yyyy");
var checkstartday = wp_root.startclicktime;
var checkbreakstartday = wp_root.breakstarttime
var yesterdayday = Qt.formatDateTime(new Date(new Date().setDate(new Date().getDate()-1)), "d");
var yesterdaymonth = Qt.formatDateTime(new Date(new Date().setDate(new Date().getDate()-1)), "M");
var yesterdayyear = Qt.formatDateTime(new Date(new Date().setDate(new Date().getDate()-1)), "yyyy");
break_timer.stop(); // Stop counting break time
launcher.setUrgent("") // FALSE
wp_time_text.wp_time_text_shadow = "00:00:00"; // Set digital timer to "00:00"
work_timer.start(); // Start counting pomodoro
progress_bar_big.color = "#C0292F"; // red
progress_bar_big.opacity = 1;
wp_start_button.start_button_text = "Pause"
wu_number.text = Number(wu_number.text) + 1; // Add 1 to pomodoro counter under image
wp_state2.text = ""; // Reset status text
wp_start_button.color = styl.button_back_color;
wp_root.worktimevariable = Czas.getCurrentTime().getTime(); // save current time in text
wp_root.startclicktime = Qt.formatDateTime(new Date(), "d");
var breaktimeduration = Czas.getTimeDifference(wp_root.timevariable, Czas.getCurrentTime());
wp_root.breakmiliduration = parseInt(wp_root.breakmiliduration, 10) + parseInt(breaktimeduration, 10);
wp_root.workpauseduration = "0"
if (thisday.toString() !== checkbreakstartday.toString()){ // Break finishes after midnight
if (Storage.checkIfRecordExist(yesterdaymonth, yesterdayday, yesterdayyear) === "false"){
Storage.saveStats(yesterdaymonth, yesterdayday, yesterdayyear, wp_root.pomonumvar, wp_root.workduration, wp_root.breakduration, wp_root.pauseduration, wp_root.workmiliduration, wp_root.breakmiliduration, wp_root.pausemiliduration)
wp_root.pomonumvar = "0"
wp_root.workmiliduration = "0"
wp_root.breakmiliduration = "0"
wp_root.pausemiliduration = "0"
}
else {
Storage.updateStats(yesterdaymonth, yesterdayday, yesterdayyear, wp_root.pomonumvar, wp_root.workduration, wp_root.breakduration, wp_root.pauseduration, wp_root.workmiliduration, wp_root.breakmiliduration, wp_root.pausemiliduration)
wp_root.pomonumvar = "0"
wp_root.workmiliduration = "0"
wp_root.breakmiliduration = "0"
wp_root.pausemiliduration = "0"
}
}
else {
if (Storage.checkIfRecordExist(thismonth, thisday, thisyear) === "false"){
workViewTextNew(thismonth, thisday, thisyear)
Storage.saveStats(thismonth, thisday,thisyear, wp_root.pomonumvar, wp_root.workduration, wp_root.breakduration, wp_root.pauseduration, wp_root.workmiliduration, wp_root.breakmiliduration, wp_root.pausemiliduration)
}
else {
workViewTextUpdate()
Storage.updateStats(thismonth, thisday,thisyear, wp_root.pomonumvar, wp_root.workduration, wp_root.breakduration, wp_root.pauseduration, wp_root.workmiliduration, wp_root.breakmiliduration, wp_root.pausemiliduration)
}
}
}
function stuffToRunWhenNextBreakStarts()
{
trayicon.onWorkplayBreakFromQML()
var thisday = Qt.formatDateTime(new Date(), "d");
var thismonth = Qt.formatDateTime(new Date(), "M");
var thisyear = Qt.formatDateTime(new Date(), "yyyy")
var checkstartday = wp_root.startclicktime;
var checkbreakstartday = wp_root.breakstarttime
var yesterdayday = Qt.formatDateTime(new Date(new Date().setDate(new Date().getDate()-1)), "d");
var yesterdaymonth = Qt.formatDateTime(new Date(new Date().setDate(new Date().getDate()-1)), "M");
var yesterdayyear = Qt.formatDateTime(new Date(new Date().setDate(new Date().getDate()-1)), "yyyy");
breakStarted()
work_timer.stop()
wp_time_text.wp_time_text_shadow = "00:00:00"; // Set digital timer to "00:00"
break_timer.start();
wp_start_button.start_button_text = "Start next Work unit"
wp_start_button.color = styl.button_back_color
progress_bar_big.color = "#95B7DB" // blue
progress_bar_big.opacity = 1;
wp_state2.text = ""
wp_root.timevariable = Czas.getCurrentTime().getTime(); // Store time in text
var worktimeduration = Czas.getTimeDifference(wp_root.worktimevariable, Czas.getCurrentTime() );
wp_root.pomonumvar = Number(wp_root.pomonumvar) + 1;
wp_root.workmiliduration = parseInt(wp_root.workmiliduration, 10) + parseInt(worktimeduration, 10) - parseInt(wp_root.workpauseduration, 10);
wp_root.breakstarttime = Qt.formatDateTime(new Date(), "d");
Storage.addWorkUnitToTrackedTask()
if (thisday.toString() !== checkstartday.toString()){ // Pomodoro finished after midnight
if(Storage.checkIfRecordExist(yesterdaymonth, yesterdayday, yesterdayyear) === "false") {
Storage.saveStats(yesterdaymonth, yesterdayday, yesterdayyear, wp_root.pomonumvar, wp_root.workduration, wp_root.breakduration, wp_root.pauseduration, wp_root.workmiliduration, wp_root.breakmiliduration, wp_root.pausemiliduration)
wp_root.pomonumvar = "0"
wp_root.workmiliduration = "0"
wp_root.breakmiliduration = "0"
wp_root.pausemiliduration = "0"
}
else {
Storage.updateStats(yesterdaymonth, yesterdayday, yesterdayyear, wp_root.pomonumvar, wp_root.workduration, wp_root.breakduration, wp_root.pauseduration, wp_root.workmiliduration, wp_root.breakmiliduration, wp_root.pausemiliduration)
wp_root.pomonumvar = "0"
wp_root.workmiliduration = "0"
wp_root.breakmiliduration = "0"
wp_root.pausemiliduration = "0"
}
}
else {
if (Storage.checkIfRecordExist(thismonth, thisday, thisyear) === "false"){
Storage.saveStats(thismonth, thisday, thisyear, wp_root.pomonumvar, wp_root.workduration, wp_root.breakduration, wp_root.pauseduration, wp_root.workmiliduration, wp_root.breakmiliduration, wp_root.pausemiliduration)
workViewTextNew(thismonth, thisday, thisyear)
}
else {
Storage.updateStats(thismonth, thisday, thisyear, wp_root.pomonumvar, wp_root.workduration, wp_root.breakduration, wp_root.pauseduration, wp_root.workmiliduration, wp_root.breakmiliduration, wp_root.pausemiliduration)
workViewTextUpdate()
}
}
}
function breakTime()
{
var currentTime = wp_time_text.text
var shortBreakTime = settings_wp.short_break_duration_setting.text
var longBreakTime = settings_wp.long_break_duration_setting.text
var pomodoroNumber = settings_wp.long_break_after_setting.work_units
if ( wu_number.text % pomodoroNumber !==0 && shortBreakTime === currentTime){
wp_state2.text = "finished!";
wp_start_button.color = styl.button_back_color_ok;
notification.somethingFinished("Short Break finished", "You should start your next Work unit", "./sounds/breakfinish.wav"); // Signal from zeegaree.py
launcher.setUrgent("True")
}
else if ( wu_number.text % pomodoroNumber ===0 && longBreakTime === currentTime){
wp_state2.text = "finished!";
wp_start_button.color = styl.button_back_color_ok;
notification.somethingFinished("Long Break finished", "You should start your next Work unit", "./sounds/breakfinish.wav"); // Signal from zeegaree.py
launcher.setUrgent("True")
}
}
function breakTimeAuto()
{
var currentTime = wp_time_text.text
var shortBreakTime = settings_wp.short_break_duration_setting.text
var longBreakTime = settings_wp.long_break_duration_setting.text
var pomodoroNumber = settings_wp.long_break_after_setting.work_units
launcher.setUrgent("") // False
if ( wu_number.text % pomodoroNumber !==0 && shortBreakTime === currentTime){
stuffToRunWhenNextWorkStarts()
notification.somethingFinished("Short Break finished", "Next Work unit started!", "./sounds/breakfinish.wav"); // Signal from zeegaree.py
}
else if ( wu_number.text % pomodoroNumber ===0 && longBreakTime === currentTime){
stuffToRunWhenNextWorkStarts()
notification.somethingFinished("Long Break finished", "Next Work unit started!", "./sounds/breakfinish.wav"); // Signal from zeegaree.py
}
}
function workTime()
{
var current_time = wp_time_text.text
var work_durration = settings_wp.work_duration_setting.text
if (current_time == work_durration) {
wp_start_button.start_button_text = "Start Break time"
wp_start_button.color = styl.button_back_color_ok
wp_state2.text = "finished!"
notification.somethingFinished("Work unit finished", "You should start your Break time", "./sounds/pomodorofinish.wav"); // Signal from zeegaree.py
launcher.setUrgent("True")
trayicon.onWorkplayBreakWarnFromQML()
}
}
function workTimeAuto()
{
var current_time = wp_time_text.text
var work_durration = settings_wp.work_duration_setting.text
if (current_time == work_durration) {
stuffToRunWhenNextBreakStarts()
notification.somethingFinished("Work unit finished", "Break time started!", "./sounds/pomodorofinish.wav"); // Signal from zeegaree.py
}
}
function startWorkplay()
{
work_timer.start()
wp_state2.text = ""
wp_start_button.color = styl.button_back_color
wp_start_button.start_button_text = "Pause"
wp_root.worktimevariable = Czas.getCurrentTime().getTime(); // Get time when START button clicked
wp_root.startclicktime = Qt.formatDateTime(new Date(), "d");
trayicon.onWorkplayStartFromQML()
}
function pauseWorkplay()
{
work_timer.stop();
wp_state2.text = "paused";
wp_start_button.start_button_text = "Resume"
wp_start_button.color = styl.button_back_color_ok;
wp_root.timevariable = Czas.getCurrentTime().getTime(); // Store time when pause button clicked
trayicon.onWorkplayPauseFromQML()
}
function resumeWorkplay()
{
var thisday = Qt.formatDateTime(new Date(), "d");
var thismonth = Qt.formatDateTime(new Date(), "M");
var thisyear = Qt.formatDateTime(new Date(), "yyyy")
var checkstartday = wp_root.startclicktime;
var checkbreakstartday = wp_root.breakstarttime
var yesterdayday = Qt.formatDateTime(new Date(new Date().setDate(new Date().getDate()-1)), "d");
var yesterdaymonth = Qt.formatDateTime(new Date(new Date().setDate(new Date().getDate()-1)), "M");
var yesterdayyear = Qt.formatDateTime(new Date(new Date().setDate(new Date().getDate()-1)), "yyyy");
work_timer.start()
wp_state2.text = ""
wp_start_button.color = styl.button_back_color;
wp_start_button.start_button_text = "Pause"
trayicon.onWorkplayStartFromQML()
var pausetimeduration = Czas.getTimeDifference(wp_root.timevariable, Czas.getCurrentTime()); // Get pause duration
wp_root.workpauseduration = parseInt(wp_root.workpauseduration, 10) + parseInt(pausetimeduration, 10);
wp_root.pausemiliduration = parseInt(wp_root.pausemiliduration, 10) + parseInt(pausetimeduration, 10) // Store and add pause duration in miliseconds
if (thisday.toString() !== checkstartday.toString()) {
/*========== yesterday stats, stats before midnight =============== */
if(Storage.checkIfRecordExist(yesterdaymonth, yesterdayday, yesterdayyear) === "false") {
Storage.saveStats(yesterdaymonth, yesterdayday, yesterdayyear, wp_root.pomonumvar, wp_root.workduration, wp_root.breakduration, wp_root.pauseduration, wp_root.workmiliduration, wp_root.breakmiliduration, wp_root.pausemiliduration)
}
else {
Storage.updateStats(yesterdaymonth, yesterdayday, yesterdayyear, wp_root.pomonumvar, wp_root.workduration, wp_root.breakduration, wp_root.pauseduration, wp_root.workmiliduration, wp_root.breakmiliduration, wp_root.pausemiliduration)
}
}
else {
if (Storage.checkIfRecordExist(thismonth, thisday, thisyear) === "false") {
workViewTextNew(thismonth, thisday, thisyear)
Storage.saveStats(thismonth, thisday, thisyear, wp_root.pomonumvar, wp_root.workduration, wp_root.breakduration, wp_root.pauseduration, wp_root.workmiliduration, wp_root.breakmiliduration, wp_root.pausemiliduration)
}
else {
workViewTextUpdate()
Storage.updateStats(thismonth, thisday, thisyear, wp_root.pomonumvar, wp_root.workduration, wp_root.breakduration, wp_root.pauseduration, wp_root.workmiliduration, wp_root.breakmiliduration, wp_root.pausemiliduration)
}
}
}
function stopWorkplay()
{
launcher.setUrgent("") // FALSE
if (wp_start_button.start_button_text == "Start next Work unit"){
wu_number.text = Number(wu_number.text)+1;
}
work_timer.stop();
break_timer.stop();
wp_time_text.wp_time_text_shadow = "00:00:00"
launcher.getPomodoroCount(0, "")
wp_start_button.start_button_text = "Start"
wp_start_button.color = styl.button_back_color_ok;
progress_bar_big.color = "#C0292F"; // red
progress_bar_big.opacity = 1;
wp_state2.text = "";
trayicon.onWorkplayStopFromQML();
}
width: parent.width
anchors {
top: parent.top
bottom: toolbarbottom.top
}
Timer {
id: break_timer
interval: 1000; repeat: true
onTriggered:{
Czas.countUp("");
auto_work_setting.isSelected ? pomodoro.breakTimeAuto() : pomodoro.breakTime()
}
}
Timer {
id: work_timer
interval: 1000
repeat: true
onTriggered: {
Czas.countUp("true");
auto_break_setting.isSelected ? pomodoro.workTimeAuto() : pomodoro.workTime();
ticking_sound_setting.isSelected ? ticking.tickTick("./sounds/ticking_clock.wav") : ""
}
}
/*================== Toolbar top =====================*/
ToolbarTop {
id: toolbartop
width: parent.width
z: 1
anchors {
top: parent.top
right: parent.right
}
toolbarText: "Work & Play"
CloseButton {
id: closebutton1
anchors {
top: parent.top
topMargin: 5
right: parent.right
rightMargin: 5
}
MouseArea {
anchors.fill: parent
onClicked: {
main_file.state = "";
wp_root.state = "";
tasklist.todo_listmodel.clear();
}
}
}
}
/*===================== Analog Work&Play view================*/
Item {
id: analog_wp
width: parent.width/2
anchors {
top: toolbartop.bottom
topMargin: 48
bottom: parent.bottom
right: digital_wp.left
}
Timer {
id: level_pulse_timer
interval: 1000
repeat: true
running: progress_bar_big.height === progress_bar_big_back.height
onTriggered: if (progress_bar_big.opacity === 1){
progress_bar_big.opacity = .6
}
else {
progress_bar_big.opacity = 1
}
}
Rectangle {
id: progress_bar_big_back
color: "#333"
width: 100
height: parent.height - 40
anchors {
bottom: parent.bottom
bottomMargin: 40
horizontalCenter: parent.horizontalCenter
}
}
Rectangle {
id: progress_bar_big
Behavior on height { NumberAnimation { duration: 100} }
color: "#C0292F"
width: progress_bar_big_back.width
height: {
var time_setting = Czas.deciteWorkOrBreak()
Math.min(
Czas.calculateHightLevelWP(progress_bar_big_back.height, time_setting, wp_time_text.wp_time_text_shadow),
progress_bar_big_back.height
)
}
anchors {
bottom: progress_bar_big_back.bottom
horizontalCenter: progress_bar_big_back.horizontalCenter
}
}
Rectangle {
id: wu_number_background
color: styl.back_color_primary
width: 50
height: 40
radius: 4
anchors {
bottom: progress_bar_big_back.bottom
bottomMargin: -4
horizontalCenter: progress_bar_big.horizontalCenter
}
Text {
id: wu_number
color: styl.text_color_primary
anchors.centerIn: parent
text: "1"
font {pixelSize: 24; family: "Ubuntu"}
}
}
}
/*===================== Digital Work&Play view================*/
Item {
id: digital_wp
width: parent.width/2
anchors {
top: toolbartop.bottom
topMargin: 48
right: parent.right
bottom: parent.bottom
}
Text {
id: wp_time_text
property string wp_time_text_shadow: "00:00:00" // Needed when time longer than hour
color: styl.text_color_primary
anchors {
top: parent.top
horizontalCenter: parent.horizontalCenter
}
text: {
var str = wp_time_text_shadow
str.slice(0, 2) == "00" ? str.slice(3) : str
}
font {
pixelSize: Math.round(Math.min(digital_wp.width/8, digital_wp.height/8))
family: "Ubuntu"
}
}
/*================================ RESET BUTTON ========================== */
Button {
id: reset_button
visible: wp_time_text.text != "00:00"
buttoncolor: styl.button_back_color_notok
anchors {
verticalCenter: wp_time_text.verticalCenter
left: wp_time_text.right
leftMargin: 12
}
buttonimage.source: isActive ? "images/reset_eee.png" : "images/reset_3d3d3d.png"
button_ma.onClicked: {
pomodoro.stopWorkplay()
}
}
Text {
id: wp_state
color: styl.text_color_primary
anchors {
top: wp_time_text.bottom
topMargin: 24
horizontalCenter: parent.horizontalCenter
}
text: if (wp_start_button.start_button_text == "Start next Work unit" && wu_number.text % settings_wp.long_break_after_setting.work_units !== 0){
return "Short Break"
}
else if (wp_start_button.start_button_text == "Start next Work unit" && wu_number.text % settings_wp.long_break_after_setting.work_units === 0){
return "Long Break"
}
else {
"Work Time"
}
font {
pixelSize: Math.round(wp_time_text.font.pixelSize/2)
family: "Ubuntu"
}
}
Text {
id: wp_state2
color: styl.text_color_primary
anchors {
top: wp_state.bottom
topMargin: 6
horizontalCenter: parent.horizontalCenter
}
text: ""
font: wp_state.font
}
/*===================== Number of tasks being tracked ================*/
Text {
id: tracked_tasks_number
property int number_of_tracked: 0
visible: number_of_tracked > 0
color: "#27ae60"
anchors {
top: wp_state2.bottom
topMargin: 24
horizontalCenter: parent.horizontalCenter
}
text: qsTr("Tasks tracked: ") + number_of_tracked
font {
pixelSize: Math.round(wp_time_text.font.pixelSize/2.5)
family: "Ubuntu"
}
}
StartButton {
id: wp_start_button
anchors {
bottom: parent.bottom
bottomMargin: 40
horizontalCenter: parent.horizontalCenter
}
start_button_text: "Start"
start_button_ma.onClicked: {
if(wp_start_button.start_button_text == "Start" || wp_start_button.start_button_text == "Resume"){
/*====================== RESUME button clicked =================*/
if (wp_time_text.wp_time_text_shadow !== "00:00:00"){
pomodoro.resumeWorkplay()
}
/*====================== START button clicked =================*/
else if (wp_time_text.wp_time_text_shadow === "00:00:00"){
pomodoro.startWorkplay()
}
}
/*====================== PAUSE button clicked =================*/
else if (wp_start_button.start_button_text == "Pause"){
pomodoro.pauseWorkplay()
}
/*====================== START NEXT POMODORO button clicked =================*/
else if (wp_start_button.start_button_text == "Start next Work unit"){
pomodoro.stuffToRunWhenNextWorkStarts()
}
/*====================== START BREAK button clicked =================*/
else if(wp_start_button.start_button_text == "Start Break time"){
pomodoro.stuffToRunWhenNextBreakStarts()
launcher.setUrgent("")
}
}
}
}
}
/*================== Overlay ===========================*/
Rectangle {
id: overlay
color: "#bb000000"
z: toolbarbottom.z + 1
width: wp_root.width
height: wp_root.height
scale: 0
MouseArea {
anchors.fill: parent
hoverEnabled: true
preventStealing: true
}
}
/*====================== Deleting Tasks ===================== */
ConfirmationWindow {
id: delete_task_confirm
z: overlay.z + 1
anchors.centerIn: overlay
scale: 0
textofnote: "Do you realy want to delete this task?"
canceltext: "Cancel"
oktext: "Delete"
okbutton_ma.onClicked: {
tasklist.todo_listview.currentItem.tracked ? tracked_tasks_number.number_of_tracked -= 1 : tracked_tasks_number.number_of_tracked
var currenttimestamp = tasklist.todo_listmodel.get(tasklist.todo_listview.currentIndex).todotimestamp
tasklist.todo_listmodel.remove(tasklist.todo_listview.currentIndex);
Storage.deleteTask(currenttimestamp);
overlay.scale = 0;
delete_task_confirm.scale = 0;
wp_root.focus = true
}
cancelbutton_ma.onClicked: {
overlay.scale = 0
delete_task_confirm.scale = 0
}
}
/*====================== Deleting All Finished Tasks for a given List===================== */
ConfirmationWindow {
id: delete_finished_task_confirm
z: overlay.z + 1
anchors.centerIn: overlay
scale: 0
textofnote: "Do you realy want to delete all finished tasks from this list?"
thing_to_delete: todo_list_name.text
canceltext: "Cancel"
oktext: "Delete"
okbutton_ma.onClicked: {
var listidtimestamp = todo_list_name.todo_list_timestamp
Storage.deleteAllFinishedTasks(listidtimestamp)
overlay.scale = 0;
delete_finished_task_confirm.scale = 0;
todo_listmodel.clear();
Storage.getTasksFromDB(todo_list_timestamp, todo_listmodel);
wp_root.focus = true
}
cancelbutton_ma.onClicked: {
overlay.scale = 0
delete_finished_task_confirm.scale = 0
}
}
/*====================== Deleting Lists ===================== */
ConfirmationWindow {
id: delete_list_confirm
z: overlay.z + 1
anchors.centerIn: overlay
scale: 0
textofnote: "Do you realy want to delete this list? Deleting the list will also remove all tasks in it."
canceltext: "Cancel"
oktext: "Delete"
okbutton_ma.onClicked: {
var currenttimestamp = listoftasks.tasks_lists_listmodel.get(listoftasks.tasks_lists_listview.currentIndex).timestamp;
listoftasks.tasks_lists_listmodel.remove(listoftasks.tasks_lists_listview.currentIndex);
Storage.deleteList(currenttimestamp)
todo_list_name.text = "ToDo List";
todo_list_name.todo_list_timestamp = "123456789"
Storage.checkIfSettingExist("todo_list_name") == "true" ? Storage.updateSettings("todo_list_name", todo_list_name.text) :
Storage.saveSetting("todo_list_name", todo_list_name.text);
Storage.checkIfSettingExist("todo_list_timestamp") == "true" ? Storage.updateSettings("todo_list_timestamp", todo_list_name.todo_list_timestamp) :
Storage.saveSetting("todo_list_timestamp", todo_list_name.todo_list_timestamp);
overlay.scale = 0;
delete_list_confirm.scale = 0;
wp_root.focus = true
}
cancelbutton_ma.onClicked: {
overlay.scale = 0;
delete_list_confirm.scale = 0;
}
}
/*====================== Deleting Notes ===================== */
ConfirmationWindow {
id: delete_note_confirm
z: overlay.z + 1
anchors.centerIn: overlay
scale: 0
textofnote: "Do you realy want to delete this note?"
thing_to_delete: ""
canceltext: "Cancel"
oktext: "Delete"
okbutton_ma.onClicked: {
var thismonth = calendar_view.month_name_header.monthNumber;
var thisyear = calendar_view.year_header.text;
var thisday = work_view_text.header.text.charAt(1) == " " ? work_view_text.header.text.charAt(0) : work_view_text.header.text.charAt(0) + work_view_text.header.text.charAt(1);
work_view_text.day_stats.visible ? Storage.updateNote(thismonth, thisday, thisyear, "") : Storage.deleteNote(thismonth, thisday, thisyear)
day_note_view.visible = false
overlay.scale = 0
delete_note_confirm.scale = 0
new_notes.visible = true
wp_root.focus = true
}
cancelbutton_ma.onClicked: {
overlay.scale = 0;
delete_note_confirm.scale = 0
}
}
EditPomodoroTime {
id: edittimewindow
z: overlay.z + 1
anchors.centerIn: overlay
scale: 0
okmouse {
onClicked: {
var M1 = (9 - 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()
settings_wp.edited_setting.text = M1+M2+":"+S1+S2
bounce_animation.start()
settingspomodoro.state = "";
Storage.checkIfSettingExist(settings_wp.edited_setting_name) == "true" ?
Storage.updateSettings(settings_wp.edited_setting_name, settings_wp.edited_setting.text) :
Storage.saveSetting(settings_wp.edited_setting_name, settings_wp.edited_setting.text)
}
}
}
EditNumber {
id: editpomodorocount
z: overlay.z + 1
anchors.centerIn: overlay
scale: 0
acceptmouse {
onClicked: {
settings_wp.edited_setting.work_units = 9 - number.current_digit;
bounce_animation.start()
settingspomodoro.state = "";
Storage.checkIfSettingExist(settings_wp.edited_setting_name) == "true" ?
Storage.updateSettings(settings_wp.edited_setting_name, settings_wp.edited_setting.work_units) :
Storage.saveSetting(settings_wp.edited_setting_name, settings_wp.edited_setting.work_units)
}
}
}
NewTaskWindow {
id: new_task_window_main
z: overlay.z + 1
anchors.centerIn: overlay
scale: 0
}
EditTaskWindow {
id: edit_task_window_main
z: overlay.z + 1
anchors.centerIn: overlay
scale: 0
}
NewListWindow {
id: new_list_window_main
z: overlay.z + 1
anchors.centerIn: overlay
scale: 0
}
EditListWindow {
id: edit_list_window_main
z: overlay.z + 1
anchors.centerIn: overlay
scale: 0
}
/* ====================== ToDo Panel ===================== */
Panel {
id: todo_panel
Text {
id: todo_header
color: styl.text_color_primary
y: 5
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Tasks")
font {family: "Ubuntu Light"; pixelSize: 24}
}
DividerBigHor {
id: divider_big
width: parent.width
anchors {
top: todo_header.bottom
topMargin: 6
}
}
Rectangle {
id: todo_list_name_background
Behavior on height { NumberAnimation { duration: 100 }}
color: styl.panel_back_color
width: parent.width
height: todo_list_name.height + 5
anchors {
top: divider_big.bottom
topMargin: 5
left: parent.left
}
Text {
id: todo_list_name
property string todo_list_timestamp: "123456789"
property string selected_task_color: ""
color: styl.info_text_color
width: parent.width - 20
anchors {
left: parent.left
leftMargin: 12
top: controls_tasks_gen.bottom
topMargin: 5
}
text: qsTr("ToDo List")
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font {family: "Ubuntu Light"; pixelSize: 18}
}
MenuButton {
id: todo_list_menu
visible: todo_header.text == "Tasks";
anchors {
right: parent.right
rightMargin: 6
verticalCenter: todo_list_name.verticalCenter
}
buttonma.onClicked: {
if(controls_tasks_gen.opacity == 0){
todo_list_menu.isActive = true
controls_tasks_gen.height = controls_tasks_gen.show_hide_finished_tasks_ma.height * 4 + controls_tasks_gen.color_setter_small.height + 30;
controls_tasks_gen.opacity = 1;
todo_list_name_background.height = todo_list_name_background.height + controls_tasks_gen.height;
}
else {
todo_list_menu.isActive = false
todo_list_name_background.height = todo_list_name_background.height - controls_tasks_gen.height;
controls_tasks_gen.height = 0;
controls_tasks_gen.opacity = 0;
}
}
}
ControlsWPTasksGeneral {
id: controls_tasks_gen
opacity: 0
width: parent.width
anchors {
top: parent.top
}
show_hide_finished_tasks_ma.onClicked: {
Storage.checkIfSettingExist("finished_tasks_visible") == "true" ? Storage.updateSettings("finished_tasks_visible", !hiddenfinished) :
Storage.saveSetting("finished_tasks_visible", !hiddenfinished)
if (hiddenfinished == false) {
hiddenfinished = true
todo_listmodel.clear()
if (todo_list_name.selected_task_color !== ""){
Storage.getNotFinishedTasksWithColor(todo_list_timestamp, todo_list_name.selected_task_color, false, todo_listmodel)
}
else {
Storage.getNotFinishedTasksFromDB(todo_list_timestamp, false, todo_listmodel)
}
}
else {
hiddenfinished = false
todo_listmodel.clear()
if (todo_list_name.selected_task_color !== "") {
Storage.getTasksWithColor(todo_list_timestamp, todo_list_name.selected_task_color, todo_listmodel)
}
else {
Storage.getTasksFromDB(todo_list_timestamp, todo_listmodel)
}
}
}
show_task_lists_ma.onClicked: {
todo_list_name_background.height = 0 /*todo_list_name_background.height - controls_tasks_gen.height*/;
controls_tasks_gen.height = 0;
controls_tasks_gen.opacity = 0;
todo_list_name_background.visible = false;
todo_list_menu.isActive = false;
listoftasks.opacity = 1;
todo_header.text = "Lists";
listoftasks.height = todo_panel.height- todo_header.height - todo_list_name_background.height - 15;