on xenial help sign in
Scope activation support
commit8fde101bc86120d5d5176d2e664eee66bffabfb1 authorAlbert Astals <albert.astals@canonical.com> dateTue 18 Feb 2014, 16:11 (13 years ago) parent289f103
5 files changed+177−6
qml/Dash/Dash.qml+44−2 qml/Dash/DashContent.qml+21−4 qml/Dash/PreviewListView.qml+1 qml/Dash/ScopeItem.qml+111 qml/Dash/graphics/dashback@27.png
qml/Dash/Dash.qml+44−2
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013, 2014 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -62,10 +62,19 @@ Showable {
6262 DashContent {
6363 id: dashContent
6464 objectName: "dashContent"
65− anchors.fill: parent
65+ width: parent.width
66+ height: parent.height
6667 model: filteredScopes
6768 scopes: scopes
6869 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+ }
6978 onScopeLoaded: {
7079 if (scopeId == dash.showScopeOnLoaded) {
7180 dash.setCurrentScope(scopeId, false, false)
@@ -74,5 +83,38 @@ Showable {
7483 }
7584 scale: dash.contentScale
7685 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+
77119 }
78120}
qml/Dash/DashContent.qml+21−4
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013, 2014 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -36,6 +36,8 @@ Item {
3636 signal contentEndReached()
3737 signal scopeLoaded(string scopeId)
3838 signal positionedAtBeginning()
39+ signal gotoScope(string scopeId)
40+ signal openScope(var scope)
3941
4042 // If we set the current scope index before the scopes have been added,
4143 // then we need to wait until the loaded signals gets emitted from the scopes
@@ -80,6 +82,10 @@ Item {
8082 }
8183 }
8284
85+ function closeScope(scope) {
86+ dashContentList.currentItem.theScope.closeScope(scope)
87+ }
88+
8389 Item {
8490 id: dashContentListHolder
8591 anchors.fill: parent
@@ -136,8 +142,8 @@ Item {
136142 onLoaded: {
137143 item.scope = Qt.binding(function() { return scope })
138144 item.isCurrent = Qt.binding(function() { return visible && ListView.isCurrentItem })
139− item.tabBarHeight = pageHeader.implicitHeight;
140− item.pageHeader = pageHeader;
145+ item.tabBarHeight = dashPageHeader.implicitHeight;
146+ item.pageHeader = dashPageHeader;
141147 item.openEffect = openEffect;
142148 item.previewListView = previewListView;
143149 dashContentList.movementStarted.connect(item.movementStarted)
@@ -149,13 +155,23 @@ Item {
149155 ignoreUnknownSignals: true
150156 onEndReached: contentEndReached()
151157 }
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+ }
152168
153169 Component.onDestruction: active = false
154170 }
155171 }
156172
157173 PageHeader {
158− id: pageHeader
174+ id: dashPageHeader
159175 objectName: "pageHeader"
160176 width: parent.width
161177 searchEntryEnabled: true
@@ -218,6 +234,7 @@ Item {
218234 openEffect: openEffect
219235 categoryView: dashContentList.currentItem ? dashContentList.currentItem.categoryView : null
220236 scope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
237+ pageHeader: dashPageHeader
221238 anchors.fill: parent
222239 }
223240}
qml/Dash/PreviewListView.qml+1
@@ -26,6 +26,7 @@ Item {
2626 property OpenEffect openEffect: null
2727 property ScopeListView categoryView: null
2828 property Scope scope: null
29+ property var pageHeader: null
2930
3031 property alias open: previewListView.open
3132 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.