-
Notifications
You must be signed in to change notification settings - Fork 15
/
main.qml
867 lines (748 loc) · 28.5 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
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
import QtQuick 1.1
import "Storage.js" as Storage
import "Theme.js" as Theme
Item {
id: main_file
property alias styles: styl
property alias stopwatcher: stopwatchwindow.stopwatcher
property alias stopwatchtime: stopwatchwindow.stext
property alias timerer: timerwindow.timerer
property alias timertime: timerwindow.ttext
property alias timerstate: timerwindow.timerstate
property alias favlistmodel: timerwindow.favlistmodel
property alias favlistview: timerwindow.favlistview
property alias pomodoroer: pomodorowindow.pomodoroer
property alias pomodorotime: pomodorowindow.pomodorotime
property alias pomodorobuttontext: pomodorowindow.buttontext
property alias pomodorostatustext: pomodorowindow.statustext
property alias pomodorostatus2text: pomodorowindow.statustext2
property alias wmtime: pomodorowindow.wmtime
property alias pmtime: pomodorowindow.pmtime
property alias bmtime: pomodorowindow.bmtime
property alias pnumb: pomodorowindow.pnumb
property alias ticking_sound_setting: pomodorowindow.ticking_sound_setting
property alias auto_work_setting: pomodorowindow.auto_work_setting
property alias auto_break_setting: pomodorowindow.auto_break_setting
property alias controls_tasks_gen: pomodorowindow.controls_tasks_gen
property alias hide_on_close_edit: settings_window.hide_on_close_edit
property alias lite_mode_edit: settings_window.lite_mode_edit
signal workSaved
function checkHideOnClose()
{
return hide_on_close_edit.isSelected
}
function resetStopwatch() {stopwatcher.resetStopwatch()}
function startStopwatch() {stopwatcher.startStopwatch()}
function pauseStopwatch() {stopwatcher.pauseStopwatch()}
function getLap() {stopwatcher.getLap()}
function getSplit() {stopwatcher.getSplit()}
function showTimer() {main_file.state = "timerBase"}
function resetTimer() {timerer.resetTimer(); timerer.resetAlarmFlag()}
function stopTimer() {timerer.stopTimer()}
function startWorkplay()
{
if (pomodororunning.text == ""){
Storage.getStats(pnumb, wmtime, bmtime, pmtime)
auto_work_setting.isSelected = Storage.checkIfSettingExist("auto_work_set") == "true" ? Storage.getSetting("auto_work_set") : false
auto_break_setting.isSelected = Storage.checkIfSettingExist("auto_break_set") == "true" ? Storage.getSetting("auto_break_set") : true
ticking_sound_setting.isSelected = Storage.checkIfSettingExist("ticking_sound") == "true" ? Storage.getSetting("ticking_sound") : false
}
pomodoroer.startWorkplay()
}
function pauseWorkplay() {pomodoroer.pauseWorkplay()}
function resumeWorkplay() {pomodoroer.resumeWorkplay()}
function stopWorkplay() {pomodoroer.stopWorkplay()}
function startNextWorkWorkplay() {pomodoroer.stuffToRunWhenNextWorkStarts()}
function startNextBreakWorkplay() {pomodoroer.stuffToRunWhenNextBreakStarts(); launcher.setUrgent("")}
width: 800
height: 600
Component.onCompleted: {
Storage.createSettingsTable();
Storage.createStatsTable();
// Storage.createTasksTable();
Storage.createListsTable();
Storage.createFinishedTasksTable();
Storage.createFavsTable();
Storage.getSettingMain();
if (Storage.checkIfDBVersionTableExists() == "not_exist"){
console.log("table not exists")
// news to user
whats_new.scale = 1;
whats_new.visible = true;
//create table
Storage.createDBVersionTable();
//add value to table
Storage.saveDBVersion(2);
if (Storage.checkIfTasksTableExists() == "exist"){
Storage.addTaskNoteVizColumnToTable()
}
}
else if (Storage.checkIfDBVersionTableExists() == "exist"){
console.log("table exist")
if (Storage.checkIfDBVersionExist(1) == "true"){
// update version
Storage.updateDBVersion(2)
// Show news to user
whats_new.scale = 1;
whats_new.visible = true;
// Add column for task notes visibility to task table
if (Storage.checkIfTasksTableExists() == "exist"){
Storage.addTaskNoteVizColumnToTable()
}
}
}
Storage.createTasksTable()
}
Styles {
id: styl
}
Rectangle {
id: alertrec
color: "#78ffffff"
visible: welcomewindow.height < 530 || welcomewindow.width < 780
width: sizealert.width + 12
height: sizealert.height + 10
radius: 4
anchors.centerIn: parent
z: 1
CloseButtonSmall {
anchors {
top: parent.top
topMargin: 10
right: parent.right
rightMargin: 10
}
}
MouseArea {
id: alertrecma
anchors.fill: parent
onClicked: {
alertrec.visible = false
}
}
Text {
id: sizealert
color: "#222"
width: welcomewindow.width - 40
anchors.centerIn: parent
z: 2
text: "Please, don't squeeze me too much! It makes me look bad."
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font.pixelSize: 40
}
}
Rectangle {
id: welcomewindow
color: styl.back_color_primary
width: parent.width
height: parent.height
/* ============================ Stopwatch ======================= */
Rectangle {
id: stopwatch
color: "#00000000"
width: if(parent.width/parent.height < 1/3){
parent.width
}
else if(parent.width/parent.height >= 1/3 && parent.width/parent.height <= 1){
parent.width/2
}
else if(parent.width/parent.height > 1 && parent.width/parent.height < 4){
parent.width/3
}
else {
parent.width/6
}
height: if(parent.width/parent.height < 1/3){
parent.height/6 - toolbar.height/6
}
else if(parent.width/parent.height >= 1/3 && parent.width/parent.height <= 1){
parent.height/3 - toolbar.height/3
}
else if(parent.width/parent.height > 1 && parent.width/parent.height < 4){
parent.height/2 - toolbar.height/2
}
else {
parent.height - toolbar.height
}
anchors {
top: parent.top
left: parent.left
}
Image {
id: stopwatchImage
source: "images/stopwatch_b_main.png"
smooth: true
width: Math.min(Math.min(parent.width * 8/10, parent.height * 8/10), 200)
height: width
anchors.centerIn: parent
Behavior on scale { NumberAnimation { easing.type: Easing.OutExpo; duration: 500 }
}
Rectangle {
opacity: .3
color: styl.back_color_primary
width: parent.width
height: width
radius: width/2
anchors.centerIn: parent
}
MouseArea {
id: mouse_area2
anchors.fill: parent
hoverEnabled: true
onEntered: stopwatchImage.scale = 1.1
onExited: stopwatchImage.scale = 1
onClicked: {
main_file.state = "stopwatchBase"
}
}
}
}
Rectangle {
id: stopwatchtextes
color: "#00000000"
width: stopwatch.width
height: stopwatch.height
anchors {
top: if(parent.width/parent.height < 1/3){
stopwatch.bottom
}
else if(parent.width/parent.height >= 1/3 && parent.width/parent.height <= 1){
parent.top
}
else if(parent.width/parent.height > 1 && parent.width/parent.height < 4){
stopwatch.bottom
}
else {
parent.top
}
left: if(parent.width/parent.height < 1/3){
parent.left
}
else if(parent.width/parent.height >= 1/3 && parent.width/parent.height <= 1){
stopwatch.right
}
else if(parent.width/parent.height > 1 && parent.width/parent.height < 4){
parent.left
}
else {
stopwatch.right
}
}
Text {
id: text1
color: styl.text_color_primary
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
topMargin: parent.height/8
}
text: qsTr("Stopwatch")
font {
pixelSize: Math.min(parent.width/10, parent.height/10)
family: "Ubuntu Light"
}
}
Text {
id: stopwatchrunning
color: styl.text_color_primary
anchors {
top: text1.bottom
topMargin: height/2
// horizontalCenter: parent.horizontalCenter
left: text1.left
leftMargin: text1.width/10
}
text: stopwatchtime === "00:00:00.0" ? "" : stopwatchtime // Display time if Stopwatch is running
font {
pixelSize: Math.min(parent.width/12, parent.height/12)
family: "Ubuntu"
}
}
}
/* ============================ Timer ======================= */
Rectangle {
id: timer
color: "#00000000"
width: stopwatch.width
height: stopwatch.height
anchors {
top: if(parent.width/parent.height < 1/3){
stopwatchtextes.bottom
}
else if(parent.width/parent.height >= 1/3 && parent.width/parent.height <= 1){
stopwatch.bottom
}
else {
parent.top
}
left: if(parent.width/parent.height < 1/3){
parent.left
}
else if(parent.width/parent.height >= 1/3 && parent.width/parent.height <= 1){
parent.left
}
else if(parent.width/parent.height > 1 && parent.width/parent.height < 4){
stopwatch.right
}
else {
stopwatchtextes.right
}
}
Image {
id: timerImage
source: "images/timer_b_main.png"
smooth: true
width: Math.min(Math.min(parent.width * 8/10, parent.height * 8/10), 200)
height: width
anchors.centerIn: parent
Behavior on scale { NumberAnimation { easing.type: Easing.OutExpo; duration: 500 }
}
Rectangle {
opacity: .3
color: styl.back_color_primary
width: parent.width
height: width
radius: width/2
anchors.centerIn: parent
}
MouseArea {
id: mouse_area4
anchors.fill: parent
hoverEnabled: true
onEntered: timerImage.scale = 1.1
onExited: timerImage.scale = 1
onClicked: {
showTimer()
}
}
}
}
Rectangle {
id: timertextes
color: "#00000000"
width: timer.width
height: timer.height
anchors {
top: if(parent.width/parent.height < 1/3){
timer.bottom
}
else if(parent.width/parent.height >= 1/3 && parent.width/parent.height <= 1){
stopwatchtextes.bottom
}
else if(parent.width/parent.height > 1 && parent.width/parent.height < 4){
timer.bottom
}
else {
parent.top
}
left: if(parent.width/parent.height < 1/3){
parent.left
}
else if(parent.width/parent.height >= 1/3 && parent.width/parent.height <= 1){
timer.right
}
else if(parent.width/parent.height > 1 && parent.width/parent.height < 4){
stopwatchtextes.right
}
else {
timer.right
}
}
Text {
id: timerText
color: styl.text_color_primary
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
topMargin: parent.height/8
}
text: qsTr("Timer")
font {
pixelSize: Math.min(parent.width/10, parent.height/11)
family: "Ubuntu Light"
}
}
Text {
id: timerrunning
color: styl.text_color_primary
anchors {
top: timerText.bottom
topMargin: height/2
left: timerText.left
leftMargin: -(timerText.width/8)
}
text: timertime === "00:00:00" ? "" : timertime // Display time if timer is running
font {
pixelSize: Math.min(parent.width/12, parent.height/12)
family: "Ubuntu"
}
}
Text {
id: timerstatetext
color: timerrunning.color
anchors {
horizontalCenter: parent.horizontalCenter
top: timerText.bottom
topMargin: height/2
}
text: timerstate === "Alarm" ? "Time's Up!" : "" // Alarm if timer stopped
font: timerrunning.font
}
}
/* ============================ Pomodoro ======================= */
Rectangle {
id: pomodoro
color: "#00000000"
width: stopwatch.width
height: stopwatch.height
anchors {
top: if(parent.width/parent.height < 1/3){
timertextes.bottom
}
else if(parent.width/parent.height >= 1/3 && parent.width/parent.height <= 1){
timer.bottom
}
else if(parent.width/parent.height > 1 && parent.width/parent.height < 4){
parent.top
}
else {
parent.top
}
left: if(parent.width/parent.height < 1/3){
parent.left
}
else if(parent.width/parent.height >= 1/3 && parent.width/parent.height <= 1){
parent.left
}
else if(parent.width/parent.height > 1 && parent.width/parent.height < 4){
timer.right
}
else {
timertextes.right
}
}
Image {
id: pomodoroImage
source: "images/pomodoro_b_main.png"
smooth: true
width: Math.min(Math.min(parent.width * 8/10, parent.height * 8/10), 200)
height: width
anchors.centerIn: parent
Behavior on scale { NumberAnimation { easing.type: Easing.OutExpo; duration: 500 } }
Rectangle {
opacity: .3
color: styl.back_color_primary
width: parent.width
height: width
radius: width/2
anchors.centerIn: parent
}
MouseArea {
id: mouse_area5
anchors.fill: parent
hoverEnabled: true
onEntered: pomodoroImage.scale = 1.1
onExited: pomodoroImage.scale = 1
onClicked: {
main_file.state = "pomodoroBase";
if (pomodororunning.text == ""){
Storage.getStats()
}
pomodorowindow.todo_list_timestamp = Storage.checkIfSettingExist("todo_list_timestamp") == "true" ? Storage.getSetting("todo_list_timestamp") : "123456789"
pomodorowindow.todo_list_name.text = Storage.checkIfSettingExist("todo_list_name") == "true" ? Storage.getSetting("todo_list_name") : "ToDo List"
var listidtimestamp = pomodorowindow.todo_list_timestamp;
var taskslistmodel = pomodorowindow.todo_listmodel;
controls_tasks_gen.hiddenfinished = Storage.checkIfSettingExist("finished_tasks_visible") == "true" ? Storage.getSetting("finished_tasks_visible") : false
controls_tasks_gen.hiddenfinished == false ? Storage.getTasksFromDB(listidtimestamp, taskslistmodel) : Storage.getNotFinishedTasksFromDB(listidtimestamp, false, taskslistmodel);
}
}
}
}
Rectangle {
id: pomodorotextes
color: "#00000000"
width: pomodoro.width
height: pomodoro.height
anchors {
top: if(parent.width/parent.height < 1/3){
pomodoro.bottom
}
else if(parent.width/parent.height >= 1/3 && parent.width/parent.height <= 1){
timertextes.bottom
}
else if(parent.width/parent.height > 1 && parent.width/parent.height < 4){
pomodoro.bottom
}
else {
parent.top
}
left: if(parent.width/parent.height < 1/3){
parent.left
}
else if(parent.width/parent.height >= 1/3 && parent.width/parent.height <= 1){
pomodoro.right
}
else if(parent.width/parent.height > 1 && parent.width/parent.height < 4){
timertextes.right
}
else {
pomodoro.right
}
}
Text {
id: pomodoroText
color: styl.text_color_primary
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
topMargin: parent.height/8
}
text: qsTr("Work & Play")
font {
pixelSize: Math.min(parent.width/10, parent.height/10)
family: "Ubuntu Light"
}
}
Text {
id: pomodororunning
color: styl.text_color_primary
anchors {
top: pomodoroText.bottom
topMargin: height/2
left: pomodoroText.left
leftMargin: pomodoroText.width/3.5
}
text: pomodorobuttontext === "Start" && pomodorotime === "00:00" ? "" : pomodorotime // Display time if pomodoro is running
font {
pixelSize: Math.min(parent.width/12, parent.height/12)
family: "Ubuntu"
}
}
Text {
id: pomodorostatetext
color: pomodororunning.color
anchors {
horizontalCenter: parent.horizontalCenter
top: pomodororunning.bottom
topMargin: height/2
}
text: pomodororunning.text === "" ? "" : pomodorostatustext
font {
pixelSize: Math.min(parent.width/14, parent.height/14)
family: "Ubuntu"
}
}
Text {
id: pomodorostate2text
color: pomodororunning.color
anchors {
horizontalCenter: parent.horizontalCenter
top: pomodorostatetext.bottom
topMargin: height/4
}
text: pomodorostatus2text
font: pomodorostatetext.font
}
}
SettingsMain {
id: settings_window
opacity: 0
anchors {
verticalCenter: parent.verticalCenter
horizontalCenter: parent.horizontalCenter
}
}
ToolbarBottom {
id: toolbar
height: 36
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
}
Rectangle {
id: settings_button
color: "#00000000"
width: 26
height: 26
radius: 4
anchors {
left: parent.left
leftMargin: 5
verticalCenter: parent.verticalCenter
}
Image {
id: imagesettings
source: "images/settings_dark.png"
anchors.centerIn: parent
}
MouseArea {
id: settings_button_ma
anchors.fill: parent
onClicked: {
main_file.state == "" ? main_file.state = "SettingsVisible" : main_file.state = ""
}
}
}
Rectangle{
id: infoButton
color: "#00000000"
width: 26
height: 26
radius: 4
anchors {
right: parent.right
rightMargin: 5
verticalCenter: parent.verticalCenter
}
Image {
id: imageinfo
source: "images/about.png"
anchors.centerIn: parent
}
MouseArea {
id: mouse_area3
anchors.fill: parent
onClicked: {
main_file.state !== "AboutVisible" ? main_file.state = "AboutVisible" : main_file.state = ""
}
}
}
Rectangle {
id: helpButton
color: "#00000000"
width: 26
height: 26
radius: 4
anchors {
right: infoButton.left
rightMargin: 5
verticalCenter: parent.verticalCenter
}
Image {
id: imagehelp
source: "images/help.png"
anchors.centerIn: parent
}
MouseArea {
id: mouse_area1
anchors.fill: parent
onClicked: {
main_file.state !== "Help" ? main_file.state = "Help" : main_file.state = ""
}
}
}
}
}
StopwatchWindow {
id: stopwatchwindow
width: parent.width
height: parent.height
x: parent.width
}
TimerWindow {
id: timerwindow
width: parent.width
height: parent.height
x: parent.width
}
PomodoroWindow {
id: pomodorowindow
width: parent.width
height: parent.height
x: parent.width
}
AboutInfo {
id: aboutinfo1
opacity: 0
width: parent.width
height: parent.height - toolbar.height
}
Rectangle {
id: overlay_help
color: "#44000000"
z: toolbar.z + 1
width: main_file.width
height: main_file.height - toolbar.height
scale: 0
MouseArea {
anchors.fill: parent
onClicked: main_file.state = ""
}
}
HelpFirst {
id: helpmain
scale: 0
z: overlay_help.z + 1
anchors.centerIn: overlay_help
}
WhatsNew {
id: whats_new
scale: 0
visible: false
width: parent.width
height: parent.height
}
states: [
State {
name: "AboutVisible"
PropertyChanges {target: aboutinfo1; opacity: 1}
PropertyChanges {target: stopwatch; opacity: 0}
PropertyChanges {target: timer; opacity: 0}
PropertyChanges {target: pomodoro; opacity: 0}
PropertyChanges {target: helpButton; opacity: 0}
PropertyChanges {target: settings_button; opacity: 0}
PropertyChanges {target: infoButton; color: styl.toolbar_bottom_button_active_color}
},
State {
name: "stopwatchBase"
PropertyChanges {target: stopwatchwindow; x: 0}
PropertyChanges {target: stopwatchwindow; opacity: 1}
PropertyChanges {target: welcomewindow; x: -parent.width}
},
State {
name: "timerBase"
PropertyChanges {target: timerwindow; x: 0}
PropertyChanges {target: timerwindow; opacity: 1}
PropertyChanges {target: welcomewindow; x: -parent.width}
},
State {
name: "pomodoroBase"
PropertyChanges {target: pomodorowindow; x: 0}
PropertyChanges {target: pomodorowindow; opacity: 1}
PropertyChanges {target: welcomewindow; x: -parent.width}
},
State {
name: "SettingsVisible"
PropertyChanges {target: settings_button; color: styl.toolbar_bottom_button_active_color}
PropertyChanges {target: settings_window; opacity: 1}
PropertyChanges {target: helpButton; visible: false}
PropertyChanges {target: infoButton; visible: false}
},
State {
name: "Help"
PropertyChanges {target: overlay_help; scale: 1}
PropertyChanges {target: helpmain; scale: 1}
PropertyChanges {target: helpButton; color: styl.toolbar_bottom_button_active_color}
}
]
transitions:
Transition {
ParallelAnimation {
NumberAnimation {
targets: [ stopwatchwindow, timerwindow, pomodorowindow, welcomewindow ]
property: "x"
easing.type: Easing.OutExpo
duration: 500
}
NumberAnimation {
targets: [ aboutinfo1, welcomewindow, stopwatchwindow, timerwindow, pomodorowindow, settings_window ]
property: "opacity"
easing.type: Easing.OutQuad
duration: 100
}
}
ColorAnimation { duration: 100}
}
}