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