Merge lp:~cimi/unity8/previewSocialComment into lp:unity8

Proposed by Andrea Cimitan
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 1807
Merged at revision: 1865
Proposed branch: lp:~cimi/unity8/previewSocialComment
Merge into: lp:unity8
Prerequisite: lp:~unity-team/unity8/previewcommentinput
Diff against target: 221 lines (+171/-1)
5 files modified
qml/Dash/Previews/PreviewComment.qml (+83/-0)
qml/Dash/Previews/PreviewWidgetFactory.qml (+2/-1)
tests/qmltests/CMakeLists.txt (+1/-0)
tests/qmltests/Dash/Previews/tst_PreviewComment.qml (+84/-0)
tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml (+1/-0)
To merge this branch: bzr merge lp:~cimi/unity8/previewSocialComment
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Josh Arenson Approve
Albert Astals Cid (community) Approve
Paweł Stołowski Pending
Review via email: mp+263339@code.launchpad.net

Commit message

Add PreviewSocialComment

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.
No, but needs backend to hook in order to show up
 * 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?
n/a
 * If you changed the UI, has there been a design review?
yes, it's as in the specs

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

See inline comment

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

spacing: units.gu(0.24)?

Seems a bit arbitrary-ish is that even an integer number of pixels?

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

Set elide: Text.ElideRight for the date too, i don't think we'll ever need it but it doesn't hurt just in case.

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

Why is the image anchored to the top without margins but the text actually has margins? feels a bit weird, is that what design wants?

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

When there's no date the text from the comment doesn't go up, is that because the date is mandatory?

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

I'm a bit concerned about
   implicitHeight: column.implicitHeight
i know that at the moment the column is always taller than the avatar, but i can see a gu change or text font size change making this not true, should it have some Math.max also considering the avatar?

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

