on xenial help sign in
Scope activation support
8fde101Albert Astals
qml/Dash/Dash.qml+44−2
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013, 2014 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -62,10 +62,19 @@ Showable {
62 DashContent {
62 DashContent {
63 id: dashContent
63 id: dashContent
64 objectName: "dashContent"
64 objectName: "dashContent"
65− anchors.fill: parent
65+ width: parent.width
66+ height: parent.height
66 model: filteredScopes
67 model: filteredScopes
67 scopes: scopes
68 scopes: scopes
68 searchHistory: dash.searchHistory
69 searchHistory: dash.searchHistory
70+ visible: x != -width
71+ onGotoScope: {
72+ dash.setCurrentScope(scopeId, true, false);
73+ }
74+ onOpenScope: {
75+ scopeItem.scope = scope;
76+ x = -width;
77+ }
69 onScopeLoaded: {
78 onScopeLoaded: {
70 if (scopeId == dash.showScopeOnLoaded) {
79 if (scopeId == dash.showScopeOnLoaded) {
71 dash.setCurrentScope(scopeId, false, false)
80 dash.setCurrentScope(scopeId, false, false)
@@ -74,5 +83,38 @@ Showable {
74 }
83 }
75 scale: dash.contentScale
84 scale: dash.contentScale
76 clip: scale != 1.0
85 clip: scale != 1.0
86+ Behavior on x {
87+ UbuntuNumberAnimation {
88+ onStopped: {
89+ if (dashContent.x == 0) {
90+ dashContent.closeScope(scopeItem.scope);
91+ scopeItem.scope = null;
92+ }
93+ }
94+ }
95+ }
96+ }
97+
98+ ScopeItem {
99+ id: scopeItem
100+ anchors.left: dashContent.right
101+ width: parent.width
102+ height: parent.height
103+ searchHistory: dash.searchHistory
104+ scale: dash.contentScale
105+ clip: scale != 1.0
106+ visible: scope != null
107+ onBack: {
108+ dashContent.x = 0;
109+ }
110+ onGotoScope: {
111+ // TODO
112+ console.log("gotoScope from an openScope scope is not implemented");
113+ }
114+ onOpenScope: {
115+ // TODO
116+ console.log("openScope from an openScope scope is not implemented");
117+ }
118+
77 }
119 }
78}
120}
qml/Dash/DashContent.qml+21−4
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013, 2014 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -36,6 +36,8 @@ Item {
36 signal contentEndReached()
36 signal contentEndReached()
37 signal scopeLoaded(string scopeId)
37 signal scopeLoaded(string scopeId)
38 signal positionedAtBeginning()
38 signal positionedAtBeginning()
39+ signal gotoScope(string scopeId)
40+ signal openScope(var scope)
39
41
40 // If we set the current scope index before the scopes have been added,
42 // If we set the current scope index before the scopes have been added,
41 // then we need to wait until the loaded signals gets emitted from the scopes
43 // then we need to wait until the loaded signals gets emitted from the scopes
@@ -80,6 +82,10 @@ Item {
80 }
82 }
81 }
83 }
82
84
85+ function closeScope(scope) {
86+ dashContentList.currentItem.theScope.closeScope(scope)
87+ }
88+
83 Item {
89 Item {
84 id: dashContentListHolder
90 id: dashContentListHolder
85 anchors.fill: parent
91 anchors.fill: parent
@@ -136,8 +142,8 @@ Item {
136 onLoaded: {
142 onLoaded: {
137 item.scope = Qt.binding(function() { return scope })
143 item.scope = Qt.binding(function() { return scope })
138 item.isCurrent = Qt.binding(function() { return visible && ListView.isCurrentItem })
144 item.isCurrent = Qt.binding(function() { return visible && ListView.isCurrentItem })
139− item.tabBarHeight = pageHeader.implicitHeight;
145+ item.tabBarHeight = dashPageHeader.implicitHeight;
140− item.pageHeader = pageHeader;
146+ item.pageHeader = dashPageHeader;
141 item.openEffect = openEffect;
147 item.openEffect = openEffect;
142 item.previewListView = previewListView;
148 item.previewListView = previewListView;
143 dashContentList.movementStarted.connect(item.movementStarted)
149 dashContentList.movementStarted.connect(item.movementStarted)
@@ -149,13 +155,23 @@ Item {
149 ignoreUnknownSignals: true
155 ignoreUnknownSignals: true
150 onEndReached: contentEndReached()
156 onEndReached: contentEndReached()
151 }
157 }
158+ Connections {
159+ target: isCurrent ? scope : null
160+ onGotoScope: {
161+ // Note here scopeId is the signal parameter and not the loader property
162+ dashContent.gotoScope(scopeId);
163+ }
164+ onOpenScope: {
165+ dashContent.openScope(scope);
166+ }
167+ }
152
168
153 Component.onDestruction: active = false
169 Component.onDestruction: active = false
154 }
170 }
155 }
171 }
156
172
157 PageHeader {
173 PageHeader {
158− id: pageHeader
174+ id: dashPageHeader
159 objectName: "pageHeader"
175 objectName: "pageHeader"
160 width: parent.width
176 width: parent.width
161 searchEntryEnabled: true
177 searchEntryEnabled: true
@@ -218,6 +234,7 @@ Item {
218 openEffect: openEffect
234 openEffect: openEffect
219 categoryView: dashContentList.currentItem ? dashContentList.currentItem.categoryView : null
235 categoryView: dashContentList.currentItem ? dashContentList.currentItem.categoryView : null
220 scope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
236 scope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
237+ pageHeader: dashPageHeader
221 anchors.fill: parent
238 anchors.fill: parent
222 }
239 }
223}
240}
qml/Dash/PreviewListView.qml+1
@@ -26,6 +26,7 @@ Item {
26 property OpenEffect openEffect: null
26 property OpenEffect openEffect: null
27 property ScopeListView categoryView: null
27 property ScopeListView categoryView: null
28 property Scope scope: null
28 property Scope scope: null
29+ property var pageHeader: null
29
30
30 property alias open: previewListView.open
31 property alias open: previewListView.open
31 property alias onScreen: previewListView.onScreen
32 property alias onScreen: previewListView.onScreen
qml/Dash/ScopeItem.qmlnew file+111
@@ -0,0 +1,111 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import Ubuntu.Components 0.1
19+import Unity 0.2
20+import "../Components"
21+
22+Item {
23+ id: root
24+
25+ property alias scope: scopeView.scope
26+
27+ property ListModel searchHistory
28+
29+ signal back
30+ signal gotoScope(string scopeId)
31+ signal openScope(var scope)
32+
33+ Item {
34+ id: scopeViewHolder
35+ anchors.fill: parent
36+
37+ GenericScopeView {
38+ id: scopeView
39+ width: parent.width
40+ height: parent.height
41+ isCurrent: scope != null
42+ tabBarHeight: scopeItemPageHeader.implicitHeight
43+ pageHeader: scopeItemPageHeader
44+ openEffect: openEffect
45+ previewListView: previewListView
46+
47+ Connections {
48+ target: isCurrent ? scope : null
49+ onGotoScope: root.gotoScope(scopeId);
50+ onOpenScope: root.openScope(scope);
51+ }
52+ }
53+
54+ PageHeader {
55+ id: scopeItemPageHeader
56+ width: parent.width
57+ searchEntryEnabled: true
58+ searchHistory: root.searchHistory
59+ scope: root.scope
60+ height: units.gu(7)
61+
62+ childItem: Row {
63+ anchors {
64+ fill: parent
65+ leftMargin: units.gu(2)
66+ }
67+ spacing: units.gu(1)
68+ Image {
69+ anchors.verticalCenter: parent.verticalCenter
70+ source: "graphics/dashback.png"
71+ MouseArea {
72+ anchors.fill: parent
73+ onClicked: root.back();
74+ }
75+ }
76+ Label {
77+ id: label
78+ anchors.verticalCenter: parent.verticalCenter
79+
80+ text: scope ? scope.name : ""
81+ color: "grey"
82+ font.family: "Ubuntu"
83+ font.weight: Font.Light
84+ fontSize: "x-large"
85+ elide: Text.ElideRight
86+ style: Text.Raised
87+ styleColor: "black"
88+ }
89+ }
90+ }
91+ }
92+
93+ DashContentOpenEffect {
94+ id: openEffect
95+ anchors {
96+ fill: parent
97+ bottomMargin: -bottomOverflow
98+ }
99+ sourceItem: scopeViewHolder
100+ previewListView: previewListView
101+ }
102+
103+ PreviewListView {
104+ id: previewListView
105+ openEffect: openEffect
106+ categoryView: scopeView.categoryView
107+ pageHeader: scopeItemPageHeader
108+ scope: root.scope
109+ anchors.fill: parent
110+ }
111+}
qml/Dash/graphics/dashback@27.pngnew file

Binary file not shown.