@@ -24,22 +24,24 @@ Item {
25 objectName: "sessionsList"
25 objectName: "sessionsList"
27− property string initiallySelectedSession
28 signal sessionSelected(string sessionKey)
27 signal sessionSelected(string sessionKey)
29 signal showLoginList()
28 signal showLoginList()
31− onInitiallySelectedSessionChanged: {
30+ // Sets the position of the background highlight
31+ function updateHighlight(session) {
32− sessionsList.currentIndex = getSelectedIndex();
32+ sessionsList.currentIndex = getIndexOfSession(session);
33− sessionsList.positionViewAtIndex(sessionsList.currentIndex, ListView.Contain);
33+ sessionsList.currentItem.initialSession = session;
36− function getSelectedIndex() {
36+ function getIndexOfSession(session) {
37 for (var i = 0; i < sessionsList.model.count; i++) {
37 for (var i = 0; i < sessionsList.model.count; i++) {
38− var key = sessionsList.model.get(i).key
38+ var key = sessionsList.model.get(i).key;
39− if (key === initiallySelectedSession) {
39+ if (key === session) {
44+ return 0; // Just choose the first session
45 function currentKey() {
47 function currentKey() {
@@ -49,7 +51,8 @@ Item {
51 Keys.onEnterPressed: {
53 Keys.onEnterPressed: {
54+ sessionSelected(currentKey());
52− showLoginList(); // Session is already selected
55+ showLoginList();
53 event.accepted = true;
56 event.accepted = true;
@@ -59,6 +62,7 @@ Item {
61 Keys.onReturnPressed: {
64 Keys.onReturnPressed: {
65+ sessionSelected(currentKey());
62 showLoginList();
66 showLoginList();
63 event.accepted = true;
67 event.accepted = true;
@@ -66,20 +70,18 @@ Item {
66 Keys.onDownPressed: {
70 Keys.onDownPressed: {
67 if (sessionsList.currentIndex < sessionsList.model.count - 1)
71 if (sessionsList.currentIndex < sessionsList.model.count - 1)
68 sessionsList.currentIndex++;
72 sessionsList.currentIndex++;
69− sessionSelected(currentKey());
70 event.accepted = true;
73 event.accepted = true;
73 Keys.onUpPressed: {
76 Keys.onUpPressed: {
74 if (sessionsList.currentIndex > 0)
77 if (sessionsList.currentIndex > 0)
75 sessionsList.currentIndex--;
78 sessionsList.currentIndex--;
76− sessionSelected(currentKey());
77 event.accepted = true;
79 event.accepted = true;
80 LoginAreaContainer {
82 LoginAreaContainer {
81 readonly property real margins: sessionsList.anchors.margins
83 readonly property real margins: sessionsList.anchors.margins
82− readonly property real prefferedHeight: {
84+ readonly property real preferredHeight: {
83 if (sessionsList.currentItem) {
85 if (sessionsList.currentItem) {
84 return (sessionsList.currentItem.height *
86 return (sessionsList.currentItem.height *
85 (1 + sessionsList.model.count)) + 2 * margins
87 (1 + sessionsList.model.count)) + 2 * margins
@@ -88,7 +90,7 @@ Item {
91− height: prefferedHeight < parent.height ? prefferedHeight : parent.height - units.gu(4)
93+ height: preferredHeight < parent.height ? preferredHeight : parent.height - units.gu(4)
92 width: parent.width
94 width: parent.width
@@ -107,8 +109,8 @@ Item {
107 margins: units.gu(2)
109 margins: units.gu(2)
110− height: parent.height - headerItem.height
113+ height: parent.height - units.gu(2.5)
112 boundsBehavior: Flickable.StopAtBounds
114 boundsBehavior: Flickable.StopAtBounds
114 model: LightDMService.sessions
116 model: LightDMService.sessions
@@ -135,14 +137,18 @@ Item {
137 headerPositioning: ListView.OverlayHeader
139 headerPositioning: ListView.OverlayHeader
141+ // The highlighting is all self-managed, so account for that
138 highlightFollowsCurrentItem: false
142 highlightFollowsCurrentItem: false
143+ highlight: QtObject {}
140 delegate: ListItem {
145 delegate: ListItem {
141 id: delegate
146 id: delegate
142 objectName: "sessionDelegate" + index
147 objectName: "sessionDelegate" + index
144− divider.visible: false
149+ property string initialSession: ""
151+ divider.visible: false
146 visible: y > sessionsList.headerItem.y
152 visible: y > sessionsList.headerItem.y
147 + sessionsList.headerItem.height
153 + sessionsList.headerItem.height
148 - sessionsList.anchors.margins
154 - sessionsList.anchors.margins
@@ -156,6 +162,16 @@ Item {
166+ id: backgroundHighlight
168+ height: sessionsList.currentItem.height
169+ width: sessionsList.currentItem.width
170+ color: theme.palette.normal.selection
172+ visible: initialSession === key && !!key
159 Rectangle {
175 Rectangle {
160 height: parent.height
176 height: parent.height
161 width: parent.width
177 width: parent.width
@@ -171,15 +187,16 @@ Item {
171 ListItemLayout {
187 ListItemLayout {
172 id: layout
188 id: layout
190+ readonly property color itemColor: theme.palette.normal.raisedText
174 SessionIcon {
191 SessionIcon {
175 id: sessionIcon
192 id: sessionIcon
176 source: icon_url
193 source: icon_url
177 SlotsLayout.position: SlotsLayout.Leading
194 SlotsLayout.position: SlotsLayout.Leading
178− color: theme.palette.normal.raisedSecondaryText
195+ color: parent.itemColor
181 title.text: display
198 title.text: display
182− title.color: theme.palette.normal.raisedText
199+ title.color: itemColor