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
=== modified file 'po/unity8.pot'
--- po/unity8.pot 2014-10-02 08:46:22 +0000
+++ po/unity8.pot 2014-10-03 12:14:11 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: unity8\n"9"Project-Id-Version: unity8\n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2014-10-02 10:35+0200\n"11"POT-Creation-Date: 2014-10-03 08:13-0400\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -160,7 +160,7 @@
160msgid "OK"160msgid "OK"
161msgstr ""161msgstr ""
162162
163#: qml/Dash/GenericScopeView.qml:411 qml/Dash/GenericScopeView.qml:533163#: qml/Dash/GenericScopeView.qml:411 qml/Dash/GenericScopeView.qml:568
164msgid "See less"164msgid "See less"
165msgstr ""165msgstr ""
166166
@@ -205,6 +205,14 @@
205msgid "Send"205msgid "Send"
206msgstr ""206msgstr ""
207207
208#: qml/Dash/PullToRefreshScopeStyle.qml:55
209msgid "Pull to refresh…"
210msgstr ""
211
212#: qml/Dash/PullToRefreshScopeStyle.qml:60
213msgid "Release to refresh…"
214msgstr ""
215
208#: qml/Dash/ScopesOverview.qml:206216#: qml/Dash/ScopesOverview.qml:206
209msgid "Manage Scopes"217msgid "Manage Scopes"
210msgstr ""218msgstr ""
211219
=== modified file 'qml/Dash/GenericScopeView.qml'
--- qml/Dash/GenericScopeView.qml 2014-09-18 21:23:55 +0000
+++ qml/Dash/GenericScopeView.qml 2014-10-03 12:14:11 +0000
@@ -15,7 +15,7 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 0.118import Ubuntu.Components 1.1
19import Utils 0.119import Utils 0.1
20import Unity 0.220import Unity 0.2
21import Dash 0.121import Dash 0.1
@@ -496,6 +496,41 @@
496 }496 }
497 }497 }
498498
499 Item {
500 id: pullToRefreshClippingItem
501 anchors.left: parent.left
502 anchors.right: parent.right
503 anchors.bottom: parent.bottom
504 height: parent.height - pullToRefresh.contentY + (pageHeaderLoader.item ? pageHeaderLoader.item.bottomItem[0].height - pageHeaderLoader.item.height : 0)
505 clip: true
506
507 PullToRefresh {
508 id: pullToRefresh
509 objectName: "pullToRefresh"
510 target: categoryView
511
512 readonly property real contentY: categoryView.contentY - categoryView.originY
513 y: -contentY - units.gu(5)
514
515 onRefresh: {
516 refreshing = true
517 scopeView.scope.refresh()
518 }
519 anchors.left: parent.left
520 anchors.right: parent.right
521
522 Connections {
523 target: scopeView
524 onProcessingChanged: if (!scopeView.processing) pullToRefresh.refreshing = false
525 }
526
527 style: PullToRefreshScopeStyle {
528 anchors.fill: parent
529 activationThreshold: units.gu(14)
530 }
531 }
532 }
533
499 AbstractButton {534 AbstractButton {
500 id: floatingSeeLess535 id: floatingSeeLess
501 objectName: "floatingSeeLess"536 objectName: "floatingSeeLess"
502537
=== added file 'qml/Dash/PullToRefreshScopeStyle.qml'
--- qml/Dash/PullToRefreshScopeStyle.qml 1970-01-01 00:00:00 +0000
+++ qml/Dash/PullToRefreshScopeStyle.qml 2014-10-03 12:14:11 +0000
@@ -0,0 +1,82 @@
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
17import QtQuick 2.3
18import Ubuntu.Components 1.1
19import Ubuntu.Components.Styles 1.1
20
21/**
22 * TODO: Once the SDK version of PullToRefreshStyle doesn't have bug 1375799
23 * (https://launchpad.net/bugs/1375799) anymore, we should switch to using a
24 * a subclass of the Ambiance version with a hidden ActivityIndicator.
25 */
26PullToRefreshStyle {
27 releaseToRefresh: styledItem.target.originY - styledItem.target.contentY > activationThreshold
28
29 Connections {
30 property bool willRefresh: false
31
32 target: styledItem.target
33 onDraggingChanged: {
34 if (!styledItem.target.dragging && releaseToRefresh) {
35 willRefresh = true
36 }
37 }
38 onContentYChanged: {
39 if (styledItem.target.originY - styledItem.target.contentY == 0 && willRefresh) {
40 styledItem.refresh()
41 willRefresh = false
42 }
43 }
44 }
45
46 Label {
47 id: pullLabel
48 anchors.horizontalCenter: parent.horizontalCenter
49 horizontalAlignment: Text.AlignHCenter
50 verticalAlignment: Text.AlignVCenter
51 states: [
52 State {
53 name: "pulling"
54 when: styledItem.target.dragging && !releaseToRefresh
55 PropertyChanges { target: pullLabel; text: i18n.tr("Pull to refresh…") }
56 },
57 State {
58 name: "releasable"
59 when: styledItem.target.dragging && releaseToRefresh
60 PropertyChanges { target: pullLabel; text: i18n.tr("Release to refresh…") }
61 }
62 ]
63 transitions: Transition {
64 SequentialAnimation {
65 UbuntuNumberAnimation {
66 target: pullLabel
67 property: "opacity"
68 to: 0.0
69 }
70 PropertyAction {
71 target: pullLabel
72 property: "text"
73 }
74 UbuntuNumberAnimation {
75 target: pullLabel
76 property: "opacity"
77 to: 1.0
78 }
79 }
80 }
81 }
82}
083
=== modified file 'tests/mocks/Unity/fake_scope.cpp'
--- tests/mocks/Unity/fake_scope.cpp 2014-09-18 21:23:55 +0000
+++ tests/mocks/Unity/fake_scope.cpp 2014-10-03 12:14:11 +0000
@@ -266,7 +266,7 @@
266266
267void Scope::refresh()267void Scope::refresh()
268{268{
269 qDebug() << "Scope::refresh is currently not implmented in the fake scopes plugin";269 Q_EMIT refreshed();
270}270}
271271
272unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)272unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
273273
=== modified file 'tests/mocks/Unity/fake_scope.h'
--- tests/mocks/Unity/fake_scope.h 2014-09-18 21:23:55 +0000
+++ tests/mocks/Unity/fake_scope.h 2014-10-03 12:14:11 +0000
@@ -79,6 +79,9 @@
7979
80 Q_INVOKABLE void refresh() override;80 Q_INVOKABLE void refresh() override;
8181
82Q_SIGNALS:
83 void refreshed(); // This is not in the Interface, here for testing benefits
84
82protected:85protected:
8386
84 QString m_id;87 QString m_id;
8588
=== modified file 'tests/qmltests/Dash/tst_GenericScopeView.qml'
--- tests/qmltests/Dash/tst_GenericScopeView.qml 2014-09-23 08:56:29 +0000
+++ tests/qmltests/Dash/tst_GenericScopeView.qml 2014-10-03 12:14:11 +0000
@@ -581,6 +581,27 @@
581581
582 genericScopeView.scope = !genericScopeView.scope;582 genericScopeView.scope = !genericScopeView.scope;
583 }583 }
584
585 function test_pullToRefresh() {
586 waitForRendering(genericScopeView)
587
588 mouseFlick(genericScopeView,
589 genericScopeView.width/2, units.gu(10),
590 genericScopeView.width/2, units.gu(80),
591 true, false)
592
593 var pullToRefresh = findChild(genericScopeView, "pullToRefresh")
594 tryCompare(pullToRefresh, "releaseToRefresh", true)
595
596 spy.target = genericScopeView.scope
597 spy.signalName = "refreshed"
598
599 mouseRelease(genericScopeView)
600 tryCompare(pullToRefresh, "releaseToRefresh", false)
601
602 spy.wait()
603 compare(spy.count, 1)
604 }
584 }605 }
585 }606 }
586}607}

Subscribers

People subscribed via source and target branches