Warning, /pim/kube/components/accounts/qml/AccountWizard.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
0003  *
0004  * This program is free software; you can redistribute it and/or modify
0005  * it under the terms of the GNU General Public License as published by
0006  * the Free Software Foundation; either version 2 of the License, or
0007  * (at your option) any later version.
0008  *
0009  * This program is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0012  * GNU General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU General Public License along
0015  * with this program; if not, write to the Free Software Foundation, Inc.,
0016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0017  */
0018 
0019 import QtQuick 2.7
0020 import QtQuick.Layouts 1.1
0021 import QtQuick.Controls 2
0022 import org.kube.framework 1.0 as Kube
0023 
0024 Kube.Popup {
0025     id: root
0026     objectName: "accountWizard"
0027 
0028     property bool requireSetup: false
0029     property var availableAccountPlugins: []
0030 
0031     modal: true
0032     closePolicy: requireSetup ? Popup.NoAutoClose : Popup.CloseOnEscape | Popup.CloseOnPressOutside
0033 
0034     clip: true
0035 
0036     StackView {
0037         id: stack
0038         anchors.fill: parent
0039         Component.onCompleted: {
0040             //If we only have one account type we skip the selection
0041             if (root.availableAccountPlugins.length == 1) {
0042                 stack.push(wizardPage.createObject(stack, {accountType: root.availableAccountPlugins[0]}))
0043             } else {
0044                 stack.push(mainView.createObject(stack))
0045             }
0046         }
0047         onCurrentItemChanged: {
0048             if (!!currentItem) {
0049                 currentItem.forceActiveFocus()
0050             }
0051         }
0052     }
0053 
0054     Component {
0055         id: mainView
0056 
0057         FocusScope {
0058             Kube.Heading {
0059                 id: heading
0060                 text: qsTr("Select your new account type")
0061                 color: Kube.Colors.highlightColor
0062             }
0063 
0064             ColumnLayout {
0065                 anchors.centerIn: parent
0066                 width: parent.width * 0.4
0067 
0068                 spacing: Kube.Units.largeSpacing
0069 
0070                 Repeater {
0071                     model: root.availableAccountPlugins
0072                     delegate: Kube.Button {
0073                         objectName: "accountTypeButton" + modelData
0074                         Layout.fillWidth: true
0075                         text: accountFactory.accountName
0076                         onClicked: stack.push(wizardPage.createObject(stack, {accountType:modelData}))
0077                         Kube.AccountFactory {
0078                             id: accountFactory
0079                             accountType: modelData
0080                         }
0081                     }
0082                 }
0083             }
0084         }
0085     }
0086 
0087     Component {
0088         id: wizardPage
0089         AccountWizardPage {
0090             focus: true
0091             requireSetup: root.requireSetup
0092             onDone: {
0093                 root.destroy()
0094                 Kube.Fabric.postMessage(Kube.Messages.componentDone, {})
0095             }
0096         }
0097     }
0098 }