17
17
* Renato Araujo Oliveira Filho <renato@canonical.com>
18
18
* Olivier Tilloy <olivier.tilloy@canonical.com>
19
* Marco Trevisan <marco.trevisan@canonical.com>
22
23
import Ubuntu.Components 1.3
23
import QtQuick.Layouts 1.1
28
28
property alias avatar: avatarImage.source
29
29
property alias icon: iconImage.source
30
property alias title: titleText.text
31
30
property alias time: timeText.text
32
property alias body: bodyText.text
31
property alias title: itemLayout.title
32
property alias body: itemLayout.summary
34
34
signal iconClicked()
36
implicitHeight: layout.height
36
implicitHeight: itemLayout.height
37
anchors { right: parent.right; left: parent.left }
38
39
function shakeIcon() {
47
rightMargin: units.gu(4)
52
Layout.preferredWidth: units.gu(6)
53
Layout.preferredHeight: units.gu(6)
50
SlotsLayout.position: SlotsLayout.Leading
52
source: ShaderEffectSource {
53
sourceItem: avatarImage
58
58
objectName: "avatar"
59
color: Qt.rgba(0.0, 0.0, 0.0, 0.0)
61
if (String(source).match(/^image:\/\/theme/)) {
62
return theme.palette.normal.backgroundText;
64
return Qt.rgba(0.0, 0.0, 0.0, 0.0);
62
when: String(avatarImage.source).match(/^image:\/\/theme/)
63
value: theme.palette.normal.backgroundText
75
elide: Text.ElideRight
76
font.weight: Font.DemiBold
79
Layout.fillWidth: true
80
// calculate width with regard to the time's incursion into this layout's space.
81
Layout.maximumWidth: layout.width - timeLayout.width - units.gu(4)
83
spacing: units.gu(0.5)
90
wrapMode: Text.WordWrap
91
elide: Text.ElideRight
94
Layout.fillWidth: true
101
anchors.right: parent.right
106
anchors.right: parent.right
111
spacing: units.gu(0.5)
68
title.objectName: "title"
69
title.font.weight: Font.DemiBold
70
title.anchors.rightMargin: timeText.width > iconImage.width ? timeText.width - iconImage.width : 0
72
summary.objectName: "body"
73
summary.maximumLineCount: 3
74
summary.wrapMode: Text.WordWrap
75
summary.elide: Text.ElideRight
115
79
objectName: "icon"
116
Layout.preferredHeight: units.gu(3)
117
Layout.preferredWidth: units.gu(3)
118
Layout.alignment: Qt.AlignRight
119
80
color: theme.palette.normal.backgroundText
83
SlotsLayout.position: SlotsLayout.Trailing
84
SlotsLayout.overrideVerticalPositioning: true
87
when: timeText.text.length
88
value: timeText.y + timeText.height + units.gu(0.1)
91
Binding on anchors.verticalCenter {
92
when: !timeText.text.length
93
value: itemLayout.verticalCenter
122
97
anchors.fill: parent
123
98
onClicked: messageHeader.iconClicked()