Dekko
Loading...
Searching...
No Matches
MailStage.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 Lomiri.Components 1.3
20import Dekko.Mail 1.0
21import Dekko.Mail.API 1.0
22import Dekko.Components 1.0
23import Dekko.Mail.Settings 1.0
24import Dekko.Mail.Stores.Views 1.0
25import Dekko.Mail.Stores.Mail 1.0
26import Dekko.Lomiri.Constants 1.0
27import Dekko.Lomiri.Stage 1.0
28import QuickFlux 1.0
29import MazDB 1.0
30import Dekko.Lomiri.Components 1.0
31import "./views"
32
34 id: ms
35
36 MazDBSettings {
37 category: "ui-property-cache"
38 property alias mailstagePanel1Size: p1.size
39 property alias mailstagePanel2Size: p2.size
40 property alias mailstagePanel3Size: p3.size
41 }
42
43 // We use a stretch row here rather than RowLayout
44 // Just because we can use the implicit size hints to stretch the correct
45 // panel. Yes we could use Layout.fillWidth but in the future there maybe
46 // more columns added to this (through plugins) and we may want to share remaining width evenly between two
47 // or more colums. Which StretchRow handles nicely
48 StretchRow {
49 spacing: 0
50 anchors.fill: parent
51
52 // Should only be visible on large FF
53 // Access is done via the navigation drawer
54 // for smaller FF's
56 id: p1
57 visible: dekko.isLargeFF
58 resizable: !dekko.isSmallFF
59 minSize: units.gu(20)
60 maxSize: units.gu(50)
61 height: parent.height
62 activeEdge: Item.Right
63 StageArea {
64 id: navMenuStage
65 stageID: ViewKeys.navigationStack
66 anchors.fill: parent
67 baseUrl: Qt.resolvedUrl("./views/NavSideBar.qml")
68 }
69 }
70
72 id: p2
73 // This is where we could no longer
74 // work with AdaptivePageLayout
75 // Our center column is actually our main page
76 // when on small form factor devices, and having to
77 // pop/push and rejig evenrything was just awful
78 // Plus i prefer our api.
79 // So we set this main page to fill screen width when
80 // on small FF. This sets the implicit width to -1
81 // and restores it on going back to larger FF's
82 stretchOnSmallFF: true
83 resizable: !dekko.isSmallFF
84 minSize: units.gu(40)
85 maxSize: units.gu(60)
86 size: units.gu(40)
87 height: parent.height
88 activeEdge: Item.Right
89 clip: true
90
91 StageArea {
92 id: msgListStage
93 stageID: ViewKeys.messageListStack
94 anchors.fill: parent
95 baseUrl: Qt.resolvedUrl("./views/MessageListView.qml")
96 function rewind() {
97 var needsDelay = false
98 if (stackCount > 1) {
99 needsDelay = true
100 while (stackCount !== 1) {
101 pop()
102 }
103 }
104 if (needsDelay) {
105 delaySignalRewind.start()
106 } else {
107 MessageActions.stackRewound()
108 }
109 }
110
111 }
112
114 anchors {
115 left: parent.left
116 top: parent.top
117 bottom: parent.bottom
118 }
119 enabled: !dekko.isLargeFF
120 visible: enabled
121 animate: true
122 width: Style.defaultPanelWidth
123 state: "fixed"
124 NavSideBar {
125 anchors.fill: parent
126 panelMode: true
127 }
128 }
129 }
130 // Take rest of space when visible
131 Stretcher {
132 visible: !dekko.isSmallFF
133 anchors {
134 top: parent.top
135 bottom: parent.bottom
136 }
137 StageArea {
138 id: msgViewStage
139 stageID: ViewKeys.messageViewStack
140 anchors.fill: parent
141 immediatePush: false
142 baseUrl: Qt.resolvedUrl("./views/NothingSelectedPage.qml")
143 delegate: DekkoAnimation.customStackViewDelegate1
144 AppListener {
145 filter: MessageKeys.openFolder
146 onDispatched: {
147 if (msgViewStage.stackCount > 1) {
148 msgViewStage.pop()
149 }
150 }
151 }
152 }
153 }
154
156 id: p3
157 visible: dekko.isLargeFF && pluginStage.stackCount
158 minSize: units.gu(20)
159 maxSize: units.gu(40)
160 size: units.gu(30)
161 height: parent.height
162 activeEdge: Item.Left
163
164 StageArea {
165 id: pluginStage
166 stageID: "pluginStack"
167 anchors.fill: parent
168 }
169 }
170 }
171
172 Timer {
173 id: delaySignalRewind
174 interval: 300
175 repeat: false
176 onTriggered: MessageActions.stackRewound()
177 }
178
179 AppListener {
180
181 Filter {
182 type: MessageKeys.openMessage
183 onDispatched: {
184 if (MailStore.currentMessageId === message.msgId) {
185 Log.logInfo("MailStage::openMessage", "Message %1 already open".arg(message.msgId))
186 return
187 }
188
189 MessageActions.setCurrentMessage(message.msgId)
190
191 var style = Qt.resolvedUrl("./messageview/DefaultMessagePage.qml")
192 if (dekko.isSmallFF) {
193 // leftStage push msgview
194 ViewActions.pushToStageArea(ViewKeys.messageListStack, style, {msgId: message.msgId})
195 } else {
196 if (msgViewStage.stackCount > 1) {
197 ViewActions.replaceTopStageAreaItem(ViewKeys.messageViewStack, style, {msgId: message.msgId})
198 } else {
199 ViewActions.pushToStageArea(ViewKeys.messageViewStack, style, {msgId: message.msgId})
200 }
201 }
202 }
203 }
204
205 Filter {
206 type: MessageKeys.rewindMessageListStack
207 onDispatched: {
208 // Listen for a new folder opening and pop the stack
209 // until we get to the msglist. MailStore is also listening on this and will take
210 // care of actually opening the folder.
211 Log.logInfo("MailStage::openFolder", "Checking stack count")
212 msgListStage.rewind()
213 }
214 }
215
216 Filter {
217 type: MessageKeys.openAccountFolder
218 onDispatched: {
219 ViewActions.closeNavDrawer()
220 if (dekko.isLargeFF) {
221 ViewActions.pushToStageArea(ViewKeys.navigationStack,
222 Qt.resolvedUrl("./views/FolderListView.qml"),
223 {
224 pageTitle: message.accountName,
225 accountId: message.accountId
226 })
227 } else {
228 ViewActions.pushToStageArea(ViewKeys.messageListStack,
229 Qt.resolvedUrl("./views/FolderListView.qml"),
230 {
231 pageTitle: message.accountName,
232 accountId: message.accountId
233 })
234 }
235 }
236 }
237 }
238}