on xenial help sign in
Hide Dash if not shown and set isActive on scopes to false accordingly.
e0fa531Michał Sawicz
Dash/Dash.qml+2
@@ -24,6 +24,8 @@ Showable {
24 id: dash
24 id: dash
25 objectName: "dash"
25 objectName: "dash"
26
26
27+ visible: shown
28+
27 property alias contentProgress: dashContent.contentProgress
29 property alias contentProgress: dashContent.contentProgress
28 property string showScopeOnLoaded: "home.scope"
30 property string showScopeOnLoaded: "home.scope"
29 property real contentScale: 1.0
31 property real contentScale: 1.0
Dash/DashContent.qml+2−2
@@ -117,12 +117,12 @@ Item {
117
117
118 // these are needed for autopilot tests
118 // these are needed for autopilot tests
119 readonly property string scopeId: scope.id
119 readonly property string scopeId: scope.id
120− readonly property bool isCurrent: ListView.isCurrentItem
120+ readonly property bool isCurrent: visible && ListView.isCurrentItem
121 readonly property bool isLoaded: status == Loader.Ready
121 readonly property bool isLoaded: status == Loader.Ready
122
122
123 onLoaded: {
123 onLoaded: {
124 item.scope = Qt.binding(function() { return scope })
124 item.scope = Qt.binding(function() { return scope })
125− item.isCurrent = Qt.binding(function() { return ListView.isCurrentItem })
125+ item.isCurrent = Qt.binding(function() { return isCurrent })
126 item.searchHistory = Qt.binding(function() { return shell.searchHistory })
126 item.searchHistory = Qt.binding(function() { return shell.searchHistory })
127 dashContentList.movementStarted.connect(item.movementStarted)
127 dashContentList.movementStarted.connect(item.movementStarted)
128 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
128 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
Dash/ScopeView.qml+11−3
@@ -31,14 +31,22 @@ FocusScope {
31 // FIXME delay the search so that daemons have time to settle, note that
31 // FIXME delay the search so that daemons have time to settle, note that
32 // removing this will break ScopeView::test_changeScope
32 // removing this will break ScopeView::test_changeScope
33 onScopeChanged: {
33 onScopeChanged: {
34+ if (scope) {
34− timer.restart();
35+ timer.restart();
35− scope.activateApplication.connect(activateApp);
36+ scope.activateApplication.connect(activateApp);
37+ }
36 }
38 }
37
39
38 function activateApp(desktopFilePath) {
40 function activateApp(desktopFilePath) {
39 shell.activateApplication(desktopFilePath);
41 shell.activateApplication(desktopFilePath);
40 }
42 }
41
43
44+ Binding {
45+ target: scope
46+ property: "isActive"
47+ value: isCurrent
48+ }
49+
42 Timer {
50 Timer {
43 id: timer
51 id: timer
44 interval: 2000
52 interval: 2000
@@ -47,7 +55,7 @@ FocusScope {
47
55
48 SortFilterProxyModel {
56 SortFilterProxyModel {
49 id: categoryFilter
57 id: categoryFilter
50− model: scope.categories
58+ model: scope ? scope.categories : null
51 dynamicSortFilter: true
59 dynamicSortFilter: true
52 filterRole: Categories.RoleCount
60 filterRole: Categories.RoleCount
53 filterRegExp: /^0$/
61 filterRegExp: /^0$/
tests/qmltests/Dash/qml/FakeScopeView.qml+3−9
@@ -17,16 +17,10 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import Unity 0.1
18import Unity 0.1
19
19
20−FocusScope {
20+import "../../../../Dash"
21− id: fakeScopeView
22− property Scope scope : null
23− property bool isCurrent : false
24−
25− property ListModel searchHistory
26
21
27− signal endReached
22+ScopeView {
28− signal movementStarted
23+ id: fakeScopeView
29− signal positionedAtBeginning
30
24
31 property alias backColor : back.color
25 property alias backColor : back.color
32
26
tests/qmltests/Dash/tst_DashContent.qml+29−5
@@ -101,17 +101,21 @@ Item {
101 when: windowShown
101 when: windowShown
102
102
103 function init() {
103 function init() {
104+ scopesModel.load();
105+ }
106+
107+ function cleanup() {
104 scopeLoadedSpy.clear();
108 scopeLoadedSpy.clear();
105 movementStartedSpy.clear();
109 movementStartedSpy.clear();
106− contentEndReachedSpy.clear()
110+ contentEndReachedSpy.clear();
107 clear_scope_status();
111 clear_scope_status();
112+ dashContent.visible = true;
108
113
109− // clear, wait for dash to empty and load scopes.
110− var dashContentList = findChild(dashContent, "dashContentList");
111− verify(dashContentList != undefined)
112 scopesModel.clear();
114 scopesModel.clear();
115+ // wait for dash to empty scopes.
116+ var dashContentList = findChild(dashContent, "dashContentList");
117+ verify(dashContentList != undefined);
113 tryCompare(dashContentList, "count", 0);
118 tryCompare(dashContentList, "count", 0);
114− scopesModel.load();
115 }
119 }
116
120
117 function test_movement_started_signal() {
121 function test_movement_started_signal() {
@@ -205,5 +209,25 @@ Item {
205 tryCompareFunction(get_current_item_object_name, data.objectName)
209 tryCompareFunction(get_current_item_object_name, data.objectName)
206 }
210 }
207
211
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+ }
208 }
232 }
209}
233}