diff options
Diffstat (limited to 'components/package/contents/ui/AccountSwitcher.qml')
-rw-r--r-- | components/package/contents/ui/AccountSwitcher.qml | 102 |
1 files changed, 56 insertions, 46 deletions
diff --git a/components/package/contents/ui/AccountSwitcher.qml b/components/package/contents/ui/AccountSwitcher.qml index 6d1c0aa2..eb5702e0 100644 --- a/components/package/contents/ui/AccountSwitcher.qml +++ b/components/package/contents/ui/AccountSwitcher.qml | |||
@@ -1,20 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> | 2 | * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net> |
3 | 3 | * | |
4 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 6 | * the Free Software Foundation; either version 2 of the License, or |
7 | (at your option) any later version. | 7 | * (at your option) any later version. |
8 | 8 | * | |
9 | This program is distributed in the hope that it will be useful, | 9 | * This program is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU General Public License for more details. | 12 | * GNU General Public License for more details. |
13 | 13 | * | |
14 | You should have received a copy of the GNU General Public License along | 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., | 15 | * with this program; if not, write to the Free Software Foundation, Inc., |
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | import QtQuick 2.4 | 19 | import QtQuick 2.4 |
20 | import QtQuick.Layouts 1.1 | 20 | import QtQuick.Layouts 1.1 |
@@ -29,74 +29,78 @@ import org.kube.framework.domain 1.0 as KubeFramework | |||
29 | import org.kube.framework.accounts 1.0 as KubeAccounts | 29 | import org.kube.framework.accounts 1.0 as KubeAccounts |
30 | import org.kube.components 1.0 as KubeComponents | 30 | import org.kube.components 1.0 as KubeComponents |
31 | 31 | ||
32 | Controls2.Button { | 32 | Controls.ToolButton { |
33 | id: accountSwitcher | 33 | id: accountSwitcher |
34 | 34 | ||
35 | property variant accountId | 35 | property variant accountId |
36 | property variant accountName | ||
37 | |||
38 | width: parent.width | ||
36 | 39 | ||
37 | KubeFramework.FolderController { | 40 | KubeFramework.FolderController { |
38 | id: folderController | 41 | id: folderController |
39 | } | 42 | } |
40 | 43 | ||
41 | text: "Accounts" | 44 | KubeAccounts.AccountsModel { |
45 | id: accountsModel | ||
46 | } | ||
47 | |||
42 | 48 | ||
43 | onClicked: { | 49 | onClicked: { |
44 | popup.open() | 50 | popup.open() |
45 | focus = false | ||
46 | } | 51 | } |
47 | 52 | ||
48 | Controls2.Popup { | 53 | Controls2.Popup { |
49 | id: popup | 54 | id: popup |
50 | 55 | ||
51 | height: 300 | 56 | height: listView.count == 0 ? Kirigami.Units.gridUnit * 4 : Kirigami.Units.gridUnit * 2 + listView.count * Kirigami.Units.gridUnit * 3 |
52 | width: 600 | 57 | width: Kirigami.Units.gridUnit * 20 |
53 | 58 | ||
54 | x: 0 | 59 | y: accountSwitcher.height |
55 | y: - popup.height | ||
56 | 60 | ||
57 | modal: true | 61 | modal: true |
58 | focus: true | 62 | focus: true |
59 | closePolicy: Controls2.Popup.CloseOnEscape | Controls2.Popup.CloseOnPressOutsideParent | 63 | closePolicy: Controls2.Popup.CloseOnEscape | Controls2.Popup.CloseOnPressOutsideParent |
60 | 64 | ||
61 | Item { | 65 | Item { |
62 | id: footer | 66 | id: buttons |
63 | |||
64 | anchors { | 67 | anchors { |
65 | bottom: parent.bottom | 68 | bottom: parent.bottom |
66 | left: parent.left | ||
67 | right: parent.right | ||
68 | margins: Kirigami.Units.largeSpacing | ||
69 | } | 69 | } |
70 | 70 | ||
71 | height: Kirigami.Units.gridUnit + Kirigami.Units.smallSpacing * 1 | 71 | height: Kirigami.Units.gridUnit * 2 |
72 | width: listView.width | 72 | width: parent.width |
73 | 73 | ||
74 | Controls2.Button { | 74 | Controls2.Button { |
75 | 75 | ||
76 | |||
76 | anchors { | 77 | anchors { |
77 | verticalCenter: parent.verticalCenter | 78 | left: parent.left |
78 | right: parent.right | 79 | bottom: parent.bottom |
79 | } | 80 | } |
80 | 81 | ||
81 | text: "Create new Account" | ||
82 | 82 | ||
83 | //iconName: "view-refresh" | ||
84 | text: "Sync" | ||
85 | enabled: folderController.synchronizeAction.enabled | ||
83 | onClicked: { | 86 | onClicked: { |
84 | accountWizard.open() | 87 | folderController.synchronizeAction.execute() |
85 | popup.close() | 88 | popup.close() |
86 | } | 89 | } |
87 | } | 90 | } |
88 | 91 | ||
89 | Controls2.Button { | 92 | Controls2.Button { |
93 | id: newAccountButton | ||
94 | |||
90 | anchors { | 95 | anchors { |
91 | verticalCenter: parent.verticalCenter | 96 | right: parent.right |
92 | left: parent.left | 97 | bottom: parent.bottom |
93 | } | 98 | } |
94 | 99 | ||
95 | //iconName: "view-refresh" | 100 | text: "Create new Account" |
96 | text: "Sync" | 101 | |
97 | enabled: folderController.synchronizeAction.enabled | ||
98 | onClicked: { | 102 | onClicked: { |
99 | folderController.synchronizeAction.execute() | 103 | accountWizard.open() |
100 | popup.close() | 104 | popup.close() |
101 | } | 105 | } |
102 | } | 106 | } |
@@ -107,15 +111,14 @@ Controls2.Button { | |||
107 | 111 | ||
108 | anchors { | 112 | anchors { |
109 | top: parent.top | 113 | top: parent.top |
110 | bottom: footer.top | 114 | bottom: buttons.top |
111 | left: parent.left | 115 | left: parent.left |
112 | right: parent.right | 116 | right: parent.right |
113 | margins: Kirigami.Units.smallSpacing | ||
114 | } | 117 | } |
115 | 118 | ||
116 | clip: true | 119 | clip: true |
117 | 120 | ||
118 | model: KubeAccounts.AccountsModel { } | 121 | model: accountsModel |
119 | 122 | ||
120 | delegate: Kirigami.AbstractListItem { | 123 | delegate: Kirigami.AbstractListItem { |
121 | id: accountDelegate | 124 | id: accountDelegate |
@@ -141,6 +144,13 @@ Controls2.Button { | |||
141 | value: model.accountId | 144 | value: model.accountId |
142 | } | 145 | } |
143 | 146 | ||
147 | QtQml.Binding { | ||
148 | target: accountSwitcher | ||
149 | property: "accountName" | ||
150 | when: listView.currentIndex == index | ||
151 | value: model.name | ||
152 | } | ||
153 | |||
144 | RowLayout { | 154 | RowLayout { |
145 | anchors { | 155 | anchors { |
146 | verticalCenter: parent.verticalCenter | 156 | verticalCenter: parent.verticalCenter |
@@ -155,9 +165,9 @@ Controls2.Button { | |||
155 | accountId: model.accountId | 165 | accountId: model.accountId |
156 | } | 166 | } |
157 | 167 | ||
158 | // Kirigami.Icon { | 168 | // Kirigami.Icon { |
159 | // source: model.icon | 169 | // source: model.icon |
160 | // } | 170 | // } |
161 | 171 | ||
162 | Controls2.Label { | 172 | Controls2.Label { |
163 | text: model.name | 173 | text: model.name |