Merge lp:~mterry/unity8/pull-to-refresh-scope into lp:unity8

Proposed by Michael Terry
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 1293
Merged at revision: 1330
Proposed branch: lp:~mterry/unity8/pull-to-refresh-scope
Merge into: lp:unity8
Diff against target: 237 lines (+153/-4)
6 files modified
po/unity8.pot (+10/-2)
qml/Dash/GenericScopeView.qml (+36/-1)
qml/Dash/PullToRefreshScopeStyle.qml (+82/-0)
tests/mocks/Unity/fake_scope.cpp (+1/-1)
tests/mocks/Unity/fake_scope.h (+3/-0)
tests/qmltests/Dash/tst_GenericScopeView.qml (+21/-0)
To merge this branch: bzr merge lp:~mterry/unity8/pull-to-refresh-scope
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Albert Astals Cid (community) Approve
James Mulholland Pending
Review via email: mp+236184@code.launchpad.net

Commit message

Add pull-to-refresh functionality to scopes.

Description of the change

Add pull-to-refresh functionality to scopes.

I used a PullToRefresh object, though it did require a manual style override to avoid the default ActivityIndicator it uses.

== Checklist ==

 * Are there any related MPs required for this MP to build/function as expected? Please list.
 No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
 Yes

 * Did you make sure that your branch does not contain spurious tags?
 Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
 NA

 * If you changed the UI, has there been a design review?
 TBD

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1289. By Michael Terry

Merge from trunk

Revision history for this message
Albert Astals Cid (aacid) wrote :

As agreed on IRC keep the code with a TODO to evaluate the use of the standard style, file the bug to the standard style to fix it and move the style code to a different file to clutter GSV less

review: Needs Fixing
1290. By Michael Terry

Break out our custom PullToRefreshStyle into its own file and add a comment about what's keeping us from using the standard version

Revision history for this message
Michael Terry (mterry) wrote :

Updated!

Revision history for this message
Albert Astals Cid (aacid) wrote :

As discussed on irc should delay a bit the refresh call until the header has gone back to its position

review: Needs Fixing
1291. By Michael Terry

Don't refresh until scope is back in place to avoid a scope-settling bug

Revision history for this message
Michael Terry (mterry) wrote :

(And fixed that header-position-refreshing issue now too)

1292. By Michael Terry

Use Item not Rectangle

1293. By Michael Terry

Update pot

Revision history for this message
Albert Astals Cid (aacid) wrote :

* Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

 * Did CI run pass? If not, please explain why.
Waiting for top approval

 * Did you make sure that the branch does not contain spurious tags?
Yes

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1294. By Michael Terry

