on e507710 help sign in
unity8/modules/Unity/Indicators/qml/messaging/HeroMessageHeader.qml
147 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.top: parent.top
42 anchors.topMargin: units.gu(2)
43 anchors.left: parent.left
44 anchors.leftMargin: units.gu(2)
45 height: units.gu(6)
46 width: units.gu(6)
47 image: Image {
48 id: __avatarImage
49 fillMode: Image.PreserveAspectFit
50 }
51 }
53 Image {
54 id: __iconImage
55 anchors.top: parent.top
56 anchors.topMargin: units.gu(2)
57 anchors.left: __avatarImageContainer.right
58 anchors.leftMargin: units.gu(1)
59 height: units.gu(1.5)
60 width: units.gu(2)
61 horizontalAlignment: Image.AlignHCenter
62 verticalAlignment: Image.AlignBottom
63 fillMode: Image.PreserveAspectFit
64 }
66 Label {
67 id: __titleText
68 anchors.baseline: __iconImage.bottom
69 anchors.left: __iconImage.right
70 anchors.leftMargin: units.gu(1)
71 anchors.right: __appIcon.left
72 anchors.rightMargin: units.gu(2)
73 elide: Text.ElideRight
74 color: "#e8e1d0"
75 font.weight: Font.DemiBold
76 fontSize: "medium"
77 }
79 Label {
80 id: __subtitleText
81 anchors.baseline: __titleText.baseline
82 anchors.baselineOffset: units.gu(2.5)
83 anchors.left: __titleText.left
84 anchors.right: __titleText.right
85 elide: Text.ElideRight
86 color: "#8f8f88"
87 fontSize: "small"
88 }
90 Label {
91 id: __bodyText
92 anchors.baseline: __subtitleText.baseline
93 anchors.baselineOffset: units.gu(2.5)
94 anchors.left: __titleText.left
95 anchors.right: parent.right
96 anchors.rightMargin: units.gu(2)
97 maximumLineCount: 2
98 wrapMode: Text.WordWrap
99 elide: Text.ElideRight
100 color: "#e8e1d0"
101 fontSize: "small"
102 }
104 Item {
105 id: __appIcon
106 width: units.gu(7)
107 height: units.gu(7)
108 anchors.top: parent.top
109 anchors.right: parent.right
110 opacity: 0.0
111 enabled: __heroMessageHeader.state === "expanded"
113 Image {
114 id: __appIconImage
115 height: width
116 anchors.left: parent.left
117 anchors.leftMargin: units.gu(2)
118 anchors.right: parent.right
119 anchors.rightMargin: units.gu(2)
120 anchors.topMargin: units.gu(1)
121 anchors.verticalCenter: parent.verticalCenter
122 fillMode: Image.PreserveAspectFit
123 }
125 MouseArea {
126 anchors.fill: parent
127 onClicked: __heroMessageHeader.appIconClicked()
128 }
129 }
131 states: State {
132 name: "expanded"
134 PropertyChanges {
135 target: __appIcon
136 opacity: 1.0
137 }
138 }
140 transitions: Transition {
141 NumberAnimation {
142 property: "opacity"
143 duration: 200
144 easing.type: Easing.OutQuad
145 }
146 }