on xenial help sign in
Don't move the list contentY unless there's a preview to show
commit88ffb54a338d4a59f97b4080237f8038138e3ba1 authorAlbert Astals <albert.astals@canonical.com> dateTue 28 Jan 2014, 12:24 (13 years ago) parent2308f33
3 files changed+12−8
qml/Dash/DashContent.qml+1−1 qml/Dash/GenericScopeView.qml+4−4 qml/Dash/PreviewListView.qml+7−3
qml/Dash/DashContent.qml+1−1
@@ -149,7 +149,7 @@ Item {
149149 ignoreUnknownSignals: true
150150 onEndReached: contentEndReached()
151151 }
152−
152+Component.onCompleted: console.log("SDFDFSD", scope.id)
153153 Component.onDestruction: active = false
154154 }
155155 }
qml/Dash/GenericScopeView.qml+4−4
@@ -186,10 +186,10 @@ FocusScope {
186186 onClicked: {
187187 // Prepare the preview in case activate() triggers a preview only
188188 openEffect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + categoryView.stickyHeaderHeight);
189+ previewListView.needsInit = true;
189190 previewListView.categoryId = categoryId
190191 previewListView.categoryDelegate = rendererLoader.item
191192 previewListView.model = target.model;
192− previewListView.init = true;
193193 previewListView.currentIndex = index;
194194
195195 var item = target.model.get(index);
@@ -207,10 +207,10 @@ FocusScope {
207207 }
208208 onPressAndHold: {
209209 openEffect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + categoryView.stickyHeaderHeight);
210+ previewListView.needsInit = true;
210211 previewListView.categoryId = categoryId
211212 previewListView.categoryDelegate = rendererLoader.item
212213 previewListView.model = target.model;
213− previewListView.init = true;
214214 previewListView.currentIndex = index;
215215 previewListView.open = true
216216
@@ -364,7 +364,7 @@ FocusScope {
364364 Connections {
365365 target: scopeView.scope
366366 onPreviewReady: {
367− if (previewListView.init) {
367+ if (previewListView.needsInit) {
368368 // Preview was triggered because of a click on the item. Need to expand now.
369369 if (!previewListView.open) {
370370 previewListView.open = true
@@ -372,8 +372,8 @@ FocusScope {
372372
373373 var index = previewListView.currentIndex
374374 previewListView.currentIndex = -1
375+ previewListView.needsInit = false
375376 previewListView.currentIndex = index
376− previewListView.init = false
377377 }
378378 previewListView.currentItem.previewData = preview
379379 }
qml/Dash/PreviewListView.qml+7−3
@@ -28,7 +28,7 @@ Item {
2828 property alias onScreen: previewListView.onScreen
2929 property alias categoryId: previewListView.categoryId
3030 property alias categoryDelegate: previewListView.categoryDelegate
31− property alias init: previewListView.init
31+ property alias needsInit: previewListView.needsInit
3232 property alias model: previewListView.model
3333 property alias currentIndex: previewListView.currentIndex
3434 property alias currentItem: previewListView.currentItem
@@ -81,13 +81,17 @@ Item {
8181 // because the ListView is built asynchronous, setting the
8282 // currentIndex directly won't work. We need to refresh it
8383 // when the first preview is ready to be displayed.
84− property bool init: true
84+ property bool needsInit: true
8585
8686 PreviewDelegateMapper {
8787 id: previewDelegateMapper
8888 }
8989
9090 onCurrentIndexChanged: {
91+ if (needsInit) {
92+ return;
93+ }
94+
9195 var row = Math.floor(currentIndex / categoryDelegate.columns);
9296 if (categoryDelegate.collapsedRowCount <= row) {
9397 categoryView.expandedCategoryId = categoryId
@@ -97,7 +101,7 @@ Item {
97101 categoryDelegate.highlightIndex = currentIndex
98102 }
99103
100− if (!init && model !== undefined) {
104+ if (model !== undefined) {
101105 var item = model.get(currentIndex)
102106 scope.preview(item.uri, item.icon, item.category, 0, item.mimetype, item.title, item.comment, item.dndUri, item.metadata)
103107 }