Warning, /pim/merkuro/src/mail/qml/MailComposer.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Aakarsh MJ <mj.akarsh@gmail.com>
0002 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
0003 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0004
0005 import QtQuick 2.15
0006 import QtQuick.Layouts 1.15
0007 import org.kde.kirigami 2.14 as Kirigami
0008 import QtQuick.Controls 2.15 as QQC2
0009 import org.kde.kitemmodels 1.0 as KItemModels
0010 import org.kde.merkuro.mail 1.0
0011 import org.kde.akonadi 1.0 as Akonadi
0012 import org.kde.kidentitymanagement 1.0 as KIdentityManagement
0013
0014 Kirigami.ScrollablePage {
0015 id: mailComposition
0016 title: i18nc("@title:window", "New Message")
0017 leftPadding: 0
0018 rightPadding: 0
0019 bottomPadding: 0
0020 topPadding: Kirigami.Units.largeSpacing
0021
0022 property MailHeaderModel mailHeaderModel: MailHeaderModel {}
0023
0024 GridLayout {
0025 columns: 2
0026 anchors.fill: parent
0027
0028 QQC2.Label {
0029 text: i18n("From:")
0030 Layout.leftMargin: Kirigami.Units.largeSpacing
0031 }
0032
0033 QQC2.TextField {
0034 id: from
0035 Layout.fillWidth: true
0036 Layout.rightMargin: Kirigami.Units.largeSpacing
0037 }
0038
0039 QQC2.Label {
0040 text: i18n("Identity:")
0041 Layout.leftMargin: Kirigami.Units.largeSpacing
0042 }
0043
0044 QQC2.ComboBox {
0045 id: identity
0046 model: KIdentityManagement.IdentityModel {}
0047 textRole: "display"
0048 valueRole: "uoid"
0049 onCurrentIndexChanged: from.text = model.email(currentValue)
0050 Layout.rightMargin: Kirigami.Units.largeSpacing
0051 Layout.fillWidth: true
0052 }
0053
0054 Repeater {
0055 model: mailHeaderModel
0056 QQC2.ComboBox {
0057 id: control
0058 Layout.row: index + 2
0059 Layout.column: 0
0060 Layout.leftMargin: Kirigami.Units.largeSpacing
0061 textRole: "text"
0062 valueRole: "value"
0063 Component.onCompleted: currentIndex = Math.min(mailHeaderModel.rowCount() - 1, 1);
0064 onCurrentIndexChanged: mailHeaderModel.updateHeaderType(index, currentValue);
0065 model: [
0066 { value: MailHeaderModel.To, text: i18n("To:") },
0067 { value: MailHeaderModel.CC, text: i18n("CC:") },
0068 { value: MailHeaderModel.BCC, text: i18n("BCC:") },
0069 { value: MailHeaderModel.ReplyTo, text: i18n("Reply-To:") },
0070 ]
0071 }
0072 }
0073 Repeater {
0074 model: mailHeaderModel
0075 QQC2.TextField {
0076 id: controlsText
0077 Layout.row: index + 2
0078 Layout.column: 1
0079 Layout.fillWidth: true
0080 Layout.rightMargin: Kirigami.Units.largeSpacing
0081 wrapMode: Text.Wrap
0082 KeyNavigation.priority: KeyNavigation.BeforeItem
0083 onTextChanged: mailHeaderModel.updateModel(index, text);
0084 }
0085 }
0086
0087 QQC2.Label {
0088 id: subject
0089 text: i18n("Subject:")
0090 Layout.leftMargin: Kirigami.Units.largeSpacing
0091 }
0092 QQC2.TextField {
0093 id: subjectText
0094 Layout.fillWidth: true
0095 Layout.rightMargin: Kirigami.Units.largeSpacing
0096 wrapMode: Text.Wrap
0097 KeyNavigation.priority: KeyNavigation.BeforeItem
0098 KeyNavigation.tab: mailContent
0099 }
0100
0101 QQC2.TextArea {
0102 id: mailContent
0103 Layout.columnSpan: 2
0104 Layout.fillWidth: true
0105 Layout.fillHeight: true
0106 background: Rectangle {
0107 color: Kirigami.Theme.backgroundColor
0108 }
0109
0110 Kirigami.Theme.colorSet: Kirigami.Theme.View
0111 Kirigami.Theme.inherit: false
0112
0113 textFormat: TextEdit.PlainText
0114 textMargin: 10
0115 wrapMode: TextEdit.Wrap
0116 KeyNavigation.priority: KeyNavigation.BeforeItem
0117 KeyNavigation.tab: attachment
0118 }
0119 }
0120
0121 footer: QQC2.ToolBar {
0122 contentItem: RowLayout {
0123 QQC2.ToolButton {
0124 id: attachment
0125 icon.name: 'document-import'
0126 KeyNavigation.priority: KeyNavigation.BeforeItem
0127 KeyNavigation.tab: discardDraft
0128 }
0129 QQC2.ToolButton {
0130 id: discardDraft
0131 icon.name: 'user-trash'
0132 }
0133 Item {
0134 Layout.fillWidth: true
0135 }
0136 QQC2.ToolButton {
0137 id: sendButton
0138 text: i18n("Send")
0139 icon.name: 'document-send'
0140 onClicked: {
0141 MailClient.send(identity.model, mailComposition.mailHeaderModel, subjectText.text, mailContent.text);
0142 close()
0143 }
0144 }
0145 }
0146 }
0147 }