Dekko
Loading...
Searching...
No Matches
CopyFoldersGroup.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 QuickFlux 1.0
21import Lomiri.Components 1.3
22import Dekko.Mail.Accounts 1.0
23import Dekko.Mail 1.0
24import Dekko.Components 1.0
25import Dekko.Mail.API 1.0
26import Dekko.Mail.Settings 1.0
27import Dekko.Mail.Stores.Settings 1.0
28import Dekko.Lomiri.Components 1.0
30SettingsGroupPage {
31 pageHeader.title: qsTr("Copies and Folders: %1").arg(SettingsStore.selectedAccount.name)
32
33 property AccountConfig incoming: account.incoming
34
35 function settingsChanged() {
36 if (incoming.baseFolder !== basePath.text
37 || account.specialUseFolderPath(Account.InboxFolder) !== inbox.text
38 || account.specialUseFolderPath(Account.DraftsFolder) !== drafts.text
39 || account.specialUseFolderPath(Account.SentFolder) !== sent.text
40 || account.specialUseFolderPath(Account.JunkFolder) !== junk.text
41 || account.specialUseFolderPath(Account.OutboxFolder) !== outbox.text
42 || account.specialUseFolderPath(Account.TrashFolder) !== trash.text)
43 {
44 return true
45 } else {
46 return false
47 }
48 }
49
50 MailPolicy {
51 id: mailPolicy
52 accountId: SettingsStore.selectedAccount.accountId
53 }
54
55 AppListener {
56
57 Filter {
58 type: SettingsKeys.saveCurrentGroup
59 onDispatched: {
60 console.log("CopyFoldersGroup::saveCurrentGroup", "Saving current group")
61 if (!settingsChanged()) {
62 return
63 }
64 incoming.baseFolder = basePath.text
65 account.setSpecialUseFolder(Account.InboxFolder, inbox.text)
66 account.setSpecialUseFolder(Account.DraftsFolder, drafts.text)
67 account.setSpecialUseFolder(Account.SentFolder, sent.text)
68 account.setSpecialUseFolder(Account.JunkFolder, junk.text)
69 account.setSpecialUseFolder(Account.OutboxFolder, outbox.text)
70 account.setSpecialUseFolder(Account.TrashFolder, trash.text)
71 SettingsStore.settingsChanged = true
72 console.log("CopyFoldersGroup::saveCurrentGroup", "Current group saved")
73 SettingsActions.currentGroupSaved()
74 }
75 }
76
77 Filter {
78 type: SettingsKeys.folderPathPicked
79 onDispatched: {
80 switch (message.fieldId) {
81 case "base":
82 basePath.text = message.path
83 break
84 case "inbox":
85 inbox.text = message.path
86 break
87 case "drafts":
88 drafts.text = message.path
89 break
90 case "spam":
91 junk.text = message.path
92 break
93 case "sent":
94 sent.text = message.path
95 break
96 case "outbox":
97 outbox.text = message.path
98 break
99 case "trash":
100 trash.text = message.path
101 break
102 }
103 }
104 }
105 }
106
108 margins: 0
109 anchors.topMargin: units.gu(1)
110 Item {
111 height: units.gu(5)
112 width: parent.width
113 visible: true
114 Label {
115 anchors {
116 left: parent.left
117 verticalCenter: parent.verticalCenter
118 margins: units.gu(2)
119 }
120 text: qsTr("Detect standard folders")
121 }
122
123 Button {
124 id: detectButton
125 Suru.highlightType: Suru.PositiveHighlight
126 color: Suru.highlightColor
127 text: qsTr("Detect")
128 anchors {
129 right: parent.right
130 verticalCenter: parent.verticalCenter
131 margins: units.gu(2)
132 }
133 onClicked: {
134 SettingsActions.detectStandardFolders()
135 }
136 }
137 }
138
140 id: basePath
141 anchors {
142 left: parent.left
143 right: parent.right
144 margins: units.gu(2)
145 }
146 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
147 title: qsTr("Base folder")
148 text: incoming.baseFolder
149 placeholderText: qsTr("Leave empty if you are unsure")
150 trailingAction: Action {
151 iconSource: Paths.actionIconUrl(Icons.InboxIcon)
152 onTriggered: SettingsActions.pickFolder(account.id, "base")
153 }
154 }
155
157 id: inbox
158 anchors {
159 left: parent.left
160 right: parent.right
161 margins: units.gu(2)
162 }
163 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
164 title: qsTr("Inbox folder")
165 text: account.specialUseFolderPath(Account.InboxFolder)
166 trailingAction: Action {
167 iconSource: Paths.actionIconUrl(Icons.InboxIcon)
168 onTriggered: SettingsActions.pickFolder(account.id, "inbox")
169 }
170 }
171
173 id: drafts
174 anchors {
175 left: parent.left
176 right: parent.right
177 margins: units.gu(2)
178 }
179 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
180 title: qsTr("Drafts folder")
181 text: account.specialUseFolderPath(Account.DraftsFolder)
182 trailingAction: Action {
183 iconSource: Paths.actionIconUrl(Icons.InboxIcon)
184 onTriggered: SettingsActions.pickFolder(account.id, "drafts")
185 }
186 }
187
189 id: junk
190 anchors {
191 left: parent.left
192 right: parent.right
193 margins: units.gu(2)
194 }
195 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
196 title: qsTr("Spam folder")
197 text: account.specialUseFolderPath(Account.JunkFolder)
198 trailingAction: Action {
199 iconSource: Paths.actionIconUrl(Icons.InboxIcon)
200 onTriggered: SettingsActions.pickFolder(account.id, "spam")
201 }
202 }
203
205 id: sent
206 anchors {
207 left: parent.left
208 right: parent.right
209 margins: units.gu(2)
210 }
211 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
212 title: qsTr("Sent folder")
213 text: account.specialUseFolderPath(Account.SentFolder)
214 trailingAction: Action {
215 iconSource: Paths.actionIconUrl(Icons.InboxIcon)
216 onTriggered: SettingsActions.pickFolder(account.id, "sent")
217 }
218 }
219
221 id: outbox
222 anchors {
223 left: parent.left
224 right: parent.right
225 margins: units.gu(2)
226 }
227 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
228 title: qsTr("Outbox folder")
229 text: account.specialUseFolderPath(Account.OutboxFolder)
230 trailingAction: Action {
231 iconSource: Paths.actionIconUrl(Icons.InboxIcon)
232 onTriggered: SettingsActions.pickFolder(account.id, "outbox")
233 }
234 }
235
237 id: trash
238 anchors {
239 left: parent.left
240 right: parent.right
241 margins: units.gu(2)
242 }
243 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
244 title: qsTr("Trash folder")
245 text: account.specialUseFolderPath(Account.TrashFolder)
246 trailingAction: Action {
247 iconSource: Paths.actionIconUrl(Icons.InboxIcon)
248 onTriggered: SettingsActions.pickFolder(account.id, "trash")
249 }
250 }
251 }
252}