summaryrefslogtreecommitdiffstats
path: root/components/mailviewer/qml
diff options
context:
space:
mode:
Diffstat (limited to 'components/mailviewer/qml')
-rw-r--r--components/mailviewer/qml/ErrorPart.qml41
-rw-r--r--components/mailviewer/qml/HtmlContent.qml81
-rw-r--r--components/mailviewer/qml/MailDataModel.qml159
-rw-r--r--components/mailviewer/qml/MailPart.qml70
-rw-r--r--components/mailviewer/qml/MailViewer.qml44
-rw-r--r--components/mailviewer/qml/TextContent.qml60
-rw-r--r--components/mailviewer/qml/main.qml30
7 files changed, 485 insertions, 0 deletions
diff --git a/components/mailviewer/qml/ErrorPart.qml b/components/mailviewer/qml/ErrorPart.qml
new file mode 100644
index 00000000..0e5d9b8e
--- /dev/null
+++ b/components/mailviewer/qml/ErrorPart.qml
@@ -0,0 +1,41 @@
1/*
2 Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
3 Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18*/
19
20import QtQuick 2.4
21
22Item {
23 id: root
24 property variant errorType
25 property string errorString
26 height: partListView.height
27 width: parent.width
28
29 Column {
30 id: partListView
31 anchors {
32 top: parent.top
33 left: parent.left
34 }
35 width: parent.width
36 spacing: 5
37 Text {
38 text: qsTr("An error occured: %1").arg(errorString)
39 }
40 }
41}
diff --git a/components/mailviewer/qml/HtmlContent.qml b/components/mailviewer/qml/HtmlContent.qml
new file mode 100644
index 00000000..3ac1bb38
--- /dev/null
+++ b/components/mailviewer/qml/HtmlContent.qml
@@ -0,0 +1,81 @@
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
19import QtQuick 2.4
20import QtQuick.Controls 1.3
21import QtWebEngine 1.4
22
23import org.kube.framework 1.0 as Kube
24
25Item {
26 id: root
27 property string content
28 //We have to give it a minimum size so the html content starts to expand
29 property int contentHeight: 10;
30
31 height: contentHeight
32 width: partColumn.width
33
34 WebEngineView {
35 id: htmlView
36 anchors.fill: parent
37 Component.onCompleted: loadHtml(content, "file:///")
38 onContentsSizeChanged: {
39 //Resizing pixel by pixel causes some mails to grow indefinitely
40 if (contentsSize.height >= root.contentHeight + 5) {
41 root.contentHeight = contentsSize.height
42 }
43 }
44 onLoadingChanged: {
45 if (loadRequest.status == WebEngineLoadRequest.LoadFailedStatus) {
46 console.warn("Failed to load html content.")
47 console.warn("Error is ", loadRequest.errorString)
48 }
49 }
50 settings {
51 webGLEnabled: false
52 touchIconsEnabled: false
53 spatialNavigationEnabled: false
54 screenCaptureEnabled: false
55 pluginsEnabled: false
56 localStorageEnabled: false
57 localContentCanAccessRemoteUrls: false
58 localContentCanAccessFileUrls: false
59 linksIncludedInFocusChain: false
60 javascriptEnabled: false
61 javascriptCanOpenWindows: false
62 javascriptCanAccessClipboard: false
63 hyperlinkAuditingEnabled: false
64 fullScreenSupportEnabled: false
65 errorPageEnabled: false
66 //defaultTextEncoding: ???
67 autoLoadImages: true
68 autoLoadIconsForPage: false
69 accelerated2dCanvasEnabled: false
70 //The webview should not steal focus
71 focusOnNavigationEnabled: false
72 }
73 profile: Kube.WebEngineProfile
74 onContextMenuRequested: function(request) {
75 request.accepted = true
76 }
77 }
78 onContentChanged: {
79 htmlView.loadHtml(content, "file:///");
80 }
81}
diff --git a/components/mailviewer/qml/MailDataModel.qml b/components/mailviewer/qml/MailDataModel.qml
new file mode 100644
index 00000000..ec7f8e74
--- /dev/null
+++ b/components/mailviewer/qml/MailDataModel.qml
@@ -0,0 +1,159 @@
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
19import QtQuick 2.4
20import QtQml.Models 2.2
21import org.kube.framework 1.0 as Kube
22
23DelegateModel {
24 id: root
25
26 delegate: Item {
27 id: partColumn
28
29 width: parent.width
30 height: childrenRect.height
31
32 function getColor(securityLevel)
33 {
34 if (securityLevel == "good") {
35 return Kube.Colors.positiveColor
36 }
37 if (securityLevel == "bad") {
38 return Kube.Colors.negativeColor
39 }
40 if (securityLevel == "notsogood") {
41 return Kube.Colors.warningColor
42 }
43 return Kube.Colors.lightgrey
44 }
45
46 function getDetails(signatureDetails)
47 {
48 var details = "";
49 if (signatureDetails.noSignaturesFound) {
50 details += qsTr("This message has been signed but we failed to validate the signature.") + "\n"
51 } else if (!signatureDetails.signatureIsGood) {
52 details += qsTr("This message is signed but the signature is invalid.") + "\n"
53 } else if (signatureDetails.keyMissing) {
54 details += qsTr("This message has been signed using the key %1.").arg(signatureDetails.keyId) + "\n";
55 details += qsTr("The key details are not available.") + "\n";
56 return details;
57 } else {
58 details += qsTr("This message has been signed using the key %1 by %2.").arg(signatureDetails.keyId).arg(signatureDetails.signer) + "\n";
59 if (signatureDetails.keyRevoked) {
60 details += qsTr("The key was revoked.") + "\n"
61 }
62 if (signatureDetails.keyExpired) {
63 details += qsTr("The key has expired.") + "\n"
64 }
65 if (signatureDetails.keyIsTrusted) {
66 details += qsTr("You are trusting this key.") + "\n"
67 }
68 }
69 return details
70 }
71
72 Column {
73 id: buttons
74 anchors.left: parent.left
75 anchors.top: parent.top
76 anchors.rightMargin: Kube.Units.smallSpacing
77 spacing: Kube.Units.smallSpacing
78 Kube.IconButton {
79 id: encryptedButton
80 width: Kube.Units.gridUnit
81 height: width
82 iconName: Kube.Icons.secure
83 color: getColor(model.securityLevel)
84 backgroundOpacity: 0.5
85 visible: model.encrypted
86 tooltip: qsTr("This message is encrypted.");
87 //FIXME make text copyable
88 // Kube.SelectableItem {
89 // visualParent: encryptedButton
90 // text: parent.tooltip
91 // }
92 }
93 Kube.IconButton {
94 id: signedButton
95 width: Kube.Units.gridUnit
96 height: width
97 iconName: Kube.Icons.signed
98 color: getColor(model.securityLevel)
99 backgroundOpacity: 0.5
100 visible: model.signed
101 tooltip: getDetails(model.signatureDetails)
102 }
103 }
104 Rectangle {
105 id: border
106 visible: encryptedButton.hovered || signedButton.hovered
107 anchors.topMargin: Kube.Units.smallSpacing
108 anchors.top: buttons.bottom
109 anchors.bottom: partLoader.bottom
110 anchors.right: buttons.right
111 width: Kube.Units.smallSpacing
112 color: getColor(model.securityLevel)
113 opacity: 0.5
114 }
115
116 Loader {
117 id: partLoader
118 anchors {
119 top: parent.top
120 left: buttons.right
121 leftMargin: Kube.Units.smallSpacing
122 right: parent.right
123 }
124 height: item ? item.contentHeight : 0
125 width: parent.width
126 }
127 Component.onCompleted: {
128 switch (model.type) {
129 case "plain":
130 partLoader.setSource("TextContent.qml",
131 {"content": model.content,
132 "embedded": model.embedded,
133 "type": model.type
134 })
135 break
136 case "html":
137 partLoader.setSource("HtmlContent.qml",
138 {"content": model.content,
139 })
140 break;
141 case "error":
142 partLoader.setSource("ErrorPart.qml",
143 {
144 "errorType": model.errorType,
145 "errorString": model.errorString,
146 })
147 break;
148 case "encapsulated":
149 partLoader.setSource("MailPart.qml",
150 {"rootIndex": root.modelIndex(index),
151 "model": root.model,
152 "sender": model.sender,
153 "date": model.date
154 })
155 break;
156 }
157 }
158 }
159}
diff --git a/components/mailviewer/qml/MailPart.qml b/components/mailviewer/qml/MailPart.qml
new file mode 100644
index 00000000..e570ebaa
--- /dev/null
+++ b/components/mailviewer/qml/MailPart.qml
@@ -0,0 +1,70 @@
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
19import QtQuick 2.4
20
21import org.kube.framework 1.0 as Kube
22
23Item {
24 id: root
25 property alias rootIndex: visualModel.rootIndex
26 property alias model: visualModel.model
27 property variant sender
28 property variant date
29 height: childrenRect.height
30
31 Rectangle {
32 id: border
33 anchors {
34 top: parent.top
35 left: parent.left
36 leftMargin: Kube.Units.smallSpacing
37 }
38 color: Kube.Colors.lightgrey
39 height: partListView.height + sender.height
40 width: Kube.Units.smallSpacing
41 }
42
43 Text {
44 id: sender
45 anchors {
46 top: parent.top
47 left: border.right
48 leftMargin: Kube.Units.smallSpacing
49 }
50
51 text: qsTr("sent by %1 on %2").arg(root.sender).arg(root.date)
52 color: "grey"
53 }
54 ListView {
55 id: partListView
56 anchors {
57 top: sender.bottom
58 left: border.right
59 margins: Kube.Units.smallSpacing
60 leftMargin: Kube.Units.smallSpacing
61 }
62 model: MailDataModel {
63 id: visualModel
64 }
65 spacing: 7
66 height: contentHeight
67 width: parent.width - Kube.Units.smallSpacing * 3
68 interactive: false
69 }
70}
diff --git a/components/mailviewer/qml/MailViewer.qml b/components/mailviewer/qml/MailViewer.qml
new file mode 100644
index 00000000..9031ec17
--- /dev/null
+++ b/components/mailviewer/qml/MailViewer.qml
@@ -0,0 +1,44 @@
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
19import QtQuick 2.4
20
21Item {
22 id: root
23 property alias rootIndex: visualModel.rootIndex
24 property alias model: visualModel.model
25 height: partListView.height
26
27 MailDataModel {
28 id: visualModel
29 }
30
31 ListView {
32 id: partListView
33 model: visualModel
34 anchors {
35 top: parent.top
36 left: parent.left
37 margins: 5
38 }
39 spacing: 5
40 height: contentHeight
41 width: parent.width - 10
42 interactive: false
43 }
44}
diff --git a/components/mailviewer/qml/TextContent.qml b/components/mailviewer/qml/TextContent.qml
new file mode 100644
index 00000000..5d8dbc90
--- /dev/null
+++ b/components/mailviewer/qml/TextContent.qml
@@ -0,0 +1,60 @@
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
19import QtQuick 2.7
20
21import org.kube.framework 1.0 as Kube
22
23Item {
24 id: root
25
26 property string content
27 property bool embedded: true
28 property string type
29
30 height: textEdit.height
31
32 TextEdit {
33 id: textEdit
34
35 anchors {
36 top: parent.top
37 left: parent.left
38 right: parent.right
39 }
40
41 selectionColor: Kube.Colors.highlightColor
42
43 readOnly: true
44 selectByMouse: true
45
46 text: content
47 wrapMode: TextEdit.Wrap
48 textFormat: Text.RichText
49
50 font.family: Kube.Font.fontFamily
51 color: embedded ? Kube.Colors.disabledTextColor : Kube.Colors.textColor
52 onLinkActivated: Qt.openUrlExternally(link)
53
54 MouseArea {
55 anchors.fill: parent
56 acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text
57 cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
58 }
59 }
60}
diff --git a/components/mailviewer/qml/main.qml b/components/mailviewer/qml/main.qml
new file mode 100644
index 00000000..e69dd5a2
--- /dev/null
+++ b/components/mailviewer/qml/main.qml
@@ -0,0 +1,30 @@
1/*
2 * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
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
19import QtQuick 2.7
20import QtQuick.Controls 2.0 as Controls2
21
22Controls2.ApplicationWindow {
23 id: app
24 height: 900
25 width: 1500
26
27 MailViewer {
28 visible: true
29 }
30}