/
main.qml
591 lines (551 loc) · 20.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
/****************************************************************************
Copyright (C) 2021 Dr. Valentin Illich
This file is part of WorkTracker.
WorkTracker is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
WorkTracker is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with WorkTracker. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.4
import QtQuick.Layouts 1.11
import QtQuick.Window 2.11
import QtQuick.Dialogs 1.1
import Qt.labs.settings 1.0
import Qt.labs.calendar 1.0
import ProjectsData 1.0
ApplicationWindow {
property int windowx: projectData.geometry.x
property int windowy: projectData.geometry.y
property int windowWidth: projectData.geometry.width
property int windowHeight: projectData.geometry.height
property color textColor: Material.foreground
id: mainWindow
x: windowx
y: windowy
width: windowWidth
height: windowHeight
visible: true
title: qsTr("Project Work ") + projectData.getProgramVersion()
onXChanged: projectData.geometry = Qt.rect(x, y, width, height)
onYChanged: projectData.geometry = Qt.rect(x, y, width, height)
onWidthChanged: projectData.geometry = Qt.rect(x, y, width, height)
onHeightChanged: projectData.geometry = Qt.rect(x, y, width, height)
ProgressModel {
id: projectData
onRecordingDisabled: jumpmenu.open()
onRecordingStopped: recordingstopped.open()
}
Rectangle {
id: mainwindow
anchors.fill: parent
color: projectData.backgrundColor
RoundButton {
id: currentDate
text: projectData.title
anchors.top: parent.top
anchors.topMargin: 8
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: Qt.application.font.pixelSize * 2
font.capitalization: Font.MixedCase
onClicked: jumpmenu.open()
ToolTip.delay: 2000
ToolTip.timeout: 10000
ToolTip.visible: hovered
ToolTip.text: qsTr("Navigation menu")
}
ListView {
id: workListView
anchors.topMargin: currentDate.height + 2*8
anchors.bottomMargin: addAlarmButton.height
anchors.fill: parent
model: projectData.itemList
delegate: WorkDelegate {}
}
RoundButton {
id: prevButton
text: "<"
anchors.left: parent.left
anchors.leftMargin: 8
anchors.top: parent.top
anchors.topMargin: 8
onClicked: projectData.previous()
ToolTip.delay: 2000
ToolTip.timeout: 10000
ToolTip.visible: hovered
ToolTip.text: qsTr("select previous time period")
}
RoundButton {
id: nextButton
text: ">"
anchors.right: parent.right
anchors.rightMargin: 8
anchors.top: parent.top
anchors.topMargin: 8
onClicked: projectData.next()
ToolTip.delay: 2000
ToolTip.timeout: 10000
ToolTip.visible: hovered
ToolTip.text: qsTr("select next time period")
}
RoundButton {
id: modeButton
text: "..."
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
anchors.left: parent.left
anchors.leftMargin: 8
onClicked: displaymenu.open()
onPressAndHold: configmenu.open()
ToolTip.delay: 2000
ToolTip.timeout: 10000
ToolTip.visible: hovered
ToolTip.text: qsTr("short press: display menu\nlong presas: config menu")
}
RoundButton {
id: addAlarmButton
text: "+"
visible: projectData.isChangeable
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: -helpButton.width / 2
onClicked: workDialog.open()
ToolTip.delay: 2000
ToolTip.timeout: 10000
ToolTip.visible: hovered
ToolTip.text: qsTr("add a new work item")
}
RoundButton {
id: helpButton
text: "?"
visible: projectData.isChangeable
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: addAlarmButton.width / 2
onClicked: projectData.showHelp()
ToolTip.delay: 2000
ToolTip.timeout: 10000
ToolTip.visible: hovered
ToolTip.text: qsTr("open documentation")
}
RoundButton {
id: sumButton
text: projectData.totalTime
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
anchors.right: parent.right
anchors.rightMargin: 8
onClicked: projectData.changeSummary()
ToolTip.delay: 2000
ToolTip.timeout: 10000
ToolTip.visible: hovered
ToolTip.text: qsTr("switch between hours and percent\n(but not in day view)")
}
}
function jumpToDay(day,month,year) {
projectData.jumpToDay(day,month,year)
jumpmenu.close()
}
Menu {
id: jumpmenu
width: windowWidth
y: currentDate.height+8
MenuItem {
width: windowWidth // needed for language changes
Material.foreground: (projectData.currentRecordingAccount == 0) ? Material.accent : textColor
text: qsTr("Recording at home")
onTriggered: projectData.currentRecordingAccount = 0
}
MenuItem {
width: windowWidth // needed for language changes
Material.foreground: projectData.currentRecordingAccount == 1 ? Material.accent : textColor
text: qsTr("Recording in office")
onTriggered: projectData.currentRecordingAccount = 1
}
MenuItem {
width: windowWidth
text: qsTr("Enter checkin time")
onTriggered: checkedInOn.open()
}
MenuSeparator {
width: windowWidth // needed for language changes
}
MenuItem {
width: windowWidth // needed for language changes
text: qsTr("Show current day")
onTriggered: jumpToDay(0,0,0)
}
MenuSeparator {
width: windowWidth // needed for language changes
}
RowLayout
{
RoundButton {
id: jumpTo
Layout.leftMargin: 8
text: qsTr("Show day:")
onClicked: jumpToDay(parseInt(jumpday.text),parseInt(jumpmonth.text),parseInt(jumpyear.text))
}
Item {
Layout.fillWidth: true
}
}
RowLayout
{
width: windowWidth // needed for language changes
TextField {
id: jumpday
placeholderText: qsTr("Day")
Layout.leftMargin: jumpTo.x+8
}
TextField {
id: jumpmonth
placeholderText: qsTr("Month")
}
TextField {
id: jumpyear
placeholderText: qsTr("Year")
}
Item {
Layout.fillWidth: true
}
}
}
Menu {
id: configmenu
width: windowWidth
y: modeButton.y-implicitHeight
MenuItem {
width: windowWidth // needed for language changes
text: qsTr("Create default from list")
onTriggered: projectData.createDefaultList()
}
MenuSeparator {
width: windowWidth // needed for language changes
}
MenuItem {
width: windowWidth // needed for language changes
enabled: false
text: qsTr("Select Language")
}
MenuItem {
width: windowWidth // needed for language changes
text: qsTr("English")
onTriggered: projectData.setLanguage(0)
}
MenuItem {
width: windowWidth // needed for language changes
text: qsTr("German")
onTriggered: projectData.setLanguage(1)
}
MenuItem {
width: windowWidth // needed for language changes
text: qsTr("French")
onTriggered: projectData.setLanguage(2)
}
}
function changeVisibleAccounts() {
displaymenu.close()
}
function changeRecordingAccount(account) {
projectData.currentRecordingAccount = account
displaymenu.close()
}
Menu {
id: displaymenu
width: windowWidth
y: modeButton.y-implicitHeight
onOpened: showwork.checked = projectData.alwaysShowWork
MenuItem {
width: windowWidth // needed for language changes (win10)
text: qsTr("Overview of year")
Material.foreground: projectData.mode == 0 ? Material.accent : textColor
onTriggered: projectData.mode = OperatingMode.DisplayYear
}
MenuItem {
width: windowWidth // needed for language changes (win10)
text: qsTr("Overview of month")
Material.foreground: projectData.mode == 1 ? Material.accent : textColor
onTriggered: projectData.mode = OperatingMode.DisplayMonth
}
MenuItem {
width: windowWidth // needed for language changes (win10)
text: qsTr("Overview of week")
Material.foreground: projectData.mode == 2 ? Material.accent : textColor
onTriggered: projectData.mode = OperatingMode.DisplayWeek
}
MenuItem {
width: windowWidth // needed for language changes (win10)
text: qsTr("Overview of day")
Material.foreground: projectData.mode == 3 ? Material.accent : textColor
onTriggered: projectData.mode = OperatingMode.DisplayRecordDay
}
MenuSeparator {
width: windowWidth // needed for language changes (win10)
}
MenuItem {
width: windowWidth // needed for language changes
enabled: false
text: qsTr("Overview using accounts")
}
RowLayout
{
RoundButton {
text: qsTr("Home")
checked: projectData.getAccountSelected(0)
checkable: true
Material.background: checked ? Material.accent : "transparent"
onToggled: projectData.setAccountSelected(0,checked)
}
RoundButton {
text: qsTr("Office")
id: officework
checked: projectData.getAccountSelected(1)
checkable: true
Material.background: checked ? Material.accent : "transparent"
onToggled: projectData.setAccountSelected(1,checked)
}
// RoundButton {
// text: "Travel"
// enabled: false
// Component.onCompleted: checked = projectData.getAccountSelected(2)
// checkable: true
// Material.background: checked ? Material.accent : "transparent"
// onToggled: projectData.setAccountSelected(2,checked)
// }
RoundButton {
text: "OK"
onClicked: changeVisibleAccounts()
}
Item {
Layout.fillWidth: true
}
}
MenuItem {
id: showwork
width: windowWidth // needed for language changes (win10)
text: qsTr("always show work items")
checkable: true
checked: projectData.alwaysShowWork
onTriggered: projectData.alwaysShowWork = checked
}
MenuItem {
id: showbreaks
width: windowWidth // needed for language changes (win10)
text: qsTr("show break times")
checkable: true
checked: projectData.showBreakTimes
onTriggered: projectData.showBreakTimes = checked
}
MenuSeparator {
width: windowWidth // needed for language changes (win10)
}
MenuItem {
width: windowWidth // needed for language changes
text: qsTr("copy to clipboard...")
onTriggered: exportpopup.open()
}
}
function saveClipboard(minutes,beginning) {
projectData.exportToClipboard(minutes,beginning)
exportpopup.close()
}
Popup {
id: exportpopup
//anchors.centerIn: parent
y: sumButton.y-implicitHeight
width: parent.width
ColumnLayout {
width: windowWidth
//anchors.fill: parent
Label {
text: qsTr("copy to clipboard...")
}
RowLayout {
visible: projectData.showExportDays
Label {
text: qsTr("including recreation time of")
visible: projectData.showExportDays
}
TextField {
id: additionalminutes
placeholderText: qsTr("minutes of rest")
visible: projectData.showExportDays
cursorVisible: true
text: ""
}
}
RowLayout {
visible: projectData.showExportDays
Label {
text: qsTr("beginning after")
visible: projectData.showExportDays
}
TextField {
id: thresholdofrest
placeholderText: qsTr("hours")
visible: projectData.showExportDays
cursorVisible: true
text: ""
}
}
RowLayout
{
visible: projectData.showExportDays
RoundButton {
text: qsTr("Mo")
visible: projectData.showExportDays
checked: projectData.getWeekdaySelected(0)
checkable: true
Material.background: checked ? Material.accent : "transparent"
onClicked: projectData.setWeekdaySelected(0,checked)
onVisibleChanged: checked = projectData.getWeekdaySelected(0)
}
RoundButton {
text: qsTr("Tu")
visible: projectData.showExportDays
checked: projectData.getWeekdaySelected(1)
checkable: true
Material.background: checked ? Material.accent : "transparent"
onClicked: projectData.setWeekdaySelected(1,checked)
onVisibleChanged: checked = projectData.getWeekdaySelected(1)
}
RoundButton {
text: qsTr("We")
visible: projectData.showExportDays
checked: projectData.getWeekdaySelected(2)
checkable: true
Material.background: checked ? Material.accent : "transparent"
onClicked: projectData.setWeekdaySelected(2,checked)
onVisibleChanged: checked = projectData.getWeekdaySelected(2)
}
RoundButton {
text: qsTr("Th")
visible: projectData.showExportDays
checked: projectData.getWeekdaySelected(3)
checkable: true
Material.background: checked ? Material.accent : "transparent"
onClicked: projectData.setWeekdaySelected(3,checked)
onVisibleChanged: checked = projectData.getWeekdaySelected(3)
}
RoundButton {
text: qsTr("Fr")
visible: projectData.showExportDays
checked: projectData.getWeekdaySelected(4)
checkable: true
Material.background: checked ? Material.accent : "transparent"
onClicked: projectData.setWeekdaySelected(4,checked)
onVisibleChanged: checked = projectData.getWeekdaySelected(4)
}
}
// RowLayout
// {
// RoundButton {
// text: qsTr("Sa")
// checked: projectData.getWeekdaySelected(5)
// checkable: true
// Material.background: checked ? Material.accent : "transparent"
// onToggled: projectData.setWeekdaySelected(5,checked)
// }
// RoundButton {
// text: qsTr("Su")
// checked: projectData.getWeekdaySelected(6)
// checkable: true
// Material.background: checked ? Material.accent : "transparent"
// onToggled: projectData.setWeekdaySelected(6,checked)
// }
// }
RowLayout {
Button {
text: qsTr("Cancel")
onClicked: exportpopup.close()
}
Button {
text: qsTr("OK")
onClicked: saveClipboard(additionalminutes.text,thresholdofrest.text)
}
}
}
}
function recordingstopignore()
{
projectData.cancelAutoStop()
recordingstopped.close()
}
Popup {
id: recordingstopped
//anchors.centerIn: parent
//y: sumButton.y-implicitHeight
width: parent.width
//x: Math.round((windowWidth - implicitWidth) / 2)
y: Math.round((windowHeight - implicitHeight) / 2)
ColumnLayout {
width: windowWidth
//anchors.fill: parent
Label {
text: qsTr("recording stopped due to inactivity")
}
RowLayout
{
Button {
text: qsTr("Reject")
onClicked: recordingstopignore()
}
Button {
text: qsTr("Accept")
onClicked: recordingstopped.close()
}
}
}
}
function enterCheckin(time) {
projectData.enterCheckin(time)
checkedInOn.close()
}
Popup {
id: checkedInOn
//anchors.centerIn: parent
//y: sumButton.y-implicitHeight
y: currentDate.height+8
width: parent.width
//x: Math.round((windowWidth - implicitWidth) / 2)
//y: Math.round((windowHeight - implicitHeight) / 2)
ColumnLayout {
width: windowWidth
//anchors.fill: parent
Label {
text: qsTr("enter chekin time")
}
TextField {
id: checkinTime
placeholderText: qsTr("hh:mm")
text: ""
}
RowLayout {
Button {
text: qsTr("Cancel")
onClicked: checkedInOn.close()
}
Button {
text: qsTr("OK")
onClicked: enterCheckin(checkinTime.text)
}
}
}
}
WorkDialog {
id: workDialog
x: Math.round((windowWidth - implicitWidth) / 2)
y: Math.round((windowHeight - implicitHeight) / 2)
workDataModel: projectData
}
}