diff options
Diffstat (limited to 'components/kube/qml/Kube.qml')
-rw-r--r-- | components/kube/qml/Kube.qml | 228 |
1 files changed, 63 insertions, 165 deletions
diff --git a/components/kube/qml/Kube.qml b/components/kube/qml/Kube.qml index 9a31ba58..be3f7e34 100644 --- a/components/kube/qml/Kube.qml +++ b/components/kube/qml/Kube.qml | |||
@@ -86,35 +86,6 @@ Controls2.ApplicationWindow { | |||
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | Kube.Listener { | ||
90 | filter: Kube.Messages.reply | ||
91 | onMessageReceived: { | ||
92 | kubeViews.openComposerWithMail(message.mail, false) | ||
93 | } | ||
94 | } | ||
95 | |||
96 | Kube.Listener { | ||
97 | filter: Kube.Messages.edit | ||
98 | onMessageReceived: { | ||
99 | kubeViews.openComposerWithMail(message.mail, true) | ||
100 | } | ||
101 | } | ||
102 | |||
103 | Kube.Listener { | ||
104 | filter: Kube.Messages.compose | ||
105 | onMessageReceived: kubeViews.openComposer(true, message.recipients) | ||
106 | } | ||
107 | |||
108 | Kube.Listener { | ||
109 | filter: Kube.Messages.requestLogin | ||
110 | onMessageReceived: kubeViews.setLoginView(message.accountId) | ||
111 | } | ||
112 | |||
113 | Kube.Listener { | ||
114 | filter: Kube.Messages.requestAccountsConfiguration | ||
115 | onMessageReceived: kubeViews.setAccountsView() | ||
116 | } | ||
117 | |||
118 | //BEGIN Shortcuts | 89 | //BEGIN Shortcuts |
119 | Shortcut { | 90 | Shortcut { |
120 | sequence: StandardKey.Quit | 91 | sequence: StandardKey.Quit |
@@ -174,48 +145,20 @@ Controls2.ApplicationWindow { | |||
174 | 145 | ||
175 | spacing: Kube.Units.largeSpacing - Kube.Units.smallSpacing | 146 | spacing: Kube.Units.largeSpacing - Kube.Units.smallSpacing |
176 | 147 | ||
177 | Kube.IconButton { | ||
178 | id: composerButton | ||
179 | iconName: Kube.Icons.edit_inverted | ||
180 | onClicked: kubeViews.openComposer(false, []) | ||
181 | activeFocusOnTab: true | ||
182 | checkable: true | ||
183 | Controls2.ButtonGroup.group: viewButtonGroup | ||
184 | tooltip: qsTr("composer") | ||
185 | } | ||
186 | |||
187 | Kube.IconButton { | ||
188 | id: mailButton | ||
189 | iconName: Kube.Icons.mail_inverted | ||
190 | onClicked: kubeViews.setMailView() | ||
191 | activeFocusOnTab: true | ||
192 | checkable: true | ||
193 | checked: true | ||
194 | Controls2.ButtonGroup.group: viewButtonGroup | ||
195 | tooltip: qsTr("mails") | ||
196 | } | ||
197 | |||
198 | Kube.IconButton { | ||
199 | id: peopleButton | ||
200 | iconName: Kube.Icons.user_inverted | ||
201 | onClicked: kubeViews.setPeopleView() | ||
202 | activeFocusOnTab: true | ||
203 | checkable: true | ||
204 | Controls2.ButtonGroup.group: viewButtonGroup | ||
205 | tooltip: qsTr("people") | ||
206 | } | ||
207 | Repeater { | 148 | Repeater { |
208 | model: Kube.ExtensionModel {} | 149 | model: Kube.ExtensionModel { |
150 | id: extensionModel | ||
151 | sortOrder: ["composer", "conversation", "people"] | ||
152 | } | ||
209 | Kube.IconButton { | 153 | Kube.IconButton { |
154 | id: button | ||
210 | iconName: model.icon | 155 | iconName: model.icon |
211 | onClicked: { | 156 | onClicked: kubeViews.showView(model.name) |
212 | var component = Qt.createComponent(model.source) | ||
213 | kubeViews.pushView(component, {}) | ||
214 | } | ||
215 | activeFocusOnTab: true | 157 | activeFocusOnTab: true |
216 | checkable: true | 158 | checkable: true |
217 | Controls2.ButtonGroup.group: viewButtonGroup | 159 | Controls2.ButtonGroup.group: viewButtonGroup |
218 | tooltip: model.tooltip | 160 | tooltip: model.tooltip |
161 | checked: kubeViews.currentViewName == model.name | ||
219 | } | 162 | } |
220 | } | 163 | } |
221 | } | 164 | } |
@@ -240,10 +183,11 @@ Controls2.ApplicationWindow { | |||
240 | Kube.IconButton { | 183 | Kube.IconButton { |
241 | id: logButton | 184 | id: logButton |
242 | iconName: Kube.Icons.info_inverted | 185 | iconName: Kube.Icons.info_inverted |
243 | onClicked: kubeViews.setLogView() | 186 | onClicked: kubeViews.showView("log") |
244 | activeFocusOnTab: true | 187 | activeFocusOnTab: true |
245 | checkable: true | 188 | checkable: true |
246 | alert: logView.pendingError | 189 | alert: kubeViews.getView("log").pendingError |
190 | checked: kubeViews.currentViewName == "log" | ||
247 | Controls2.ButtonGroup.group: viewButtonGroup | 191 | Controls2.ButtonGroup.group: viewButtonGroup |
248 | tooltip: qsTr("logview") | 192 | tooltip: qsTr("logview") |
249 | } | 193 | } |
@@ -251,141 +195,95 @@ Controls2.ApplicationWindow { | |||
251 | Kube.IconButton { | 195 | Kube.IconButton { |
252 | id: accountsButton | 196 | id: accountsButton |
253 | iconName: Kube.Icons.menu_inverted | 197 | iconName: Kube.Icons.menu_inverted |
254 | onClicked: kubeViews.setAccountsView() | 198 | onClicked: kubeViews.showView("accounts") |
255 | activeFocusOnTab: true | 199 | activeFocusOnTab: true |
256 | checkable: true | 200 | checkable: true |
201 | checked: kubeViews.currentViewName == "accounts" | ||
257 | Controls2.ButtonGroup.group: viewButtonGroup | 202 | Controls2.ButtonGroup.group: viewButtonGroup |
258 | tooltip: qsTr("settings") | 203 | tooltip: qsTr("settings") |
259 | } | 204 | } |
260 | } | 205 | } |
261 | } | 206 | } |
262 | Controls2.StackView { | 207 | ViewManager { |
263 | id: kubeViews | 208 | id: kubeViews |
264 | |||
265 | anchors { | 209 | anchors { |
266 | top: mainContent.top | 210 | top: mainContent.top |
267 | bottom: mainContent.bottom | 211 | bottom: mainContent.bottom |
268 | } | 212 | } |
269 | Layout.fillWidth: true | 213 | Layout.fillWidth: true |
270 | 214 | ||
271 | Kube.Listener { | 215 | extensionModel: extensionModel |
272 | filter: Kube.Messages.componentDone | ||
273 | onMessageReceived: { | ||
274 | //Return to the mailview if we try to pop everything off | ||
275 | if (kubeViews.depth == 1) { | ||
276 | kubeViews.setMailView() | ||
277 | } else { | ||
278 | kubeViews.pop(Controls2.StackView.Immediate) | ||
279 | } | ||
280 | } | ||
281 | } | ||
282 | |||
283 | onCurrentItemChanged: { | ||
284 | if (currentItem) { | ||
285 | currentItem.forceActiveFocus() | ||
286 | } | ||
287 | } | ||
288 | 216 | ||
289 | Component.onCompleted: { | 217 | Component.onCompleted: { |
290 | //Setup the initial item stack | 218 | dontFocus = true |
291 | if (!currentItem) { | 219 | showView("conversation") |
292 | setMailView() | 220 | if (startupCheck.noAccount) { |
293 | if (startupCheck.noAccount) { | 221 | showView("accounts") |
294 | setAccountsView() | ||
295 | } | ||
296 | } | 222 | } |
223 | dontFocus = false | ||
297 | } | 224 | } |
298 | 225 | ||
299 | ///Replace the current view (we can't go back to the old view, and we destroy the old view) | 226 | Kube.Listener { |
300 | function replaceView(view) { | 227 | filter: Kube.Messages.reply |
301 | if (currentItem != view) { | 228 | onMessageReceived: kubeViews.replaceView("composer", {message: message.mail, loadAsDraft: false}) |
302 | kubeViews.replace(null, view, {}, Controls2.StackView.Immediate) | ||
303 | } | ||
304 | } | ||
305 | |||
306 | ///Push a new view on the stack (the old view remains, and we can go back once done) | ||
307 | function pushView(view, properties) { | ||
308 | kubeViews.push(view, properties, Controls2.StackView.Immediate) | ||
309 | } | ||
310 | |||
311 | //TODO replacing here while a composer is open is destructive | ||
312 | function setPeopleView() { | ||
313 | replaceView(peopleView) | ||
314 | } | 229 | } |
315 | 230 | ||
316 | function setMailView() { | 231 | Kube.Listener { |
317 | replaceView(mailView) | 232 | filter: Kube.Messages.edit |
233 | onMessageReceived: kubeViews.replaceView("composer", {message: message.mail, loadAsDraft: true}) | ||
318 | } | 234 | } |
319 | 235 | ||
320 | function setAccountsView() { | 236 | Kube.Listener { |
321 | pushView(accountsView, {}) | 237 | filter: Kube.Messages.compose |
238 | onMessageReceived: kubeViews.replaceView("composer", {newMessage: true, recipients: message.recipients}) | ||
322 | } | 239 | } |
323 | 240 | ||
324 | function setLogView() { | 241 | Kube.Listener { |
325 | replaceView(logView) | 242 | filter: Kube.Messages.requestAccountsConfiguration |
243 | onMessageReceived: kubeViews.showView("accounts") | ||
326 | } | 244 | } |
327 | 245 | ||
328 | function setLoginView(account) { | 246 | Kube.Listener { |
329 | if (currentItem != loginView) { | 247 | filter: Kube.Messages.componentDone |
330 | pushView(loginView, {accountId: account}) | 248 | onMessageReceived: { |
249 | kubeViews.closeView() | ||
331 | } | 250 | } |
332 | } | 251 | } |
333 | 252 | ||
334 | function openComposer(newMessage, recipients) { | 253 | Kube.Listener { |
335 | pushView(composerView, {newMessage: newMessage, recipients: recipients}) | 254 | filter: Kube.Messages.requestLogin |
336 | } | 255 | onMessageReceived: { |
337 | 256 | loginView.createObject(kubeViews, {accountId: message.accountId}) | |
338 | function openComposerWithMail(mail, openAsDraft) { | ||
339 | pushView(composerView, {message: mail, loadAsDraft: openAsDraft}) | ||
340 | } | ||
341 | |||
342 | |||
343 | //These items are not visible until pushed onto the stack, so we keep them in resources instead of items | ||
344 | resources: [ | ||
345 | //Not components so we maintain state | ||
346 | MailView { | ||
347 | id: mailView | ||
348 | anchors.fill: parent | ||
349 | Controls2.StackView.onActivated: mailButton.checked = true | ||
350 | Controls2.StackView.onDeactivated: mailButton.checked = false | ||
351 | }, | ||
352 | PeopleView { | ||
353 | id: peopleView | ||
354 | anchors.fill: parent | ||
355 | Controls2.StackView.onActivated: peopleButton.checked = true | ||
356 | Controls2.StackView.onDeactivated: peopleButton.checked = false | ||
357 | }, | ||
358 | //Not a component because otherwise we can't log stuff | ||
359 | LogView { | ||
360 | id: logView | ||
361 | anchors.fill: parent | ||
362 | Controls2.StackView.onActivated: logButton.checked = true | ||
363 | Controls2.StackView.onDeactivated: logButton.checked = false | ||
364 | } | ||
365 | ] | ||
366 | //A component so it's always destroyed when we're done | ||
367 | Component { | ||
368 | id: composerView | ||
369 | ComposerView { | ||
370 | anchors.fill: parent | ||
371 | Controls2.StackView.onActivated: composerButton.checked = true | ||
372 | Controls2.StackView.onDeactivated: composerButton.checked = false | ||
373 | } | ||
374 | } | ||
375 | Component { | ||
376 | id: accountsView | ||
377 | AccountsView { | ||
378 | anchors.fill: parent | ||
379 | Controls2.StackView.onActivated: accountsButton.checked = true | ||
380 | Controls2.StackView.onDeactivated: accountsButton.checked = false | ||
381 | } | 257 | } |
382 | } | 258 | } |
259 | |||
383 | Component { | 260 | Component { |
384 | id: loginView | 261 | id: loginView |
385 | LoginView { | 262 | Kube.Popup { |
386 | anchors.fill: parent | 263 | id: popup |
264 | property alias accountId: login.accountId | ||
265 | visible: true | ||
266 | parent: Controls2.ApplicationWindow.overlay | ||
267 | height: app.height | ||
268 | width: app.width - app.sidebarWidth | ||
269 | x: app.sidebarWidth | ||
270 | y: 0 | ||
271 | modal: true | ||
272 | closePolicy: Controls2.Popup.NoAutoClose | ||
273 | Kube.LoginAccount { | ||
274 | id: login | ||
275 | anchors { | ||
276 | fill: parent | ||
277 | bottomMargin: Kube.Units.largeSpacing | ||
278 | } | ||
279 | onDone: { | ||
280 | popup.close() | ||
281 | kubeViews.currentItem.forceActiveFocus() | ||
282 | } | ||
283 | } | ||
387 | } | 284 | } |
388 | } | 285 | } |
286 | |||
389 | } | 287 | } |
390 | } | 288 | } |
391 | //END Main content | 289 | //END Main content |