Warning, /plasma-mobile/raven/src/contents/ui/MailViewer.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu>
0002 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0003 
0004 import QtQuick 2.15
0005 import QtQuick.Layouts 1.15
0006 import QtQuick.Controls 2.15 as QQC2
0007 import QtGraphicalEffects 1.15
0008 
0009 import org.kde.raven 1.0
0010 import org.kde.kirigami 2.14 as Kirigami
0011 import org.kde.kitemmodels 1.0 as KItemModels
0012 
0013 import './mailpartview'
0014 import './private'
0015 
0016 QQC2.Page {
0017     id: root
0018     property var item
0019     property string subject
0020     property string from
0021     property string sender
0022     property string to
0023     property date dateTime
0024 
0025     Kirigami.Theme.colorSet: Kirigami.Theme.View
0026     Kirigami.Theme.inherit: false
0027 
0028     padding: Kirigami.Units.largeSpacing * 2
0029 
0030     header: QQC2.ToolBar {
0031         id: mailHeader
0032         padding: root.padding
0033 
0034         Kirigami.Theme.inherit: false
0035         Kirigami.Theme.colorSet: Kirigami.Theme.View
0036 
0037         background: Item {
0038             Rectangle {
0039                 anchors.fill: parent
0040                 color: Kirigami.Theme.alternateBackgroundColor
0041             }
0042             
0043             Kirigami.Separator {
0044                 anchors.top: parent.top
0045                 anchors.left: parent.left
0046                 anchors.right: parent.right
0047             }
0048             
0049             Kirigami.Separator {
0050                 anchors.bottom: parent.bottom
0051                 anchors.left: parent.left
0052                 anchors.right: parent.right
0053             }
0054         }
0055 
0056         ColumnLayout {
0057             width: mailHeader.width - mailHeader.leftPadding - mailHeader.rightPadding
0058             spacing: Kirigami.Units.smallSpacing
0059 
0060             RowLayout {
0061                 Layout.fillWidth: true
0062                 
0063                 QQC2.Label {
0064                     text: root.from
0065                     elide: Text.ElideRight
0066                     Layout.fillWidth: true
0067                 }
0068 
0069                 QQC2.Label {
0070                     text: root.dateTime.toLocaleString(Qt.locale(), Locale.ShortFormat)
0071                     horizontalAlignment: Text.AlignRight
0072                 }
0073             }
0074 
0075             RowLayout {
0076                 Layout.fillWidth: true
0077                 
0078                 QQC2.Label {
0079                     text: i18n("Sender:")
0080                     font.bold: true
0081                     visible: root.sender.length > 0 && root.sender !== root.from
0082                     Layout.rightMargin: Kirigami.Units.largeSpacing
0083                 }
0084 
0085                 QQC2.Label {
0086                     visible: root.sender.length > 0 && root.sender !== root.from
0087                     text: root.sender
0088                     elide: Text.ElideRight
0089                     Layout.fillWidth: true
0090                 }
0091             }
0092 
0093             RowLayout {
0094                 Layout.fillWidth: true
0095                 
0096                 QQC2.Label {
0097                     text: i18n("To:")
0098                     font.bold: true
0099                     Layout.rightMargin: Kirigami.Units.largeSpacing
0100                 }
0101 
0102                 QQC2.Label {
0103                     text: root.to
0104                     elide: Text.ElideRight
0105                     Layout.fillWidth: true
0106                 }
0107             }
0108         }
0109     }
0110 
0111     MailPartView {
0112         id: mailPartView
0113         anchors.fill: parent
0114         item: root.item
0115     }
0116 
0117     footer: QQC2.ToolBar {
0118         padding: root.padding
0119 
0120         Kirigami.Theme.inherit: false
0121         Kirigami.Theme.colorSet: Kirigami.Theme.View
0122 
0123         background: Item {
0124             Kirigami.Separator {
0125                 anchors {
0126                     left: parent.left
0127                     right: parent.right
0128                     top: undefined
0129                     bottom:  parent.bottom
0130                 }
0131             }
0132         }
0133 
0134         Flow {
0135             anchors.fill: parent
0136             spacing: Kirigami.Units.smallSpacing
0137             Repeater {
0138                 model: mailPartView.attachmentModel
0139 
0140                 delegate: AttachmentDelegate {
0141                     name: model.name
0142                     type: model.type
0143                     icon.name: model.iconName
0144 
0145                     clip: true
0146 
0147                     actionIcon: 'download'
0148                     actionTooltip: i18n("Save attachment")
0149                     onExecute: mailPartView.attachmentModel.saveAttachmentToDisk(mailPartView.attachmentModel.index(index, 0))
0150                     onClicked: mailPartView.attachmentModel.openAttachment(mailPartView.attachmentModel.index(index, 0))
0151                     onPublicKeyImport: mailPartView.attachmentModel.importPublicKey(mailPartView.attachmentModel.index(index, 0))
0152                 }
0153             }
0154         }
0155     }
0156 }