From 43aa73617d790b695aa14443d162ad001b9d315b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 20 Feb 2017 17:04:23 +0100 Subject: Turn the mailviewer into a component as well --- components/mailviewer/contents/ui/EmbededPart.qml | 54 +++++++++++++++ .../mailviewer/contents/ui/EncryptionPart.qml | 75 +++++++++++++++++++++ components/mailviewer/contents/ui/GREEN.png | Bin 0 -> 153 bytes components/mailviewer/contents/ui/GREY.png | Bin 0 -> 153 bytes components/mailviewer/contents/ui/HtmlContent.qml | 70 +++++++++++++++++++ .../mailviewer/contents/ui/MailDataModel.qml | 66 ++++++++++++++++++ components/mailviewer/contents/ui/MailPart.qml | 47 +++++++++++++ components/mailviewer/contents/ui/MailViewer.qml | 46 +++++++++++++ components/mailviewer/contents/ui/PURPLE.png | Bin 0 -> 153 bytes components/mailviewer/contents/ui/RED.png | Bin 0 -> 153 bytes .../mailviewer/contents/ui/SignaturePart.qml | 68 +++++++++++++++++++ components/mailviewer/contents/ui/TextContent.qml | 61 +++++++++++++++++ components/mailviewer/contents/ui/YELLOW.png | Bin 0 -> 153 bytes components/mailviewer/contents/ui/main.qml | 30 +++++++++ 14 files changed, 517 insertions(+) create mode 100644 components/mailviewer/contents/ui/EmbededPart.qml create mode 100644 components/mailviewer/contents/ui/EncryptionPart.qml create mode 100644 components/mailviewer/contents/ui/GREEN.png create mode 100644 components/mailviewer/contents/ui/GREY.png create mode 100644 components/mailviewer/contents/ui/HtmlContent.qml create mode 100644 components/mailviewer/contents/ui/MailDataModel.qml create mode 100644 components/mailviewer/contents/ui/MailPart.qml create mode 100644 components/mailviewer/contents/ui/MailViewer.qml create mode 100644 components/mailviewer/contents/ui/PURPLE.png create mode 100644 components/mailviewer/contents/ui/RED.png create mode 100644 components/mailviewer/contents/ui/SignaturePart.qml create mode 100644 components/mailviewer/contents/ui/TextContent.qml create mode 100644 components/mailviewer/contents/ui/YELLOW.png create mode 100644 components/mailviewer/contents/ui/main.qml (limited to 'components/mailviewer/contents') diff --git a/components/mailviewer/contents/ui/EmbededPart.qml b/components/mailviewer/contents/ui/EmbededPart.qml new file mode 100644 index 00000000..8921ab6f --- /dev/null +++ b/components/mailviewer/contents/ui/EmbededPart.qml @@ -0,0 +1,54 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 + +Item { + + height: mailPart.height + width: mailPart.width + + + Rectangle { + id: border + color: "lightgrey" + height: mailPart.height + width: 5 + } + + Text { + id: sender + + anchors { + left: border.right + leftMargin: 15 + } + + text: "sent by " + model.sender + " on " + model.date + color: "grey" + } + + MailPart { + id: mailPart + + anchors.top: sender.bottom + + } + +} + diff --git a/components/mailviewer/contents/ui/EncryptionPart.qml b/components/mailviewer/contents/ui/EncryptionPart.qml new file mode 100644 index 00000000..058c9af7 --- /dev/null +++ b/components/mailviewer/contents/ui/EncryptionPart.qml @@ -0,0 +1,75 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 + +Item { + id: encryption + property alias rootIndex: visualModel.rootIndex + property bool debug: true + height: partListView.height + width: parent.width + + MailDataModel { + id: visualModel + debug: encryption.debug + model: messageParser.newTree + } + + Column { + id: partListView + anchors { + top: parent.top + left: parent.left + } + width: parent.width + spacing: 5 + Text { + width: parent.width + visible: encryption.debug + text: model.type + } + Text { + visible: model.errorType || encryption.debug + text: model.errorType + ": " + model.errorString + } + BorderImage { + width: parent.width + height: childrenRect.height + 40 + border { left: 5; top: 5; right: 6; bottom: 6 } + horizontalTileMode: BorderImage.Round + verticalTileMode: BorderImage.Round + + source: /* "securityborders"+ */ model.securityLevel +".png" + ListView { + model: visualModel + anchors { + top: parent.top + left: parent.left + margins: 20 + } + height: contentHeight + width: parent.width - 40 + + spacing: 20 + + interactive: false + } + } + } +} diff --git a/components/mailviewer/contents/ui/GREEN.png b/components/mailviewer/contents/ui/GREEN.png new file mode 100644 index 00000000..60f8e10d Binary files /dev/null and b/components/mailviewer/contents/ui/GREEN.png differ diff --git a/components/mailviewer/contents/ui/GREY.png b/components/mailviewer/contents/ui/GREY.png new file mode 100644 index 00000000..146e8927 Binary files /dev/null and b/components/mailviewer/contents/ui/GREY.png differ diff --git a/components/mailviewer/contents/ui/HtmlContent.qml b/components/mailviewer/contents/ui/HtmlContent.qml new file mode 100644 index 00000000..4fc694f9 --- /dev/null +++ b/components/mailviewer/contents/ui/HtmlContent.qml @@ -0,0 +1,70 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 +import QtQuick.Controls 1.3 +import QtWebEngine 1.3 + +Item { + id: root + property string content: model.content + //We have to give it a minimum size so the html content starts to expand + property int contentHeight: 10; + + height: contentHeight + width: partColumn.width + + WebEngineView { + id: htmlView + anchors.fill: parent + Component.onCompleted: loadHtml(content, "file:///") + onContentsSizeChanged: { + root.contentHeight = contentsSize.height; + } + onLoadingChanged: { + if (loadRequest.status === WebEngineView.LoadFailedStatus) { + console.warn("Failed to load html content."); + console.warn("Error is ", loadRequest.errorString); + } + } + settings { + webGLEnabled: false + touchIconsEnabled: false + spatialNavigationEnabled: false + screenCaptureEnabled: false + pluginsEnabled: false + localStorageEnabled: false + localContentCanAccessRemoteUrls: false + localContentCanAccessFileUrls: false + linksIncludedInFocusChain: false + javascriptEnabled: false + javascriptCanOpenWindows: false + javascriptCanAccessClipboard: false + hyperlinkAuditingEnabled: false + fullScreenSupportEnabled: false + errorPageEnabled: false + //defaultTextEncoding: ??? + autoLoadImages: false + autoLoadIconsForPage: false + accelerated2dCanvasEnabled: false + } + } + onContentChanged: { + htmlView.loadHtml(content, "file:///"); + } +} diff --git a/components/mailviewer/contents/ui/MailDataModel.qml b/components/mailviewer/contents/ui/MailDataModel.qml new file mode 100644 index 00000000..e0e65c49 --- /dev/null +++ b/components/mailviewer/contents/ui/MailDataModel.qml @@ -0,0 +1,66 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 +import QtQml.Models 2.2 + +DelegateModel { + id: mailDataModel + property bool debug: true + delegate: Item { + id: partColumn + width: parent.width + height: childrenRect.height + Loader { + id: partLoader + anchors { + top: parent.top + left: parent.left + } + height: item? item.contentHeight : 0 + width: parent.width + } + Component.onCompleted: { + switch (model.type) { + case "PlainTextContent": + case "Content": + partLoader.source = "TextContent.qml" + partLoader.item.debug = mailDataModel.debug + return; + case "HtmlContent": + partLoader.source = "HtmlContent.qml" + return; + case "Signature": + partLoader.source = "SignaturePart.qml" + partLoader.item.rootIndex = mailDataModel.modelIndex(index) + partLoader.item.debug = mailDataModel.debug + return; + case "Encryption": + partLoader.source = "EncryptionPart.qml" + partLoader.item.rootIndex = mailDataModel.modelIndex(index) + partLoader.item.debug = mailDataModel.debug + return; + } + if (model.hasModelChildren) { + partLoader.source = "MailPart.qml" + partLoader.item.rootIndex = mailDataModel.modelIndex(index) + partLoader.item.debug = mailDataModel.debug + } + } + } +} diff --git a/components/mailviewer/contents/ui/MailPart.qml b/components/mailviewer/contents/ui/MailPart.qml new file mode 100644 index 00000000..30bf1ee0 --- /dev/null +++ b/components/mailviewer/contents/ui/MailPart.qml @@ -0,0 +1,47 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 + +Item { + id: root + property alias rootIndex: visualModel.rootIndex + property bool debug: true + height: partListView.height + 10 + width: parent.width + + MailDataModel { + id: visualModel + debug: root.debug + model: messageParser.newTree + } + + ListView { + id: partListView + model: visualModel + anchors { + top: parent.top + left: parent.left + margins: 5 + } + spacing: 5 + height: contentHeight + width: parent.width - 10 + interactive: false + } +} diff --git a/components/mailviewer/contents/ui/MailViewer.qml b/components/mailviewer/contents/ui/MailViewer.qml new file mode 100644 index 00000000..0f7efca2 --- /dev/null +++ b/components/mailviewer/contents/ui/MailViewer.qml @@ -0,0 +1,46 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 + +Item { + id: root + property alias rootIndex: visualModel.rootIndex + property bool debug: false + height: partListView.height + + MailDataModel { + id: visualModel + debug: root.debug + model: messageParser.newTree + } + + ListView { + id: partListView + model: visualModel + anchors { + top: parent.top + left: parent.left + margins: 5 + } + spacing: 5 + height: contentHeight + width: parent.width - 10 + interactive: false + } +} diff --git a/components/mailviewer/contents/ui/PURPLE.png b/components/mailviewer/contents/ui/PURPLE.png new file mode 100644 index 00000000..5ea1eda2 Binary files /dev/null and b/components/mailviewer/contents/ui/PURPLE.png differ diff --git a/components/mailviewer/contents/ui/RED.png b/components/mailviewer/contents/ui/RED.png new file mode 100644 index 00000000..5bb547e2 Binary files /dev/null and b/components/mailviewer/contents/ui/RED.png differ diff --git a/components/mailviewer/contents/ui/SignaturePart.qml b/components/mailviewer/contents/ui/SignaturePart.qml new file mode 100644 index 00000000..0a2fe525 --- /dev/null +++ b/components/mailviewer/contents/ui/SignaturePart.qml @@ -0,0 +1,68 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 + +Item { + id: signature + property alias rootIndex: visualModel.rootIndex + property bool debug: true + height: partListView.height + width: parent.width + + MailDataModel { + id: visualModel + debug: signature.debug + model: messageParser.newTree + } + Column { + id: partListView + anchors { + top: parent.top + left: parent.left + } + width: parent.width + spacing: 5 + Text { + width: parent.width + visible: signature.debug + text: model.type + } + BorderImage { + width: parent.width + height: childrenRect.height + 40 + border { left: 5; top: 5; right: 6; bottom: 6 } + horizontalTileMode: BorderImage.Round + verticalTileMode: BorderImage.Round + source: /* "securityborders"+ */ model.securityLevel +".png" + ListView { + model: visualModel + anchors { + top: parent.top + left: parent.left + margins: 20 + } + height: contentHeight + width: parent.width - 40 + + spacing: 20 + interactive: false + } + } + } +} diff --git a/components/mailviewer/contents/ui/TextContent.qml b/components/mailviewer/contents/ui/TextContent.qml new file mode 100644 index 00000000..d3ae80f9 --- /dev/null +++ b/components/mailviewer/contents/ui/TextContent.qml @@ -0,0 +1,61 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.7 +import org.kde.kirigami 1.0 as Kirigami + +Item { + id: textItem + + property bool debug: true + + width: partColumn.width + height: textColumn.height + + Column { + id: textColumn + + anchors { + top: parent.top + left: parent.left + } + + width: parent.width + spacing: 5 + + TextEdit { + width: parent.width + + readOnly: true + selectByMouse: true + + text: model.content + wrapMode: Text.WordWrap + + color: model.embeded ? Kirigami.Theme.diabledTextColor : Kirigami.Theme.textColor + } + + //BEGIN debug + Text { + width: parent.width + visible: textItem.debug + text: model.type + } + //END debug + } +} diff --git a/components/mailviewer/contents/ui/YELLOW.png b/components/mailviewer/contents/ui/YELLOW.png new file mode 100644 index 00000000..db629e35 Binary files /dev/null and b/components/mailviewer/contents/ui/YELLOW.png differ diff --git a/components/mailviewer/contents/ui/main.qml b/components/mailviewer/contents/ui/main.qml new file mode 100644 index 00000000..e69dd5a2 --- /dev/null +++ b/components/mailviewer/contents/ui/main.qml @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2017 Christian Mollekopf, + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.7 +import QtQuick.Controls 2.0 as Controls2 + +Controls2.ApplicationWindow { + id: app + height: 900 + width: 1500 + + MailViewer { + visible: true + } +} -- cgit v1.2.3