visible: source.status === Image.Ready is a bit weird since for http images (that i guess it's what we will use mainly there?) it means that first the text will be full width and then will be relayouted to include the image.

That feels a bit weird, what do you think?

To test, replace
  "source": "../../graphics/avatars/amanda@12.png"
with
  "source": "https://assets.ubuntu.com/sites/ubuntu/latest/u/img/homepage/kylin/meizu-takeover.jpg"
and run
  make tryPreviewSocialComment

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

[11:20:18] <patriciadavila> tsdgeos: if there's not subtitle (date & time info) available, yes, we shall move it {the comment} up :)

This probably means we really need the max calculation in the height now.

review: Needs Fixing
lp:~cimi/unity8/previewSocialComment updated
1803. By Andrea Cimitan

Subtitle is optional

1804. By Andrea Cimitan

Renames

Revision history for this message
Andrea Cimitan (cimi) wrote :

> visible: source.status === Image.Ready is a bit weird since for http images
> (that i guess it's what we will use mainly there?) it means that first the
> text will be full width and then will be relayouted to include the image.
>
> That feels a bit weird, what do you think?
>
> To test, replace
> "source": "../../graphics/avatars/amanda@12.png"
> with
> "source":
> "https://assets.ubuntu.com/sites/ubuntu/latest/u/img/homepage/kylin/meizu-
> takeover.jpg"
> and run
> make tryPreviewSocialComment

I see... but that is what we do in CardCreator too... anything else?

Revision history for this message
Andrea Cimitan (cimi) wrote :

> spacing: units.gu(0.24)?
>
> Seems a bit arbitrary-ish is that even an integer number of pixels?
That's the only value that give me the text aligned like in the mockups. Might be that the ubuntu font might not be precisely 1gu

Revision history for this message
Andrea Cimitan (cimi) wrote :

> Why is the image anchored to the top without margins but the text actually has
> margins? feels a bit weird, is that what design wants?

From the mockups, yes

lp:~cimi/unity8/previewSocialComment updated
1805. By Andrea Cimitan

More changes for review

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

> > visible: source.status === Image.Ready is a bit weird since for http images
> > (that i guess it's what we will use mainly there?) it means that first the
> > text will be full width and then will be relayouted to include the image.
> >
> > That feels a bit weird, what do you think?
> >
> > To test, replace
> > "source": "../../graphics/avatars/amanda@12.png"
> > with
> > "source":
> > "https://assets.ubuntu.com/sites/ubuntu/latest/u/img/homepage/kylin/meizu-
> > takeover.jpg"
> > and run
> > make tryPreviewSocialComment
>
> I see... but that is what we do in CardCreator too... anything else?

But CardCreator works and this one doesn't have you seen any card created by the cardcreator have the text jumping because the image loads async? no, this one does.

review: Needs Fixing
lp:~cimi/unity8/previewSocialComment updated
1806. By Andrea Cimitan

Use different method for checking if source is set

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

what about adding "opacity: source.status === Image.Ready ? 1 : 0 " to the ubuntushape?

review: Needs Information
lp:~cimi/unity8/previewSocialComment updated
1807. By Andrea Cimitan

Merged

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.
It's all weird :/

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

review: Approve
Revision history for this message
Josh Arenson (josharenson) 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.
I don't see a recent CI run

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

Left a comment inline, but approving since this is already top level approved and the suggestion isn't a big deal.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'qml/Dash/Previews/PreviewComment.qml'
2--- qml/Dash/Previews/PreviewComment.qml 1970-01-01 00:00:00 +0000
3+++ qml/Dash/Previews/PreviewComment.qml 2015-07-06 15:33:26 +0000
4@@ -0,0 +1,83 @@
5+/*
6+ * Copyright (C) 2015 Canonical, Ltd.
7+ *
8+ * This program is free software; you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License as published by
10+ * the Free Software Foundation; version 3.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ */
20+
21+import QtQuick 2.0
22+import Ubuntu.Components 1.2
23+
24+/*! \brief Preview widget for comments.
25+
26+ This widget shows an (optional) avatar contained in widgetData["source"]
27+ along with a label that comes from widgetData["author"],
28+ a (optional) subtitle from widgetData["subtitle"] and the comment widgetData["comment"].
29+*/
30+
31+PreviewWidget {
32+ id: root
33+ implicitHeight: Math.max(avatar.height, column.implicitHeight)
34+
35+ UbuntuShape {
36+ id: avatar
37+ objectName: "avatar"
38+ anchors {
39+ left: parent.left
40+ top: parent.top
41+ }
42+ width: units.gu(6)
43+ height: width
44+ source: Image {
45+ source: widgetData["source"]
46+ }
47+ radius: "medium"
48+ opacity: source.status === Image.Ready ? 1 : 0
49+ visible: widgetData["source"] !== ""
50+ }
51+
52+ Column {
53+ id: column
54+ objectName: "column"
55+ anchors {
56+ left: avatar.visible ? avatar.right : parent.left
57+ right: parent.right
58+ top: parent.top
59+ topMargin: units.gu(0.5)
60+ leftMargin: avatar.visible ? units.gu(1) : 0
61+ }
62+ spacing: units.gu(0.24)
63+
64+ Label {
65+ width: parent.width
66+ text: widgetData["author"] || ""
67+ fontSize: "small"
68+ maximumLineCount: 1
69+ elide: Text.ElideRight
70+ }
71+ Label {
72+ objectName: "subtitle"
73+ width: parent.width
74+ visible: text !== ""
75+ text: widgetData["subtitle"] || ""
76+ fontSize: "xx-small"
77+ maximumLineCount: 1
78+ elide: Text.ElideRight
79+ }
80+ Label {
81+ width: parent.width
82+ text: widgetData["comment"] || ""
83+ fontSize: "small"
84+ wrapMode: Text.Wrap
85+ }
86+ }
87+}
88
89=== modified file 'qml/Dash/Previews/PreviewWidgetFactory.qml'
90--- qml/Dash/Previews/PreviewWidgetFactory.qml 2015-07-06 15:33:26 +0000
91+++ qml/Dash/Previews/PreviewWidgetFactory.qml 2015-07-06 15:33:26 +0000
92@@ -50,6 +50,8 @@
93 switch (widgetType) {
94 case "actions": return "PreviewActions.qml";
95 case "audio": return "PreviewAudioPlayback.qml";
96+ case "comment": return "PreviewComment.qml";
97+ case "comment-input": return "PreviewCommentInput.qml";
98 case "expandable": return "PreviewExpandable.qml";
99 case "gallery": return "PreviewImageGallery.qml";
100 case "header": return "PreviewHeader.qml";
101@@ -62,7 +64,6 @@
102 case "table": return "PreviewTable.qml";
103 case "text": return "PreviewTextSummary.qml";
104 case "video": return "PreviewVideoPlayback.qml";
105- case "comment-input": return "PreviewCommentInput.qml";
106 default: return "";
107 }
108 }
109
110=== modified file 'tests/qmltests/CMakeLists.txt'
111--- tests/qmltests/CMakeLists.txt 2015-07-06 15:33:26 +0000
112+++ tests/qmltests/CMakeLists.txt 2015-07-06 15:33:26 +0000
113@@ -27,6 +27,7 @@
114 add_unity8_qmltest(Dash/Previews Preview)
115 add_unity8_qmltest(Dash/Previews PreviewActions)
116 add_unity8_qmltest(Dash/Previews PreviewAudioPlayback)
117+add_unity8_qmltest(Dash/Previews PreviewComment)
118 add_unity8_qmltest(Dash/Previews PreviewCommentInput)
119 add_unity8_qmltest(Dash/Previews PreviewExpandable)
120 add_unity8_qmltest(Dash/Previews PreviewHeader)
121
122=== added file 'tests/qmltests/Dash/Previews/tst_PreviewComment.qml'
123--- tests/qmltests/Dash/Previews/tst_PreviewComment.qml 1970-01-01 00:00:00 +0000
124+++ tests/qmltests/Dash/Previews/tst_PreviewComment.qml 2015-07-06 15:33:26 +0000
125@@ -0,0 +1,84 @@
126+/*
127+ * Copyright 2015 Canonical Ltd.
128+ *
129+ * This program is free software; you can redistribute it and/or modify
130+ * it under the terms of the GNU General Public License as published by
131+ * the Free Software Foundation; version 3.
132+ *
133+ * This program is distributed in the hope that it will be useful,
134+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
135+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
136+ * GNU General Public License for more details.
137+ *
138+ * You should have received a copy of the GNU General Public License
139+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
140+ */
141+
142+import QtQuick 2.0
143+import QtTest 1.0
144+import Ubuntu.Components 1.1
145+import "../../../../qml/Dash/Previews"
146+import Unity.Test 0.1 as UT
147+
148+Rectangle {
149+ id: root
150+ width: units.gu(40)
151+ height: units.gu(80)
152+ color: Theme.palette.selected.background
153+
154+ property var comment: {
155+ "author": "Claire Thompson",
156+ "subtitle": "28/04/2015 3:48pm",
157+ "comment": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
158+ "source": "../../graphics/avatars/amanda@12.png"
159+ }
160+
161+ property var commentNoImage: {
162+ "author": "Claire Thompson",
163+ "subtitle": "28/04/2015 3:48pm",
164+ "comment": "Been quite a while since I really liked one.",
165+ "source": ""
166+ }
167+
168+ property var commentNoSubtitle: {
169+ "author": "Claire Thompson",
170+ "comment": "Been quite a while since I really liked one.",
171+ "source": "../../graphics/avatars/amanda@12.png"
172+ }
173+
174+ PreviewComment {
175+ id: previewComment
176+ anchors.left: parent.left
177+ anchors.right: parent.right
178+ widgetData: comment
179+ widgetId: "previewComment"
180+ }
181+
182+ UT.UnityTestCase {
183+ name: "PreviewCommentTest"
184+ when: windowShown
185+
186+ function init() {
187+ previewComment.widgetData = comment;
188+ }
189+
190+ function test_AnchorsNoAvatar() {
191+ var column = findChild(previewComment, "column");
192+ var avatar = findChild(previewComment, "avatar");
193+
194+ compare(previewComment.widgetData, comment);
195+ compare(avatar.visible, true);
196+ compare(column.anchors.left, avatar.anchors.right);
197+
198+ previewComment.widgetData = commentNoImage;
199+ tryCompare(avatar, "visible", false);
200+ compare(column.anchors.left, previewComment.anchors.left);
201+ }
202+
203+ function test_OptionalSubtitle() {
204+ var subtitle = findChild(previewComment, "subtitle");
205+ previewComment.widgetData = commentNoSubtitle;
206+ tryCompare(subtitle, "visible", false);
207+ }
208+ }
209+}
210
211=== modified file 'tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml'
212--- tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml 2015-07-06 15:33:26 +0000
213+++ tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml 2015-07-06 15:33:26 +0000
214@@ -77,6 +77,7 @@
215 return [
216 { tag: "Actions", type: "actions", source: "PreviewActions.qml" },
217 { tag: "Audio", type: "audio", source: "PreviewAudioPlayback.qml" },
218+ { tag: "Comment", type: "comment", source: "PreviewComment.qml" },
219 { tag: "Comment Input", type: "comment-input", source: "PreviewCommentInput.qml" },
220 { tag: "Expandable", type: "expandable", source: "PreviewExpandable.qml" },
221 { tag: "Gallery", type: "gallery", source: "PreviewImageGallery.qml" },

Subscribers

People subscribed via source and target branches