on xenial help sign in
Don't move the list contentY unless there's a preview to show Fixes: 1271676
071ea3bAlbert Astals
qml/Dash/PreviewListView.qml+9−4
@@ -88,15 +88,19 @@ Item {
88 id: previewDelegateMapper
88 id: previewDelegateMapper
89 }
89 }
90
90
91− onCurrentIndexChanged: {
91+ onCurrentIndexChanged: positionListView();
92+
93+ function positionListView() {
94+ if (!open) {
95+ return;
96+ }
97+
92 var row = Math.floor(currentIndex / categoryDelegate.columns);
98 var row = Math.floor(currentIndex / categoryDelegate.columns);
93 if (categoryDelegate.collapsedRowCount <= row) {
99 if (categoryDelegate.collapsedRowCount <= row) {
94 categoryView.expandedCategoryId = categoryId
100 categoryView.expandedCategoryId = categoryId
95 }
101 }
96
102
97− if (open) {
98− categoryDelegate.highlightIndex = currentIndex
103+ categoryDelegate.highlightIndex = currentIndex
99− }
100
104
101 if (!init && model !== undefined) {
105 if (!init && model !== undefined) {
102 var item = model.get(currentIndex)
106 var item = model.get(currentIndex)
@@ -137,6 +141,7 @@ Item {
137 onScreen = true;
141 onScreen = true;
138 categoryDelegate.highlightIndex = currentIndex;
142 categoryDelegate.highlightIndex = currentIndex;
139 pageHeader.unfocus();
143 pageHeader.unfocus();
144+ positionListView();
140 } else {
145 } else {
141 // Cancel any pending preview requests or actions
146 // Cancel any pending preview requests or actions
142 if (previewListView.currentItem.previewData !== undefined) {
147 if (previewListView.currentItem.previewData !== undefined) {
tests/mocks/Unity/fake_scope.cpp+4−4
@@ -36,9 +36,9 @@ Scope::Scope(QString const& id, QString const& name, bool visible, QObject* pare
36 , m_visible(visible)
36 , m_visible(visible)
37 , m_searching(false)
37 , m_searching(false)
38 , m_isActive(false)
38 , m_isActive(false)
39+ , m_previewRendererName("preview-generic")
39 , m_categories(new Categories(this))
40 , m_categories(new Categories(this))
40 , m_results(new DeeListModel(this))
41 , m_results(new DeeListModel(this))
41− , m_previewRendererName("preview-generic")
42{
42{
43 DeeModel* results_model = create_results_model(20, 300);
43 DeeModel* results_model = create_results_model(20, 300);
44 m_categories->setResultModel(results_model);
44 m_categories->setResultModel(results_model);
@@ -155,7 +155,6 @@ void Scope::activate(const QVariant &uri, const QVariant &icon_hint, const QVari
155 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
155 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
156 const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
156 const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
157{
157{
158− Q_UNUSED(uri);
159 Q_UNUSED(icon_hint);
158 Q_UNUSED(icon_hint);
160 Q_UNUSED(category);
159 Q_UNUSED(category);
161 Q_UNUSED(result_type);
160 Q_UNUSED(result_type);
@@ -165,7 +164,8 @@ void Scope::activate(const QVariant &uri, const QVariant &icon_hint, const QVari
165 Q_UNUSED(dnd_uri);
164 Q_UNUSED(dnd_uri);
166 Q_UNUSED(metadata);
165 Q_UNUSED(metadata);
167
166
167+ if (uri != "uri://result.2")
168− m_timer.start();
168+ m_timer.start();
169}
169}
170
170
171void Scope::preview(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
171void Scope::preview(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
@@ -202,7 +202,7 @@ DeeModel* create_categories_model(unsigned category_count) {
202 for(unsigned i = 0; i < category_count; ++i)
202 for(unsigned i = 0; i < category_count; ++i)
203 {
203 {
204 dee_model_append(category_model,
204 dee_model_append(category_model,
205− std::to_string(i).c_str(),
205+ (i == 2) ? "applications.scope" : std::to_string(i).c_str(),
206 ("Category "+std::to_string(i)).c_str(),
206 ("Category "+std::to_string(i)).c_str(),
207 "gtk-apply",
207 "gtk-apply",
208 i % 2 == 0 ? "grid" : "carousel",
208 i % 2 == 0 ? "grid" : "carousel",
tests/qmltests/Dash/tst_GenericScopeView.qml+49−19
@@ -32,7 +32,7 @@ Item {
32 id: scopes
32 id: scopes
33
33
34 onLoadedChanged: {
34 onLoadedChanged: {
35− genericScopeView.scope = scopes.get(0)
35+ genericScopeView.scope = scopes.get(2)
36 }
36 }
37 }
37 }
38
38
@@ -94,37 +94,42 @@ Item {
94 function test_showDash() {
94 function test_showDash() {
95 previewListView.open = true;
95 previewListView.open = true;
96 tryCompare(openEffect, "live", true);
96 tryCompare(openEffect, "live", true);
97− scopes.get(0).showDash();
97+ scopes.get(2).showDash();
98 tryCompare(previewListView, "open", false);
98 tryCompare(previewListView, "open", false);
99 tryCompare(openEffect, "live", true);
99 tryCompare(openEffect, "live", true);
100 }
100 }
101
101
102 function test_hideDash() {
102 function test_hideDash() {
103 previewListView.open = true;
103 previewListView.open = true;
104− scopes.get(0).hideDash();
104+ scopes.get(2).hideDash();
105 tryCompare(previewListView, "open", false);
105 tryCompare(previewListView, "open", false);
106 tryCompare(openEffect, "gap", 0);
106 tryCompare(openEffect, "gap", 0);
107 }
107 }
108
108
109− function openPreview() {
109+ function openPreview(filterGridName, willOpen) {
110− var categoryListView = findChild(genericScopeView, "categoryListView");
110+ if (filterGridName === undefined)
111− categoryListView.positionAtBeginning();
111+ filterGridName = "0";
112−
112+ if (willOpen === undefined)
113+ willOpen = true;
113 tryCompareFunction(function() {
114 tryCompareFunction(function() {
114− var tile = findChild(findChild(genericScopeView, "0"), "delegate0");
115+ var filterGrid = findChild(genericScopeView, filterGridName);
116+ if (filterGrid != null) {
117+ var tile = findChild(filterGrid, "delegate0");
115− return tile != undefined;
118+ return tile != null;
119+ }
120+ return false;
116 },
121 },
117 true);
122 true);
118− var tile = findChild(findChild(genericScopeView, "0"), "delegate0");
123+ var tile = findChild(findChild(genericScopeView, filterGridName), "delegate0");
119 mouseClick(tile, tile.width / 2, tile.height / 2);
124 mouseClick(tile, tile.width / 2, tile.height / 2);
120− tryCompare(previewListView, "open", true);
125+ tryCompare(previewListView, "open", willOpen);
121− tryCompare(openEffect, "gap", 1);
126+ tryCompare(openEffect, "gap", willOpen ? 1 : 0);
122 }
127 }
123
128
124 function checkArrowPosition(index) {
129 function checkArrowPosition(index) {
125 tryCompareFunction(function() {
130 tryCompareFunction(function() {
126 var tile = findChild(findChild(genericScopeView, "0"), "delegate" + index);
131 var tile = findChild(findChild(genericScopeView, "0"), "delegate" + index);
127− return tile != undefined;
132+ return tile != null;
128 },
133 },
129 true);
134 true);
130 var tile = findChild(findChild(genericScopeView, "0"), "delegate" + index);
135 var tile = findChild(findChild(genericScopeView, "0"), "delegate" + index);
@@ -148,6 +153,8 @@ Item {
148
153
149 function test_previewOpenClose() {
154 function test_previewOpenClose() {
150 tryCompare(previewListView, "open", false);
155 tryCompare(previewListView, "open", false);
156+ var categoryListView = findChild(genericScopeView, "categoryListView");
157+ categoryListView.positionAtBeginning();
151
158
152 openPreview();
159 openPreview();
153
160
@@ -187,6 +194,9 @@ Item {
187 }
194 }
188
195
189 function test_previewCycle() {
196 function test_previewCycle() {
197+ var categoryListView = findChild(genericScopeView, "categoryListView");
198+ categoryListView.positionAtBeginning();
199+
190 tryCompare(previewListView, "open", false);
200 tryCompare(previewListView, "open", false);
191 tryCompare(openEffect, "gap", 0);
201 tryCompare(openEffect, "gap", 0);
192
202
@@ -241,8 +251,13 @@ Item {
241 }
251 }
242
252
243 function test_show_spinner() {
253 function test_show_spinner() {
254+ var categoryListView = findChild(genericScopeView, "categoryListView");
255+ waitForRendering(categoryListView);
256+ categoryListView.contentY = units.gu(13);
244 openPreview();
257 openPreview();
245 var previewLoader = findChild(previewListView, "previewLoader0");
258 var previewLoader = findChild(previewListView, "previewLoader0");
259+ compare(previewLoader.source.toString().split("/").pop(), "DashPreviewPlaceholder.qml");
260+ compare(categoryListView.contentY, 0)
246 tryCompare(previewLoader, "progress", 1.0);
261 tryCompare(previewLoader, "progress", 1.0);
247 tryCompareFunction(function() { return previewLoader.item != undefined; }, true);
262 tryCompareFunction(function() { return previewLoader.item != undefined; }, true);
248
263
@@ -258,13 +273,13 @@ Item {
258 function test_changeScope() {
273 function test_changeScope() {
259 genericScopeView.scope.searchQuery = "test"
274 genericScopeView.scope.searchQuery = "test"
260 genericScopeView.scope = scopes.get(1)
275 genericScopeView.scope = scopes.get(1)
261− genericScopeView.scope = scopes.get(0)
276+ genericScopeView.scope = scopes.get(2)
262 tryCompare(genericScopeView.scope, "searchQuery", "")
277 tryCompare(genericScopeView.scope, "searchQuery", "")
263 }
278 }
264
279
265 function test_filter_expand_collapse() {
280 function test_filter_expand_collapse() {
266 // wait for the item to be there
281 // wait for the item to be there
267− tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader0") != undefined; }, true);
282+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader0") != null; }, true);
268
283
269 var header = findChild(genericScopeView, "dashSectionHeader0")
284 var header = findChild(genericScopeView, "dashSectionHeader0")
270 var category = findChild(genericScopeView, "dashCategory0")
285 var category = findChild(genericScopeView, "dashCategory0")
@@ -301,7 +316,7 @@ Item {
301 }
316 }
302
317
303 function test_showPreviewCarousel() {
318 function test_showPreviewCarousel() {
304− tryCompareFunction(function() { return findChild(genericScopeView, "carouselDelegate") != undefined; }, true);
319+ tryCompareFunction(function() { return findChild(genericScopeView, "carouselDelegate") != null; }, true);
305 var tile = findChild(genericScopeView, "carouselDelegate");
320 var tile = findChild(genericScopeView, "carouselDelegate");
306 mouseClick(tile, tile.width / 2, tile.height / 2);
321 mouseClick(tile, tile.width / 2, tile.height / 2);
307 tryCompare(openEffect, "gap", 1);
322 tryCompare(openEffect, "gap", 1);
@@ -329,13 +344,13 @@ Item {
329
344
330 function test_filter_expand_expand_collapse() {
345 function test_filter_expand_expand_collapse() {
331 // wait for the item to be there
346 // wait for the item to be there
332− tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader2") != undefined; }, true);
347+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeaderapplications.scope") != null; }, true);
333
348
334 var categoryListView = findChild(genericScopeView, "categoryListView");
349 var categoryListView = findChild(genericScopeView, "categoryListView");
335 categoryListView.contentY = categoryListView.height;
350 categoryListView.contentY = categoryListView.height;
336
351
337− var header2 = findChild(genericScopeView, "dashSectionHeader2")
352+ var header2 = findChild(genericScopeView, "dashSectionHeaderapplications.scope")
338− var category2 = findChild(genericScopeView, "dashCategory2")
353+ var category2 = findChild(genericScopeView, "dashCategoryapplications.scope")
339 var category2FilterGrid = category2.children[0].children[0].children[0];
354 var category2FilterGrid = category2.children[0].children[0].children[0];
340 verify(UT.Util.isInstanceOf(category2FilterGrid, "FilterGrid"));
355 verify(UT.Util.isInstanceOf(category2FilterGrid, "FilterGrid"));
341
356
@@ -368,6 +383,21 @@ Item {
368 tryCompare(category2, "filtered", true);
383 tryCompare(category2, "filtered", true);
369 }
384 }
370
385
386+ function test_bug1271676_no_move_y_no_preview() {
387+ waitForRendering(genericScopeView);
388+ var categoryListView = findChild(genericScopeView, "categoryListView");
389+ waitForRendering(categoryListView);
390+ tryCompareFunction(function() { return findChild(genericScopeView, "dashCategoryapplications.scope") != null; }, true);
391+ var category = findChild(genericScopeView, "dashCategoryapplications.scope")
392+ categoryListView.contentY = category.y;
393+ waitForRendering(categoryListView);
394+ var contentYBefore = categoryListView.contentY
395+ openPreview("applications.scope", false); // This actually doesn't open anything because we
396+ // have code so that the item of installed
397+ // does activate instead of preview and never shows a preview
398+ compare(categoryListView.contentY, contentYBefore);
399+ }
400+
371 function test_narrow_delegate_ranges_expand() {
401 function test_narrow_delegate_ranges_expand() {
372 tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
402 tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
373 var category = findChild(genericScopeView, "dashCategory0")
403 var category = findChild(genericScopeView, "dashCategory0")