on xenial help sign in
collapse any open preview when programmatically switching current dash index
0d9d9d8Michael Zanetti
Dash/DashContent.qml+7−2
@@ -64,8 +64,13 @@ Item {
64 }
64 }
65 set_current_index = undefined;
65 set_current_index = undefined;
66
66
67− if (dashContentList.count > index)
67+ if (dashContentList.count > index) {
68− {
68+
69+ // collapse any currently shown preview
70+ if (dashContentList.currentItem && dashContentList.currentItem.item.previewShown) {
71+ dashContentList.currentItem.item.previewShown = false;
72+ }
73+
69 dashContentList.currentIndex = index
74 dashContentList.currentIndex = index
70
75
71 if (reset) {
76 if (reset) {
Dash/GenericScopeView.qml+1−1
@@ -21,7 +21,7 @@ import "../Components/ListItems" as ListItems
21
21
22ScopeView {
22ScopeView {
23 id: scopeView
23 id: scopeView
24− property alias previewShown: previewLoader.onScreen
24+ property alias previewShown: previewLoader.open
25
25
26 onIsCurrentChanged: {
26 onIsCurrentChanged: {
27 pageHeader.resetSearch();
27 pageHeader.resetSearch();
tests/qmltests/Dash/qml/FakeScopeView.qml+1
@@ -21,6 +21,7 @@ FocusScope {
21 id: fakeScopeView
21 id: fakeScopeView
22 property Scope scope : null
22 property Scope scope : null
23 property bool isCurrent : false
23 property bool isCurrent : false
24+ property bool previewShown: false
24
25
25 property ListModel searchHistory
26 property ListModel searchHistory
26
27
tests/qmltests/Dash/tst_DashContent.qml+19−1
@@ -106,7 +106,7 @@ Item {
106 contentEndReachedSpy.clear()
106 contentEndReachedSpy.clear()
107 clear_scope_status();
107 clear_scope_status();
108
108
109− // clear, wait for dahs to empty and load scopes.
109+ // clear, wait for dash to empty and load scopes.
110 var dashContentList = findChild(dashContent, "dashContentList");
110 var dashContentList = findChild(dashContent, "dashContentList");
111 verify(dashContentList != undefined)
111 verify(dashContentList != undefined)
112 scopesModel.clear();
112 scopesModel.clear();
@@ -178,6 +178,24 @@ Item {
178 compare(dashContent.currentIndex, currentScopeIndex, "Scope should not change if changing to greater index than count");
178 compare(dashContent.currentIndex, currentScopeIndex, "Scope should not change if changing to greater index than count");
179 }
179 }
180
180
181+ function test_set_current_scope_index_closes_preview() {
182+ var dashContentList = findChild(dashContent, "dashContentList");
183+ tryCompare(dashContentList, "count", 5);
184+ dashContentList.currentIndex = 0;
185+ tryCompare(dashContentList.currentItem, "progress", 1);
186+ var itemBeforeSwitching = dashContentList.currentItem;
187+
188+ waitForRendering(itemBeforeSwitching)
189+
190+ itemBeforeSwitching.item.previewShown = true;
191+
192+ var next_index = 1;
193+
194+ dashContent.setCurrentScopeAtIndex(next_index, true, false);
195+ tryCompare(dashContent, "currentIndex", next_index);
196+ compare(itemBeforeSwitching.item.previewShown, false);
197+ }
198+
181 function get_current_item_object_name() {
199 function get_current_item_object_name() {
182 var dashContentList = findChild(dashContent, "dashContentList");
200 var dashContentList = findChild(dashContent, "dashContentList");
183 verify(dashContentList != undefined);
201 verify(dashContentList != undefined);