on xenial help sign in
Subtitle is optional
commit11d074bac5ee6d9192bb7b0762ab780f190cafc1 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateWed 1 Jul 2015, 16:44 (11 years ago) parent395b27e
2 files changed+24−6
qml/Dash/Previews/PreviewSocialComment.qml+4−2 tests/qmltests/Dash/Previews/tst_PreviewSocialComment.qml+20−4
qml/Dash/Previews/PreviewSocialComment.qml+4−2
@@ -21,7 +21,7 @@ import Ubuntu.Components 1.2
2121
2222 This widget shows an (optional) avatar contained in widgetData["source"]
2323 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"].
2525*/
2626
2727PreviewWidget {
@@ -64,8 +64,10 @@ PreviewWidget {
6464 elide: Text.ElideRight
6565 }
6666 Label {
67+ objectName: "subtitle"
6768 width: parent.width
68− text: widgetData["date"] || ""
69+ visible: text !== ""
70+ text: widgetData["subtitle"] || ""
6971 fontSize: "xx-small"
7072 maximumLineCount: 1
7173 }
tests/qmltests/Dash/Previews/tst_PreviewSocialComment.qml+20−4
@@ -28,16 +28,22 @@ Rectangle {
2828
2929 property var comment: {
3030 "author": "Claire Thompson",
31− "date": "28/04/2015 3:48pm",
31+ "subtitle": "28/04/2015 3:48pm",
3232 "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.",
3333 "source": "../../graphics/avatars/amanda@12.png"
3434 }
3535
3636 property var commentNoImage: {
3737 "author": "Claire Thompson",
38− "date": "28/04/2015 3:48pm",
38+ "subtitle": "28/04/2015 3:48pm",
3939 "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"
4147 }
4248
4349 PreviewSocialComment {
@@ -52,7 +58,11 @@ Rectangle {
5258 name: "PreviewSocialCommentTest"
5359 when: windowShown
5460
55− function testAnchorsNoAvatar() {
61+ function init() {
62+ previewCommentInput.widgetData = comment;
63+ }
64+
65+ function test_AnchorsNoAvatar() {
5666 var column = findChild(previewCommentInput, "column");
5767 var avatar = findChild(previewCommentInput, "avatar");
5868
@@ -64,5 +74,11 @@ Rectangle {
6474 tryCompare(avatar, "visible", false);
6575 compare(column.anchors.left, previewCommentInput.anchors.left);
6676 }
77+
78+ function test_OptionalSubtitle() {
79+ var subtitle = findChild(previewCommentInput, "subtitle");
80+ previewCommentInput.widgetData = commentNoSubtitle;
81+ tryCompare(subtitle, "visible", false);
82+ }
6783 }
6884}