on xenial help sign in
Move stuff up to Dash and some more wiring
commitc2a42236a38e9c4ff1f65e6f52e0310db478ffba authorAlbert Astals <albert.astals@canonical.com> dateFri 11 Jul 2014, 15:04 (12 years ago) parentcdbcece
6 files changed+105−69
qml/Dash/Dash.qml+84−2 qml/Dash/DashContent.qml−64 qml/Dash/ScopesOverview.qml+7−1 tests/mocks/Unity/fake_scope.cpp−1 tests/mocks/Unity/fake_scopesoverview.cpp+12−1 tests/mocks/Unity/fake_scopesoverview.h+2
qml/Dash/Dash.qml+84−2
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19+import Ubuntu.Gestures 0.1
1920import Unity 0.2
2021import Utils 0.1
2122import "../Components"
@@ -29,7 +30,7 @@ Showable {
2930 property string showScopeOnLoaded: "clickscope"
3031 property real contentScale: 1.0
3132
32− property alias overviewHandleHeight: dashContent.overviewHandleHeight
33+ property alias overviewHandleHeight: overviewDragHandle.height
3334
3435 function setCurrentScope(scopeId, animate, reset) {
3536 var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId)
@@ -68,6 +69,42 @@ Showable {
6869 filterRegExp: RegExp("^true$")
6970 }
7071
72+ QtObject {
73+ id: overviewController
74+
75+ property bool accepted: false
76+ property bool enableAnimation: false
77+ property real progress: 0
78+ }
79+
80+ ScopesOverview {
81+ id: scopesOverview
82+ anchors.fill: parent
83+ scope: scopes ? scopes.getScope("scopesOverview") : null
84+ progress: overviewController.progress
85+ scopeScale: dashContent.scale
86+ visible: scopeScale != 1
87+ onDone: hide();
88+ onFavoriteSelected: {
89+ dashContent.setCurrentScopeAtIndex(index, false, false);
90+ hide();
91+ }
92+ function hide() {
93+ overviewController.enableAnimation = true;
94+ overviewController.progress = 0;
95+ overviewController.accepted = false;
96+ }
97+
98+ Connections {
99+ target: scopesOverview.scope
100+ onOpenScope: {
101+ scopeItem.scope = scope;
102+ scopesOverview.hide();
103+ dashContent.x = -dashContent.width; // TODO
104+ }
105+ }
106+ }
107+
71108 DashContent {
72109 id: dashContent
73110 objectName: "dashContent"
@@ -89,18 +126,35 @@ Showable {
89126 dash.showScopeOnLoaded = ""
90127 }
91128 }
92− scale: dash.contentScale
129+ scale: dash.contentScale * (1 - overviewController.progress * 0.6)
93130 clip: scale != 1.0 || scopeItem.visible
94131 Behavior on x {
95132 UbuntuNumberAnimation {
96133 onRunningChanged: {
97134 if (!running && dashContent.x == 0) {
135+ // TODO If it came from ScopesOverview it has to be ScopesOverview.scope.closeScope()
98136 dashContent.closeScope(scopeItem.scope);
99137 scopeItem.scope = null;
100138 }
101139 }
102140 }
103141 }
142+
143+ enabled: scale == 1
144+ opacity: 1 - overviewController.progress
145+ Behavior on scale {
146+ id: dashContentScaleAnimation
147+ enabled: overviewController.enableAnimation
148+ UbuntuNumberAnimation { }
149+ }
150+ }
151+
152+ Image {
153+ anchors.fill: scopeItem
154+ source: parent.width > parent.height ? "graphics/paper_landscape.png" : "graphics/paper_portrait.png"
155+ fillMode: Image.PreserveAspectCrop
156+ horizontalAlignment: Image.AlignRight
157+ verticalAlignment: Image.AlignTop
104158 }
105159
106160 GenericScopeView {
@@ -114,6 +168,7 @@ Showable {
114168 hasBackAction: true
115169 isCurrent: visible
116170 onBackClicked: {
171+ // TODO if coming from dash overview this needs to go to overview
117172 closeOverlayScope();
118173 closePreview();
119174 }
@@ -128,4 +183,31 @@ Showable {
128183 }
129184 }
130185 }
186+
187+ EdgeDragArea {
188+ id: overviewDragHandle
189+ direction: Direction.Upwards
190+ distanceThreshold: units.gu(20)
191+ enabled: !overviewController.accepted || dragging
192+
193+ anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
194+ height: units.gu(2)
195+
196+ onSceneDistanceChanged: {
197+ overviewController.enableAnimation = false;
198+ overviewController.progress = Math.min(1, sceneDistance / distanceThreshold);
199+ }
200+
201+ onStatusChanged: {
202+ if (status == DirectionalDragArea.Recognized) {
203+ overviewController.accepted = true;
204+ }
205+ }
206+
207+ onDraggingChanged: {
208+ overviewController.enableAnimation = true;
209+ overviewController.progress = overviewController.accepted ? 1 : 0;
210+ }
211+ }
212+
131213}
qml/Dash/DashContent.qml−64
@@ -16,7 +16,6 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19−import Ubuntu.Gestures 0.1
2019import Unity 0.2
2120import Utils 0.1
2221import "../Components"
@@ -27,7 +26,6 @@ Item {
2726 property var model: null
2827 property var scopes: null
2928 readonly property alias currentIndex: dashContentList.currentIndex
30− property alias overviewHandleHeight: overviewDragHandle.height
3129
3230 signal scopeLoaded(string scopeId)
3331 signal gotoScope(string scopeId)
@@ -85,39 +83,11 @@ Item {
8583 dashContentList.currentItem.theScope.closeScope(scope)
8684 }
8785
88− QtObject {
89− id: overviewController
90−
91− property bool accepted: false
92− property bool enableAnimation: false
93− property real progress: 0
94− }
95−
96− ScopesOverview {
97− id: scopesOverview
98− anchors.fill: parent
99− scope: scopes ? scopes.getScope("scopesOverview") : null
100− progress: overviewController.progress
101− scopeScale: dashContentListHolder.scale
102− onDone: hide();
103− onFavoriteSelected: {
104− dashContentList.currentIndex = index;
105− hide();
106− }
107− function hide() {
108− overviewController.enableAnimation = true;
109− overviewController.progress = 0;
110− overviewController.accepted = false;
111− }
112− }
113−
11486 Item {
11587 id: dashContentListHolder
11688
11789 anchors.fill: parent
11890
119− enabled: scale == 1
120−
12191 Image {
12292 anchors.fill: parent
12393 source: parent.width > parent.height ? "graphics/paper_landscape.png" : "graphics/paper_portrait.png"
@@ -201,39 +171,5 @@ Item {
201171 Component.onDestruction: active = false
202172 }
203173 }
204−
205− opacity: 1 - overviewController.progress
206− scale: 1 - overviewController.progress * 0.6
207− Behavior on scale {
208− id: dashContentScaleAnimation
209− enabled: overviewController.enableAnimation
210− UbuntuNumberAnimation { }
211− }
212− }
213−
214− EdgeDragArea {
215− id: overviewDragHandle
216− direction: Direction.Upwards
217− distanceThreshold: units.gu(20)
218− enabled: !overviewController.accepted || dragging
219−
220− anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
221− height: units.gu(2)
222−
223− onSceneDistanceChanged: {
224− overviewController.enableAnimation = false;
225− overviewController.progress = Math.min(1, sceneDistance / distanceThreshold);
226− }
227−
228− onStatusChanged: {
229− if (status == DirectionalDragArea.Recognized) {
230− overviewController.accepted = true;
231− }
232− }
233−
234− onDraggingChanged: {
235− overviewController.enableAnimation = true;
236− overviewController.progress = overviewController.accepted ? 1 : 0;
237− }
238174 }
239175}
qml/Dash/ScopesOverview.qml+7−1
@@ -205,7 +205,13 @@ Item {
205205 Connections {
206206 target: loader.item
207207 onClicked: {
208− if (tabBarHolder.currentTab == 0) root.favoriteSelected(index)
208+ if (tabBarHolder.currentTab == 0) {
209+ root.favoriteSelected(index)
210+ } else {
211+ // This will result in an openScope
212+ // that we handle in Dash.qml
213+ scope.activate(result)
214+ }
209215 }
210216 }
211217 }
tests/mocks/Unity/fake_scope.cpp−1
@@ -167,7 +167,6 @@ void Scope::cancelActivation()
167167
168168void Scope::closeScope(unity::shell::scopes::ScopeInterface* /*scope*/)
169169{
170− qFatal("Scope::closeScope is not implemented");
171170}
172171
173172QString Scope::currentDepartmentId() const
tests/mocks/Unity/fake_scopesoverview.cpp+12−1
@@ -27,6 +27,14 @@ ScopesOverview::ScopesOverview(Scopes* parent)
2727 m_categories = new ScopesOverviewCategories(parent, this);
2828}
2929
30+void ScopesOverview::activate(QVariant const& result)
31+{
32+ Scopes *scopes = dynamic_cast<Scopes*>(parent());
33+ Q_EMIT openScope(scopes->getScope(result.toString()));
34+}
35+
36+
37+
3038ScopesOverviewCategories::ScopesOverviewCategories(Scopes *scopes, QObject* parent)
3139 : unity::shell::scopes::CategoriesInterface(parent)
3240 , m_scopes(scopes)
@@ -98,6 +106,8 @@ ScopesOverviewCategories::data(const QModelIndex& index, int role) const
98106 }
99107}
100108
109+
110+
101111ScopesOverviewResultsModel::ScopesOverviewResultsModel(Scopes *scopes, bool isFavoriteCategory, QObject* parent)
102112 : unity::shell::scopes::ResultsModelInterface(parent)
103113 , m_scopes(scopes)
@@ -134,8 +144,9 @@ ScopesOverviewResultsModel::data(const QModelIndex& index, int role) const
134144 case RoleUri:
135145 case RoleCategoryId:
136146 case RoleDndUri:
137− case RoleResult:
138147 return QString();
148+ case RoleResult:
149+ return m_scopes->scopeAt(index.row(), m_isFavoriteCategory)->id();
139150 case RoleTitle:
140151 return m_scopes->scopeAt(index.row(), m_isFavoriteCategory)->name();
141152 case RoleArt:
tests/mocks/Unity/fake_scopesoverview.h+2
@@ -28,6 +28,8 @@ class ScopesOverview : public Scope
2828
2929public:
3030 ScopesOverview(Scopes* parent = 0);
31+
32+ Q_INVOKABLE void activate(QVariant const& result) override;
3133};
3234
3335class ScopesOverviewCategories : public unity::shell::scopes::CategoriesInterface