@@ -24,26 +24,26 @@ 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);
34− // A workaround to get the initial highlight correct
34+ var newY = sessionsList.currentItem.y + sessionsList.headerItem.height
35− sessionsList.highlightFollowsCurrentItem = true;
35+ sessionsList.backgroundHighlight.y = newY;
36− sessionsList.positionViewAtIndex(sessionsList.currentIndex, ListView.Contain);
37− sessionsList.highlightFollowsCurrentItem = false;
40− function getSelectedIndex() {
38+ function getIndexOfSession(session) {
41 for (var i = 0; i < sessionsList.model.count; i++) {
39 for (var i = 0; i < sessionsList.model.count; i++) {
42− var key = sessionsList.model.get(i).key
40+ var key = sessionsList.model.get(i).key;
43− if (key === initiallySelectedSession) {
41+ if (key === session) {
46+ return 0; // Just choose the first session
49 function currentKey() {
49 function currentKey() {
@@ -104,6 +104,8 @@ Item {
104 UbuntuListView {
104 UbuntuListView {
105 id: sessionsList
105 id: sessionsList
107+ readonly property alias backgroundHighlight: backgroundHighlight
107 anchors {
109 anchors {
108 top: parent.top
110 top: parent.top
109 left: parent.left
111 left: parent.left
@@ -139,9 +141,14 @@ Item {
141 headerPositioning: ListView.OverlayHeader
143 headerPositioning: ListView.OverlayHeader
145+ // The highlighting is all self-managed, so account for that
142 highlightFollowsCurrentItem: false
146 highlightFollowsCurrentItem: false
147+ highlight: QtObject {}
150+ id: backgroundHighlight
144− highlight: Rectangle {
145 height: sessionsList.currentItem.height
152 height: sessionsList.currentItem.height
146 width: sessionsList.currentItem.width
153 width: sessionsList.currentItem.width
147 color: theme.palette.normal.selection
154 color: theme.palette.normal.selection