-
Notifications
You must be signed in to change notification settings - Fork 15
/
EditTaskWindow.qml
358 lines (307 loc) · 10.9 KB
/
EditTaskWindow.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
import QtQuick 1.1
import "Storage.js" as Storage
Rectangle {
id: root
property alias task_name: task_name
property alias task_timestamp: task_name.tasktimestamp
property alias units_planned: units_planned
property alias units_done: units_done
property alias note: note
property color task_color
property alias color_setter_window: color_setter_window
Behavior on scale {NumberAnimation{}}
color: styl.dialog_back_color
width: 400
height: 350 + note_background.height
radius: 4
/* ============================= Task Name Description ===================== */
Text {
id: task_name_descr
color: styl.text_color_secondary
anchors {
left: task_name_background.left
bottom: task_name_background.top
bottomMargin: 2
}
text: qsTr("Task name")
font { family: "Ubuntu"; pixelSize: 12 }
}
/* ============================= Task Name Background ===================== */
Rectangle {
id: task_name_background
color: styl.text_entry_back_color
width: parent.width - 24
height: task_name.height + 10
radius: 4
anchors {
left: parent.left
leftMargin: 12
top: parent.top
topMargin: 36
}
/* ============================= Task Name ===================== */
TextInput {
id: task_name
property string tasktimestamp: "" // Task timestamp
color: styl.text_entry_text_color
width: parent.width - 4
x: 2
y: 5
text: ""
maximumLength: 150
font { family: "Ubuntu"; pixelSize: 18 }
selectByMouse: true
onCursorVisibleChanged: selectAll()
KeyNavigation.tab: color_select
KeyNavigation.backtab: save_button
Keys.onReturnPressed: save_button.focus = true
Keys.onEnterPressed: save_button.focus = true
}
}
/* ============================= Task Color ===================== */
Text {
id: task_color_desc
color: styl.text_color_secondary
anchors {
left: task_color_background.left
bottom: task_color_background.top
bottomMargin: 2
}
text: qsTr("Task Colour")
font { family: "Ubuntu"; pixelSize: 12 }
}
Rectangle {
id: task_color_background
color: color_select.focus ? color_select.color : styl.text_entry_back_color
width: parent.width/5
height: units_planned.height + 10
radius: 4
anchors {
left: parent.left
leftMargin: 12
top: task_name_background.bottom
topMargin: 30
}
/* ============================= Color Select Button ===================== */
Rectangle {
id: color_select
color: task_color
width: parent.width - 6
height: parent.height - 6
anchors.centerIn: parent
MouseArea {
id: color_select_ma
anchors.fill: parent
onClicked: {
color_setter_window.visible = true
color_setter_window.focus = true
color_setter_window.color = task_color
}
}
KeyNavigation.tab: units_planned
KeyNavigation.backtab: task_name
Keys.onEnterPressed: color_select_ma.clicked(true)
Keys.onReturnPressed: color_select_ma.clicked(true)
}
}
/* ============================= Planned Units Description ===================== */
Text {
id: units_planned_descr
color: styl.text_color_secondary
anchors {
left: units_planned_background.left
bottom: units_planned_background.top
bottomMargin: 2
}
text: qsTr("Work units planned")
font { family: "Ubuntu"; pixelSize: 12 }
}
/* ============================= Planned Units Background ===================== */
Rectangle {
id: units_planned_background
color: styl.text_entry_back_color
width: parent.width/5
height: units_planned.height + 10
radius: 4
anchors {
left: parent.left
leftMargin: 12
top: task_color_background.bottom
topMargin: 30
}
/* ============================= Planned Units ===================== */
TextInput {
id: units_planned
color: styl.text_entry_text_color
width: parent.width - 4
x: 2
y: 5
text: ""
maximumLength: 2
font { family: "Ubuntu"; pixelSize: 18 }
selectByMouse: true
validator: IntValidator{bottom: 1; top: 99;}
onCursorVisibleChanged: selectAll()
KeyNavigation.tab: units_done
KeyNavigation.backtab: color_select
Keys.onEnterPressed: save_button.focus = true
Keys.onReturnPressed: save_button.focus = true
}
}
/* ============================= Done Units Description ===================== */
Text {
id: units_done_descr
color: styl.text_color_secondary
anchors {
left: units_done_background.left
bottom: units_done_background.top
bottomMargin: 2
}
text: qsTr("Work units done")
font { family: "Ubuntu"; pixelSize: 12 }
}
/* ============================= Done Units Background ===================== */
Rectangle {
id: units_done_background
color: styl.text_entry_back_color
width: parent.width/5
height: units_done.height + 10
radius: 4
anchors {
left: parent.left
leftMargin: 12
top: units_planned_background.bottom
topMargin: 30
}
/* ============================= Done Units ===================== */
TextInput {
id: units_done
color: styl.text_entry_text_color
width: parent.width - 4
x: 2
y: 5
text: ""
maximumLength: 2
font { family: "Ubuntu"; pixelSize: 18 }
selectByMouse: true
validator: IntValidator{bottom: 1; top: 99;}
onCursorVisibleChanged: selectAll()
KeyNavigation.tab: note
KeyNavigation.backtab: units_planned
Keys.onEnterPressed: save_button.focus = true
Keys.onReturnPressed: save_button.focus = true
}
}
/* ============================= Note Description ===================== */
Text {
id: note_descr
color: styl.text_color_secondary
anchors {
left: note_background.left
bottom: note_background.top
bottomMargin: 2
}
text: qsTr("Note")
font { family: "Ubuntu"; pixelSize: 12 }
}
/* ============================= Note Background ===================== */
Rectangle {
id: note_background
color: styl.text_entry_back_color
width: parent.width - 24
height: note.height + 10
radius: 4
anchors {
left: parent.left
leftMargin: 12
top: units_done_background.bottom
topMargin: 30
}
/* ============================= Note ===================== */
TextEdit {
id: note
color: styl.text_entry_text_color
width: parent.width - 4
x: 2
y: 5
text: ""
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
font { family: "Ubuntu"; pixelSize: 18 }
selectByMouse: true
onCursorVisibleChanged: selectAll()
KeyNavigation.tab: cancel_button
KeyNavigation.backtab: units_done
KeyNavigation.priority: KeyNavigation.BeforeItem
Keys.onPressed: {
if ((event.key == Qt.Key_Enter || event.key == Qt.Key_Return) && (event.modifiers & Qt.ControlModifier))
save_button.focus = true;
}
}
}
/* ============================= Cancel Button ===================== */
Button {
id: cancel_button
anchors {
left: parent.left
leftMargin: 12
bottom: parent.bottom
bottomMargin: 12
}
buttontext: qsTr("Cancel")
KeyNavigation.tab: save_button
KeyNavigation.backtab: note
button_ma.onClicked: {
overlay.scale = 0;
edit_task_window_main.scale = 0;
wp_root.focus = true;
}
}
/* ============================= Save Button ===================== */
Button {
id: save_button
buttoncolor: styl.button_back_color_ok
anchors {
right: parent.right
rightMargin: 12
bottom: parent.bottom
bottomMargin: 12
}
buttontext: qsTr("Save")
KeyNavigation.tab: task_name
KeyNavigation.backtab: cancel_button
button_ma.onClicked: {
var timestamp = task_name.tasktimestamp
var taskname = task_name.text;
var listname = todo_list_name.text;
var color = task_color;
var unitsplan = Number(units_planned.text);
var unitsdone = Number(units_done.text);
var tasknote = !note.text.replace(/\s/g, '').length ? "" : note.text;
Storage.updateTask(timestamp, taskname, color, unitsplan, unitsdone, tasknote);
Storage.updateFinishedTask(timestamp, taskname, listname, color,"Units planned: " + unitsplan, "Units done: " + unitsdone, tasknote);
if (todo_list_name.selected_task_color == "" || todo_list_name.selected_task_color == color){
tasklist.todo_listmodel.set(tasklist.todo_listview.currentIndex,
{"todoname": taskname,
"task_color": color,
"unitsplanned": unitsplan,
"unitsdone": unitsdone,
"visibility": tasknote !== "",
"todonote" : tasknote}
)
}
else {
tasklist.todo_listmodel.remove(tasklist.todo_listview.currentIndex)
}
overlay.scale = 0;
edit_task_window_main.scale = 0;
wp_root.focus = true;
}
}
/* ============================= Color Settings Window ===================== */
ColourSetter {
id: color_setter_window
visible: false
radius: parent.radius
anchors.fill: parent
}
}