on xenial help sign in
Hide Dash if not shown and set isActive on scopes to false accordingly.
commite0fa5311ceb13823147909f135086d48c9a421fb authorMichał Sawicz <michal.sawicz@canonical.com> dateTue 24 Sep 2013, 11:52 (13 years ago) parent9942542
5 files changed+47−19
Dash/Dash.qml+2 Dash/DashContent.qml+2−2 Dash/ScopeView.qml+11−3 tests/qmltests/Dash/qml/FakeScopeView.qml+3−9 tests/qmltests/Dash/tst_DashContent.qml+29−5
Dash/Dash.qml+2
@@ -24,6 +24,8 @@ Showable {
2424 id: dash
2525 objectName: "dash"
2626
27+ visible: shown
28+
2729 property alias contentProgress: dashContent.contentProgress
2830 property string showScopeOnLoaded: "home.scope"
2931 property real contentScale: 1.0
Dash/DashContent.qml+2−2
@@ -117,12 +117,12 @@ Item {
117117
118118 // these are needed for autopilot tests
119119 readonly property string scopeId: scope.id
120− readonly property bool isCurrent: ListView.isCurrentItem
120+ readonly property bool isCurrent: visible && ListView.isCurrentItem
121121 readonly property bool isLoaded: status == Loader.Ready
122122
123123 onLoaded: {
124124 item.scope = Qt.binding(function() { return scope })
125− item.isCurrent = Qt.binding(function() { return ListView.isCurrentItem })
125+ item.isCurrent = Qt.binding(function() { return isCurrent })
126126 item.searchHistory = Qt.binding(function() { return shell.searchHistory })
127127 dashContentList.movementStarted.connect(item.movementStarted)
128128 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
Dash/ScopeView.qml+11−3
@@ -31,14 +31,22 @@ FocusScope {
3131 // FIXME delay the search so that daemons have time to settle, note that
3232 // removing this will break ScopeView::test_changeScope
3333 onScopeChanged: {
34− timer.restart();
35− scope.activateApplication.connect(activateApp);
34+ if (scope) {
35+ timer.restart();
36+ scope.activateApplication.connect(activateApp);
37+ }
3638 }
3739
3840 function activateApp(desktopFilePath) {
3941 shell.activateApplication(desktopFilePath);
4042 }
4143
44+ Binding {
45+ target: scope
46+ property: "isActive"
47+ value: isCurrent
48+ }
49+
4250 Timer {
4351 id: timer
4452 interval: 2000
@@ -47,7 +55,7 @@ FocusScope {
4755
4856 SortFilterProxyModel {
4957 id: categoryFilter
50− model: scope.categories
58+ model: scope ? scope.categories : null
5159 dynamicSortFilter: true
5260 filterRole: Categories.RoleCount
5361 filterRegExp: /^0$/
tests/qmltests/Dash/qml/FakeScopeView.qml+3−9
@@ -17,16 +17,10 @@
1717import QtQuick 2.0
1818import Unity 0.1
1919
20−FocusScope {
21− id: fakeScopeView
22− property Scope scope : null
23− property bool isCurrent : false
24−
25− property ListModel searchHistory
20+import "../../../../Dash"
2621
27− signal endReached
28− signal movementStarted
29− signal positionedAtBeginning
22+ScopeView {
23+ id: fakeScopeView
3024
3125 property alias backColor : back.color
3226
tests/qmltests/Dash/tst_DashContent.qml+29−5
@@ -101,17 +101,21 @@ Item {
101101 when: windowShown
102102
103103 function init() {
104+ scopesModel.load();
105+ }
106+
107+ function cleanup() {
104108 scopeLoadedSpy.clear();
105109 movementStartedSpy.clear();
106− contentEndReachedSpy.clear()
110+ contentEndReachedSpy.clear();
107111 clear_scope_status();
112+ dashContent.visible = true;
108113
109− // clear, wait for dash to empty and load scopes.
110− var dashContentList = findChild(dashContent, "dashContentList");
111− verify(dashContentList != undefined)
112114 scopesModel.clear();
115+ // wait for dash to empty scopes.
116+ var dashContentList = findChild(dashContent, "dashContentList");
117+ verify(dashContentList != undefined);
113118 tryCompare(dashContentList, "count", 0);
114− scopesModel.load();
115119 }
116120
117121 function test_movement_started_signal() {
@@ -205,5 +209,25 @@ Item {
205209 tryCompareFunction(get_current_item_object_name, data.objectName)
206210 }
207211
212+ function test_is_active_data() {
213+ return [
214+ {tag: "select 0", select: 0, visible: true, active0: true, active1: false, active2: false, active3: false},
215+ {tag: "select 2", select: 2, visible: true, active0: false, active1: false, active2: true, active3: false},
216+ {tag: "invisible", select: 0, visible: false, active0: false, active1: false, active2: false, active3: false},
217+ ]
218+ }
219+
220+ function test_is_active(data) {
221+ var dashContentList = findChild(dashContent, "dashContentList");
222+
223+ tryCompare(scopeLoadedSpy, "count", 5);
224+
225+ dashContent.setCurrentScopeAtIndex(data.select, true, false);
226+ dashContent.visible = data.visible;
227+
228+ tryCompare(scopesModel.get(0), "isActive", data.active0);
229+ tryCompare(scopesModel.get(1), "isActive", data.active1);
230+ tryCompare(scopesModel.get(2), "isActive", data.active2);
231+ }
208232 }
209233}