on xenial help sign in
Subtitle is optional
11d074bAndrea Cimitan
qml/Dash/Previews/PreviewSocialComment.qml+4−2
@@ -21,7 +21,7 @@ import Ubuntu.Components 1.2
21
21
22 This widget shows an (optional) avatar contained in widgetData["source"]
22 This widget shows an (optional) avatar contained in widgetData["source"]
23 along with a label that comes from widgetData["author"],
23 along with a label that comes from widgetData["author"],
24− a date date from widgetData["date"] and the comment widgetData["comment"].
24+ a (optional) subtitle from widgetData["subtitle"] and the comment widgetData["comment"].
25*/
25*/
26
26
27PreviewWidget {
27PreviewWidget {
@@ -64,8 +64,10 @@ PreviewWidget {
64 elide: Text.ElideRight
64 elide: Text.ElideRight
65 }
65 }
66 Label {
66 Label {
67+ objectName: "subtitle"
67 width: parent.width
68 width: parent.width
69+ visible: text !== ""
68− text: widgetData["date"] || ""
70+ text: widgetData["subtitle"] || ""
69 fontSize: "xx-small"
71 fontSize: "xx-small"
70 maximumLineCount: 1
72 maximumLineCount: 1
71 }
73 }
tests/qmltests/Dash/Previews/tst_PreviewSocialComment.qml+20−4
@@ -28,16 +28,22 @@ Rectangle {
28
28
29 property var comment: {
29 property var comment: {
30 "author": "Claire Thompson",
30 "author": "Claire Thompson",
31− "date": "28/04/2015 3:48pm",
31+ "subtitle": "28/04/2015 3:48pm",
32 "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.",
32 "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.",
33 "source": "../../graphics/avatars/amanda@12.png"
33 "source": "../../graphics/avatars/amanda@12.png"
34 }
34 }
35
35
36 property var commentNoImage: {
36 property var commentNoImage: {
37 "author": "Claire Thompson",
37 "author": "Claire Thompson",
38− "date": "28/04/2015 3:48pm",
38+ "subtitle": "28/04/2015 3:48pm",
39 "comment": "Been quite a while since I really liked one.",
39 "comment": "Been quite a while since I really liked one.",
40− "source": "null"
40+ "source": ""
41+ }
42+
43+ property var commentNoSubtitle: {
44+ "author": "Claire Thompson",
45+ "comment": "Been quite a while since I really liked one.",
46+ "source": "../../graphics/avatars/amanda@12.png"
41 }
47 }
42
48
43 PreviewSocialComment {
49 PreviewSocialComment {
@@ -52,7 +58,11 @@ Rectangle {
52 name: "PreviewSocialCommentTest"
58 name: "PreviewSocialCommentTest"
53 when: windowShown
59 when: windowShown
54
60
55− function testAnchorsNoAvatar() {
61+ function init() {
62+ previewCommentInput.widgetData = comment;
63+ }
64+
65+ function test_AnchorsNoAvatar() {
56 var column = findChild(previewCommentInput, "column");
66 var column = findChild(previewCommentInput, "column");
57 var avatar = findChild(previewCommentInput, "avatar");
67 var avatar = findChild(previewCommentInput, "avatar");
58
68
@@ -64,5 +74,11 @@ Rectangle {
64 tryCompare(avatar, "visible", false);
74 tryCompare(avatar, "visible", false);
65 compare(column.anchors.left, previewCommentInput.anchors.left);
75 compare(column.anchors.left, previewCommentInput.anchors.left);
66 }
76 }
77+
78+ function test_OptionalSubtitle() {
79+ var subtitle = findChild(previewCommentInput, "subtitle");
80+ previewCommentInput.widgetData = commentNoSubtitle;
81+ tryCompare(subtitle, "visible", false);
82+ }
67 }
83 }
68}
84}