on xenial help sign in
collapse any open preview when programmatically switching current dash index
commit0d9d9d811b48fe796cd358f39262983fe68fb38c authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 17 Sep 2013, 17:54 (13 years ago) parent6a74c57
4 files changed+28−4
Dash/DashContent.qml+7−2 Dash/GenericScopeView.qml+1−1 tests/qmltests/Dash/qml/FakeScopeView.qml+1 tests/qmltests/Dash/tst_DashContent.qml+19−1
Dash/DashContent.qml+7−2
@@ -64,8 +64,13 @@ Item {
6464 }
6565 set_current_index = undefined;
6666
67− if (dashContentList.count > index)
68− {
67+ if (dashContentList.count > index) {
68+
69+ // collapse any currently shown preview
70+ if (dashContentList.currentItem && dashContentList.currentItem.item.previewShown) {
71+ dashContentList.currentItem.item.previewShown = false;
72+ }
73+
6974 dashContentList.currentIndex = index
7075
7176 if (reset) {
Dash/GenericScopeView.qml+1−1
@@ -21,7 +21,7 @@ import "../Components/ListItems" as ListItems
2121
2222ScopeView {
2323 id: scopeView
24− property alias previewShown: previewLoader.onScreen
24+ property alias previewShown: previewLoader.open
2525
2626 onIsCurrentChanged: {
2727 pageHeader.resetSearch();
tests/qmltests/Dash/qml/FakeScopeView.qml+1
@@ -21,6 +21,7 @@ FocusScope {
2121 id: fakeScopeView
2222 property Scope scope : null
2323 property bool isCurrent : false
24+ property bool previewShown: false
2425
2526 property ListModel searchHistory
2627
tests/qmltests/Dash/tst_DashContent.qml+19−1
@@ -106,7 +106,7 @@ Item {
106106 contentEndReachedSpy.clear()
107107 clear_scope_status();
108108
109− // clear, wait for dahs to empty and load scopes.
109+ // clear, wait for dash to empty and load scopes.
110110 var dashContentList = findChild(dashContent, "dashContentList");
111111 verify(dashContentList != undefined)
112112 scopesModel.clear();
@@ -178,6 +178,24 @@ Item {
178178 compare(dashContent.currentIndex, currentScopeIndex, "Scope should not change if changing to greater index than count");
179179 }
180180
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+
181199 function get_current_item_object_name() {
182200 var dashContentList = findChild(dashContent, "dashContentList");
183201 verify(dashContentList != undefined);