summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-09-22 11:58:47 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-09-22 11:58:47 +0200
commitf25a8fb49abf8a9b7ba5d6f8fbd4c05bd647c1c0 (patch)
treec1066b0c9bd9d4a0e1be952dcad7b65af39baa79
parent2a60a0723257cfd6855233b9af27dc9735915435 (diff)
downloadkube-f25a8fb49abf8a9b7ba5d6f8fbd4c05bd647c1c0.tar.gz
kube-f25a8fb49abf8a9b7ba5d6f8fbd4c05bd647c1c0.zip
Fixed showing a loginview after the account setup
The view managment is starting to become a mess. I guess we'll need something like a state machine in the long run managing the view transitions.
-rw-r--r--components/accounts/contents/ui/AccountWizardPage.qml22
-rw-r--r--components/kube/contents/ui/Kube.qml24
-rw-r--r--framework/src/domain/settings/accountsettings.cpp12
-rw-r--r--framework/src/startupcheck.cpp7
-rw-r--r--framework/src/startupcheck.h7
5 files changed, 41 insertions, 31 deletions
diff --git a/components/accounts/contents/ui/AccountWizardPage.qml b/components/accounts/contents/ui/AccountWizardPage.qml
index 74decf1f..18001419 100644
--- a/components/accounts/contents/ui/AccountWizardPage.qml
+++ b/components/accounts/contents/ui/AccountWizardPage.qml
@@ -32,6 +32,16 @@ FocusScope {
32 property bool isFirstView: root.Controls2.StackView.index == 0 32 property bool isFirstView: root.Controls2.StackView.index == 0
33 property bool requireSetup: false 33 property bool requireSetup: false
34 34
35 function save() {
36 if (loader.item.valid) {
37 loader.item.save()
38 Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": loader.item.accountIdentifier});
39 root.done()
40 } else {
41 console.warn("Invalid settings.");
42 }
43 }
44
35 Kube.AccountFactory { 45 Kube.AccountFactory {
36 id: accountFactory 46 id: accountFactory
37 accountType: root.accountType 47 accountType: root.accountType
@@ -47,6 +57,8 @@ FocusScope {
47 } 57 }
48 } 58 }
49 59
60 Keys.onReturnPressed: save()
61
50 //Item to avoid anchors conflict with stack 62 //Item to avoid anchors conflict with stack
51 Item { 63 Item {
52 anchors{ 64 anchors{
@@ -135,15 +147,7 @@ FocusScope {
135 } 147 }
136 148
137 text: qsTr("Save") 149 text: qsTr("Save")
138 onClicked: { 150 onClicked: save()
139 if (loader.item.valid) {
140 loader.item.save()
141 Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": loader.item.accountIdentifier});
142 root.done()
143 } else {
144 console.warn("Invalid settings.");
145 }
146 }
147 } 151 }
148 } 152 }
149 } 153 }
diff --git a/components/kube/contents/ui/Kube.qml b/components/kube/contents/ui/Kube.qml
index 7625c52c..0a92b783 100644
--- a/components/kube/contents/ui/Kube.qml
+++ b/components/kube/contents/ui/Kube.qml
@@ -47,11 +47,7 @@ Controls2.ApplicationWindow {
47 property variant currentAccount 47 property variant currentAccount
48 onCurrentAccountChanged: { 48 onCurrentAccountChanged: {
49 if (!!currentAccount) { 49 if (!!currentAccount) {
50 if (kubeViews.currentItem && !Kube.Keyring.isUnlocked(currentAccount)) { 50 Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": currentAccount})
51 kubeViews.setLoginView()
52 } else {
53 Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": currentAccount})
54 }
55 } 51 }
56 } 52 }
57 53
@@ -66,7 +62,7 @@ Controls2.ApplicationWindow {
66 } 62 }
67 63
68 Kube.StartupCheck { 64 Kube.StartupCheck {
69 onNoAccount: kubeViews.setAccountsView() 65 id: startupCheck
70 } 66 }
71 67
72 //Listener 68 //Listener
@@ -252,7 +248,12 @@ Controls2.ApplicationWindow {
252 248
253 Kube.Listener { 249 Kube.Listener {
254 filter: Kube.Messages.componentDone 250 filter: Kube.Messages.componentDone
255 onMessageReceived: kubeViews.pop(Controls2.StackView.Immediate) 251 onMessageReceived: {
252 kubeViews.pop(Controls2.StackView.Immediate)
253 if (!!app.currentAccount && !Kube.Keyring.isUnlocked(app.currentAccount)) {
254 kubeViews.setLoginView()
255 }
256 }
256 } 257 }
257 258
258 ///Replace the current view (we can't go back to the old view, and we destroy the old view) 259 ///Replace the current view (we can't go back to the old view, and we destroy the old view)
@@ -305,10 +306,15 @@ Controls2.ApplicationWindow {
305 } 306 }
306 307
307 Component.onCompleted: { 308 Component.onCompleted: {
309 //Setup the initial item stack
308 if (!currentItem) { 310 if (!currentItem) {
309 setMailView(); 311 setMailView();
310 if (!!app.currentAccount && !Kube.Keyring.isUnlocked(app.currentAccount)) { 312 if (startupCheck.noAccount) {
311 setLoginView() 313 setAccountsView()
314 } else {
315 if (!!app.currentAccount && !Kube.Keyring.isUnlocked(app.currentAccount)) {
316 setLoginView()
317 }
312 } 318 }
313 } 319 }
314 } 320 }
diff --git a/framework/src/domain/settings/accountsettings.cpp b/framework/src/domain/settings/accountsettings.cpp
index c174adfe..acf85522 100644
--- a/framework/src/domain/settings/accountsettings.cpp
+++ b/framework/src/domain/settings/accountsettings.cpp
@@ -292,7 +292,9 @@ void AccountSettings::saveImapResource()
292 {"server", mImapServer}, 292 {"server", mImapServer},
293 {"username", mImapUsername} 293 {"username", mImapUsername}
294 }); 294 });
295 Kube::AccountKeyring{mAccountIdentifier}.storePassword(mImapIdentifier, mImapPassword); 295 if (!mImapPassword.isEmpty()) {
296 Kube::AccountKeyring{mAccountIdentifier}.storePassword(mImapIdentifier, mImapPassword);
297 }
296} 298}
297 299
298void AccountSettings::saveCardDavResource() 300void AccountSettings::saveCardDavResource()
@@ -301,7 +303,9 @@ void AccountSettings::saveCardDavResource()
301 {"server", mCardDavServer}, 303 {"server", mCardDavServer},
302 {"username", mCardDavUsername} 304 {"username", mCardDavUsername}
303 }); 305 });
304 Kube::AccountKeyring{mAccountIdentifier}.storePassword(mCardDavIdentifier, mCardDavPassword); 306 if (!mCardDavPassword.isEmpty()) {
307 Kube::AccountKeyring{mAccountIdentifier}.storePassword(mCardDavIdentifier, mCardDavPassword);
308 }
305} 309}
306 310
307void AccountSettings::saveMaildirResource() 311void AccountSettings::saveMaildirResource()
@@ -317,7 +321,9 @@ void AccountSettings::saveMailtransportResource()
317 {"server", mSmtpServer}, 321 {"server", mSmtpServer},
318 {"username", mSmtpUsername} 322 {"username", mSmtpUsername}
319 }); 323 });
320 Kube::AccountKeyring{mAccountIdentifier}.storePassword(mMailtransportIdentifier, mSmtpPassword); 324 if (!mSmtpPassword.isEmpty()) {
325 Kube::AccountKeyring{mAccountIdentifier}.storePassword(mMailtransportIdentifier, mSmtpPassword);
326 }
321} 327}
322 328
323void AccountSettings::saveIdentity() 329void AccountSettings::saveIdentity()
diff --git a/framework/src/startupcheck.cpp b/framework/src/startupcheck.cpp
index 850be7bb..fa750173 100644
--- a/framework/src/startupcheck.cpp
+++ b/framework/src/startupcheck.cpp
@@ -23,13 +23,10 @@
23StartupCheck::StartupCheck(QObject *parent) 23StartupCheck::StartupCheck(QObject *parent)
24 : QObject(parent) 24 : QObject(parent)
25{ 25{
26 QMetaObject::invokeMethod(this, "check", Qt::QueuedConnection);
27} 26}
28 27
29void StartupCheck::check() 28bool StartupCheck::noAccount() const
30{ 29{
31 auto accounts = Sink::Store::read<Sink::ApplicationDomain::SinkAccount>({}); 30 auto accounts = Sink::Store::read<Sink::ApplicationDomain::SinkAccount>({});
32 if (accounts.isEmpty()) { 31 return accounts.isEmpty();
33 emit noAccount();
34 }
35} 32}
diff --git a/framework/src/startupcheck.h b/framework/src/startupcheck.h
index dd79ee04..b8b2e3a0 100644
--- a/framework/src/startupcheck.h
+++ b/framework/src/startupcheck.h
@@ -21,12 +21,9 @@
21 21
22class StartupCheck : public QObject { 22class StartupCheck : public QObject {
23 Q_OBJECT 23 Q_OBJECT
24 Q_PROPERTY(bool noAccount READ noAccount CONSTANT);
24public: 25public:
25 StartupCheck(QObject *parent = nullptr); 26 StartupCheck(QObject *parent = nullptr);
26 27
27signals: 28 bool noAccount() const;
28 void noAccount();
29
30private Q_SLOTS:
31 void check();
32}; 29};