Warning, /pim/merkuro/src/mail/qml/FolderView.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
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 org.kde.kirigami 2.14 as Kirigami
0007 import QtQuick.Controls 2.15 as QQC2
0008 import Qt.labs.platform 1.1
0009 import QtQuick.Dialogs 6.2
0010 import org.kde.merkuro.mail 1.0
0011 import org.kde.kitemmodels 1.0 as KItemModels
0012 import './private'
0013
0014 Kirigami.ScrollablePage {
0015 id: folderView
0016 title: MailManager.selectedFolderName
0017
0018 property var collection
0019
0020 Loader {
0021 id: mailSaveLoader
0022
0023 active: false
0024 onLoaded: item.open();
0025
0026 sourceComponent: FileDialog {
0027 title: i18n("Save Message - Merkuro-Mail")
0028 nameFilters: [i18n("email messages (*.mbox)")]
0029 currentFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
0030 fileMode: fileDialog.SaveFile
0031
0032 onAccepted: {
0033 if (fileUrl) {
0034 MailManager.saveMail(fileUrl, folderView.collection);
0035 }
0036 mailSaveLoader.active = false;
0037 }
0038 onRejected: mailSaveLoader.active = false;
0039 }
0040 }
0041
0042 actions: Kirigami.Action {
0043 icon.name: 'mail-send'
0044 text: i18nc("@action:menu", "Create")
0045 onTriggered: applicationWindow().pageStack.pushDialogLayer(Qt.resolvedUrl("./MailComposer.qml"))
0046 }
0047
0048 ListView {
0049 id: mails
0050 model: MailManager.folderModel
0051 currentIndex: -1
0052
0053 Component {
0054 id: contextMenu
0055 QQC2.Menu {
0056 property int row
0057 property var status
0058
0059 QQC2.Menu {
0060 title: i18nc("@action:menu", "Mark Message")
0061 QQC2.MenuItem {
0062 text: i18n("Mark Message as Read")
0063 }
0064 QQC2.MenuItem {
0065 text: i18n("Mark Message as Unread")
0066 }
0067
0068 QQC2.MenuSeparator {}
0069
0070 QQC2.MenuItem {
0071 text: status.isImportant ? i18n("Don't Mark as Important") : i18n("Mark as Important")
0072 }
0073 }
0074
0075 QQC2.MenuItem {
0076 icon.name: 'delete'
0077 text: i18n("Move to Trash")
0078 }
0079
0080 QQC2.MenuItem {
0081 icon.name: 'edit-move'
0082 text: i18n("Move Message to...")
0083 }
0084
0085 QQC2.MenuItem {
0086 icon.name: 'edit-copy'
0087 text: i18n("Copy Message to...")
0088 }
0089
0090 QQC2.MenuItem {
0091 icon.name: 'view-calendar'
0092 text: i18n("Add Followup Reminder")
0093 }
0094
0095 QQC2.MenuItem {
0096 icon.name: 'document-save-as'
0097 text: i18nc("@action:button", "Save as...")
0098 onClicked: mailSaveLoader.active = true
0099 }
0100 }
0101 }
0102
0103 Connections {
0104 target: MailManager
0105
0106 function onFolderModelChanged() {
0107 mails.currentIndex = -1;
0108 }
0109 }
0110
0111 Kirigami.PlaceholderMessage {
0112 id: mailboxSelected
0113 anchors.centerIn: parent
0114 visible: MailManager.selectedFolderName === ""
0115 text: i18n("No mailbox selected")
0116 explanation: i18n("Select a mailbox from the sidebar.")
0117 icon.name: "mail-unread"
0118 }
0119
0120 Kirigami.PlaceholderMessage {
0121 anchors.centerIn: parent
0122 visible: mails.count === 0 && !mailboxSelected.visible
0123 text: i18n("Mailbox is empty")
0124 icon.name: "mail-folder-inbox"
0125 }
0126
0127 section.delegate: Kirigami.ListSectionHeader {
0128 required property string section
0129 label: section
0130 }
0131 section.property: "date"
0132
0133 delegate: MailDelegate {
0134 id: mailDelegate
0135
0136 onOpenMailRequested: {
0137 applicationWindow().pageStack.push(Qt.resolvedUrl('ConversationViewer.qml'), {
0138 emptyItem: mailDelegate.item,
0139 props: {
0140 from: mailDelegate.from,
0141 to: mailDelegate.to,
0142 sender: mailDelegate.sender,
0143 item: mailDelegate.item,
0144 title: mailDelegate.title,
0145 }
0146 });
0147
0148 if (!mailDelegate.status.isRead) {
0149 const status = MailManager.folderModel.copyMessageStatus(mailDelegate.status);
0150 status.isRead = true;
0151 MailManager.folderModel.updateMessageStatus(index, status)
0152 }
0153 }
0154
0155 onStarMailRequested: {
0156 const status = MailManager.folderModel.copyMessageStatus(mailDelegate.status);
0157 status.isImportant = !status.isImportant;
0158 MailManager.folderModel.updateMessageStatus(index, status)
0159 }
0160
0161 onContextMenuRequested: {
0162 const menu = contextMenu.createObject(folderView, {
0163 row: index,
0164 status: MailManager.folderModel.copyMessageStatus(mailDelegate.status),
0165 });
0166 folderView.collection = mailDelegate.item;
0167 menu.popup();
0168 }
0169 }
0170 }
0171 }