Dekko
Loading...
Searching...
No Matches
MessageListActionPopover.qml
1/* Copyright (C) 2016 - 2017 Dan Chapman <dpniel@ubuntu.com>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
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
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18import QtQuick 2.4
19import QtQuick.Controls.Suru 2.2
20import Lomiri.Components 1.3
21import Lomiri.Components.Popups 1.3
22import Dekko.Mail 1.0
23import Dekko.Mail.API 1.0
24import Dekko.Components 1.0
25import Dekko.Lomiri.Components 1.0
27Popover {
28 id: actionPopover
29 property var msg
30
31 contentWidth: units.gu(30)
32
33 Column {
34 id: containerLayout
35
36 anchors {
37 left: parent.left
38 top: parent.top
39 right: parent.right
40 }
41
42 ContextGroup {
43 contextActions: [
44 ContextAction {
45 description: msg && msg.isRead ? qsTr("Mark as unread") : qsTr("Mark as read")
46 actionIcon: msg && msg.isRead ? Icons.MailUnreadIcon : Icons.MailReadIcon
47 onTriggered: {
48 MessageActions.markMessageRead(msg.messageId, !msg.isRead)
49 PopupUtils.close(actionPopover)
50 }
51 },
53 description: msg && msg.isImportant ? qsTr("Mark as not important") : qsTr("Mark as important")
54 actionIcon: msg && msg.isImportant ? Icons.UnStarredIcon : Icons.StarredIcon
55 onTriggered: {
56 MessageActions.markMessageImportant(msg.messageId, !msg.isImportant)
57 PopupUtils.close(actionPopover)
58 }
59 }
60 ]
61 }
62
64 contextActions: [
66 description: qsTr("To-do")
67 actionIcon: Icons.ViewListSymbolic
68 selectedIcon: Icons.TickIcon
69 Suru.highlightType: Suru.PositiveHighlight
70 selectedIconColor: Suru.highlightColor
71 selected: msg && msg.isTodo
72 onTriggered: {
73 // remove done flag if re-marking as todo
74 if (msg.isDone) {
75 MessageActions.markMessageAsDone(msg.messageId, false)
76 }
77 MessageActions.markMessageAsTodo(msg.messageId, !msg.isTodo)
78 PopupUtils.close(actionPopover)
79 }
80 },
82 visible: msg && msg.isTodo
83 description: qsTr("Done")
84 actionIcon: Icons.SelectIcon
85 onTriggered: {
86 // markMessageDone will remove the Todo flag if it is set
87 MessageActions.markMessageAsDone(msg.messageId, !msg.isDone)
88 PopupUtils.close(actionPopover)
89 }
90 }
91 ]
92 }
93
95 contextActions: [
97 description: qsTr("Reply")
98 actionIcon: Icons.MailRepliedAllIcon
99 onTriggered: {
100 ComposerActions.respondToMessage(msg.isListPost ? SubmissionManager.ReplyList : SubmissionManager.Reply, msg.messageId)
101 PopupUtils.close(actionPopover)
102 }
103 },
105 description: qsTr("Reply all")
106 actionIcon: Icons.MailRepliedIcon
107 onTriggered: {
108 ComposerActions.respondToMessage(SubmissionManager.ReplyAll, msg.messageId)
109 PopupUtils.close(actionPopover)
110 }
111 },
113 description: qsTr("Forward")
114 actionIcon: Icons.MailForwardedIcon
115 onTriggered: {
116 ComposerActions.forwardMessage(SubmissionManager.ForwardInline, msg.messageId)
117 PopupUtils.close(actionPopover)
118 }
119 },
121 description: qsTr("Forward As Attachment")
122 actionIcon: Icons.MailForwardedIcon
123 onTriggered: {
124 ComposerActions.forwardMessage(SubmissionManager.ForwardAsAttachment, msg.messageId)
125 PopupUtils.close(actionPopover)
126 }
127 }
128 ]
129 }
130
132 divider.visible: false // last group so we don't need divider
133 contextActions: [
135 description: qsTr("Move")
136 actionIcon: Icons.InboxIcon
137 onTriggered: {
138 MailboxActions.moveMessage(msg.parentAccountId, msg.messageId)
139 PopupUtils.close(actionPopover)
140 }
141 },
142
144 description: msg ? qsTr("Restore to %1").arg(msg.previousFolderName) : ""
145 actionIcon: Icons.UndoIcon
146 visible: msg && msg.canBeRestored
147 onTriggered: {
148 MessageActions.restoreMessage(msg.messageId)
149 PopupUtils.close(actionPopover)
150 }
151 },
153 description: qsTr("Delete")
154 actionIcon: Icons.DeleteIcon
155 onTriggered: {
156 MessageActions.deleteMessage(msg.messageId)
157 PopupUtils.close(actionPopover)
158 }
159 }
160 ]
161 }
162 }
163}