summaryrefslogtreecommitdiffstats
path: root/framework/qml/MailViewer.qml
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-23 12:00:31 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-23 13:09:00 +0200
commit966d85717c115cc03f2d1b0f41a24fd363726027 (patch)
treefa9e0f2c1cf65fbaa444988e2c26ec9b455fab90 /framework/qml/MailViewer.qml
parent5d529c9252c386abaa76ec1a981ff99f50ce3dc0 (diff)
downloadkube-966d85717c115cc03f2d1b0f41a24fd363726027.tar.gz
kube-966d85717c115cc03f2d1b0f41a24fd363726027.zip
All of the MailViewer in one place
Diffstat (limited to 'framework/qml/MailViewer.qml')
-rw-r--r--framework/qml/MailViewer.qml386
1 files changed, 349 insertions, 37 deletions
diff --git a/framework/qml/MailViewer.qml b/framework/qml/MailViewer.qml
index 3e118a8d..b6ea4502 100644
--- a/framework/qml/MailViewer.qml
+++ b/framework/qml/MailViewer.qml
@@ -18,59 +18,371 @@
18 18
19import QtQuick 2.7 19import QtQuick 2.7
20import QtQuick.Controls 1.4 as Controls1 20import QtQuick.Controls 1.4 as Controls1
21import QtQuick.Controls 2
21import QtQuick.Layouts 1.1 22import QtQuick.Layouts 1.1
22 23
23import org.kube.components.mailviewer 1.0 as MV 24import org.kube.components.mailviewer 1.0 as MV
24import org.kube.framework 1.0 as Kube 25import org.kube.framework 1.0 as Kube
25 26
26Item { 27import QtQuick.Layouts 1.1
28import org.kde.kirigami 1.0 as Kirigami
29
30Rectangle {
27 id: root 31 id: root
32
28 property variant message; 33 property variant message;
29 property int desiredHeight: mailViewer.height + 20 34 property variant subject;
30 property variant attachments: messageParser.attachments 35 property variant sender;
36 property variant senderName;
37 property variant to;
38 property variant cc;
39 property variant bcc;
40 property variant date;
41 property variant trash;
42 property variant draft;
43 property variant sent;
44 property bool incomplete: false;
31 45
32 clip: true 46 implicitHeight: header.height + attachments.height + body.height + incompleteBody.height + footer.height + Kube.Units.largeSpacing
33 47
34 MV.MailViewer { 48 //Overlay for non-active mails
35 anchors.top: root.top 49 Rectangle {
36 id: mailViewer 50 anchors.fill: parent
37 model: messageParser.newTree 51 visible: !wrapper.isCurrent
38 debug: false 52 color: "lightGrey"
39 width: parent.width 53 z: 1
54 opacity: 0.2
40 } 55 }
41 56
42 Controls1.TreeView { 57 color: Kube.Colors.viewBackgroundColor
43 id: mailStructure 58
44 // anchors.fill: parent 59 Kube.MessageParser {
45 // anchors.top: root.attachments.rowCount() > 0 ? attachments.bottom : mailViewer.bottom 60 id: messageParser
46 visible: mailViewer.debug 61 message: root.message
47 width: parent.width 62 }
48 height: 400 63
49 Controls1.TableViewColumn { 64 //BEGIN header
50 role: "type" 65 Item {
51 title: "Type" 66 id: header
52 width: 300 67
68 anchors {
69 top: parent.top
70 left: parent.left
71 right: parent.right
72 margins: Kube.Units.largeSpacing
73 }
74
75 height: headerContent.height + Kube.Units.smallSpacing
76
77 states: [
78 State {
79 name: "small"
80 PropertyChanges { target: subject; wrapMode: Text.NoWrap}
81 PropertyChanges { target: recipients; visible: true}
82 PropertyChanges { target: to; visible: false}
83 PropertyChanges { target: cc; visible: false}
84 PropertyChanges { target: bcc; visible: false}
85 },
86 State {
87 name: "details"
88 PropertyChanges { target: subject; wrapMode: Text.WrapAnywhere}
89 PropertyChanges { target: recipients; visible: false}
90 PropertyChanges { target: to; visible: true}
91 PropertyChanges { target: cc; visible: true}
92 PropertyChanges { target: bcc; visible: true}
93 }
94 ]
95
96 state: "small"
97
98 Kube.Label {
99 id: date_label
100
101 anchors {
102 right: seperator.right
103 top: parent.top
104 }
105
106 text: Qt.formatDateTime(root.date, "dd MMM yyyy hh:mm")
107
108 font.pointSize: Kirigami.Theme.defaultFont.pointSize * 0.7
109 opacity: 0.75
110 }
111
112 Column {
113 id: headerContent
114
115 anchors {
116 //left: to_l.right
117 horizontalCenter: parent.horizontalCenter
118 }
119
120 //spacing: Kube.Units.smallSpacing
121
122 width: parent.width
123
124 Row{
125 id: from
126
127 width: parent.width
128
129 spacing: Kube.Units.smallSpacing
130 clip: true
131
132 Kube.Label {
133 id: senderName
134
135 text: root.senderName
136 font.weight: Font.DemiBold
137 opacity: 0.75
138 }
139
140 Kube.Label {
141 width: parent.width - senderName.width - date_label.width - Kube.Units.largeSpacing
142
143
144 text: root.sender
145 elide: Text.ElideRight
146 opacity: 0.75
147 clip: true
148 }
149 }
150
151 Kube.Label {
152 id: subject
153
154 width: to.width
155
156 text: root.subject
157 elide: Text.ElideRight
158 opacity: 0.75
159 font.italic: true
160 states: [
161 State {
162 name: "trash"; when: root.trash
163 PropertyChanges { target: subject; text: "Trash: " + root.subject }
164 },
165 State {
166 name: "draft"; when: root.draft
167 PropertyChanges { target: subject; text: "Draft: " + root.subject }
168 },
169 State {
170 name: "sent"; when: root.sent
171 PropertyChanges { target: subject; text: "Sent: " + root.subject }
172 }
173 ]
174 }
175
176 Kube.Label {
177 id: recipients
178
179 width: parent.width - goDown.width - Kube.Units.smallSpacing
180
181 text:"to: "+ root.to + " " + root.cc + " " + root.bcc
182 elide: Text.ElideRight
183 opacity: 0.75
184 }
185
186 Kube.Label {
187 id: to
188
189 width: parent.width - goDown.width - Kube.Units.smallSpacing
190
191 text:"to: " + root.to
192 wrapMode: Text.WordWrap
193 opacity: 0.75
194 }
195
196 Kube.Label {
197 id: cc
198
199 width: parent.width - goDown.width - Kube.Units.smallSpacing
200
201 text:"cc: " + root.cc
202 wrapMode: Text.WordWrap
203 opacity: 0.75
204 }
205
206 Kube.Label {
207 id: bcc
208
209 width: parent.width - goDown.width - Kube.Units.smallSpacing
210
211 text:"bcc: " + root.bcc
212 wrapMode: Text.WordWrap
213 opacity: 0.75
214 }
215
216 }
217
218 Rectangle {
219 id: goDown
220
221 anchors {
222 bottom: seperator.top
223 right: seperator.right
224 }
225
226 height: Kube.Units.gridUnit
227 width: height
228
229 color: Kube.Colors.backgroundColor
230
231 Controls1.ToolButton {
232 anchors.fill: parent
233
234 iconName: header.state === "details" ? Kube.Icons.goUp : Kube.Icons.goDown
235
236 onClicked: {
237 header.state === "details" ? header.state = "small" : header.state = "details"
238 }
239 }
240 }
241
242 Rectangle {
243 id: seperator
244
245 anchors {
246 left: parent.left
247 right: parent.right
248 bottom: parent.bottom
249 }
250
251 height: 1
252
253 color: Kube.Colors.textColor
254 opacity: 0.5
255 }
256 }
257 //END header
258
259 Flow {
260 id: attachments
261
262 anchors {
263 top: header.bottom
264 topMargin: Kube.Units.smallSpacing
265 right: header.right
266 }
267
268 width: header.width - Kube.Units.largeSpacing
269
270 layoutDirection: Qt.RightToLeft
271 spacing: Kube.Units.smallSpacing
272 clip: true
273
274 Repeater {
275 model: messageParser.attachments
276
277 delegate: AttachmentDelegate {
278 name: model.name
279 icon: "mail-attachment"
280
281 clip: true
282
283 //TODO size encrypted signed type
284 }
53 } 285 }
54 Controls1.TableViewColumn { 286 }
55 role: "embeded" 287
56 title: "Embeded" 288 Item {
57 width: 60 289 id: body
290
291 visible: !root.incomplete
292 anchors {
293 top: header.bottom
294 left: header.left
295 right: header.right
296 leftMargin: Kube.Units.largeSpacing
297 rightMargin: Kube.Units.largeSpacing
298 topMargin: Math.max(attachments.height, Kube.Units.largeSpacing)
58 } 299 }
59 Controls1.TableViewColumn { 300 height: mailViewer.height + 20
60 role: "securityLevel" 301
61 title: "SecurityLevel" 302 clip: true
62 width: 60 303
304 MV.MailViewer {
305 id: mailViewer
306 anchors.top: body.top
307 anchors.left: body.left
308 anchors.right: body.right
309 model: messageParser.newTree
310 debug: false
63 } 311 }
64 Controls1.TableViewColumn { 312
65 role: "content" 313 }
66 title: "Content" 314
67 width: 200 315 Kube.Label {
316 id: incompleteBody
317 anchors {
318 top: header.bottom
319 left: header.left
320 right: header.right
321 leftMargin: Kube.Units.largeSpacing
322 rightMargin: Kube.Units.largeSpacing
323 topMargin: Math.max(attachments.height, Kube.Units.largeSpacing)
68 } 324 }
69 model: messageParser.newTree 325 visible: root.incomplete
326 text: "Incomplete body..."
327 color: Kube.Colors.textColor
328 enabled: false
329 states: [
330 State {
331 name: "inprogress"; when: model.status == Kube.MailListModel.InProgressStatus
332 PropertyChanges { target: incompleteBody; text: "Downloading message..." }
333 },
334 State {
335 name: "error"; when: model.status == Kube.MailListModel.ErrorStatus
336 PropertyChanges { target: incompleteBody; text: "Failed to download message..." }
337 }
338 ]
70 } 339 }
340 Item {
341 id: footer
71 342
72 Kube.MessageParser { 343 anchors.bottom: parent.bottom
73 id: messageParser 344
74 message: root.message 345 height: Kube.Units.gridUnit * 2
346 width: parent.width
347
348 Kube.Label {
349 anchors{
350 verticalCenter: parent.verticalCenter
351 left: parent.left
352 leftMargin: Kube.Units.largeSpacing
353 }
354
355 text: model.trash ? qsTr("Delete Mail") : qsTr("Move to trash")
356 opacity: 0.5
357 MouseArea {
358 anchors.fill: parent
359 enabled: parent.enabled
360 onClicked: {
361 if (model.trash) {
362 Kube.Fabric.postMessage(Kube.Messages.remove, {"mail": model.mail})
363 } else {
364 Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": model.mail})
365 }
366 }
367 }
368 }
369
370 Controls1.ToolButton {
371 visible: !model.trash
372 anchors{
373 verticalCenter: parent.verticalCenter
374 right: parent.right
375 rightMargin: Kube.Units.largeSpacing
376 }
377
378 iconName: model.draft ? Kube.Icons.edit : Kube.Icons.replyToSender
379 onClicked: {
380 if (model.draft) {
381 Kube.Fabric.postMessage(Kube.Messages.edit, {"mail": model.mail, "isDraft": model.draft})
382 } else {
383 Kube.Fabric.postMessage(Kube.Messages.reply, {"mail": model.mail, "isDraft": model.draft})
384 }
385 }
386 }
75 } 387 }
76} 388}