@@ -24,22 +24,24 @@ Item {
2424 id: root
2525 objectName: "sessionsList"
2626
27− property string initiallySelectedSession
2827 signal sessionSelected(string sessionKey)
2928 signal showLoginList()
3029
31− onInitiallySelectedSessionChanged: {
32− sessionsList.currentIndex = getSelectedIndex();
33− sessionsList.positionViewAtIndex(sessionsList.currentIndex, ListView.Contain);
30+ // Sets the position of the background highlight
31+ function updateHighlight(session) {
32+ sessionsList.currentIndex = getIndexOfSession(session);
33+ sessionsList.currentItem.initialSession = session;
3434 }
3535
36− function getSelectedIndex() {
36+ function getIndexOfSession(session) {
3737 for (var i = 0; i < sessionsList.model.count; i++) {
38− var key = sessionsList.model.get(i).key
39− if (key === initiallySelectedSession) {
38+ var key = sessionsList.model.get(i).key;
39+ if (key === session) {
4040 return i;
4141 }
4242 }
43+
44+ return 0; // Just choose the first session
4345 }
4446
4547 function currentKey() {
@@ -49,7 +51,8 @@ Item {
4951 }
5052
5153 Keys.onEnterPressed: {
52− showLoginList(); // Session is already selected
54+ sessionSelected(currentKey());
55+ showLoginList();
5356 event.accepted = true;
5457 }
5558
@@ -59,6 +62,7 @@ Item {
5962 }
6063
6164 Keys.onReturnPressed: {
65+ sessionSelected(currentKey());
6266 showLoginList();
6367 event.accepted = true;
6468 }
@@ -66,20 +70,18 @@ Item {
6670 Keys.onDownPressed: {
6771 if (sessionsList.currentIndex < sessionsList.model.count - 1)
6872 sessionsList.currentIndex++;
69− sessionSelected(currentKey());
7073 event.accepted = true;
7174 }
7275
7376 Keys.onUpPressed: {
7477 if (sessionsList.currentIndex > 0)
7578 sessionsList.currentIndex--;
76− sessionSelected(currentKey());
7779 event.accepted = true;
7880 }
7981
8082 LoginAreaContainer {
8183 readonly property real margins: sessionsList.anchors.margins
82− readonly property real prefferedHeight: {
84+ readonly property real preferredHeight: {
8385 if (sessionsList.currentItem) {
8486 return (sessionsList.currentItem.height *
8587 (1 + sessionsList.model.count)) + 2 * margins
@@ -88,7 +90,7 @@ Item {
8890 }
8991 }
9092
91− height: prefferedHeight < parent.height ? prefferedHeight : parent.height - units.gu(4)
93+ height: preferredHeight < parent.height ? preferredHeight : parent.height - units.gu(4)
9294 width: parent.width
9395
9496 anchors {
@@ -107,8 +109,8 @@ Item {
107109 margins: units.gu(2)
108110 }
109111
110− height: parent.height - headerItem.height
111−
112+ clip: true
113+ height: parent.height - units.gu(2.5)
112114 boundsBehavior: Flickable.StopAtBounds
113115
114116 model: LightDMService.sessions
@@ -135,14 +137,18 @@ Item {
135137 }
136138
137139 headerPositioning: ListView.OverlayHeader
140+
141+ // The highlighting is all self-managed, so account for that
138142 highlightFollowsCurrentItem: false
143+ highlight: QtObject {}
139144
140145 delegate: ListItem {
141146 id: delegate
142147 objectName: "sessionDelegate" + index
143148
144− divider.visible: false
149+ property string initialSession: ""
145150
151+ divider.visible: false
146152 visible: y > sessionsList.headerItem.y
147153 + sessionsList.headerItem.height
148154 - sessionsList.anchors.margins
@@ -156,6 +162,16 @@ Item {
156162 }
157163 }
158164
165+ Rectangle {
166+ id: backgroundHighlight
167+
168+ height: sessionsList.currentItem.height
169+ width: sessionsList.currentItem.width
170+ color: theme.palette.normal.selection
171+
172+ visible: initialSession === key && !!key
173+ }
174+
159175 Rectangle {
160176 height: parent.height
161177 width: parent.width
@@ -171,15 +187,16 @@ Item {
171187 ListItemLayout {
172188 id: layout
173189
190+ readonly property color itemColor: theme.palette.normal.raisedText
174191 SessionIcon {
175192 id: sessionIcon
176193 source: icon_url
177194 SlotsLayout.position: SlotsLayout.Leading
178− color: theme.palette.normal.raisedSecondaryText
195+ color: parent.itemColor
179196 }
180197
181198 title.text: display
182− title.color: theme.palette.normal.raisedText
199+ title.color: itemColor
183200 }
184201 }
185202 }