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

Proposed by Ying-Chun Liu
Status: Merged
Approved by: Michał Sawicz
Approved revision: 101
Merged at revision: 98
Proposed branch: lp:~paulliu/unity8/activate3
Merge into: lp:unity8
Diff against target: 278 lines (+237/-0)
3 files modified
Dash/Generic/GenericPreview.qml (+84/-0)
Dash/GenericScopeView.qml (+119/-0)
Dash/PreviewDelegateMapper.qml (+34/-0)
To merge this branch: bzr merge lp:~paulliu/unity8/activate3
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Daniel d'Andrada (community) Approve
Michał Sawicz Needs Fixing
Paweł Stołowski Approve
Review via email: mp+173071@code.launchpad.net

Commit message

Add Generic Preview.
Modify GenericScopeView to support activate and preview.

Description of the change

Add Generic Preview.
Modify GenericScopeView to support activate and preview.

To post a comment you must log in.
Paweł Stołowski (stolowski) wrote :

We tested this before with my activation-previews branch (that got merged already) and it worked fine. +1

review: Approve
Michal Hruby (mhr3) wrote :

113 + scopeView.scope.activate(column_0, column_1,
114 + column_2, column_3,
115 + column_4, column_5,
116 + column_6, column_7,
117 + column_8)

Note that these column references will need to be changed once https://code.launchpad.net/~mhr3/unity8/use-dee-filtermodel/+merge/171846 is merged.

Daniel d'Andrada (dandrader) wrote :

41 + property int numOfRows: (count+1)/2

