From b77216db4b6d941afb03325e0843509621a283da Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 18 Dec 2017 21:00:05 +0100 Subject: We no longer need the kpackage structure --- components/accounts/qml/AccountWizard.qml | 93 ++++++++++++++++ components/accounts/qml/AccountWizardPage.qml | 155 ++++++++++++++++++++++++++ components/accounts/qml/main.qml | 30 +++++ 3 files changed, 278 insertions(+) create mode 100644 components/accounts/qml/AccountWizard.qml create mode 100644 components/accounts/qml/AccountWizardPage.qml create mode 100644 components/accounts/qml/main.qml (limited to 'components/accounts/qml') diff --git a/components/accounts/qml/AccountWizard.qml b/components/accounts/qml/AccountWizard.qml new file mode 100644 index 00000000..4a11ca05 --- /dev/null +++ b/components/accounts/qml/AccountWizard.qml @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2016 Michael Bohlender, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.7 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 as Controls2 +import org.kube.framework 1.0 as Kube + +Kube.Popup { + id: root + objectName: "accountWizard" + + property bool requireSetup: false + property var availableAccountPlugins: [] + + modal: true + closePolicy: requireSetup ? Controls2.Popup.NoAutoClose : Controls2.Popup.CloseOnEscape | Controls2.Popup.CloseOnPressOutside + + clip: true + + Controls2.StackView { + id: stack + anchors.fill: parent + Component.onCompleted: { + //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)) + } + } + onCurrentItemChanged: { + if (!!currentItem) { + currentItem.forceActiveFocus() + } + } + } + + Component { + id: mainView + + FocusScope { + Kube.Heading { + id: heading + text: qsTr("Select your new account type") + color: Kube.Colors.highlightColor + } + + ColumnLayout { + anchors.centerIn: parent + width: parent.width * 0.4 + + spacing: Kube.Units.largeSpacing + + Repeater { + model: root.availableAccountPlugins + delegate: Kube.Button { + Layout.fillWidth: true + text: modelData + onClicked: stack.push(wizardPage.createObject(app, {accountType:modelData})) + } + } + } + } + } + + Component { + id: wizardPage + AccountWizardPage { + focus: true + requireSetup: root.requireSetup + onDone: { + root.close() + Kube.Fabric.postMessage(Kube.Messages.componentDone, {}) + } + } + } +} diff --git a/components/accounts/qml/AccountWizardPage.qml b/components/accounts/qml/AccountWizardPage.qml new file mode 100644 index 00000000..9f11ac36 --- /dev/null +++ b/components/accounts/qml/AccountWizardPage.qml @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2016 Michael Bohlender, + * Copyright (C) 2017 Christian Mollekopf, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.7 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.4 as Controls +import QtQuick.Controls 2.0 as Controls2 +import org.kube.framework 1.0 as Kube + + +FocusScope { + id: root + property string accountType + signal done() + + 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."); + } + } + + //accountType -> uiPath + Kube.AccountFactory { + id: accountFactory + accountType: root.accountType + } + + Controls.ToolButton { + id: backButton + iconName: Kube.Icons.goBack + tooltip: "go back" + visible: !root.isFirstView + onClicked: { + stack.pop() + } + } + + Keys.onReturnPressed: save() + + //Item to avoid anchors conflict with stack + Item { + anchors{ + top: backButton.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } + + Kube.Heading { + id: heading + text: loader.item.heading + color: Kube.Colors.highlightColor + } + + Kube.Label { + id: subHeadline + + anchors { + left: heading.left + top: heading.bottom + } + + width: parent.width + text: loader.item.subheadline + color: Kube.Colors.disabledTextColor + wrapMode: Text.Wrap + } + + Item { + id: accountEdit + anchors { + top:subHeadline.bottom + left: parent.left + right: parent.right + topMargin: Kube.Units.largeSpacing * 2 + } + + Loader { + id: loader + anchors.fill: parent + focus: true + source: accountFactory.uiPath + } + } + + Item { + id: spacer + Layout.fillHeight: true + anchors { + top:accountEdit.bottom + bottom: footer.top + left: parent.left + right: parent.right + } + } + + //This is where we should place the account wizard ui + Item { + id: footer + + anchors { + bottom: parent.bottom + left: parent.left + right: parent.right + topMargin: Kube.Units.largeSpacing * 2 + } + + Kube.Button { + anchors { + left: parent.left + bottom: parent.bottom + } + visible: !root.requireSetup + + text: qsTr("Discard") + onClicked: { + root.done() + } + } + + Kube.PositiveButton { + anchors { + right: parent.right + bottom: parent.bottom + } + + text: qsTr("Save") + onClicked: save() + } + } + } +} diff --git a/components/accounts/qml/main.qml b/components/accounts/qml/main.qml new file mode 100644 index 00000000..e15bca8f --- /dev/null +++ b/components/accounts/qml/main.qml @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2016 Michael Bohlender, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.7 +import QtQuick.Controls 2.0 as Controls2 + +Controls2.ApplicationWindow { + id: app + height: 900 + width: 1500 + + AccountWizard { + visible: true + } +} -- cgit v1.2.3