From f25a8fb49abf8a9b7ba5d6f8fbd4c05bd647c1c0 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 22 Sep 2017 11:58:47 +0200 Subject: 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. --- .../accounts/contents/ui/AccountWizardPage.qml | 22 ++++++++++++-------- components/kube/contents/ui/Kube.qml | 24 ++++++++++++++-------- 2 files changed, 28 insertions(+), 18 deletions(-) (limited to 'components') 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 { property bool isFirstView: root.Controls2.StackView.index == 0 property bool requireSetup: false + function save() { + if (loader.item.valid) { + loader.item.save() + Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": loader.item.accountIdentifier}); + root.done() + } else { + console.warn("Invalid settings."); + } + } + Kube.AccountFactory { id: accountFactory accountType: root.accountType @@ -47,6 +57,8 @@ FocusScope { } } + Keys.onReturnPressed: save() + //Item to avoid anchors conflict with stack Item { anchors{ @@ -135,15 +147,7 @@ FocusScope { } text: qsTr("Save") - onClicked: { - if (loader.item.valid) { - loader.item.save() - Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": loader.item.accountIdentifier}); - root.done() - } else { - console.warn("Invalid settings."); - } - } + onClicked: save() } } } 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 { property variant currentAccount onCurrentAccountChanged: { if (!!currentAccount) { - if (kubeViews.currentItem && !Kube.Keyring.isUnlocked(currentAccount)) { - kubeViews.setLoginView() - } else { - Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": currentAccount}) - } + Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": currentAccount}) } } @@ -66,7 +62,7 @@ Controls2.ApplicationWindow { } Kube.StartupCheck { - onNoAccount: kubeViews.setAccountsView() + id: startupCheck } //Listener @@ -252,7 +248,12 @@ Controls2.ApplicationWindow { Kube.Listener { filter: Kube.Messages.componentDone - onMessageReceived: kubeViews.pop(Controls2.StackView.Immediate) + onMessageReceived: { + kubeViews.pop(Controls2.StackView.Immediate) + if (!!app.currentAccount && !Kube.Keyring.isUnlocked(app.currentAccount)) { + kubeViews.setLoginView() + } + } } ///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 { } Component.onCompleted: { + //Setup the initial item stack if (!currentItem) { setMailView(); - if (!!app.currentAccount && !Kube.Keyring.isUnlocked(app.currentAccount)) { - setLoginView() + if (startupCheck.noAccount) { + setAccountsView() + } else { + if (!!app.currentAccount && !Kube.Keyring.isUnlocked(app.currentAccount)) { + setLoginView() + } } } } -- cgit v1.2.3