on bbbdccd help sign in
unity8/qml/Dash/Previews/PreviewComment.qml
83 lines 2.4 kB history raw
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.4
18import Ubuntu.Components 1.3
20/*! \brief Preview widget for comments.
22 This widget shows an (optional) avatar contained in widgetData["source"]
23 along with a label that comes from widgetData["author"],
24 a (optional) subtitle from widgetData["subtitle"] and the comment widgetData["comment"].
25*/
27PreviewWidget {
28 id: root
29 implicitHeight: Math.max(avatar.height, column.implicitHeight)
31 UbuntuShape {
32 id: avatar
33 objectName: "avatar"
34 anchors {
35 left: parent.left
36 top: parent.top
37 }
38 width: units.gu(6)
39 height: width
40 source: Image {
41 source: widgetData["source"]
42 }
43 radius: "medium"
44 opacity: source.status === Image.Ready ? 1 : 0
45 visible: widgetData["source"] !== ""
46 }
48 Column {
49 id: column
50 objectName: "column"
51 anchors {
52 left: avatar.visible ? avatar.right : parent.left
53 right: parent.right
54 top: parent.top
55 topMargin: units.gu(0.5)
56 leftMargin: avatar.visible ? units.gu(1) : 0
57 }
58 spacing: units.gu(0.24)
60 Label {
61 width: parent.width
62 text: widgetData["author"] || ""
63 fontSize: "small"
64 maximumLineCount: 1
65 elide: Text.ElideRight
66 }
67 Label {
68 objectName: "subtitle"
69 width: parent.width
70 visible: text !== ""
71 text: widgetData["subtitle"] || ""
72 fontSize: "xx-small"
73 maximumLineCount: 1
74 elide: Text.ElideRight
75 }
76 Label {
77 width: parent.width
78 text: widgetData["comment"] || ""
79 fontSize: "small"
80 wrapMode: Text.Wrap
81 }
82 }