Update from trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/unity8.pot'
2--- po/unity8.pot 2014-10-02 08:46:22 +0000
3+++ po/unity8.pot 2014-10-03 12:14:11 +0000
4@@ -8,7 +8,7 @@
5 msgstr ""
6 "Project-Id-Version: unity8\n"
7 "Report-Msgid-Bugs-To: \n"
8-"POT-Creation-Date: 2014-10-02 10:35+0200\n"
9+"POT-Creation-Date: 2014-10-03 08:13-0400\n"
10 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Language-Team: LANGUAGE <LL@li.org>\n"
13@@ -160,7 +160,7 @@
14 msgid "OK"
15 msgstr ""
16
17-#: qml/Dash/GenericScopeView.qml:411 qml/Dash/GenericScopeView.qml:533
18+#: qml/Dash/GenericScopeView.qml:411 qml/Dash/GenericScopeView.qml:568
19 msgid "See less"
20 msgstr ""
21
22@@ -205,6 +205,14 @@
23 msgid "Send"
24 msgstr ""
25
26+#: qml/Dash/PullToRefreshScopeStyle.qml:55
27+msgid "Pull to refresh…"
28+msgstr ""
29+
30+#: qml/Dash/PullToRefreshScopeStyle.qml:60
31+msgid "Release to refresh…"
32+msgstr ""
33+
34 #: qml/Dash/ScopesOverview.qml:206
35 msgid "Manage Scopes"
36 msgstr ""
37
38=== modified file 'qml/Dash/GenericScopeView.qml'
39--- qml/Dash/GenericScopeView.qml 2014-09-18 21:23:55 +0000
40+++ qml/Dash/GenericScopeView.qml 2014-10-03 12:14:11 +0000
41@@ -15,7 +15,7 @@
42 */
43
44 import QtQuick 2.0
45-import Ubuntu.Components 0.1
46+import Ubuntu.Components 1.1
47 import Utils 0.1
48 import Unity 0.2
49 import Dash 0.1
50@@ -496,6 +496,41 @@
51 }
52 }
53
54+ Item {
55+ id: pullToRefreshClippingItem
56+ anchors.left: parent.left
57+ anchors.right: parent.right
58+ anchors.bottom: parent.bottom
59+ height: parent.height - pullToRefresh.contentY + (pageHeaderLoader.item ? pageHeaderLoader.item.bottomItem[0].height - pageHeaderLoader.item.height : 0)
60+ clip: true
61+
62+ PullToRefresh {
63+ id: pullToRefresh
64+ objectName: "pullToRefresh"
65+ target: categoryView
66+
67+ readonly property real contentY: categoryView.contentY - categoryView.originY
68+ y: -contentY - units.gu(5)
69+
70+ onRefresh: {
71+ refreshing = true
72+ scopeView.scope.refresh()
73+ }
74+ anchors.left: parent.left
75+ anchors.right: parent.right
76+
77+ Connections {
78+ target: scopeView
79+ onProcessingChanged: if (!scopeView.processing) pullToRefresh.refreshing = false
80+ }
81+
82+ style: PullToRefreshScopeStyle {
83+ anchors.fill: parent
84+ activationThreshold: units.gu(14)
85+ }
86+ }
87+ }
88+
89 AbstractButton {
90 id: floatingSeeLess
91 objectName: "floatingSeeLess"
92
93=== added file 'qml/Dash/PullToRefreshScopeStyle.qml'
94--- qml/Dash/PullToRefreshScopeStyle.qml 1970-01-01 00:00:00 +0000
95+++ qml/Dash/PullToRefreshScopeStyle.qml 2014-10-03 12:14:11 +0000
96@@ -0,0 +1,82 @@
97+/*
98+ * Copyright (C) 2014 Canonical, Ltd.
99+ *
100+ * This program is free software; you can redistribute it and/or modify
101+ * it under the terms of the GNU General Public License as published by
102+ * the Free Software Foundation; version 3.
103+ *
104+ * This program is distributed in the hope that it will be useful,
105+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
106+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
107+ * GNU General Public License for more details.
108+ *
109+ * You should have received a copy of the GNU General Public License
110+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
111+ */
112+
113+import QtQuick 2.3
114+import Ubuntu.Components 1.1
115+import Ubuntu.Components.Styles 1.1
116+
117+/**
118+ * TODO: Once the SDK version of PullToRefreshStyle doesn't have bug 1375799
119+ * (https://launchpad.net/bugs/1375799) anymore, we should switch to using a
120+ * a subclass of the Ambiance version with a hidden ActivityIndicator.
121+ */
122+PullToRefreshStyle {
123+ releaseToRefresh: styledItem.target.originY - styledItem.target.contentY > activationThreshold
124+
125+ Connections {
126+ property bool willRefresh: false
127+
128+ target: styledItem.target
129+ onDraggingChanged: {
130+ if (!styledItem.target.dragging && releaseToRefresh) {
131+ willRefresh = true
132+ }
133+ }
134+ onContentYChanged: {
135+ if (styledItem.target.originY - styledItem.target.contentY == 0 && willRefresh) {
136+ styledItem.refresh()
137+ willRefresh = false
138+ }
139+ }
140+ }
141+
142+ Label {
143+ id: pullLabel
144+ anchors.horizontalCenter: parent.horizontalCenter
145+ horizontalAlignment: Text.AlignHCenter
146+ verticalAlignment: Text.AlignVCenter
147+ states: [
148+ State {
149+ name: "pulling"
150+ when: styledItem.target.dragging && !releaseToRefresh
151+ PropertyChanges { target: pullLabel; text: i18n.tr("Pull to refresh…") }
152+ },
153+ State {
154+ name: "releasable"
155+ when: styledItem.target.dragging && releaseToRefresh
156+ PropertyChanges { target: pullLabel; text: i18n.tr("Release to refresh…") }
157+ }
158+ ]
159+ transitions: Transition {
160+ SequentialAnimation {
161+ UbuntuNumberAnimation {
162+ target: pullLabel
163+ property: "opacity"
164+ to: 0.0
165+ }
166+ PropertyAction {
167+ target: pullLabel
168+ property: "text"
169+ }
170+ UbuntuNumberAnimation {
171+ target: pullLabel
172+ property: "opacity"
173+ to: 1.0
174+ }
175+ }
176+ }
177+ }
178+}
179
180=== modified file 'tests/mocks/Unity/fake_scope.cpp'
181--- tests/mocks/Unity/fake_scope.cpp 2014-09-18 21:23:55 +0000
182+++ tests/mocks/Unity/fake_scope.cpp 2014-10-03 12:14:11 +0000
183@@ -266,7 +266,7 @@
184
185 void Scope::refresh()
186 {
187- qDebug() << "Scope::refresh is currently not implmented in the fake scopes plugin";
188+ Q_EMIT refreshed();
189 }
190
191 unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
192
193=== modified file 'tests/mocks/Unity/fake_scope.h'
194--- tests/mocks/Unity/fake_scope.h 2014-09-18 21:23:55 +0000
195+++ tests/mocks/Unity/fake_scope.h 2014-10-03 12:14:11 +0000
196@@ -79,6 +79,9 @@
197
198 Q_INVOKABLE void refresh() override;
199
200+Q_SIGNALS:
201+ void refreshed(); // This is not in the Interface, here for testing benefits
202+
203 protected:
204
205 QString m_id;
206
207=== modified file 'tests/qmltests/Dash/tst_GenericScopeView.qml'
208--- tests/qmltests/Dash/tst_GenericScopeView.qml 2014-09-23 08:56:29 +0000
209+++ tests/qmltests/Dash/tst_GenericScopeView.qml 2014-10-03 12:14:11 +0000
210@@ -581,6 +581,27 @@
211
212 genericScopeView.scope = !genericScopeView.scope;
213 }
214+
215+ function test_pullToRefresh() {
216+ waitForRendering(genericScopeView)
217+
218+ mouseFlick(genericScopeView,
219+ genericScopeView.width/2, units.gu(10),
220+ genericScopeView.width/2, units.gu(80),
221+ true, false)
222+
223+ var pullToRefresh = findChild(genericScopeView, "pullToRefresh")
224+ tryCompare(pullToRefresh, "releaseToRefresh", true)
225+
226+ spy.target = genericScopeView.scope
227+ spy.signalName = "refreshed"
228+
229+ mouseRelease(genericScopeView)
230+ tryCompare(pullToRefresh, "releaseToRefresh", false)
231+
232+ spy.wait()
233+ compare(spy.count, 1)
234+ }
235 }
236 }
237 }

Subscribers

People subscribed via source and target branches