Merge lp:~paulliu/unity8/addrenderer into lp:unity8

Proposed by Ying-Chun Liu
Status: Merged
Approved by: Daniel d'Andrada
Approved revision: 116
Merged at revision: 121
Proposed branch: lp:~paulliu/unity8/addrenderer
Merge into: lp:unity8
Diff against target: 336 lines (+231/-42)
5 files modified
Components/Carousel.qml (+38/-1)
Dash/Generic/GenericCarousel.qml (+58/-0)
Dash/Generic/GenericFilterGrid.qml (+59/-0)
Dash/Generic/GenericFilterGridPotrait.qml (+30/-0)
Dash/GenericScopeView.qml (+46/-41)
To merge this branch: bzr merge lp:~paulliu/unity8/addrenderer
Reviewer Review Type Date Requested Status
Daniel d'Andrada (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+175028@code.launchpad.net

Commit message

Let GenericScope support loading different renderers.

Description of the change

Let GenericScope supports loading different renderers.

To post a comment you must log in.
lp:~paulliu/unity8/addrenderer updated
112. By Ying-Chun Liu

Modify Filter grid to rectangle.
Add Potrait filter grid for videos.

113. By Ying-Chun Liu

rename video -> generic

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~paulliu/unity8/addrenderer updated
114. By Ying-Chun Liu

Use IconUtil for Carousel.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Some minor stuff
================

According to our coding guidelines, in javascript code you should end statements with ";". Even though that file doesn't follow the guidelines, I think we must start rectifying it by making new code comply.

------------------------------------------------------

+++ Components/Carousel.qml 2013-07-16 14:11:33 +0000
@@ -52,6 +52,12 @@ Item {
     /// @param itemY is y of the clicked delegate
     signal clicked(int index, var delegateItem, real itemY)

+ /// Emitted when the user pressAndHold on an item
+ /// @param index is the index of the clicked item
+ /// @param delegateItem is the clicked component/delegate itself
+ /// @param itemY is y of the clicked delegate

The documentation of the parameters tell about a "clicked item". But the item wasn't clicked (it's a long press).

------------------------------------------------------

+ /* We're pressAndHold the selected item and

Syntax is not right. Looks like you just copy-pasted and then s/click*/pressAndHold.

Will continue the review tomorrow.

review: Needs Fixing
lp:~paulliu/unity8/addrenderer updated
115. By Ying-Chun Liu

fix comments

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

apart from that, code looks ok.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~paulliu/unity8/addrenderer updated
116. By Ying-Chun Liu

