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 on 2013-07-16

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

113. By Ying-Chun Liu on 2013-07-16

rename video -> generic

lp:~paulliu/unity8/addrenderer updated
114. By Ying-Chun Liu on 2013-07-16

Use IconUtil for Carousel.

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 on 2013-07-17

fix comments

Daniel d'Andrada (dandrader) wrote :

apart from that, code looks ok.

lp:~paulliu/unity8/addrenderer updated
116. By Ying-Chun Liu on 2013-07-17

Add semi-colon to javascript code.

review: Approve
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Components/Carousel.qml'
2--- Components/Carousel.qml 2013-06-12 08:28:15 +0000
3+++ Components/Carousel.qml 2013-07-17 16:28:25 +0000
4@@ -52,6 +52,12 @@
5 /// @param itemY is y of the clicked delegate
6 signal clicked(int index, var delegateItem, real itemY)
7
8+ /// Emitted when the user pressed and held on an item
9+ /// @param index is the index of the held item
10+ /// @param delegateItem is the held component/delegate itself
11+ /// @param itemY is y of the held delegate
12+ signal pressAndHold(int index, var delegateItem, real itemY)
13+
14 implicitHeight: listView.tileHeight * selectedItemScaleFactor
15
16 /* Basic idea behind the carousel effect is to move the items of the delegates (compacting /stuffing them).
17@@ -159,6 +165,30 @@
18 newContentXAnimation.start()
19 }
20
21+ function itemPressAndHold(index, delegateItem) {
22+ var x = CarouselJS.getXFromContinuousIndex(index,
23+ realWidth,
24+ realContentWidth,
25+ tileWidth,
26+ gapToMiddlePhase,
27+ gapToEndPhase,
28+ carousel.drawBuffer);
29+
30+ if (Math.abs(x - contentX) < 1) {
31+ /* We're pressAndHold the selected item and
32+ we're in the neighbourhood of radius 1 pixel from it.
33+ Let's emit the pressAndHold signal. */
34+ carousel.pressAndHold(index, delegateItem, delegateItem.y);
35+ return;
36+ }
37+
38+ stepAnimation.stop();
39+ newContentXAnimation.stop();
40+
41+ newContentX = x;
42+ newContentXAnimation.start();
43+ }
44+
45 onMovementStarted: {
46 stepAnimation.stop()
47 newContentXAnimation.stop()
48@@ -279,7 +309,14 @@
49
50 anchors.fill: parent
51
52- onClicked: listView.itemClicked(index, item)
53+ onClicked: {
54+ listView.itemClicked(index, item)
55+ }
56+
57+ onPressAndHold: {
58+ listView.itemPressAndHold(index, item)
59+ }
60+
61 }
62 }
63 }
64
65=== added file 'Dash/Generic/GenericCarousel.qml'
66--- Dash/Generic/GenericCarousel.qml 1970-01-01 00:00:00 +0000
67+++ Dash/Generic/GenericCarousel.qml 2013-07-17 16:28:25 +0000
68@@ -0,0 +1,58 @@
69+/*
70+ * Copyright (C) 2013 Canonical, Ltd.
71+ *
72+ * This program is free software; you can redistribute it and/or modify
73+ * it under the terms of the GNU General Public License as published by
74+ * the Free Software Foundation; version 3.
75+ *
76+ * This program is distributed in the hope that it will be useful,
77+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
78+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
79+ * GNU General Public License for more details.
80+ *
81+ * You should have received a copy of the GNU General Public License
82+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
83+ */
84+
85+import QtQuick 2.0
86+import Ubuntu.Components 0.1
87+import "../../Components"
88+import "../../Components/IconUtil.js" as IconUtil
89+
90+Carousel {
91+ id: genericCarousel
92+
93+ tileAspectRatio: 198 / 288
94+ minimumTileWidth: units.gu(13)
95+ itemComponent: carouselDelegateGeneric
96+ selectedItemScaleFactor: 1.14
97+ cacheBuffer: 1404 // 18px * 13gu * 6
98+ height: implicitHeight + units.gu(6)
99+
100+ Component {
101+ id: carouselDelegateGeneric
102+
103+ BaseCarouselDelegate {
104+ id: item
105+
106+ UbuntuShape {
107+ anchors.fill: parent
108+ radius: "medium"
109+ borderSource: ""
110+ image: Image {
111+ asynchronous: true
112+ sourceSize { width: item.width; height: item.height }
113+ source: model ? IconUtil.from_gicon(model.icon) : ""
114+ }
115+ }
116+
117+ BorderImage {
118+ anchors.centerIn: parent
119+ opacity: 0.6
120+ source: "../../Components/graphics/non-selected.sci"
121+ width: parent.width + units.gu(1.5)
122+ height: parent.height + units.gu(1.5)
123+ }
124+ }
125+ }
126+}
127
128=== added file 'Dash/Generic/GenericFilterGrid.qml'
129--- Dash/Generic/GenericFilterGrid.qml 1970-01-01 00:00:00 +0000
130+++ Dash/Generic/GenericFilterGrid.qml 2013-07-17 16:28:25 +0000
131@@ -0,0 +1,59 @@
132+/*
133+ * Copyright (C) 2013 Canonical, Ltd.
134+ *
135+ * This program is free software; you can redistribute it and/or modify
136+ * it under the terms of the GNU General Public License as published by
137+ * the Free Software Foundation; version 3.
138+ *
139+ * This program is distributed in the hope that it will be useful,
140+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
141+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
142+ * GNU General Public License for more details.
143+ *
144+ * You should have received a copy of the GNU General Public License
145+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
146+ */
147+
148+import QtQuick 2.0
149+import "../../Components"
150+import "../../Components/IconUtil.js" as IconUtil
151+
152+FilterGrid {
153+ id: filtergrid
154+
155+ filter: false
156+ minimumHorizontalSpacing: units.gu(0.5)
157+ delegateWidth: units.gu(11)
158+ delegateHeight: units.gu(9.5)
159+ verticalSpacing: units.gu(2)
160+
161+ property int iconWidth: units.gu(8)
162+ property int iconHeight: units.gu(7.5)
163+
164+ signal clicked(int index, var delegateItem, real itemY)
165+ signal pressAndHold(int index, var delegateItem, real itemY)
166+
167+ delegate: Tile {
168+ id: tile
169+ objectName: "delegate" + index
170+ width: filtergrid.cellWidth
171+ height: filtergrid.cellHeight
172+ text: model.title
173+ imageWidth: filtergrid.iconWidth
174+ imageHeight: filtergrid.iconHeight
175+
176+ source: IconUtil.from_gicon(model.icon)
177+
178+ fillMode: Image.PreserveAspectCrop
179+
180+ onClicked: {
181+ var data = { model: model }
182+ filtergrid.clicked(index, data, tile.y)
183+ }
184+
185+ onPressAndHold: {
186+ var data = { model: model }
187+ filtergrid.pressAndHold(index, data, tile.y)
188+ }
189+ }
190+}
191
192=== added file 'Dash/Generic/GenericFilterGridPotrait.qml'
193--- Dash/Generic/GenericFilterGridPotrait.qml 1970-01-01 00:00:00 +0000
194+++ Dash/Generic/GenericFilterGridPotrait.qml 2013-07-17 16:28:25 +0000
195@@ -0,0 +1,30 @@
196+/*
197+ * Copyright (C) 2013 Canonical, Ltd.
198+ *
199+ * This program is free software; you can redistribute it and/or modify
200+ * it under the terms of the GNU General Public License as published by
201+ * the Free Software Foundation; version 3.
202+ *
203+ * This program is distributed in the hope that it will be useful,
204+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
205+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
206+ * GNU General Public License for more details.
207+ *
208+ * You should have received a copy of the GNU General Public License
209+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
210+ */
211+
212+import QtQuick 2.0
213+import "../../Components"
214+
215+GenericFilterGrid {
216+ id: filtergrid
217+
218+ minimumHorizontalSpacing: units.gu(0.5)
219+ delegateWidth: units.gu(11)
220+ delegateHeight: units.gu(18)
221+ verticalSpacing: units.gu(2)
222+
223+ iconWidth: (width / columns) * 0.8
224+ iconHeight: iconWidth * 16 / 11
225+}
226
227=== modified file 'Dash/GenericScopeView.qml'
228--- Dash/GenericScopeView.qml 2013-07-10 12:58:58 +0000
229+++ Dash/GenericScopeView.qml 2013-07-17 16:28:25 +0000
230@@ -56,53 +56,45 @@
231 delegate: ListItems.Base {
232 highlightWhenPressed: false
233
234- FilterGrid {
235- id: filtergrid
236- model: results
237-
238+ Loader {
239+ id: rendererLoader
240 anchors {
241 top: parent.top
242 left: parent.left
243 right: parent.right
244 }
245
246- filter: false
247- minimumHorizontalSpacing: units.gu(0.5)
248- delegateWidth: units.gu(11)
249- delegateHeight: units.gu(18)
250- verticalSpacing: units.gu(2)
251-
252- delegate: Tile {
253- width: filtergrid.cellWidth
254- height: filtergrid.cellHeight
255- text: title
256- imageWidth: units.gu(11)
257- imageHeight: units.gu(16)
258-
259- source: IconUtil.from_gicon(icon)
260-
261- MouseArea {
262- anchors {
263- fill: parent
264- }
265- onClicked: {
266- mouse.accepted = true
267- effect.positionPx = mapToItem(categoryView, 0, 0).y
268- scopeView.scope.activate(uri, icon,
269- category, 0,
270- mimetype, title,
271- comment, dndUri,
272- metadata)
273- }
274- onPressAndHold: {
275- mouse.accepted = true
276- effect.positionPx = mapToItem(categoryView, 0, 0).y
277- scopeView.scope.preview(uri, icon,
278- category, 0,
279- mimetype, title,
280- comment, dndUri,
281- metadata)
282- }
283+ source: getRenderer(model.renderer, model.contentType)
284+
285+ onLoaded: {
286+ item.model = results
287+ }
288+
289+ Connections {
290+ target: rendererLoader.item
291+ onClicked: {
292+ effect.positionPx = mapToItem(categoryView, 0, itemY).y
293+ scopeView.scope.activate(delegateItem.model.uri,
294+ delegateItem.model.icon,
295+ delegateItem.model.category,
296+ 0,
297+ delegateItem.model.mimetype,
298+ delegateItem.model.title,
299+ delegateItem.model.comment,
300+ delegateItem.model.dndUri,
301+ delegateItem.model.metadata)
302+ }
303+ onPressAndHold: {
304+ effect.positionPx = mapToItem(categoryView, 0, itemY).y
305+ scopeView.scope.preview( delegateItem.model.uri,
306+ delegateItem.model.icon,
307+ delegateItem.model.category,
308+ 0,
309+ delegateItem.model.mimetype,
310+ delegateItem.model.title,
311+ delegateItem.model.comment,
312+ delegateItem.model.dndUri,
313+ delegateItem.model.metadata)
314 }
315 }
316 }
317@@ -122,6 +114,19 @@
318 }
319 }
320
321+ function getRenderer(rendererId, contentType) {
322+ switch (rendererId) {
323+ case "grid": {
324+ switch (contentType) {
325+ case "video": return "Generic/GenericFilterGridPotrait.qml";
326+ default: return "Generic/GenericFilterGrid.qml";
327+ }
328+ }
329+ case "carousel": return "Generic/GenericCarousel.qml";
330+ default: return "Generic/GenericFilterGrid.qml";
331+ }
332+ }
333+
334 OpenEffect {
335 id: effect
336 anchors {

Subscribers

People subscribed via source and target branches