Please check our coding guidelines (https://launchpad.net/canonical-client-development-guidelines)

"""
v = w * x + y / z; // Binary operators usually have spaces around them,
v = w*x + y/z; // but it's okay to remove spaces around factors.
v = w * (x + z); // Parentheses should have no spaces inside them.
"""

review: Needs Fixing
Michał Sawicz (saviq) wrote :

Tapping outside of the preview (below - where you can see other items) results in activation and the preview isn't dismissed.

Unknown preview type: N5unity4dash13SocialPreviewE
Renderer preview-social not found, using preview-generic

These should only be debug prints probably.

Photo preview does not show the image, is that related?

review: Needs Fixing
Daniel d'Andrada (dandrader) wrote :

> 41 + property int numOfRows: (count+1)/2
>
> Please check our coding guidelines (https://launchpad.net/canonical-client-
> development-guidelines)
>
> """
> v = w * x + y / z; // Binary operators usually have spaces around them,
> v = w*x + y/z; // but it's okay to remove spaces around factors.
> v = w * (x + z); // Parentheses should have no spaces inside them.
> """

By the way, it happens in several places and not only on this line of this file.

Daniel d'Andrada (dandrader) wrote :

243 + property var previewDelegateMapping: {"preview-generic": "Generic/GenericPreview.qml",
244 + }
245 + property string genericPreview: "Generic/GenericPreview.qml"

1 - private variables should be encapsulated in a "d" object (https://docs.google.com/a/canonical.com/document/d/1gd87Wo_CSB0DpFWLpTKIIXQfdmFncrq0PHSr9H2PTnk/edit?usp=sharing)

2 - Avoid repeating yourself. Use genericPreview var in you mapping variable.

Therefore:

  // private variables
  property var d: QtObject {
      readonly property string genericPreview: "Generic/GenericPreview.qml"
      property var previewDelegateMapping: {"preview-generic" : genericPreview }
  }

Daniel d'Andrada (dandrader) wrote :

- Switching to the adjacent dash (by swiping horizontally) doesn't make the preview close. When you swipe back, the preview is still there.

- Icon doesn't get sunken while pressed.

review: Needs Fixing
Daniel d'Andrada (dandrader) wrote :

In Dash/GenericScopeView.qml

98 +import "Generic"

Not needed.

Ying-Chun Liu (paulliu) wrote :

hi, for Icon doesn't get sunken while pressed, we are working on it on another branch which the tiles should be renderer by category hints.
We'll fix it there.

Daniel d'Andrada (dandrader) wrote :

Dash/Generic/GenericPreview.qml:29: ReferenceError: IconpreviewData is not defined

review: Needs Fixing
Daniel d'Andrada (dandrader) wrote :

> hi, for Icon doesn't get sunken while pressed, we are working on it on another
> branch which the tiles should be renderer by category hints.
> We'll fix it there.

Ok

Daniel d'Andrada (dandrader) wrote :

Looks ok now.

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'Dash/Generic'
2=== added file 'Dash/Generic/GenericPreview.qml'
3--- Dash/Generic/GenericPreview.qml 1970-01-01 00:00:00 +0000
4+++ Dash/Generic/GenericPreview.qml 2013-07-10 13:33:26 +0000
5@@ -0,0 +1,84 @@
6+/*
7+ * Copyright (C) 2013 Canonical, Ltd.
8+ *
9+ * This program is free software; you can redistribute it and/or modify
10+ * it under the terms of the GNU General Public License as published by
11+ * the Free Software Foundation; version 3.
12+ *
13+ * This program is distributed in the hope that it will be useful,
14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+ * GNU General Public License for more details.
17+ *
18+ * You should have received a copy of the GNU General Public License
19+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20+ */
21+
22+import QtQuick 2.0
23+import Ubuntu.Components 0.1
24+import "../../Components"
25+import "../../Components/ListItems" as ListItems
26+import "../../Components/IconUtil.js" as IconUtil
27+import ".."
28+
29+DashPreview {
30+ id: genericPreview
31+ property var previewData
32+
33+ title: previewData.title
34+ url: IconUtil.from_gicon(previewData.image)
35+ previewWidthRatio: 0.6
36+
37+ buttons: GridView {
38+ id: buttons
39+ model: genericPreview.previewData.actions
40+
41+ property int numOfRows: (count + 1) / 2
42+ property int spacing: units.gu(1)
43+ height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
44+
45+ cellWidth: Math.max(units.gu(9), width / 2)
46+ cellHeight: buttonHeight + spacing
47+ property int buttonWidth: Math.max(0, width / 2 - spacing)
48+ property int buttonHeight: units.gu(4)
49+
50+ delegate: Button {
51+ width: Math.max(units.gu(4), buttons.buttonWidth)
52+ height: buttons.buttonHeight
53+ color: "#dd4814"
54+ text: modelData.displayName
55+ iconSource: modelData.iconHint
56+ iconPosition: "right"
57+ visible: true
58+ onClicked: {
59+ genericPreview.previewData.execute(modelData.id, { })
60+ }
61+ }
62+ focus: false
63+ }
64+ description: Column {
65+ spacing: units.gu(2)
66+
67+ Label {
68+ visible: text != ""
69+ fontSize: "medium"
70+ opacity: 0.6
71+ color: "white"
72+ text: previewData.subtitle
73+ style: Text.Raised
74+ styleColor: "black"
75+ wrapMode: Text.WordWrap
76+ }
77+
78+ Label {
79+ visible: text != ""
80+ fontSize: "small"
81+ opacity: 0.6
82+ color: "white"
83+ text: previewData.description
84+ style: Text.Raised
85+ styleColor: "black"
86+ wrapMode: Text.WordWrap
87+ }
88+ }
89+}
90
91=== modified file 'Dash/GenericScopeView.qml'
92--- Dash/GenericScopeView.qml 2013-07-04 11:14:37 +0000
93+++ Dash/GenericScopeView.qml 2013-07-10 13:33:26 +0000
94@@ -22,6 +22,7 @@
95
96 ScopeView {
97 id: scopeView
98+ property alias previewShown: previewLoader.onScreen
99
100 onIsCurrentChanged: {
101 pageHeader.resetSearch();
102@@ -47,6 +48,8 @@
103 id: categoryView
104 anchors.fill: parent
105 model: scopeView.categories
106+ forceNoClip: previewLoader.onScreen
107+
108 onAtYEndChanged: if (atYEnd) endReached()
109 onMovingChanged: if (moving && atYEnd) endReached()
110
111@@ -75,7 +78,32 @@
112 text: title
113 imageWidth: units.gu(11)
114 imageHeight: units.gu(16)
115+
116 source: IconUtil.from_gicon(icon)
117+
118+ MouseArea {
119+ anchors {
120+ fill: parent
121+ }
122+ onClicked: {
123+ mouse.accepted = true
124+ effect.positionPx = mapToItem(categoryView, 0, 0).y
125+ scopeView.scope.activate(uri, icon,
126+ category, 0,
127+ mimetype, title,
128+ comment, dndUri,
129+ metadata)
130+ }
131+ onPressAndHold: {
132+ mouse.accepted = true
133+ effect.positionPx = mapToItem(categoryView, 0, 0).y
134+ scopeView.scope.preview(uri, icon,
135+ category, 0,
136+ mimetype, title,
137+ comment, dndUri,
138+ metadata)
139+ }
140+ }
141 }
142 }
143 }
144@@ -93,4 +121,95 @@
145 searchEntryEnabled: true
146 }
147 }
148+
149+ OpenEffect {
150+ id: effect
151+ anchors {
152+ fill: parent
153+ bottomMargin: -bottomOverflow
154+ }
155+ sourceItem: categoryView
156+
157+ enabled: gap > 0.0
158+
159+ topGapPx: (1 - gap) * positionPx
160+ topOpacity: (1 - gap * 1.2)
161+ bottomGapPx: positionPx + gap * (targetBottomGapPx - positionPx)
162+ bottomOverflow: units.gu(20)
163+ bottomOpacity: 1 - (gap * 0.8)
164+
165+ property int targetBottomGapPx: height - units.gu(8) - bottomOverflow
166+ property real gap: previewLoader.open ? 1.0 : 0.0
167+
168+ Behavior on gap {
169+ NumberAnimation {
170+ duration: 200
171+ easing.type: Easing.InOutQuad
172+ onRunningChanged: {
173+ if (!previewLoader.open && !running) {
174+ previewLoader.onScreen = false
175+ }
176+ }
177+ }
178+ }
179+ }
180+
181+ Connections {
182+ target: scopeView.scope
183+ onPreviewReady: {
184+ previewLoader.previewData = preview
185+ previewLoader.open = true
186+ }
187+ }
188+
189+ PreviewDelegateMapper {
190+ id: previewDelegateMapper
191+ }
192+
193+ Connections {
194+ ignoreUnknownSignals: true
195+ target: previewLoader.valid ? previewLoader.item : null
196+ onClose: {
197+ previewLoader.open = false
198+ }
199+ }
200+
201+ Loader {
202+ id: previewLoader
203+ property var previewData
204+ height: effect.bottomGapPx - effect.topGapPx
205+ anchors {
206+ top: parent.top
207+ topMargin: effect.topGapPx
208+ left: parent.left
209+ right: parent.right
210+ }
211+ source: onScreen ? previewDelegateMapper.map(previewLoader.previewData.rendererName) : ""
212+
213+ property bool open: false
214+ property bool onScreen: false
215+ property bool valid: item !== null
216+
217+ onOpenChanged: {
218+ if (open) {
219+ onScreen = true
220+ }
221+ }
222+
223+ onLoaded: {
224+ item.previewData = previewLoader.previewData
225+ }
226+ }
227+
228+ // TODO: Move as InverseMouseArea to DashPreview
229+ MouseArea {
230+ enabled: previewLoader.onScreen
231+ anchors {
232+ fill: parent
233+ topMargin: effect.bottomGapPx
234+ }
235+ onClicked: {
236+ previewLoader.open = false;
237+ }
238+ }
239 }
240
241=== added file 'Dash/PreviewDelegateMapper.qml'
242--- Dash/PreviewDelegateMapper.qml 1970-01-01 00:00:00 +0000
243+++ Dash/PreviewDelegateMapper.qml 2013-07-10 13:33:26 +0000
244@@ -0,0 +1,34 @@
245+/*
246+ * Copyright (C) 2013 Canonical, Ltd.
247+ *
248+ * This program is free software; you can redistribute it and/or modify
249+ * it under the terms of the GNU General Public License as published by
250+ * the Free Software Foundation; version 3.
251+ *
252+ * This program is distributed in the hope that it will be useful,
253+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
254+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
255+ * GNU General Public License for more details.
256+ *
257+ * You should have received a copy of the GNU General Public License
258+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
259+ */
260+
261+import QtQuick 2.0
262+
263+QtObject {
264+ property var d: QtObject {
265+ readonly property string genericPreview: "Generic/GenericPreview.qml"
266+ property var previewDelegateMapping: {"preview-generic": genericPreview,
267+ }
268+ }
269+
270+ function map(rendererName) {
271+ var customPreview = d.previewDelegateMapping[rendererName]
272+ if (customPreview != undefined) {
273+ return customPreview
274+ }
275+ console.debug("Renderer "+rendererName+" not found, using preview-generic")
276+ return d.genericPreview
277+ }
278+}

Subscribers

People subscribed via source and target branches