diff options
Diffstat (limited to 'framework/qml/InlineAccountSwitcher.qml')
-rw-r--r-- | framework/qml/InlineAccountSwitcher.qml | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/framework/qml/InlineAccountSwitcher.qml b/framework/qml/InlineAccountSwitcher.qml index d87dac9a..4131b971 100644 --- a/framework/qml/InlineAccountSwitcher.qml +++ b/framework/qml/InlineAccountSwitcher.qml | |||
@@ -20,23 +20,15 @@ import QtQuick 2.4 | |||
20 | import QtQuick.Layouts 1.1 | 20 | import QtQuick.Layouts 1.1 |
21 | import org.kube.framework 1.0 as Kube | 21 | import org.kube.framework 1.0 as Kube |
22 | 22 | ||
23 | Rectangle { | 23 | FocusScope { |
24 | id: root | 24 | id: root |
25 | |||
26 | property string currentAccount: null | 25 | property string currentAccount: null |
27 | 26 | ||
28 | Kube.AccountsModel { | ||
29 | id: accountsModel | ||
30 | } | ||
31 | |||
32 | color: Kube.Colors.textColor | ||
33 | clip: true | ||
34 | |||
35 | ColumnLayout { | 27 | ColumnLayout { |
36 | anchors.fill: parent | 28 | anchors.fill: parent |
37 | 29 | ||
38 | Repeater { | 30 | Repeater { |
39 | model: accountsModel | 31 | model: Kube.AccountsModel {} |
40 | onItemAdded: { | 32 | onItemAdded: { |
41 | //Autoselect the first account to appear | 33 | //Autoselect the first account to appear |
42 | if (!currentAccount) { | 34 | if (!currentAccount) { |
@@ -45,12 +37,13 @@ Rectangle { | |||
45 | } | 37 | } |
46 | 38 | ||
47 | delegate: Item { | 39 | delegate: Item { |
48 | id: accountDelagte | 40 | id: accountDelegate |
49 | property variant currentData: model | 41 | property variant currentData: model |
42 | property bool isCurrent: (model.accountId == root.currentAccount) | ||
50 | 43 | ||
51 | height: Kube.Units.gridUnit | 44 | height: Kube.Units.gridUnit |
52 | width: root.width | 45 | width: root.width |
53 | Layout.fillHeight: model.accountId == root.currentAccount | 46 | Layout.fillHeight: isCurrent |
54 | 47 | ||
55 | Rectangle { | 48 | Rectangle { |
56 | id: accountLabel | 49 | id: accountLabel |
@@ -59,6 +52,10 @@ Rectangle { | |||
59 | width: parent.width | 52 | width: parent.width |
60 | 53 | ||
61 | color: Kube.Colors.textColor | 54 | color: Kube.Colors.textColor |
55 | activeFocusOnTab: !isCurrent | ||
56 | Keys.onReturnPressed: { | ||
57 | root.currentAccount = model.accountId | ||
58 | } | ||
62 | 59 | ||
63 | MouseArea { | 60 | MouseArea { |
64 | anchors.fill: parent | 61 | anchors.fill: parent |
@@ -111,10 +108,10 @@ Rectangle { | |||
111 | right: parent.right | 108 | right: parent.right |
112 | bottom: parent.bottom | 109 | bottom: parent.bottom |
113 | } | 110 | } |
111 | activeFocusOnTab: true | ||
114 | 112 | ||
115 | accountId: model.accountId | 113 | accountId: currentData.accountId |
116 | visible: model.accountId == root.currentAccount | 114 | visible: isCurrent |
117 | |||
118 | } | 115 | } |
119 | } | 116 | } |
120 | } | 117 | } |