on 551c708 help sign in
unity8/plugins/Unity/Indicators/Messaging/qml/HeroMessageHeader.qml
161 lines 4.2 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
24Item {
25 id: heroMessageHeader
27 property alias avatar: avatarImage.source
28 property alias icon: iconImage.source
29 property alias appIcon: appIconImage.source
30 property alias titleText: __titleText
31 property alias subtitleText: __subtitleText
32 property alias bodyText: __bodyText
33 property real bodyBottom: bodyText.y + bodyText.height
35 signal appIconClicked()
37 height: units.gu(9)
39 UbuntuShape {
40 id: avatarImageContainer
41 anchors {
42 top: parent.top
43 topMargin: units.gu(2)
44 left: parent.left
45 leftMargin: units.gu(2)
46 }
47 height: units.gu(6)
48 width: units.gu(6)
49 image: Image {
50 id: avatarImage
51 fillMode: Image.PreserveAspectFit
52 }
53 }
55 Image {
56 id: iconImage
57 anchors {
58 top: parent.top
59 topMargin: units.gu(2)
60 left: avatarImageContainer.right
61 leftMargin: units.gu(1)
62 }
63 height: units.gu(1.5)
64 width: units.gu(2)
65 horizontalAlignment: Image.AlignHCenter
66 verticalAlignment: Image.AlignBottom
67 fillMode: Image.PreserveAspectFit
68 }
70 Label {
71 id: __titleText
72 anchors {
73 baseline: iconImage.bottom
74 left: iconImage.right
75 leftMargin: units.gu(1)
76 right: __appIcon.left
77 rightMargin: units.gu(2)
78 }
79 elide: Text.ElideRight
80 color: "#e8e1d0"
81 font.weight: Font.DemiBold
82 fontSize: "medium"
83 }
85 Label {
86 id: __subtitleText
87 anchors {
88 baseline: __titleText.baseline
89 baselineOffset: units.gu(2.5)
90 left: __titleText.left
91 right: __titleText.right
92 }
93 elide: Text.ElideRight
94 color: "#8f8f88"
95 fontSize: "small"
96 }
98 Label {
99 id: __bodyText
100 anchors {
101 baseline: __subtitleText.baseline
102 baselineOffset: units.gu(2.5)
103 left: __titleText.left
104 right: parent.right
105 rightMargin: units.gu(2)
106 }
107 maximumLineCount: 2
108 wrapMode: Text.WordWrap
109 elide: Text.ElideRight
110 color: "#e8e1d0"
111 fontSize: "small"
112 }
114 Item {
115 id: __appIcon
116 width: units.gu(7)
117 height: units.gu(7)
118 anchors {
119 top: parent.top
120 right: parent.right
121 }
122 opacity: 0.0
123 enabled: heroMessageHeader.state === "expanded"
125 Image {
126 id: appIconImage
127 height: width
128 anchors {
129 left: parent.left
130 leftMargin: units.gu(2)
131 right: parent.right
132 rightMargin: units.gu(2)
133 topMargin: units.gu(1)
134 verticalCenter: parent.verticalCenter
135 }
136 fillMode: Image.PreserveAspectFit
137 }
139 MouseArea {
140 anchors.fill: parent
141 onClicked: heroMessageHeader.appIconClicked()
142 }
143 }
145 states: State {
146 name: "expanded"
148 PropertyChanges {
149 target: __appIcon
150 opacity: 1.0
151 }
152 }
154 transitions: Transition {
155 NumberAnimation {
156 property: "opacity"
157 duration: 200
158 easing.type: Easing.OutQuad
159 }
160 }