From 3f1187e1ecd3dfa04f8bdf8022b03e7d739d9b80 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 8 Sep 2017 12:54:31 +0200 Subject: Generalize the single account concept. * The wizard get's configured with a list of available accounts. * If only a single account type is available we skip the selection. * For the first account, account setup can not be aborted. * In single account mode the account can not be removed. --- components/accounts/contents/ui/AccountWizard.qml | 21 ++++++++++----------- .../accounts/contents/ui/AccountWizardPage.qml | 4 ++-- components/kube/contents/ui/AccountsView.qml | 14 ++++++++++---- 3 files changed, 22 insertions(+), 17 deletions(-) (limited to 'components') diff --git a/components/accounts/contents/ui/AccountWizard.qml b/components/accounts/contents/ui/AccountWizard.qml index 996eeb6c..b4720174 100644 --- a/components/accounts/contents/ui/AccountWizard.qml +++ b/components/accounts/contents/ui/AccountWizard.qml @@ -25,24 +25,24 @@ Kube.Popup { id: root - property bool singleAccountMode: false - property string forceAccountType: "" + property bool requireSetup: false + property var availableAccountPlugins: [] modal: true focus: true - closePolicy: singleAccountMode ? Controls2.Popup.NoAutoClose : Controls2.Popup.CloseOnEscape | Controls2.Popup.CloseOnPressOutside + closePolicy: requireSetup ? Controls2.Popup.NoAutoClose : Controls2.Popup.CloseOnEscape | Controls2.Popup.CloseOnPressOutside clip: true Controls2.StackView { id: stack - anchors.fill: parent - - initialItem: root.singleAccountMode ? null : mainView Component.onCompleted: { - if (root.singleAccountMode) { - stack.push(wizardPage.createObject(app, {accountType: root.forceAccountType})) + //If we only have one account type we skip the selection + if (root.availableAccountPlugins.length == 1) { + stack.push(wizardPage.createObject(app, {accountType: root.availableAccountPlugins[0]})) + } else { + stack.push(mainView.createObject(app)) } } } @@ -64,8 +64,7 @@ Kube.Popup { spacing: Kube.Units.largeSpacing Repeater { - //TODO replace by model of available accounts - model: ["kolabnow", "imap", "maildir", "gmail"] + model: root.availableAccountPlugins delegate: Kube.Button { Layout.fillWidth: true text: modelData @@ -81,7 +80,7 @@ Kube.Popup { Component { id: wizardPage AccountWizardPage { - singleAccountMode: root.singleAccountMode + requireSetup: root.requireSetup onDone: { root.close() Kube.Fabric.postMessage(Kube.Messages.componentDone, {}) diff --git a/components/accounts/contents/ui/AccountWizardPage.qml b/components/accounts/contents/ui/AccountWizardPage.qml index b0b33049..f7885ce4 100644 --- a/components/accounts/contents/ui/AccountWizardPage.qml +++ b/components/accounts/contents/ui/AccountWizardPage.qml @@ -30,7 +30,7 @@ Item { signal done() property bool isFirstView: root.Controls2.StackView.index == 0 - property bool singleAccountMode: false + property bool requireSetup: false Kube.AccountFactory { id: accountFactory @@ -119,7 +119,7 @@ Item { left: parent.left bottom: parent.bottom } - visible: !root.singleAccountMode + visible: !root.requireSetup text: qsTr("Discard") onClicked: { diff --git a/components/kube/contents/ui/AccountsView.qml b/components/kube/contents/ui/AccountsView.qml index adcc2b68..5b19d3fd 100644 --- a/components/kube/contents/ui/AccountsView.qml +++ b/components/kube/contents/ui/AccountsView.qml @@ -26,7 +26,10 @@ import org.kube.components.accounts 1.0 as KubeAccounts Rectangle { id: root color: Kube.Colors.backgroundColor - property bool singleAccountMode: true + //Defines whether more than one account is supported. + property bool singleAccountMode: false + //Defines available account types. + property var availableAccountPlugins: ["kolabnow", "imap", "maildir", "gmail"] Controls.SplitView { height: parent.height @@ -102,11 +105,15 @@ Rectangle { bottomMargin: Kube.Units.largeSpacing } - singleAccountMode: root.singleAccountMode + canRemove: !root.singleAccountMode Component.onCompleted: { + //We don't have any accounts setup if accountId is empty, so we trigger the accountWizard //FIXME: this assumes we load accounts synchronously, which we do right now. if (accountId == "") { + //Require the setup to be completed since it's the first account + accountWizard.requireSetup = true + //Launch account wizard accountWizard.open() } } @@ -118,8 +125,7 @@ Rectangle { KubeAccounts.AccountWizard { id: accountWizard - singleAccountMode: root.singleAccountMode - forceAccountType: "kolabnow" + availableAccountPlugins: root.availableAccountPlugins height: app.height * 0.85 width: app.width * 0.85 -- cgit v1.2.3