Add semi-colon to javascript code.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) :
review: Approve
Revision history for this message
Daniel d'Andrada (dandrader) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Components/Carousel.qml'
--- Components/Carousel.qml 2013-06-12 08:28:15 +0000
+++ Components/Carousel.qml 2013-07-17 16:28:25 +0000
@@ -52,6 +52,12 @@
52 /// @param itemY is y of the clicked delegate52 /// @param itemY is y of the clicked delegate
53 signal clicked(int index, var delegateItem, real itemY)53 signal clicked(int index, var delegateItem, real itemY)
5454
55 /// Emitted when the user pressed and held on an item
56 /// @param index is the index of the held item
57 /// @param delegateItem is the held component/delegate itself
58 /// @param itemY is y of the held delegate
59 signal pressAndHold(int index, var delegateItem, real itemY)
60
55 implicitHeight: listView.tileHeight * selectedItemScaleFactor61 implicitHeight: listView.tileHeight * selectedItemScaleFactor
5662
57 /* Basic idea behind the carousel effect is to move the items of the delegates (compacting /stuffing them).63 /* Basic idea behind the carousel effect is to move the items of the delegates (compacting /stuffing them).
@@ -159,6 +165,30 @@
159 newContentXAnimation.start()165 newContentXAnimation.start()
160 }166 }
161167
168 function itemPressAndHold(index, delegateItem) {
169 var x = CarouselJS.getXFromContinuousIndex(index,
170 realWidth,
171 realContentWidth,
172 tileWidth,
173 gapToMiddlePhase,
174 gapToEndPhase,
175 carousel.drawBuffer);
176
177 if (Math.abs(x - contentX) < 1) {
178 /* We're pressAndHold the selected item and
179 we're in the neighbourhood of radius 1 pixel from it.
180 Let's emit the pressAndHold signal. */
181 carousel.pressAndHold(index, delegateItem, delegateItem.y);
182 return;
183 }
184
185 stepAnimation.stop();
186 newContentXAnimation.stop();
187
188 newContentX = x;
189 newContentXAnimation.start();
190 }
191
162 onMovementStarted: {192 onMovementStarted: {
163 stepAnimation.stop()193 stepAnimation.stop()
164 newContentXAnimation.stop()194 newContentXAnimation.stop()
@@ -279,7 +309,14 @@
279309
280 anchors.fill: parent310 anchors.fill: parent
281311
282 onClicked: listView.itemClicked(index, item)312 onClicked: {
313 listView.itemClicked(index, item)
314 }
315
316 onPressAndHold: {
317 listView.itemPressAndHold(index, item)
318 }
319
283 }320 }
284 }321 }
285 }322 }
286323
=== added file 'Dash/Generic/GenericCarousel.qml'
--- Dash/Generic/GenericCarousel.qml 1970-01-01 00:00:00 +0000
+++ Dash/Generic/GenericCarousel.qml 2013-07-17 16:28:25 +0000
@@ -0,0 +1,58 @@
1/*
2 * Copyright (C) 2013 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.0
18import Ubuntu.Components 0.1
19import "../../Components"
20import "../../Components/IconUtil.js" as IconUtil
21
22Carousel {
23 id: genericCarousel
24
25 tileAspectRatio: 198 / 288
26 minimumTileWidth: units.gu(13)
27 itemComponent: carouselDelegateGeneric
28 selectedItemScaleFactor: 1.14
29 cacheBuffer: 1404 // 18px * 13gu * 6
30 height: implicitHeight + units.gu(6)
31
32 Component {
33 id: carouselDelegateGeneric
34
35 BaseCarouselDelegate {
36 id: item
37
38 UbuntuShape {
39 anchors.fill: parent
40 radius: "medium"
41 borderSource: ""
42 image: Image {
43 asynchronous: true
44 sourceSize { width: item.width; height: item.height }
45 source: model ? IconUtil.from_gicon(model.icon) : ""
46 }
47 }
48
49 BorderImage {
50 anchors.centerIn: parent
51 opacity: 0.6
52 source: "../../Components/graphics/non-selected.sci"
53 width: parent.width + units.gu(1.5)
54 height: parent.height + units.gu(1.5)
55 }
56 }
57 }
58}
059
=== added file 'Dash/Generic/GenericFilterGrid.qml'
--- Dash/Generic/GenericFilterGrid.qml 1970-01-01 00:00:00 +0000
+++ Dash/Generic/GenericFilterGrid.qml 2013-07-17 16:28:25 +0000
@@ -0,0 +1,59 @@
1/*
2 * Copyright (C) 2013 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.0
18import "../../Components"
19import "../../Components/IconUtil.js" as IconUtil
20
21FilterGrid {
22 id: filtergrid
23
24 filter: false
25 minimumHorizontalSpacing: units.gu(0.5)
26 delegateWidth: units.gu(11)
27 delegateHeight: units.gu(9.5)
28 verticalSpacing: units.gu(2)
29
30 property int iconWidth: units.gu(8)
31 property int iconHeight: units.gu(7.5)
32
33 signal clicked(int index, var delegateItem, real itemY)
34 signal pressAndHold(int index, var delegateItem, real itemY)
35
36 delegate: Tile {
37 id: tile
38 objectName: "delegate" + index
39 width: filtergrid.cellWidth
40 height: filtergrid.cellHeight
41 text: model.title
42 imageWidth: filtergrid.iconWidth
43 imageHeight: filtergrid.iconHeight
44
45 source: IconUtil.from_gicon(model.icon)
46
47 fillMode: Image.PreserveAspectCrop
48
49 onClicked: {
50 var data = { model: model }
51 filtergrid.clicked(index, data, tile.y)
52 }
53
54 onPressAndHold: {
55 var data = { model: model }
56 filtergrid.pressAndHold(index, data, tile.y)
57 }
58 }
59}
060
=== added file 'Dash/Generic/GenericFilterGridPotrait.qml'
--- Dash/Generic/GenericFilterGridPotrait.qml 1970-01-01 00:00:00 +0000
+++ Dash/Generic/GenericFilterGridPotrait.qml 2013-07-17 16:28:25 +0000
@@ -0,0 +1,30 @@
1/*
2 * Copyright (C) 2013 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.0
18import "../../Components"
19
20GenericFilterGrid {
21 id: filtergrid
22
23 minimumHorizontalSpacing: units.gu(0.5)
24 delegateWidth: units.gu(11)
25 delegateHeight: units.gu(18)
26 verticalSpacing: units.gu(2)
27
28 iconWidth: (width / columns) * 0.8
29 iconHeight: iconWidth * 16 / 11
30}
031
=== modified file 'Dash/GenericScopeView.qml'
--- Dash/GenericScopeView.qml 2013-07-10 12:58:58 +0000
+++ Dash/GenericScopeView.qml 2013-07-17 16:28:25 +0000
@@ -56,53 +56,45 @@
56 delegate: ListItems.Base {56 delegate: ListItems.Base {
57 highlightWhenPressed: false57 highlightWhenPressed: false
5858
59 FilterGrid {59 Loader {
60 id: filtergrid60 id: rendererLoader
61 model: results
62
63 anchors {61 anchors {
64 top: parent.top62 top: parent.top
65 left: parent.left63 left: parent.left
66 right: parent.right64 right: parent.right
67 }65 }
6866
69 filter: false67 source: getRenderer(model.renderer, model.contentType)
70 minimumHorizontalSpacing: units.gu(0.5)68
71 delegateWidth: units.gu(11)69 onLoaded: {
72 delegateHeight: units.gu(18)70 item.model = results
73 verticalSpacing: units.gu(2)71 }
7472
75 delegate: Tile {73 Connections {
76 width: filtergrid.cellWidth74 target: rendererLoader.item
77 height: filtergrid.cellHeight75 onClicked: {
78 text: title76 effect.positionPx = mapToItem(categoryView, 0, itemY).y
79 imageWidth: units.gu(11)77 scopeView.scope.activate(delegateItem.model.uri,
80 imageHeight: units.gu(16)78 delegateItem.model.icon,
8179 delegateItem.model.category,
82 source: IconUtil.from_gicon(icon)80 0,
8381 delegateItem.model.mimetype,
84 MouseArea {82 delegateItem.model.title,
85 anchors {83 delegateItem.model.comment,
86 fill: parent84 delegateItem.model.dndUri,
87 }85 delegateItem.model.metadata)
88 onClicked: {86 }
89 mouse.accepted = true87 onPressAndHold: {
90 effect.positionPx = mapToItem(categoryView, 0, 0).y88 effect.positionPx = mapToItem(categoryView, 0, itemY).y
91 scopeView.scope.activate(uri, icon,89 scopeView.scope.preview( delegateItem.model.uri,
92 category, 0,90 delegateItem.model.icon,
93 mimetype, title,91 delegateItem.model.category,
94 comment, dndUri,92 0,
95 metadata)93 delegateItem.model.mimetype,
96 }94 delegateItem.model.title,
97 onPressAndHold: {95 delegateItem.model.comment,
98 mouse.accepted = true96 delegateItem.model.dndUri,
99 effect.positionPx = mapToItem(categoryView, 0, 0).y97 delegateItem.model.metadata)
100 scopeView.scope.preview(uri, icon,
101 category, 0,
102 mimetype, title,
103 comment, dndUri,
104 metadata)
105 }
106 }98 }
107 }99 }
108 }100 }
@@ -122,6 +114,19 @@
122 }114 }
123 }115 }
124116
117 function getRenderer(rendererId, contentType) {
118 switch (rendererId) {
119 case "grid": {
120 switch (contentType) {
121 case "video": return "Generic/GenericFilterGridPotrait.qml";
122 default: return "Generic/GenericFilterGrid.qml";
123 }
124 }
125 case "carousel": return "Generic/GenericCarousel.qml";
126 default: return "Generic/GenericFilterGrid.qml";
127 }
128 }
129
125 OpenEffect {130 OpenEffect {
126 id: effect131 id: effect
127 anchors {132 anchors {

Subscribers

People subscribed via source and target branches