diff options
Diffstat (limited to 'components/accounts/qml')
-rw-r--r-- | components/accounts/qml/AccountWizard.qml | 93 | ||||
-rw-r--r-- | components/accounts/qml/AccountWizardPage.qml | 155 | ||||
-rw-r--r-- | components/accounts/qml/main.qml | 30 |
3 files changed, 278 insertions, 0 deletions
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | import QtQuick 2.7 | ||
20 | import QtQuick.Layouts 1.1 | ||
21 | import QtQuick.Controls 2.0 as Controls2 | ||
22 | import org.kube.framework 1.0 as Kube | ||
23 | |||
24 | Kube.Popup { | ||
25 | id: root | ||
26 | objectName: "accountWizard" | ||
27 | |||
28 | property bool requireSetup: false | ||
29 | property var availableAccountPlugins: [] | ||
30 | |||
31 | modal: true | ||
32 | closePolicy: requireSetup ? Controls2.Popup.NoAutoClose : Controls2.Popup.CloseOnEscape | Controls2.Popup.CloseOnPressOutside | ||
33 | |||
34 | clip: true | ||
35 | |||
36 | Controls2.StackView { | ||
37 | id: stack | ||
38 | anchors.fill: parent | ||
39 | Component.onCompleted: { | ||
40 | //If we only have one account type we skip the selection | ||
41 | if (root.availableAccountPlugins.length == 1) { | ||
42 | stack.push(wizardPage.createObject(app, {accountType: root.availableAccountPlugins[0]})) | ||
43 | } else { | ||
44 | stack.push(mainView.createObject(app)) | ||
45 | } | ||
46 | } | ||
47 | onCurrentItemChanged: { | ||
48 | if (!!currentItem) { | ||
49 | currentItem.forceActiveFocus() | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | |||
54 | Component { | ||
55 | id: mainView | ||
56 | |||
57 | FocusScope { | ||
58 | Kube.Heading { | ||
59 | id: heading | ||
60 | text: qsTr("Select your new account type") | ||
61 | color: Kube.Colors.highlightColor | ||
62 | } | ||
63 | |||
64 | ColumnLayout { | ||
65 | anchors.centerIn: parent | ||
66 | width: parent.width * 0.4 | ||
67 | |||
68 | spacing: Kube.Units.largeSpacing | ||
69 | |||
70 | Repeater { | ||
71 | model: root.availableAccountPlugins | ||
72 | delegate: Kube.Button { | ||
73 | Layout.fillWidth: true | ||
74 | text: modelData | ||
75 | onClicked: stack.push(wizardPage.createObject(app, {accountType:modelData})) | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | |||
82 | Component { | ||
83 | id: wizardPage | ||
84 | AccountWizardPage { | ||
85 | focus: true | ||
86 | requireSetup: root.requireSetup | ||
87 | onDone: { | ||
88 | root.close() | ||
89 | Kube.Fabric.postMessage(Kube.Messages.componentDone, {}) | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | } | ||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> | ||
3 | * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | import QtQuick 2.7 | ||
21 | import QtQuick.Layouts 1.1 | ||
22 | import QtQuick.Controls 1.4 as Controls | ||
23 | import QtQuick.Controls 2.0 as Controls2 | ||
24 | import org.kube.framework 1.0 as Kube | ||
25 | |||
26 | |||
27 | FocusScope { | ||
28 | id: root | ||
29 | property string accountType | ||
30 | signal done() | ||
31 | |||
32 | property bool isFirstView: root.Controls2.StackView.index == 0 | ||
33 | property bool requireSetup: false | ||
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 | |||
45 | //accountType -> uiPath | ||
46 | Kube.AccountFactory { | ||
47 | id: accountFactory | ||
48 | accountType: root.accountType | ||
49 | } | ||
50 | |||
51 | Controls.ToolButton { | ||
52 | id: backButton | ||
53 | iconName: Kube.Icons.goBack | ||
54 | tooltip: "go back" | ||
55 | visible: !root.isFirstView | ||
56 | onClicked: { | ||
57 | stack.pop() | ||
58 | } | ||
59 | } | ||
60 | |||
61 | Keys.onReturnPressed: save() | ||
62 | |||
63 | //Item to avoid anchors conflict with stack | ||
64 | Item { | ||
65 | anchors{ | ||
66 | top: backButton.bottom | ||
67 | left: parent.left | ||
68 | right: parent.right | ||
69 | bottom: parent.bottom | ||
70 | } | ||
71 | |||
72 | Kube.Heading { | ||
73 | id: heading | ||
74 | text: loader.item.heading | ||
75 | color: Kube.Colors.highlightColor | ||
76 | } | ||
77 | |||
78 | Kube.Label { | ||
79 | id: subHeadline | ||
80 | |||
81 | anchors { | ||
82 | left: heading.left | ||
83 | top: heading.bottom | ||
84 | } | ||
85 | |||
86 | width: parent.width | ||
87 | text: loader.item.subheadline | ||
88 | color: Kube.Colors.disabledTextColor | ||
89 | wrapMode: Text.Wrap | ||
90 | } | ||
91 | |||
92 | Item { | ||
93 | id: accountEdit | ||
94 | anchors { | ||
95 | top:subHeadline.bottom | ||
96 | left: parent.left | ||
97 | right: parent.right | ||
98 | topMargin: Kube.Units.largeSpacing * 2 | ||
99 | } | ||
100 | |||
101 | Loader { | ||
102 | id: loader | ||
103 | anchors.fill: parent | ||
104 | focus: true | ||
105 | source: accountFactory.uiPath | ||
106 | } | ||
107 | } | ||
108 | |||
109 | Item { | ||
110 | id: spacer | ||
111 | Layout.fillHeight: true | ||
112 | anchors { | ||
113 | top:accountEdit.bottom | ||
114 | bottom: footer.top | ||
115 | left: parent.left | ||
116 | right: parent.right | ||
117 | } | ||
118 | } | ||
119 | |||
120 | //This is where we should place the account wizard ui | ||
121 | Item { | ||
122 | id: footer | ||
123 | |||
124 | anchors { | ||
125 | bottom: parent.bottom | ||
126 | left: parent.left | ||
127 | right: parent.right | ||
128 | topMargin: Kube.Units.largeSpacing * 2 | ||
129 | } | ||
130 | |||
131 | Kube.Button { | ||
132 | anchors { | ||
133 | left: parent.left | ||
134 | bottom: parent.bottom | ||
135 | } | ||
136 | visible: !root.requireSetup | ||
137 | |||
138 | text: qsTr("Discard") | ||
139 | onClicked: { | ||
140 | root.done() | ||
141 | } | ||
142 | } | ||
143 | |||
144 | Kube.PositiveButton { | ||
145 | anchors { | ||
146 | right: parent.right | ||
147 | bottom: parent.bottom | ||
148 | } | ||
149 | |||
150 | text: qsTr("Save") | ||
151 | onClicked: save() | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | } | ||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | import QtQuick 2.7 | ||
20 | import QtQuick.Controls 2.0 as Controls2 | ||
21 | |||
22 | Controls2.ApplicationWindow { | ||
23 | id: app | ||
24 | height: 900 | ||
25 | width: 1500 | ||
26 | |||
27 | AccountWizard { | ||
28 | visible: true | ||
29 | } | ||
30 | } | ||