diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-12-21 11:25:09 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-12-21 13:49:37 +0100 |
commit | 819c6f545087f6d636a3db5093a285401756036d (patch) | |
tree | ded6597e5dbd27f89664327247b6280988d67029 /components | |
parent | 2adc4f79f0b63ec02914ae8972e4ab99bfd9779a (diff) | |
download | kube-819c6f545087f6d636a3db5093a285401756036d.tar.gz kube-819c6f545087f6d636a3db5093a285401756036d.zip |
A separate accounts module that listens for the account selection, and
requests a login if necessary.
Diffstat (limited to 'components')
-rw-r--r-- | components/kube/qml/Accounts.qml | 42 | ||||
-rw-r--r-- | components/kube/qml/Kube.qml | 38 | ||||
-rw-r--r-- | components/kube/qml/LogView.qml | 2 |
3 files changed, 51 insertions, 31 deletions
diff --git a/components/kube/qml/Accounts.qml b/components/kube/qml/Accounts.qml new file mode 100644 index 00000000..40a2c70b --- /dev/null +++ b/components/kube/qml/Accounts.qml | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | import QtQuick 2.7 | ||
20 | import org.kube.framework 1.0 as Kube | ||
21 | |||
22 | Item { | ||
23 | |||
24 | Kube.AccountFactory { | ||
25 | id: accountFactory | ||
26 | } | ||
27 | |||
28 | Kube.Listener { | ||
29 | filter: Kube.Messages.accountSelection | ||
30 | onMessageReceived: { | ||
31 | accountFactory.accountId = message.accountId | ||
32 | if (!Kube.Keyring.isUnlocked(message.accountId)) { | ||
33 | if (accountFactory.requiresKeyring) { | ||
34 | Kube.Fabric.postMessage(Kube.Messages.requestLogin, {accountId: message.accountId}) | ||
35 | } else { | ||
36 | Kube.Keyring.unlock(message.accountId) | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | } | ||
41 | |||
42 | } | ||
diff --git a/components/kube/qml/Kube.qml b/components/kube/qml/Kube.qml index 79b18a2f..e7c4f70e 100644 --- a/components/kube/qml/Kube.qml +++ b/components/kube/qml/Kube.qml | |||
@@ -1,5 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net> | 2 | * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net> |
3 | * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com> | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
@@ -50,12 +51,6 @@ Controls2.ApplicationWindow { | |||
50 | } | 51 | } |
51 | } | 52 | } |
52 | 53 | ||
53 | //accountId -> requiresKeyring | ||
54 | Kube.AccountFactory { | ||
55 | id: accountFactory | ||
56 | accountId: !!app.currentAccount ? app.currentAccount : "" | ||
57 | } | ||
58 | |||
59 | //Interval sync | 54 | //Interval sync |
60 | Timer { | 55 | Timer { |
61 | id: intervalSync | 56 | id: intervalSync |
@@ -70,10 +65,13 @@ Controls2.ApplicationWindow { | |||
70 | id: startupCheck | 65 | id: startupCheck |
71 | } | 66 | } |
72 | 67 | ||
68 | Accounts { | ||
69 | } | ||
70 | |||
73 | //Listener | 71 | //Listener |
74 | Kube.Listener { | 72 | Kube.Listener { |
75 | filter: Kube.Messages.accountSelection | 73 | filter: Kube.Messages.accountSelection |
76 | onMessageReceived: app.currentAccount = message.account | 74 | onMessageReceived: app.currentAccount = message.accountId |
77 | } | 75 | } |
78 | 76 | ||
79 | Kube.Listener { | 77 | Kube.Listener { |
@@ -109,7 +107,7 @@ Controls2.ApplicationWindow { | |||
109 | 107 | ||
110 | Kube.Listener { | 108 | Kube.Listener { |
111 | filter: Kube.Messages.requestLogin | 109 | filter: Kube.Messages.requestLogin |
112 | onMessageReceived: kubeViews.setLoginView() | 110 | onMessageReceived: kubeViews.setLoginView(message.accountId) |
113 | } | 111 | } |
114 | 112 | ||
115 | Kube.Listener { | 113 | Kube.Listener { |
@@ -127,12 +125,6 @@ Controls2.ApplicationWindow { | |||
127 | sequence: StandardKey.Find | 125 | sequence: StandardKey.Find |
128 | } | 126 | } |
129 | Shortcut { | 127 | Shortcut { |
130 | onActivated: { | ||
131 | Kube.Fabric.postMessage(Kube.Messages.unlockKeyring, {accountId: app.currentAccount}) | ||
132 | } | ||
133 | sequence: "Ctrl+l" | ||
134 | } | ||
135 | Shortcut { | ||
136 | id: syncShortcut | 128 | id: syncShortcut |
137 | sequence: StandardKey.Refresh | 129 | sequence: StandardKey.Refresh |
138 | onActivated: !!app.currentFolder ? Kube.Fabric.postMessage(Kube.Messages.synchronize, {"folder": app.currentFolder}) : Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": app.currentAccount}) | 130 | onActivated: !!app.currentFolder ? Kube.Fabric.postMessage(Kube.Messages.synchronize, {"folder": app.currentFolder}) : Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": app.currentAccount}) |
@@ -262,17 +254,6 @@ Controls2.ApplicationWindow { | |||
262 | } | 254 | } |
263 | Layout.fillWidth: true | 255 | Layout.fillWidth: true |
264 | 256 | ||
265 | function loginIfNecessary() | ||
266 | { | ||
267 | if (!!app.currentAccount && !Kube.Keyring.isUnlocked(app.currentAccount)) { | ||
268 | if (accountFactory.requiresKeyring) { | ||
269 | setLoginView() | ||
270 | } else { | ||
271 | Kube.Keyring.unlock(app.currentAccount) | ||
272 | } | ||
273 | } | ||
274 | } | ||
275 | |||
276 | Kube.Listener { | 257 | Kube.Listener { |
277 | filter: Kube.Messages.componentDone | 258 | filter: Kube.Messages.componentDone |
278 | onMessageReceived: { | 259 | onMessageReceived: { |
@@ -282,7 +263,6 @@ Controls2.ApplicationWindow { | |||
282 | } else { | 263 | } else { |
283 | kubeViews.pop(Controls2.StackView.Immediate) | 264 | kubeViews.pop(Controls2.StackView.Immediate) |
284 | } | 265 | } |
285 | kubeViews.loginIfNecessary() | ||
286 | } | 266 | } |
287 | } | 267 | } |
288 | 268 | ||
@@ -298,8 +278,6 @@ Controls2.ApplicationWindow { | |||
298 | setMailView() | 278 | setMailView() |
299 | if (startupCheck.noAccount) { | 279 | if (startupCheck.noAccount) { |
300 | setAccountsView() | 280 | setAccountsView() |
301 | } else { | ||
302 | loginIfNecessary() | ||
303 | } | 281 | } |
304 | } | 282 | } |
305 | } | 283 | } |
@@ -333,9 +311,9 @@ Controls2.ApplicationWindow { | |||
333 | replaceView(logView) | 311 | replaceView(logView) |
334 | } | 312 | } |
335 | 313 | ||
336 | function setLoginView() { | 314 | function setLoginView(account) { |
337 | if (currentItem != loginView) { | 315 | if (currentItem != loginView) { |
338 | pushView(loginView, {accountId: currentAccount}) | 316 | pushView(loginView, {accountId: account}) |
339 | } | 317 | } |
340 | } | 318 | } |
341 | 319 | ||
diff --git a/components/kube/qml/LogView.qml b/components/kube/qml/LogView.qml index 3b0aa2d5..4ae1a67c 100644 --- a/components/kube/qml/LogView.qml +++ b/components/kube/qml/LogView.qml | |||
@@ -285,7 +285,7 @@ Controls.SplitView { | |||
285 | text: qsTr("Change Password") | 285 | text: qsTr("Change Password") |
286 | onClicked: { | 286 | onClicked: { |
287 | Kube.Fabric.postMessage(Kube.Messages.componentDone, {}) | 287 | Kube.Fabric.postMessage(Kube.Messages.componentDone, {}) |
288 | Kube.Fabric.postMessage(Kube.Messages.requestLogin, {}) | 288 | Kube.Fabric.postMessage(Kube.Messages.requestLogin, {accountId: accountId}) |
289 | } | 289 | } |
290 | } | 290 | } |
291 | } | 291 | } |