on bbacdf7 help sign in
unity8/plugins/Unity/Indicators/Messaging/qml/SimpleTextMessage.qml
107 lines 2.9 kB history raw
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import Unity.Indicators 0.1
25HeroMessage {
26 id: __heroMessage
28 property string title: ""
29 property var time
30 property string message: ""
32 property alias footer: footerLoader.sourceComponent
34 expandedHeight: fullMessage.y + fullMessage.height + units.gu(2)
35 heroMessageHeader.titleText.text: title
36 heroMessageHeader.subtitleText.text: timeFormatter.timeString
37 heroMessageHeader.bodyText.text: message
39 Item {
40 id: fullMessage
42 anchors {
43 left: parent.left
44 leftMargin: units.gu(2)
45 right: parent.right
46 rightMargin: units.gu(2)
47 top: heroMessageHeader.bottom
48 }
49 height: childrenRect.height
50 opacity: 0.0
51 enabled: false
53 TimeFormatter {
54 id: timeFormatter
55 time: __heroMessage.time
56 format: "hh:mm - MMM dd"
57 }
59 Label {
60 id: bodyText
61 anchors {
62 top: parent.top
63 left: parent.left
64 right: parent.right
65 }
66 wrapMode: Text.WordWrap
67 elide: Text.ElideRight
68 color: "#e8e1d0"
69 fontSize: "medium"
70 text: heroMessageHeader.bodyText.text
71 }
73 Loader {
74 id: footerLoader
76 anchors {
77 top: bodyText.bottom
78 topMargin: units.gu(2)
79 left: parent.left
80 right: parent.right
81 }
82 height: item != undefined ? units.gu(4) : 0
83 }
85 states: State {
86 name: "expanded"
87 when: __heroMessage.state === "expanded"
89 PropertyChanges {
90 target: heroMessageHeader.bodyText
91 opacity: 0.0
92 }
94 PropertyChanges {
95 target: fullMessage
96 opacity: 1.0
97 enabled: true
98 }
99 }
100 transitions: Transition {
101 NumberAnimation {
102 property: "opacity"
103 duration: 200
104 }
105 }
106 }