diff options
Diffstat (limited to 'components/package/contents/ui/ConversationView.qml')
-rw-r--r-- | components/package/contents/ui/ConversationView.qml | 440 |
1 files changed, 440 insertions, 0 deletions
diff --git a/components/package/contents/ui/ConversationView.qml b/components/package/contents/ui/ConversationView.qml new file mode 100644 index 00000000..3c76928f --- /dev/null +++ b/components/package/contents/ui/ConversationView.qml | |||
@@ -0,0 +1,440 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | import QtQuick 2.7 | ||
20 | import QtQuick.Controls 1.3 as Controls1 | ||
21 | import QtQuick.Controls 2 | ||
22 | import QtQuick.Layouts 1.1 | ||
23 | import org.kde.kirigami 1.0 as Kirigami | ||
24 | |||
25 | import QtQml 2.2 as QtQml | ||
26 | |||
27 | import org.kube.framework.domain 1.0 as KubeFramework | ||
28 | import org.kube.framework.actions 1.0 as KubeAction | ||
29 | |||
30 | Rectangle { | ||
31 | id: root | ||
32 | |||
33 | property variant mail; | ||
34 | |||
35 | color: Kirigami.Theme.backgroundColor | ||
36 | |||
37 | ListView { | ||
38 | id: listView | ||
39 | anchors { | ||
40 | top: parent.top | ||
41 | left: parent.left | ||
42 | right: parent.right | ||
43 | bottom: parent.bottom | ||
44 | } | ||
45 | |||
46 | clip: true | ||
47 | |||
48 | model: KubeFramework.MailListModel { | ||
49 | mail: root.mail | ||
50 | } | ||
51 | |||
52 | header: Item { | ||
53 | height: Kirigami.Units.gridUnit * 0.5 | ||
54 | width: parent.width | ||
55 | |||
56 | } | ||
57 | |||
58 | footer: Item { | ||
59 | height: Kirigami.Units.gridUnit | ||
60 | width: parent.width | ||
61 | } | ||
62 | |||
63 | delegate: mailDelegate | ||
64 | |||
65 | boundsBehavior: Flickable.StopAtBounds | ||
66 | |||
67 | //Always scroll to the end of the conversation | ||
68 | highlightFollowsCurrentItem: true | ||
69 | //Scroll quickly | ||
70 | highlightMoveDuration: 1 | ||
71 | onCountChanged: { | ||
72 | //TODO: ideally we should only do this initially, not when new messages enter while you're reading. | ||
73 | currentIndex = count - 1; | ||
74 | } | ||
75 | |||
76 | //Intercept all scroll events, | ||
77 | //necessary due to the webengineview | ||
78 | KubeFramework.MouseProxy { | ||
79 | anchors.fill: parent | ||
80 | target: listView | ||
81 | forwardWheelEvents: true | ||
82 | } | ||
83 | } | ||
84 | Component { | ||
85 | id: mailDelegate | ||
86 | |||
87 | Item { | ||
88 | |||
89 | height: sheet.height + Kirigami.Units.gridUnit | ||
90 | width: parent.width | ||
91 | |||
92 | Rectangle { | ||
93 | id: sheet | ||
94 | anchors.centerIn: parent | ||
95 | implicitHeight: header.height + attachments.height + body.height + footer.height + Kirigami.Units.largeSpacing | ||
96 | width: parent.width - Kirigami.Units.gridUnit * 2 | ||
97 | |||
98 | color: Kirigami.Theme.viewBackgroundColor | ||
99 | |||
100 | //BEGIN header | ||
101 | Item { | ||
102 | id: header | ||
103 | |||
104 | anchors { | ||
105 | top: parent.top | ||
106 | left: parent.left | ||
107 | right: parent.right | ||
108 | margins: Kirigami.Units.largeSpacing | ||
109 | } | ||
110 | |||
111 | height: headerContent.height + Kirigami.Units.smallSpacing | ||
112 | |||
113 | states: [ | ||
114 | State { | ||
115 | name: "small" | ||
116 | PropertyChanges { target: subject; wrapMode: Text.NoWrap} | ||
117 | PropertyChanges { target: recipients; visible: true} | ||
118 | PropertyChanges { target: to; visible: false} | ||
119 | PropertyChanges { target: cc; visible: false} | ||
120 | PropertyChanges { target: bcc; visible: false} | ||
121 | }, | ||
122 | State { | ||
123 | name: "details" | ||
124 | PropertyChanges { target: subject; wrapMode: Text.WrapAnywhere} | ||
125 | PropertyChanges { target: recipients; visible: false} | ||
126 | PropertyChanges { target: to; visible: true} | ||
127 | PropertyChanges { target: cc; visible: true} | ||
128 | PropertyChanges { target: bcc; visible: true} | ||
129 | } | ||
130 | ] | ||
131 | |||
132 | state: "small" | ||
133 | |||
134 | Text { | ||
135 | id: date_label | ||
136 | |||
137 | anchors { | ||
138 | right: seperator.right | ||
139 | top: parent.top | ||
140 | } | ||
141 | |||
142 | text: Qt.formatDateTime(model.date, "dd MMM yyyy hh:mm") | ||
143 | |||
144 | font.pointSize: Kirigami.Theme.defaultFont.pointSize * 0.7 | ||
145 | color: Kirigami.Theme.textColor | ||
146 | opacity: 0.75 | ||
147 | } | ||
148 | |||
149 | Column { | ||
150 | id: headerContent | ||
151 | |||
152 | anchors { | ||
153 | //left: to_l.right | ||
154 | horizontalCenter: parent.horizontalCenter | ||
155 | } | ||
156 | |||
157 | //spacing: Kirigami.Units.smallSpacing | ||
158 | |||
159 | width: parent.width | ||
160 | |||
161 | Row{ | ||
162 | id: from | ||
163 | |||
164 | width: parent.width | ||
165 | |||
166 | spacing: Kirigami.Units.smallSpacing | ||
167 | clip: true | ||
168 | |||
169 | Text { | ||
170 | id: senderName | ||
171 | |||
172 | text: model.senderName | ||
173 | |||
174 | font.weight: Font.DemiBold | ||
175 | color: Kirigami.Theme.textColor | ||
176 | opacity: 0.75 | ||
177 | } | ||
178 | |||
179 | Text { | ||
180 | |||
181 | text: model.sender | ||
182 | |||
183 | width: parent.width - senderName.width - date_label.width - Kirigami.Units.largeSpacing | ||
184 | elide: Text.ElideRight | ||
185 | |||
186 | color: Kirigami.Theme.textColor | ||
187 | opacity: 0.75 | ||
188 | |||
189 | clip: true | ||
190 | } | ||
191 | } | ||
192 | |||
193 | Text { | ||
194 | id: subject | ||
195 | |||
196 | width: to.width | ||
197 | |||
198 | text: model.subject | ||
199 | |||
200 | elide: Text.ElideRight | ||
201 | |||
202 | color: Kirigami.Theme.textColor | ||
203 | opacity: 0.75 | ||
204 | font.italic: true | ||
205 | } | ||
206 | |||
207 | Text { | ||
208 | id: recipients | ||
209 | |||
210 | width: parent.width - goDown.width - Kirigami.Units.smallSpacing | ||
211 | |||
212 | text:"to: "+ model.to + " " + model.cc + " " + model.bcc | ||
213 | |||
214 | elide: Text.ElideRight | ||
215 | |||
216 | color: Kirigami.Theme.textColor | ||
217 | opacity: 0.75 | ||
218 | } | ||
219 | |||
220 | Text { | ||
221 | id: to | ||
222 | |||
223 | width: parent.width - goDown.width - Kirigami.Units.smallSpacing | ||
224 | |||
225 | text:"to: " + model.to | ||
226 | |||
227 | wrapMode: Text.WordWrap | ||
228 | color: Kirigami.Theme.textColor | ||
229 | opacity: 0.75 | ||
230 | } | ||
231 | |||
232 | Text { | ||
233 | id: cc | ||
234 | |||
235 | width: parent.width - goDown.width - Kirigami.Units.smallSpacing | ||
236 | |||
237 | text:"cc: " + model.cc | ||
238 | |||
239 | wrapMode: Text.WordWrap | ||
240 | color: Kirigami.Theme.textColor | ||
241 | opacity: 0.75 | ||
242 | } | ||
243 | |||
244 | Text { | ||
245 | id: bcc | ||
246 | |||
247 | width: parent.width - goDown.width - Kirigami.Units.smallSpacing | ||
248 | |||
249 | text:"bcc: " + model.bcc | ||
250 | |||
251 | wrapMode: Text.WordWrap | ||
252 | color: Kirigami.Theme.textColor | ||
253 | opacity: 0.75 | ||
254 | } | ||
255 | |||
256 | } | ||
257 | Rectangle { | ||
258 | id: goDown | ||
259 | anchors { | ||
260 | bottom: seperator.top | ||
261 | right: seperator.right | ||
262 | } | ||
263 | |||
264 | height: Kirigami.Units.gridUnit | ||
265 | width: height | ||
266 | |||
267 | color: Kirigami.Theme.backgroundColor | ||
268 | |||
269 | Controls1.ToolButton { | ||
270 | anchors.fill: parent | ||
271 | |||
272 | iconName: "go-down" | ||
273 | } | ||
274 | } | ||
275 | |||
276 | Rectangle { | ||
277 | anchors { | ||
278 | bottom: seperator.top | ||
279 | right: seperator.right | ||
280 | } | ||
281 | |||
282 | height: Kirigami.Units.gridUnit | ||
283 | width: height | ||
284 | |||
285 | color: Kirigami.Theme.backgroundColor | ||
286 | |||
287 | Controls1.ToolButton { | ||
288 | anchors.fill: parent | ||
289 | |||
290 | iconName: header.state === "details" ? "go-up" : "go-down" | ||
291 | |||
292 | onClicked: { | ||
293 | header.state === "details" ? header.state = "small" : header.state = "details" | ||
294 | } | ||
295 | } | ||
296 | } | ||
297 | |||
298 | Rectangle { | ||
299 | id: seperator | ||
300 | |||
301 | anchors { | ||
302 | left: parent.left | ||
303 | right: parent.right | ||
304 | bottom: parent.bottom | ||
305 | } | ||
306 | |||
307 | height: 1 | ||
308 | |||
309 | color: Kirigami.Theme.textColor | ||
310 | opacity: 0.5 | ||
311 | } | ||
312 | } | ||
313 | //END header | ||
314 | |||
315 | Flow { | ||
316 | id: attachments | ||
317 | |||
318 | anchors { | ||
319 | top: header.bottom | ||
320 | topMargin: Kirigami.Units.smallSpacing | ||
321 | right: header.right | ||
322 | } | ||
323 | |||
324 | width: header.width - Kirigami.Units.largeSpacing | ||
325 | |||
326 | layoutDirection: Qt.RightToLeft | ||
327 | spacing: Kirigami.Units.smallSpacing | ||
328 | clip: true | ||
329 | |||
330 | Repeater { | ||
331 | model: body.attachments | ||
332 | |||
333 | delegate: AttachmentDelegate { | ||
334 | name: model.name | ||
335 | icon: "mail-attachment" | ||
336 | |||
337 | clip: true | ||
338 | |||
339 | //TODO size encrypted signed type | ||
340 | } | ||
341 | } | ||
342 | } | ||
343 | |||
344 | MailViewer { | ||
345 | id: body | ||
346 | |||
347 | anchors { | ||
348 | top: header.bottom | ||
349 | left: header.left | ||
350 | right: header.right | ||
351 | leftMargin: Kirigami.Units.largeSpacing | ||
352 | rightMargin: Kirigami.Units.largeSpacing | ||
353 | topMargin: Math.max(attachments.height, Kirigami.Units.largeSpacing) | ||
354 | } | ||
355 | |||
356 | width: header.width - Kirigami.Units.largeSpacing * 2 | ||
357 | height: desiredHeight | ||
358 | |||
359 | message: model.mimeMessage | ||
360 | } | ||
361 | |||
362 | Item { | ||
363 | id: footer | ||
364 | |||
365 | anchors.bottom: parent.bottom | ||
366 | |||
367 | height: Kirigami.Units.gridUnit * 2 | ||
368 | width: parent.width | ||
369 | |||
370 | Text { | ||
371 | anchors{ | ||
372 | verticalCenter: parent.verticalCenter | ||
373 | left: parent.left | ||
374 | leftMargin: Kirigami.Units.largeSpacing | ||
375 | } | ||
376 | |||
377 | KubeFramework.MailController { | ||
378 | id: mailController | ||
379 | mail: model.mail | ||
380 | } | ||
381 | |||
382 | text: model.trash ? qsTr("Delete Mail") : qsTr("Move to trash") | ||
383 | color: Kirigami.Theme.textColor | ||
384 | opacity: 0.5 | ||
385 | enabled: model.trash ? mailController.removeAction.enabled : mailController.moveToTrashAction.enabled | ||
386 | MouseArea { | ||
387 | anchors.fill: parent | ||
388 | enabled: parent.enabled | ||
389 | onClicked: { | ||
390 | if (model.trash) { | ||
391 | mailController.removeAction.execute(); | ||
392 | } else { | ||
393 | mailController.moveToTrashAction.execute(); | ||
394 | } | ||
395 | } | ||
396 | } | ||
397 | } | ||
398 | |||
399 | Controls1.ToolButton { | ||
400 | visible: !model.trash | ||
401 | anchors{ | ||
402 | verticalCenter: parent.verticalCenter | ||
403 | right: parent.right | ||
404 | rightMargin: Kirigami.Units.largeSpacing | ||
405 | } | ||
406 | |||
407 | KubeAction.Context { | ||
408 | id: mailcontext | ||
409 | property variant mail | ||
410 | property bool isDraft | ||
411 | mail: model.mail | ||
412 | isDraft: model.draft | ||
413 | } | ||
414 | |||
415 | KubeAction.Action { | ||
416 | id: replyAction | ||
417 | actionId: "org.kde.kube.actions.reply" | ||
418 | context: maillistcontext | ||
419 | } | ||
420 | |||
421 | KubeAction.Action { | ||
422 | id: editAction | ||
423 | actionId: "org.kde.kube.actions.edit" | ||
424 | context: maillistcontext | ||
425 | } | ||
426 | |||
427 | iconName: model.draft ? "document-edit" : "mail-reply-sender" | ||
428 | onClicked: { | ||
429 | if (model.draft) { | ||
430 | editAction.execute() | ||
431 | } else { | ||
432 | replyAction.execute() | ||
433 | } | ||
434 | } | ||
435 | } | ||
436 | } | ||
437 | } | ||
438 | } | ||
439 | } | ||
440 | } | ||