on xenial help sign in
Move stuff up to Dash and some more wiring
c2a4223Albert Astals
qml/Dash/Dash.qml+84−2
@@ -16,6 +16,7 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19+import Ubuntu.Gestures 0.1
19import Unity 0.2
20import Unity 0.2
20import Utils 0.1
21import Utils 0.1
21import "../Components"
22import "../Components"
@@ -29,7 +30,7 @@ Showable {
29 property string showScopeOnLoaded: "clickscope"
30 property string showScopeOnLoaded: "clickscope"
30 property real contentScale: 1.0
31 property real contentScale: 1.0
31
32
32− property alias overviewHandleHeight: dashContent.overviewHandleHeight
33+ property alias overviewHandleHeight: overviewDragHandle.height
33
34
34 function setCurrentScope(scopeId, animate, reset) {
35 function setCurrentScope(scopeId, animate, reset) {
35 var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId)
36 var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId)
@@ -68,6 +69,42 @@ Showable {
68 filterRegExp: RegExp("^true$")
69 filterRegExp: RegExp("^true$")
69 }
70 }
70
71
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+
71 DashContent {
108 DashContent {
72 id: dashContent
109 id: dashContent
73 objectName: "dashContent"
110 objectName: "dashContent"
@@ -89,18 +126,35 @@ Showable {
89 dash.showScopeOnLoaded = ""
126 dash.showScopeOnLoaded = ""
90 }
127 }
91 }
128 }
92− scale: dash.contentScale
129+ scale: dash.contentScale * (1 - overviewController.progress * 0.6)
93 clip: scale != 1.0 || scopeItem.visible
130 clip: scale != 1.0 || scopeItem.visible
94 Behavior on x {
131 Behavior on x {
95 UbuntuNumberAnimation {
132 UbuntuNumberAnimation {
96 onRunningChanged: {
133 onRunningChanged: {
97 if (!running && dashContent.x == 0) {
134 if (!running && dashContent.x == 0) {
135+ // TODO If it came from ScopesOverview it has to be ScopesOverview.scope.closeScope()
98 dashContent.closeScope(scopeItem.scope);
136 dashContent.closeScope(scopeItem.scope);
99 scopeItem.scope = null;
137 scopeItem.scope = null;
100 }
138 }
101 }
139 }
102 }
140 }
103 }
141 }
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
104 }
158 }
105
159
106 GenericScopeView {
160 GenericScopeView {
@@ -114,6 +168,7 @@ Showable {
114 hasBackAction: true
168 hasBackAction: true
115 isCurrent: visible
169 isCurrent: visible
116 onBackClicked: {
170 onBackClicked: {
171+ // TODO if coming from dash overview this needs to go to overview
117 closeOverlayScope();
172 closeOverlayScope();
118 closePreview();
173 closePreview();
119 }
174 }
@@ -128,4 +183,31 @@ Showable {
128 }
183 }
129 }
184 }
130 }
185 }
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+
131}
213}
qml/Dash/DashContent.qml−64
@@ -16,7 +16,6 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19−import Ubuntu.Gestures 0.1
20import Unity 0.2
19import Unity 0.2
21import Utils 0.1
20import Utils 0.1
22import "../Components"
21import "../Components"
@@ -27,7 +26,6 @@ Item {
27 property var model: null
26 property var model: null
28 property var scopes: null
27 property var scopes: null
29 readonly property alias currentIndex: dashContentList.currentIndex
28 readonly property alias currentIndex: dashContentList.currentIndex
30− property alias overviewHandleHeight: overviewDragHandle.height
31
29
32 signal scopeLoaded(string scopeId)
30 signal scopeLoaded(string scopeId)
33 signal gotoScope(string scopeId)
31 signal gotoScope(string scopeId)
@@ -85,39 +83,11 @@ Item {
85 dashContentList.currentItem.theScope.closeScope(scope)
83 dashContentList.currentItem.theScope.closeScope(scope)
86 }
84 }
87
85
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−
114 Item {
86 Item {
115 id: dashContentListHolder
87 id: dashContentListHolder
116
88
117 anchors.fill: parent
89 anchors.fill: parent
118
90
119− enabled: scale == 1
120−
121 Image {
91 Image {
122 anchors.fill: parent
92 anchors.fill: parent
123 source: parent.width > parent.height ? "graphics/paper_landscape.png" : "graphics/paper_portrait.png"
93 source: parent.width > parent.height ? "graphics/paper_landscape.png" : "graphics/paper_portrait.png"
@@ -201,39 +171,5 @@ Item {
201 Component.onDestruction: active = false
171 Component.onDestruction: active = false
202 }
172 }
203 }
173 }
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− }
238 }
174 }
239}
175}
qml/Dash/ScopesOverview.qml+7−1
@@ -205,7 +205,13 @@ Item {
205 Connections {
205 Connections {
206 target: loader.item
206 target: loader.item
207 onClicked: {
207 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+ }
209 }
215 }
210 }
216 }
211 }
217 }
tests/mocks/Unity/fake_scope.cpp−1
@@ -167,7 +167,6 @@ void Scope::cancelActivation()
167
167
168void Scope::closeScope(unity::shell::scopes::ScopeInterface* /*scope*/)
168void Scope::closeScope(unity::shell::scopes::ScopeInterface* /*scope*/)
169{
169{
170− qFatal("Scope::closeScope is not implemented");
171}
170}
172
171
173QString Scope::currentDepartmentId() const
172QString Scope::currentDepartmentId() const
tests/mocks/Unity/fake_scopesoverview.cpp+12−1
@@ -27,6 +27,14 @@ ScopesOverview::ScopesOverview(Scopes* parent)
27 m_categories = new ScopesOverviewCategories(parent, this);
27 m_categories = new ScopesOverviewCategories(parent, this);
28}
28}
29
29
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+
30ScopesOverviewCategories::ScopesOverviewCategories(Scopes *scopes, QObject* parent)
38ScopesOverviewCategories::ScopesOverviewCategories(Scopes *scopes, QObject* parent)
31 : unity::shell::scopes::CategoriesInterface(parent)
39 : unity::shell::scopes::CategoriesInterface(parent)
32 , m_scopes(scopes)
40 , m_scopes(scopes)
@@ -98,6 +106,8 @@ ScopesOverviewCategories::data(const QModelIndex& index, int role) const
98 }
106 }
99}
107}
100
108
109+
110+
101ScopesOverviewResultsModel::ScopesOverviewResultsModel(Scopes *scopes, bool isFavoriteCategory, QObject* parent)
111ScopesOverviewResultsModel::ScopesOverviewResultsModel(Scopes *scopes, bool isFavoriteCategory, QObject* parent)
102 : unity::shell::scopes::ResultsModelInterface(parent)
112 : unity::shell::scopes::ResultsModelInterface(parent)
103 , m_scopes(scopes)
113 , m_scopes(scopes)
@@ -134,8 +144,9 @@ ScopesOverviewResultsModel::data(const QModelIndex& index, int role) const
134 case RoleUri:
144 case RoleUri:
135 case RoleCategoryId:
145 case RoleCategoryId:
136 case RoleDndUri:
146 case RoleDndUri:
137− case RoleResult:
138 return QString();
147 return QString();
148+ case RoleResult:
149+ return m_scopes->scopeAt(index.row(), m_isFavoriteCategory)->id();
139 case RoleTitle:
150 case RoleTitle:
140 return m_scopes->scopeAt(index.row(), m_isFavoriteCategory)->name();
151 return m_scopes->scopeAt(index.row(), m_isFavoriteCategory)->name();
141 case RoleArt:
152 case RoleArt:
tests/mocks/Unity/fake_scopesoverview.h+2
@@ -28,6 +28,8 @@ class ScopesOverview : public Scope
28
28
29public:
29public:
30 ScopesOverview(Scopes* parent = 0);
30 ScopesOverview(Scopes* parent = 0);
31+
32+ Q_INVOKABLE void activate(QVariant const& result) override;
31};
33};
32
34
33class ScopesOverviewCategories : public unity::shell::scopes::CategoriesInterface
35class ScopesOverviewCategories : public unity::shell::scopes::CategoriesInterface