on bbbdccd help sign in
unity8/qml/Dash/Previews/PreviewTextSummary.qml
73 lines 2.3 kB history raw
1/*
2 * Copyright (C) 2014,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
19import "../../Components"
21/*! \brief Preview widget for text.
23 This widget shows text contained in widgetData["text"]
24 along with a title that comes from widgetData["title"].
26 In case the widget is collapsed it only shows 3 lines of text.
27 */
29PreviewWidget {
30 id: root
31 implicitHeight: childrenRect.height
33 Label {
34 id: titleLabel
35 objectName: "titleLabel"
36 anchors {
37 left: parent.left
38 right: parent.right
39 }
40 height: visible ? implicitHeight : 0
41 fontSize: "large"
42 color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
43 visible: text !== ""
44 opacity: .8
45 text: widgetData["title"] || ""
46 wrapMode: Text.Wrap
47 }
49 Label {
50 id: textLabel
51 objectName: "textLabel"
53 readonly property int maximumCollapsedLineCount: 3
55 anchors {
56 left: parent.left
57 right: parent.right
58 top: titleLabel.visible ? titleLabel.bottom : parent.top
59 }
60 height: (lineCount <= maximumCollapsedLineCount || root.expanded) ? contentHeight : contentHeight / lineCount * maximumCollapsedLineCount
61 clip: true
62 fontSize: "small"
63 lineHeight: 1.2
64 color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
65 opacity: .8
66 text: widgetData["text"] || ""
67 wrapMode: Text.Wrap
69 Behavior on height {
70 UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
71 }
72 }