summaryrefslogtreecommitdiffstats
path: root/components/package/contents/ui/AccountSwitcher.qml
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-04-04 19:19:41 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-04-04 19:19:41 +0200
commitd9295fc8f19e4005f8454e7f193f80316550ac0c (patch)
treef27c370d54bced09212b9c4a12b827d1cebb6110 /components/package/contents/ui/AccountSwitcher.qml
parentd002eae7f8b443dd1bad914444c296088c2b6e85 (diff)
downloadkube-d9295fc8f19e4005f8454e7f193f80316550ac0c.tar.gz
kube-d9295fc8f19e4005f8454e7f193f80316550ac0c.zip
One framework plugin to rule them all
Diffstat (limited to 'components/package/contents/ui/AccountSwitcher.qml')
-rw-r--r--components/package/contents/ui/AccountSwitcher.qml215
1 files changed, 0 insertions, 215 deletions
diff --git a/components/package/contents/ui/AccountSwitcher.qml b/components/package/contents/ui/AccountSwitcher.qml
deleted file mode 100644
index 0cd91adc..00000000
--- a/components/package/contents/ui/AccountSwitcher.qml
+++ /dev/null
@@ -1,215 +0,0 @@
1/*
2 * Copyright (C) 2017 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
19import QtQuick 2.4
20import QtQuick.Layouts 1.1
21import QtQuick.Controls 2.0 as Controls2
22import QtQuick.Controls 1.4 as Controls
23
24import QtQml 2.2 as QtQml
25
26import org.kde.kirigami 1.0 as Kirigami
27
28import org.kube.framework.domain 1.0 as KubeFramework
29import org.kube.framework.accounts 1.0 as KubeAccounts
30import org.kube.components 1.0 as KubeComponents
31import org.kube.components.theme 1.0 as KubeTheme
32
33Controls.ToolButton {
34 id: accountSwitcher
35
36 property variant accountId
37 property variant accountName
38
39 width: parent.width
40
41 KubeFramework.FolderController {
42 id: folderController
43 accountId: accountId
44 }
45
46 KubeAccounts.AccountsModel {
47 id: accountsModel
48 }
49
50
51 onClicked: {
52 popup.open()
53 }
54
55 Controls2.Popup {
56 id: popup
57
58 height: listView.count == 0 ? Kirigami.Units.gridUnit * 4 : Kirigami.Units.gridUnit * 2 + listView.count * Kirigami.Units.gridUnit * 3
59 width: Kirigami.Units.gridUnit * 20
60
61 y: accountSwitcher.height
62
63 modal: true
64 focus: true
65 closePolicy: Controls2.Popup.CloseOnEscape | Controls2.Popup.CloseOnPressOutsideParent
66
67 Item {
68 id: buttons
69 anchors {
70 bottom: parent.bottom
71 }
72
73 height: Kirigami.Units.gridUnit * 2
74 width: parent.width
75
76 Controls2.Button {
77 anchors {
78 left: parent.left
79 bottom: parent.bottom
80 }
81
82 //iconName: "view-refresh"
83 text: "Sync"
84 enabled: folderController.synchronizeAction.enabled
85 onClicked: {
86 folderController.synchronizeAction.execute()
87 popup.close()
88 }
89 }
90
91 KubeComponents.PositiveButton {
92 id: newAccountButton
93
94 anchors {
95 right: parent.right
96 bottom: parent.bottom
97 }
98
99 text: "Create new Account"
100
101 onClicked: {
102 accountWizard.open()
103 popup.close()
104 }
105 }
106 }
107
108 ListView {
109 id: listView
110
111 anchors {
112 top: parent.top
113 bottom: buttons.top
114 left: parent.left
115 right: parent.right
116 }
117
118 clip: true
119
120 model: accountsModel
121
122 delegate: Kirigami.AbstractListItem {
123 id: accountDelegate
124
125 height: Kirigami.Units.gridUnit * 2
126
127 enabled: true
128 supportsMouseEvents: true
129
130 checked: listView.currentIndex == index
131 onClicked: {
132 listView.currentIndex = model.index
133 popup.close()
134 }
135 Item {
136 height: Kirigami.Units.gridUnit + Kirigami.Units.smallSpacing * 1
137 width: listView.width
138
139 QtQml.Binding {
140 target: accountSwitcher
141 property: "accountId"
142 when: listView.currentIndex == index
143 value: model.accountId
144 }
145
146 QtQml.Binding {
147 target: accountSwitcher
148 property: "accountName"
149 when: listView.currentIndex == index
150 value: model.name
151 }
152
153 RowLayout {
154 anchors {
155 verticalCenter: parent.verticalCenter
156 left: parent.left
157 margins: Kirigami.Units.smallSpacing
158 }
159
160 Layout.fillHeight: true
161
162 Controls2.Label {
163 text: model.name
164 }
165
166 Controls.ToolButton {
167 id: statusIcon
168 visible: false
169 iconName: ""
170 enabled: false
171 states: [
172 State {
173 name: "busy"; when: model.status == KubeAccountsFramework.AccountsModel.BusyStatus
174 PropertyChanges { target: statusIcon; iconName: KubeTheme.Icons.busy; visible: true }
175 },
176 State {
177 name: "error"; when: model.status == KubeAccountsFramework.AccountsModel.ErrorStatus
178 PropertyChanges { target: statusIcon; iconName: KubeTheme.Icons.error; visible: true }
179 },
180 State {
181 name: "checkmark"; when: model.status == KubeAccountsFramework.AccountsModel.ConnectedStatus
182 PropertyChanges { target: statusIcon; iconName: KubeTheme.Icons.connected; visible: true }
183 }
184 ]
185 }
186 }
187 Controls2.Button {
188
189 anchors {
190 right: parent.right
191 rightMargin: Kirigami.Units.largeSpacing
192 verticalCenter: parent.verticalCenter
193 }
194
195 opacity: hovered ? 1 : 0.7
196 visible: accountDelegate.containsMouse
197 text: "edit"
198
199 onClicked: {
200 editAccountComponent.createObject(app, {accountId:model.accountId})
201 popup.close()
202 }
203
204 Component {
205 id: editAccountComponent
206 KubeComponents.EditAccountDialog {
207 anchors.fill: parent
208 }
209 }
210 }
211 }
212 }
213 }
214 }
215}