-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
2114 lines (2008 loc) · 124 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
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
import QtQuick.Layouts
import QtQuick.Controls
import QtCharts
import QtQuick.Templates as T
import './Components'
import './Fonts'
ApplicationWindow{
id:root_app
width:942
height:525
visible:true
color:bg_color
title:'Qtmonkeytype'
font.family:Fonts.roboto_mono
// property font roboto: ({
// family: Fonts.roboto_mono,
// pointSize: 10,
// weight:500
// })
property color bg_color: Qt.color('#323437')
property color main_color: Qt.color('#e2b714')
property color caret_color: Qt.color('#e2b714')
property color sub_color: Qt.color('#646669')
property color sub_alt_color: Qt.color('#2c2e31')
property color text_color: Qt.color('#d1d0c5')
property color error_color: Qt.color('#ca4754')
property color error_extra_color: Qt.color('#7e2a33')
property color colorful_error_color: Qt.color('#ca4754')
property color colorful_error_extra_color: Qt.color('#7e2a33')
MouseArea{
// it is better to detect mouse movement
anchors.fill:parent
hoverEnabled:true
onPositionChanged: {
// console.log(Math.random())
textEdit.active=false
}
onClicked:{
// console.log('clicked')
textEdit.focus=true
}
}
ColumnLayout{
anchors.fill:parent
anchors.margins:34
spacing:30
ColumnLayout{
opacity:textEdit.active ? 0 : 1
Layout.fillWidth:true
spacing:30
RowLayout{
id:title
Layout.fillWidth:true
spacing:6
ColorImage{
Layout.topMargin:5
source:'./images/logo.svg'
color:root_app.main_color
sourceSize.height:23
}
Text{
id:monkeytype_name
Layout.alignment:Qt.AlignTop
text:"<font color='#a6e214'>Qt</font>monkeytype"
textFormat: TextEdit.RichText
font.family:Fonts.lexend_deca
font.weight:600
font.pointSize:25
color:root_app.text_color.toString()
Text{
anchors.top:parent.top
anchors.left:parent.left
anchors.topMargin:-2
anchors.leftMargin:40
text:"monkey see"
font.family:Fonts.lexend_deca
font.pointSize:9
color:root_app.sub_color.toString()
}
}
RowLayout{
Layout.leftMargin:10
Layout.fillWidth:true
Layout.fillHeight:true
spacing:20
Button{
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:monkeytype_name.height-15
implicitWidth:28
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M528 448H48c-26.5 0-48-21.5-48-48V112c0-26.5 21.5-48 48-48h480c26.5 0 48 21.5 48 48v288c0 26.5-21.5 48-48 48zM128 180v-40c0-6.6-5.4-12-12-12H76c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm-336 96v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm-336 96v-40c0-6.6-5.4-12-12-12H76c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm288 0v-40c0-6.6-5.4-12-12-12H172c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h232c6.6 0 12-5.4 12-12zm96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12z"/></svg>'
imageSize.width:20
buttonText:''
imageColor:root_app.sub_color.toString()
color:root_app.bg_color
}
Button{
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:monkeytype_name.height-15
implicitWidth:28
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M528 448H112c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h416c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm64-320c-26.5 0-48 21.5-48 48 0 7.1 1.6 13.7 4.4 19.8L476 239.2c-15.4 9.2-35.3 4-44.2-11.6L350.3 85C361 76.2 368 63 368 48c0-26.5-21.5-48-48-48s-48 21.5-48 48c0 15 7 28.2 17.7 37l-81.5 142.6c-8.9 15.6-28.9 20.8-44.2 11.6l-72.3-43.4c2.7-6 4.4-12.7 4.4-19.8 0-26.5-21.5-48-48-48S0 149.5 0 176s21.5 48 48 48c2.6 0 5.2-.4 7.7-.8L128 416h384l72.3-192.8c2.5 .4 5.1 .8 7.7 .8 26.5 0 48-21.5 48-48s-21.5-48-48-48z"/></svg>'
imageSize.width:20
buttonText:''
imageColor:root_app.sub_color.toString()
color:root_app.bg_color
}
Button{
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:monkeytype_name.height-15
implicitWidth:28
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 192 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M20 424.2h20V279.8H20c-11 0-20-9-20-20V212c0-11 9-20 20-20h112c11 0 20 9 20 20v212.2h20c11 0 20 9 20 20V492c0 11-9 20-20 20H20c-11 0-20-9-20-20v-47.8c0-11 9-20 20-20zM96 0C56.2 0 24 32.2 24 72s32.2 72 72 72 72-32.2 72-72S135.8 0 96 0z"/></svg>'
imageSize.height:height-8
buttonText:''
imageColor:root_app.sub_color.toString()
color:root_app.bg_color
}
Button{
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:monkeytype_name.height-15
implicitWidth:28
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4 .6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"/></svg>'
imageSize.height:height-8
buttonText:''
imageColor:root_app.sub_color.toString()
color:root_app.bg_color
}
Item{
Layout.fillWidth:true
}
Button{
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:monkeytype_name.height-15
implicitWidth:28
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M224 512c35.3 0 64-28.7 64-64H160c0 35.4 28.7 64 64 64zm215.4-149.7c-19.3-20.8-55.5-52-55.5-154.3 0-77.7-54.5-139.9-127.9-155.2V32c0-17.7-14.3-32-32-32s-32 14.3-32 32v20.8C118.6 68.1 64.1 130.3 64.1 208c0 102.3-36.2 133.5-55.5 154.3-6 6.5-8.7 14.2-8.6 21.7 .1 16.4 13 32 32.1 32h383.8c19.1 0 32-15.6 32.1-32 .1-7.6-2.6-15.3-8.6-21.7z"/></svg>'
imageSize.height:height-8
buttonText:''
imageColor:root_app.sub_color.toString()
color:root_app.bg_color
}
Button{
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:monkeytype_name.height-15
implicitWidth:28
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M313.6 304c-28.7 0-42.5 16-89.6 16-47.1 0-60.8-16-89.6-16C60.2 304 0 364.2 0 438.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-25.6c0-74.2-60.2-134.4-134.4-134.4zM400 464H48v-25.6c0-47.6 38.8-86.4 86.4-86.4 14.6 0 38.3 16 89.6 16 51.7 0 74.9-16 89.6-16 47.6 0 86.4 38.8 86.4 86.4V464zM224 288c79.5 0 144-64.5 144-144S303.5 0 224 0 80 64.5 80 144s64.5 144 144 144zm0-240c52.9 0 96 43.1 96 96s-43.1 96-96 96-96-43.1-96-96 43.1-96 96-96z"/></svg>'
imageSize.height:height-8
buttonText:''
imageColor:root_app.sub_color.toString()
color:root_app.bg_color
}
}
}
Rectangle{
id:mainMenu
Layout.alignment:Qt.AlignCenter
Layout.preferredWidth:parent.width*0.9
Layout.maximumWidth:870
radius: 8
height:40
color:root_app.sub_alt_color.toString()
Flickable {
clip: true
boundsBehavior: Flickable.StopAtBounds
anchors.fill:parent
anchors.leftMargin:25
anchors.rightMargin:25
anchors.topMargin:10
contentWidth: mainRows.width; contentHeight: mainRows.height
flickableDirection: Flickable.HorizontalFlick
ScrollBar.horizontal: ScrollBar {
implicitHeight:8
}
ButtonGroup { id: typeMode_btns }
RowLayout{
id:mainRows
spacing:20
RowButton{
id:punctuation
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:parent.height
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M256 8C118.9 8 8 118.9 8 256c0 137.1 110.9 248 248 248 48.2 0 95.3-14.1 135.4-40.2 12-7.8 14.6-24.3 5.6-35.4l-10.2-12.4c-7.7-9.4-21.2-11.7-31.4-5.1C325.9 429.8 291.3 440 256 440c-101.5 0-184-82.5-184-184S154.5 72 256 72c100.1 0 184 57.6 184 160 0 38.8-21.1 79.7-58.2 83.7-17.3-.5-16.9-12.9-13.5-30l23.4-121.1C394.7 149.8 383.3 136 368.2 136h-45a13.5 13.5 0 0 0 -13.4 12l0 .1c-14.7-17.9-40.4-21.8-60-21.8-74.6 0-137.8 62.2-137.8 151.5 0 65.3 36.8 105.9 96 105.9 27 0 57.4-15.6 75-38.3 9.5 34.1 40.6 34.1 70.7 34.1C462.6 379.4 504 307.8 504 232 504 95.7 394 8 256 8zm-21.7 304.4c-22.2 0-36.1-15.6-36.1-40.8 0-45 30.8-72.7 58.6-72.7 22.3 0 35.6 15.2 35.6 40.8 0 45.1-33.9 72.7-58.2 72.7z"/></svg>'
imageSize.height:height-8
buttonText:'punctuation'
fontWeight:500
fontSize:10
imageColor:checked? root_app.main_color:root_app.sub_color.toString()
textColor:checked? root_app.main_color:root_app.sub_color.toString()
color:"transparent"
checkable:true
onClicked:{
checked=!checked
textEdit.punctuation=checked
textEdit.resetProperties(textEdit.repeated)
}
}
RowButton{
id:numbers
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:parent.height
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M440.7 182.1l7.1-40c1.3-7.4-4.3-14.1-11.8-14.1h-74.8l14.6-81.9C377.1 38.8 371.5 32 364 32h-40.6a12 12 0 0 0 -11.8 9.9L296.2 128H197.5l14.6-81.9C213.5 38.8 207.8 32 200.4 32h-40.6a12 12 0 0 0 -11.8 9.9L132.5 128H53.4a12 12 0 0 0 -11.8 9.9l-7.1 40C33.2 185.2 38.8 192 46.3 192h74.8L98.2 320H19.1a12 12 0 0 0 -11.8 9.9l-7.1 40C-1.1 377.2 4.5 384 12 384h74.8L72.2 465.9C70.9 473.2 76.5 480 84 480h40.6a12 12 0 0 0 11.8-9.9L151.8 384h98.6l-14.6 81.9C234.5 473.2 240.2 480 247.7 480h40.6a12 12 0 0 0 11.8-9.9L315.5 384h79.1a12 12 0 0 0 11.8-9.9l7.1-40c1.3-7.4-4.3-14.1-11.8-14.1h-74.8l22.9-128h79.1a12 12 0 0 0 11.8-9.9zM261.9 320h-98.6l22.9-128h98.6l-22.9 128z"/></svg>'
imageSize.height:height-8
buttonText:'numbers'
fontWeight:500
fontSize:10
imageColor:checked? root_app.main_color:root_app.sub_color.toString()
textColor:checked? root_app.main_color:root_app.sub_color.toString()
color:"transparent"
checkable:true
onClicked:{
checked=!checked
textEdit.numbers=checked
textEdit.resetProperties(textEdit.repeated)
}
}
Rectangle{
width:4
Layout.fillHeight: true
color:root_app.bg_color
radius:4
}
RowButton{
id:timeMode
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:parent.height
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M256 8C119 8 8 119 8 256S119 504 256 504 504 393 504 256 393 8 256 8zm92.5 313h0l-20 25a16 16 0 0 1 -22.5 2.5h0l-67-49.7a40 40 0 0 1 -15-31.2V112a16 16 0 0 1 16-16h32a16 16 0 0 1 16 16V256l58 42.5A16 16 0 0 1 348.5 321z"/></svg>'
imageSize.height:height-8
buttonText:'time'
fontWeight:500
fontSize:10
checkable:true
autoExclusive: true
imageColor:checked? root_app.main_color:root_app.sub_color.toString()
textColor:checked? root_app.main_color:root_app.sub_color.toString()
color:"transparent"
onClicked:{
checked=true
// textEdit.wordCount=50
textEdit.resetProperties(textEdit.repeated)
}
onCheckedChanged:{
if(checked){
//apply default values when first time checked
textEdit.wordCount=50
timer.timeMode_limit=60
}
}
ButtonGroup.group:typeMode_btns
}
RowButton{
id:wordsMode
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:parent.height
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M432 416h-23.4L277.9 53.7A32 32 0 0 0 247.6 32h-47.2a32 32 0 0 0 -30.3 21.7L39.4 416H16a16 16 0 0 0 -16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0 -16-16h-19.6l23.3-64h152.6l23.3 64H304a16 16 0 0 0 -16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0 -16-16zM176.9 272L224 142.5 271.2 272z"/></svg>'
imageSize.height:height-8
buttonText:'words'
fontWeight:500
fontSize:10
checked:true
checkable:true
autoExclusive: true
imageColor:checked? root_app.main_color:root_app.sub_color.toString()
textColor:checked? root_app.main_color:root_app.sub_color.toString()
color:"transparent"
onClicked:{
checked=true
textEdit.resetProperties(textEdit.repeated)
}
onCheckedChanged:{
//apply default values when first time checked
if(checked){
textEdit.wordCount=50
}
}
ButtonGroup.group:typeMode_btns
}
RowButton{
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:parent.height
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M464 256h-80v-64c0-35.3 28.7-64 64-64h8c13.3 0 24-10.7 24-24V56c0-13.3-10.7-24-24-24h-8c-88.4 0-160 71.6-160 160v240c0 26.5 21.5 48 48 48h128c26.5 0 48-21.5 48-48V304c0-26.5-21.5-48-48-48zm-288 0H96v-64c0-35.3 28.7-64 64-64h8c13.3 0 24-10.7 24-24V56c0-13.3-10.7-24-24-24h-8C71.6 32 0 103.6 0 192v240c0 26.5 21.5 48 48 48h128c26.5 0 48-21.5 48-48V304c0-26.5-21.5-48-48-48z"/></svg>'
imageSize.height:height-8
buttonText:'quote'
fontWeight:500
fontSize:10
checkable:true
autoExclusive: true
imageColor:checked? root_app.main_color:root_app.sub_color.toString()
textColor:checked? root_app.main_color:root_app.sub_color.toString()
color:"transparent"
onClicked:{
checked=true
textEdit.resetProperties(textEdit.repeated)
}
ButtonGroup.group:typeMode_btns
}
RowButton{
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
// implicitWidth:content.width
Layout.alignment:Qt.AlignBottom
implicitHeight:parent.height
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M634.9 462.7l-288-448C341 5.5 330.9 0 320 0s-21 5.5-26.9 14.7l-288 448a32 32 0 0 0 -1.2 32.6A32 32 0 0 0 32 512h576c11.7 0 22.5-6.4 28.1-16.7a32 32 0 0 0 -1.2-32.6zM320 91.2L405.4 224H320l-64 64-38.1-38.1L320 91.2z"/></svg>'
imageSize.height:height-8
buttonText:'zen'
fontWeight:500
fontSize:10
checkable:true
autoExclusive: true
imageColor:checked? root_app.main_color:root_app.sub_color.toString()
textColor:checked? root_app.main_color:root_app.sub_color.toString()
color:"transparent"
onClicked:{
checked=true
textEdit.resetProperties(textEdit.repeated)
}
ButtonGroup.group:typeMode_btns
}
RowButton{
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
// implicitWidth:content.width
Layout.alignment:Qt.AlignBottom
implicitHeight:parent.height
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M507.7 109.1c-2.2-9-13.5-12.1-20.1-5.5l-74.4 74.4-67.9-11.3-11.3-67.9 74.4-74.4c6.6-6.6 3.4-17.9-5.7-20.2-47.4-11.7-99.6 .9-136.6 37.9-39.6 39.6-50.6 97.1-34.1 147.2L18.7 402.8c-25 25-25 65.5 0 90.5 25 25 65.5 25 90.5 0l213.2-213.2c50.1 16.7 107.5 5.7 147.4-34.2 37.1-37.1 49.7-89.3 37.9-136.7zM64 472c-13.3 0-24-10.8-24-24 0-13.3 10.8-24 24-24s24 10.7 24 24c0 13.3-10.8 24-24 24z"/></svg>'
imageSize.height:height-8
buttonText:'custom'
fontWeight:500
fontSize:10
checkable:true
autoExclusive: true
imageColor:checked? root_app.main_color:root_app.sub_color.toString()
textColor:checked? root_app.main_color:root_app.sub_color.toString()
color:"transparent"
onClicked:{
checked=true
textEdit.resetProperties(textEdit.repeated)
}
ButtonGroup.group:typeMode_btns
}
Rectangle{
width:4
Layout.fillHeight: true
color:root_app.bg_color
radius:4
}
Repeater{
model:timeMode.checked?[15,30,60,120]:[10,25,50,100]
// onModelChanged:{
// if(timeMode.checked){
// timer.timeMode_limit=60
// }else{
// textEdit.wordCount=50
// }
// textEdit.resetProperties(textEdit.repeated)
// }
delegate :Button{
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:parent.height
implicitWidth:20
buttonText:modelData
fontSize:9
fontWeight:400
textColor:checked ? root_app.main_color :root_app.sub_color.toString()
color:"transparent"
checkable:true
autoExclusive: true
checked:index===2
onClicked:{
checked=true
// console.log(timer.timeStep)
if(timeMode.checked){
timer.timeMode_limit=parseInt(modelData)
}else{
textEdit.wordCount=parseInt(modelData)
}
textEdit.resetProperties(textEdit.repeated)
}
}
}
Button{
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
Layout.alignment:Qt.AlignBottom
implicitHeight:parent.height
implicitWidth:20
imageSize.height:height-8
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M501.1 395.7L384 278.6c-23.1-23.1-57.6-27.6-85.4-13.9L192 158.1V96L64 0 0 64l96 128h62.1l106.6 106.6c-13.6 27.8-9.2 62.3 13.9 85.4l117.1 117.1c14.6 14.6 38.2 14.6 52.7 0l52.7-52.7c14.5-14.6 14.5-38.2 0-52.7zM331.7 225c28.3 0 54.9 11 74.9 31l19.4 19.4c15.8-6.9 30.8-16.5 43.8-29.5 37.1-37.1 49.7-89.3 37.9-136.7-2.2-9-13.5-12.1-20.1-5.5l-74.4 74.4-67.9-11.3L334 98.9l74.4-74.4c6.6-6.6 3.4-17.9-5.7-20.2-47.4-11.7-99.6 .9-136.6 37.9-28.5 28.5-41.9 66.1-41.2 103.6l82.1 82.1c8.1-1.9 16.5-2.9 24.7-2.9zm-103.9 82l-56.7-56.7L18.7 402.8c-25 25-25 65.5 0 90.5s65.5 25 90.5 0l123.6-123.6c-7.6-19.9-9.9-41.6-5-62.7zM64 472c-13.2 0-24-10.8-24-24 0-13.3 10.7-24 24-24s24 10.7 24 24c0 13.2-10.7 24-24 24z"/></svg>'
buttonText:''
imageColor:checked ? root_app.main_color :root_app.sub_color.toString()
color:"transparent"
checkable:true
autoExclusive: true
onClicked:{
checked=true
}
}
}
}
}
RowLayout{
Layout.fillWidth:true
spacing:30
Item{
Layout.fillWidth:true
}
RowButton{
visible:textEdit.repeated
hoverColor:"transparent"
pressColor:"transparent"
content.spacing:20
Layout.alignment:Qt.AlignCenter
implicitHeight:content.height
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Pro 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M142.9 142.9c62.2-62.2 162.7-62.5 225.3-1L327 183c-6.9 6.9-8.9 17.2-5.2 26.2s12.5 14.8 22.2 14.8H463.5c0 0 0 0 0 0H472c13.3 0 24-10.7 24-24V72c0-9.7-5.8-18.5-14.8-22.2s-19.3-1.7-26.2 5.2L413.4 96.6c-87.6-86.5-228.7-86.2-315.8 1C73.2 122 55.6 150.7 44.8 181.4c-5.9 16.7 2.9 34.9 19.5 40.8s34.9-2.9 40.8-19.5c7.7-21.8 20.2-42.3 37.8-59.8zM16 312v7.6 .7V440c0 9.7 5.8 18.5 14.8 22.2s19.3 1.7 26.2-5.2l41.6-41.6c87.6 86.5 228.7 86.2 315.8-1c24.4-24.4 42.1-53.1 52.9-83.7c5.9-16.7-2.9-34.9-19.5-40.8s-34.9 2.9-40.8 19.5c-7.7 21.8-20.2 42.3-37.8 59.8c-62.2 62.2-162.7 62.5-225.3 1L185 329c6.9-6.9 8.9-17.2 5.2-26.2s-12.5-14.8-22.2-14.8H48.4h-.7H40c-13.3 0-24 10.7-24 24z"/></svg>'
imageSize.height:height-4
buttonText:'repeated'
fontWeight:600
fontSize:12
checkable:true
autoExclusive: true
disabledImageColor:root_app.error_color.toString()
textColor:root_app.error_color.toString()
color:"transparent"
enabled:false
}
RowButton{
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
content.spacing:20
Layout.alignment:Qt.AlignCenter
implicitHeight:content.height
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm82.3 357.6c-3.9 3.9-8 8-11.3 11.3-3 3-5.1 6.7-6.2 10.7-1.5 5.7-2.7 11.4-4.8 16.9l-17.4 46.9c-13.8 3-28 4.7-42.7 4.7v-27.4c1.7-12.6-7.6-36.3-22.6-51.3-6-6-9.4-14.1-9.4-22.6v-32c0-11.6-6.3-22.3-16.5-28-14.4-8-34.8-19.1-48.8-26.1-11.5-5.8-22.1-13.1-31.7-21.8l-.8-.7a114.8 114.8 0 0 1 -18.1-20.7c-9.4-13.8-24.7-36.4-34.6-51.1 20.5-45.5 57.4-82 103.2-101.9l24 12C203.5 89.7 216 82 216 70.1v-11.3c8-1.3 16.1-2.1 24.4-2.4l28.3 28.3c6.3 6.3 6.3 16.4 0 22.6L264 112l-10.3 10.3c-3.1 3.1-3.1 8.2 0 11.3l4.7 4.7c3.1 3.1 3.1 8.2 0 11.3l-8 8a8 8 0 0 1 -5.7 2.3h-9c-2.1 0-4.1 .8-5.6 2.3l-9.9 9.7a8 8 0 0 0 -1.6 9.3l15.6 31.2c2.7 5.3-1.2 11.6-7.2 11.6h-5.6c-1.9 0-3.8-.7-5.2-2l-9.3-8.1a16 16 0 0 0 -15.6-3.1l-31.2 10.4a12 12 0 0 0 -8.2 11.3c0 4.5 2.6 8.7 6.6 10.7l11.1 5.5c9.4 4.7 19.8 7.2 30.3 7.2s22.6 27.3 32 32h66.8c8.5 0 16.6 3.4 22.6 9.4l13.7 13.7a30.5 30.5 0 0 1 8.9 21.6 46.5 46.5 0 0 1 -13.7 33zM417 274.3c-5.8-1.5-10.8-5-14.2-10l-18-27a24 24 0 0 1 0-26.6l19.6-29.4c2.3-3.5 5.5-6.3 9.2-8.2l13-6.5C440.2 193.6 448 223.9 448 256c0 8.7-.7 17.2-1.8 25.5L417 274.3z"/></svg>'
imageSize.height:height-4
buttonText:'english'
fontWeight:state==="Hovering"?600:500
fontSize:12
checkable:true
autoExclusive: true
imageColor:checked? root_app.main_color:root_app.sub_color.toString()
textColor:checked? root_app.main_color:root_app.sub_color.toString()
color:"transparent"
onClicked:{
}
}
RowButton{
id:customPace_btn
visible:textEdit.repeated
hoverColor:root_app.text_color.toString()
pressColor:root_app.sub_color.toString()
content.spacing:20
Layout.alignment:Qt.AlignCenter
implicitHeight:content.height
imageSource:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M288 32C128.9 32 0 160.9 0 320c0 52.8 14.3 102.3 39.1 144.8 5.6 9.6 16.3 15.2 27.4 15.2h443c11.1 0 21.8-5.6 27.4-15.2C561.8 422.3 576 372.8 576 320c0-159.1-128.9-288-288-288zm0 64c14.7 0 26.6 10.1 30.3 23.7-1.1 2.3-2.6 4.2-3.5 6.7l-9.2 27.7c-5.1 3.5-11 6-17.6 6-17.7 0-32-14.3-32-32S270.3 96 288 96zM96 384c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm48-160c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm246.8-72.4l-61.3 184C343.1 347.3 352 364.5 352 384c0 11.7-3.4 22.6-8.9 32H232.9c-5.5-9.5-8.9-20.3-8.9-32 0-33.9 26.5-61.4 59.9-63.6l61.3-184c4.2-12.6 17.7-19.5 30.4-15.2 12.6 4.2 19.4 17.8 15.2 30.4zm14.7 57.2l15.5-46.6c3.5-1.3 7.1-2.2 11.1-2.2 17.7 0 32 14.3 32 32s-14.3 32-32 32c-11.4 0-20.9-6.3-26.6-15.2zM480 384c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"/></svg>'
imageSize.height:height-4
buttonText:'custom pace '+pace+' wpm'
fontWeight:state==="Hovering"?600:500
fontSize:12
checkable:true
autoExclusive: true
imageColor:checked? root_app.main_color:root_app.sub_color.toString()
textColor:checked? root_app.main_color:root_app.sub_color.toString()
color:"transparent"
property int pace:98
onClicked:{
// checked=!checked
choosePace.open()
}
Popup {
id:choosePace
// Component.onCompleted:{
// open()
// }
parent:Overlay.overlay
x:parent.width/2 - width/2
y:200
// anchors.centerIn:parent
modal: true
dim:true
focus: true
// closePolicy: Popup.NoAutoClose
padding: 0
onOpened: {
}
onClosed: {
}
enter: Transition {
// grow_fade_in
NumberAnimation {
property: "opacity"
from: 0.0
to: 1.0
easing.type: Easing.InOutQuad
duration: 150
}
}
exit: Transition {
// shrink_fade_out
NumberAnimation {
property: "opacity"
from: 1.0
to: 0.0
easing.type: Easing.InOutQuad
duration: 150
}
}
background: Rectangle {
color:Qt.rgba(0,0,0,0)
}
Rectangle {
implicitWidth: root_app.width *0.5
implicitHeight: 50
color: root_app.bg_color
radius:8
RowLayout{
anchors.fill:parent
spacing:0
ColorImage{
Layout.alignment:Qt.AlignCenter
Layout.leftMargin:20
Layout.rightMargin:10
source:'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M285.5 273L91.1 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.7-22.7c-9.4-9.4-9.4-24.5 0-33.9L188.5 256 34.5 101.3c-9.3-9.4-9.3-24.5 0-33.9l22.7-22.7c9.4-9.4 24.6-9.4 33.9 0L285.5 239c9.4 9.4 9.4 24.6 0 33.9z"/></svg>'
color:'#8d8d8d'
sourceSize.width:10
}
TextField{
Layout.fillWidth:true
Layout.fillHeight:true
placeholderText:'custom...'
validator: IntValidator{}
onTextEdited:{
customPace_btn.pace=parseInt(text)
}
onAccepted:{
choosePace.close()
}
}
}
}
Overlay.modal: Rectangle {
color: Qt.rgba(0, 0, 0, .5)
}
}
}
Item{
Layout.fillWidth:true
}
}
Behavior on opacity{
NumberAnimation {
duration: 250
easing.type: Easing.InOutQuad
}
}
PropertyChanges{ enabled:!textEdit.active}
}
Rectangle{
id:content_textEdit
Layout.fillWidth:true
Layout.maximumHeight:32*4
Layout.preferredHeight:32*4
color:"transparent"
Text {
anchors.bottom:parent.top
anchors.bottomMargin:10
opacity:!textEdit.active ? 0:1
text: timeMode.checked?timer.timeStep + "/"+timer.timeMode_limit:textEdit.cursorPosition + "/" + textEdit.length
font.pointSize: 16
color: root_app.main_color
horizontalAlignment: Text.AlignLeft
font.family: Fonts.roboto_mono
font.weight: 600
}
Flickable {
id: flick
anchors.fill:parent
contentWidth: textEdit.contentWidth
contentHeight: textEdit.contentHeight
clip: true
interactive:false
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.VerticalFlick
function ensureVisible(r)
{
if (contentX >= r.x)
contentX = r.x;
else if (contentX+width <= r.x+r.width)
contentX = r.x+r.width-width;
if (contentY >= r.y)
contentY = r.y ;
else if ((contentY+height)/2 <= r.y+r.height)
contentY = r.y+r.height-height/2;
}
TextEdit{
// onTextChanged:{
// // console.log('jel')
// // console.log(textEdit.positionToRectangle(textEdit.positionAt(textEdit.contentWidth,cursorDelegate_.y)).x)
// // if(textEdit.positionToRectangle(textEdit.positionAt(textEdit.contentWidth,cursorDelegate_.y)).x===0 && textEdit.positionToRectangle(textEdit.positionAt(textEdit.contentWidth,cursorDelegate_.y)).y/32 + 1=== lineCount-3){
// // console.log('before last')
// // }
// }
id:textEdit
width:flick.width
onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
selectByMouse :false
focus:true
opacity:0
property bool punctuation
property bool numbers
// Behavior on rawText{
SequentialAnimation {
id:refreshTextAnimation
NumberAnimation {
target: textEdit
property: "opacity"
// from: 0.0
to: 0.0
// easing.type: Easing.InOutQuad
duration: 0
// running:true
}
PauseAnimation{
duration:100
}
NumberAnimation {
target: textEdit
property: "opacity"
// from: 0.0
to: 1.0
easing.type: Easing.OutCubic
duration: 300
// running:true
}
}
function generateText(now=textEdit.wordCount) {
//now=numberofwords
// console.log('generate: ->'+now)
var numWords=now
var includePunctuation=textEdit.punctuation
var includeNumbers=textEdit.numbers
var words = [
"write", "govern", "here", "of", "another", "see", "they", "these",
"one", "many", "turn", "can", "to", "down", "there", "too", "about", "home",
"a", "as", "lead", "use", "make", "long", "much", "well", "because",
"day", "now", "when", "than", "for", "do", "consider", "since"
];
var punctuation = [".", ",", "!", "?", ";", ":"];
var numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
var text = "";
for (var i = 0; i < numWords; i++) {
var word = words[Math.floor(Math.random() * words.length)];
if (includeNumbers && Math.random() < 0.2) {
word += numbers[Math.floor(Math.random() * numbers.length)];
}
if (includePunctuation && Math.random() < 0.3) {
word += punctuation[Math.floor(Math.random() * punctuation.length)];
}
if(i===0 && now===textEdit.wordCount){
// make sure it gets the most first word in the text and not the new generated timeMode text
textEdit.currentWord=word
// console.log(textEdit.currentWord)
}
text += word + " ";
}
return text
}
function resetProperties(isrepeated){
if(isrepeated){
// if you want to maintain the text and reset everything
refreshTextAnimation.start()
// console.log((textEdit.rawText)+ "<")
// console.log((textEdit.rawText.trim())+ "<")
textEdit.text="<p style='line-height:100%' >" +(timeMode.checked?textEdit.rawText:textEdit.rawText.trim())+"</p>"
}else{
var genText=generateText()
if(!timeMode.checked){
genText=genText.trim()
}
refreshTextAnimation.start()
textEdit.rawText=genText
textEdit.text = "<p style='line-height:100%' >" +genText+"</p>"
}
textEdit.cursorPosition=0
textEdit.active=false
textEdit.currentWordIndex=0
textEdit.writtenWords=0
textEdit.rawWrittenWords=0
timer.timeStep=1
timer.maxSpeed=0
timer.rawMaxSpeed=0
textEdit.repeated=isrepeated
series1.removePoints(0,series1.count)
series2.removePoints(0,series2.count)
// console.log('this is cnt : '+paceAnimation.cnt)
// console.log('ReSet')
// if(textEdit.repeated){
// paceAnimation.cnt=textEdit.lineCount-1
// paceAnimation.complete()
// }
}
wrapMode: TextEdit.Wrap
textFormat: TextEdit.RichText
font.family:Fonts.roboto_mono
font.pointSize:18
property int wordCount:50
Component.onCompleted:{
//initialising
resetProperties(false)
}
color:root_app.sub_color.toString()
property int rlength:0
cursorDelegate: Rectangle{
visible:false
}
onEditingFinished:{
}
selectionColor : root_app.caret_color
Rectangle {
id:cursorDelegate_
width: 2
height:32
color: root_app.caret_color
radius: 3
x:parent.cursorRectangle.x
y:parent.cursorRectangle.y
Behavior on x {
NumberAnimation {
easing.type: Easing.OutQuart
duration: 300
}
}
onYChanged:{
// console.log('hello')
if(timeMode.checked && textEdit.active){
// console.log('added')
textEdit.insert(textEdit.length,textEdit.generateText(15))
}
}
SequentialAnimation on opacity {
// alwaysRunToEnd:true
running: !textEdit.active;
loops: Animation.Infinite;
NumberAnimation { to: 0; duration: 500; easing.type: "OutQuad"}
NumberAnimation { to: 1; duration: 500; easing.type: "InQuad"}
onRunningChanged:{
if(!running){
cursorDelegate_.opacity=1
}
}
}
}
Rectangle {
id:customPace_rect
width: 2
height:32
color: root_app.sub_color.toString()
radius: 3
opacity:0.5
visible:paceAnimation.running
NumberAnimation {
id:paceAnimation
target:customPace_rect
property:"x"
from:0
to:textEdit.positionToRectangle(textEdit.positionAt(textEdit.contentWidth,customPace_rect.y)).x
duration: (textEdit.positionAt(textEdit.contentWidth,customPace_rect.y)-textEdit.positionAt(0,customPace_rect.y))*60/(customPace_btn.pace*5)*1000
onFinished:{
// console.log('round'+ paceAnimation.cnt)
if(paceAnimation.cnt===textEdit.lineCount-1){
// console.log('finish')
paceAnimation.cnt=0
customPace_rect.y=0
return
}
customPace_rect.y=customPace_rect.y+32
paceAnimation.cnt++
start()
}
property int cnt:0
}
}
Keys.onPressed:event=>{
active=true
// console.log(textEdit.rawWrittenWords)
if (event.key === Qt.Key_Left){
event.accepted = true
return
}
if (event.key === Qt.Key_Up){
event.accepted = true
return
}
if (event.key === Qt.Key_Right){
event.accepted = true
return
}
if (event.key === Qt.Key_Down){
event.accepted = true
return
}
// Check if Ctrl key is pressed
if (event.modifiers & Qt.ControlModifier) {
if (event.key === Qt.Key_Backspace) {
if(cursorPosition===currentWordIndex){
event.accepted=true
return
}
var writtenText=getText(currentWordIndex,cursorPosition)
if(writtenText.length >= currentWord.length){
insert(cursorPosition,"<font color="+root_app.sub_color.toString()+">"+currentWord+"</font>")
cursorPosition=cursorPosition-currentWord.length
}else{
insert(cursorPosition,"<font color="+root_app.sub_color.toString()+">"+writtenText+"</font>")
cursorPosition=cursorPosition-writtenText.length
}
return
}
return
if (event.matches(StandardKey.Undo)) {
event.accepted = true
return
}
if (event.matches(StandardKey.Undo)) {
event.accepted = true
return
}
// Disable Ctrl+A (Select All)
if (event.key === Qt.Key_A) {
event.accepted = true
return
}
return
}
if (event.key === Qt.Key_Backspace){
if(cursorPosition===currentWordIndex){
event.accepted=true
return
}
if(getText(currentWordIndex,cursorPosition).length > currentWord.length){
return
}else{
insert(cursorPosition,"<font color="+root_app.sub_color.toString()+">"+currentWord[cursorPosition-currentWordIndex-1]+"</font>")
cursorPosition--
}
return
}
if (event.key === Qt.Key_Escape){
focus=false
}
if (event.key === Qt.Key_Space){
//if last word ,space is no longer jumping so rawWrittenWords shouldn't increase
if(getText(cursorPosition,textEdit.length).indexOf(" ")!==-1){
// rawWrittenWords is Ideal writtenWords
rawWrittenWords++
// console.log('rawwritten: '+rawWrittenWords)
}
if(cursorPosition-currentWordIndex===currentWord.length){
writtenWords++
// console.log('Written: '+writtenWords)
}
cursorPosition = cursorPosition+ getText(cursorPosition,textEdit.length).indexOf(" ")+1
currentWord=getText(cursorPosition,cursorPosition+getText(cursorPosition,textEdit.length).indexOf(" "))
if(currentWord===" "){
currentWord=getText(cursorPosition,textEdit.length)
}
currentWordIndex=cursorPosition
event.accepted=true
return
}
if (getText(cursorPosition,cursorPosition+1)===" "){
// console.log('spce')
insert(cursorPosition,"<font color="+root_app.error_extra_color.toString()+">"+event.text+"</font>")
event.accepted =true
return
}
if(event.text===''){
event.accepted =true
return;
}
var charColor=event.text === getText(cursorPosition,cursorPosition+1) ? root_app.text_color.toString():root_app.error_color.toString()
insert(cursorPosition,"<font color='"+charColor+"'>"+(getText(cursorPosition,cursorPosition+1))+"</font>")
remove(cursorPosition,cursorPosition+1)
if(cursorPosition === length){
textEdit.writtenWords++
textEdit.rawWrittenWords++
// console.log('raw is :' +rawWrittenWords)
// console.log(textEdit.wordCount)
finished_test.open()
active=false
}
event.accepted =true
}
property string currentWord
property int currentWordIndex:0
property bool active:false
property int writtenWords:0
property int rawWrittenWords:0
property bool repeated:false
property string rawText
onActiveChanged:{
if(textEdit.repeated===false){
return
}
if(active && cursorPosition===0){
// console.log('am active')
paceAnimation.running=true
}
}
onRepeatedChanged:{
//the paceCursor should stop when !repeated
if (!repeated){
// console.log('1cnt is : '+paceAnimation.cnt)
paceAnimation.complete()
// console.log('2cnt is : '+paceAnimation.cnt)
if(paceAnimation.cnt!==0){
paceAnimation.cnt=textEdit.lineCount-1
paceAnimation.complete()
}
}
}
Timer {
id:timer
interval: 1000
property int timeStep: 1
repeat: true
running: textEdit.active?timeMode.checked?timeStep<timeMode_limit+1:true:false
// triggeredOnStart:true
property int maxSpeed:0
property int rawMaxSpeed:0
property int timeMode_limit:60
onTriggered: {
// console.log(timeStep+ "/" + timeMode_limit)
// for cpm
// var speed=Math.round((textEdit.cursorPosition/timeStep)*60)
// series1.append(timeStep,speed)
// if(speed> maxSpeed){
// maxSpeed=speed