@@ -94,20 +94,70 @@ Item {
9494 width: parent.width
9595 height: parent.height
9696
97+ Timer {
98+ id: resizeTimer
99+ interval: 100
100+ repeat: false
101+ onTriggered: {
102+ dashContentList.currentIndex = dashContentList.currentIndexBeforeResize;
103+ resetCurrentIndexTimer.stop();
104+ dashContentList.currentIndexBeforeResize = -1;
105+ }
106+ }
107+ Timer {
108+ id: resetCurrentIndexTimer
109+ interval: 1
110+ repeat: false
111+ onTriggered: {
112+ dashContentList.currentIndex = dashContentList.currentIndexBeforeResize;
113+ }
114+ }
115+
116+ function onSizeChanged() {
117+ if (!resizeTimer.running) {
118+ dashContentList.currentIndexBeforeResize = dashContentList.currentIndex;
119+ resizeTimer.start();
120+ } else {
121+ resizeTimer.restart();
122+ }
123+ }
124+
125+ onWidthChanged: {
126+ onSizeChanged();
127+ dashContentList.width = dashContentListHolder.width;
128+ }
129+
130+ onHeightChanged: {
131+ onSizeChanged();
132+ dashContentList.height = dashContentListHolder.height;
133+ }
134+
97135 ListView {
98136 id: dashContentList
99137 objectName: "dashContentList"
100138
101139 interactive: dashContent.scopes.loaded && !previewListView.open && currentItem && !currentItem.moving
140+ && !resizeTimer.running
141+
142+ property int currentIndexBeforeResize: -1
143+ onCurrentIndexChanged: {
144+ if (resizeTimer.running && currentIndex != currentIndexBeforeResize) {
145+ // Bogus ListView currentIndex change caused by the resize.
146+ // Work around this bug by resetting it to its value before the resize
147+ // took place.
148+ // But we have to do it outside its own onChanged slot, hence the timer.
149+ resetCurrentIndexTimer.start();
150+ }
151+ }
102152
103− anchors.fill: parent
153+ //anchors.fill: parent /* working around the "currentIndex change due to resize" bug */
104154 model: dashContent.model
105155 orientation: ListView.Horizontal
106156 boundsBehavior: Flickable.DragAndOvershootBounds
107157 flickDeceleration: units.gu(625)
108158 maximumFlickVelocity: width * 5
109159 snapMode: ListView.SnapOneItem
110− highlightMoveDuration: 250
160+ highlightMoveDuration: 0 //250 /* working around the "currentIndex change due to resize" bug */
111161 highlightRangeMode: ListView.StrictlyEnforceRange
112162 // TODO Investigate if we can switch to a smaller cache buffer when/if UbuntuShape gets more performant
113163 cacheBuffer: 1073741823