Dekko
Loading...
Searching...
No Matches
MessageHeader.qml
1/* Copyright (C) 2016 - 2017 Dan Chapman <dpniel@ubuntu.com>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18import QtQuick 2.4
19import Lomiri.Components 1.3
20import Lomiri.Components.Popups 1.3
21import Dekko.Components 1.0
22import Dekko.Mail 1.0
23import Dekko.Mail.API 1.0
24import Dekko.Mail.Settings 1.0
25import Dekko.Lomiri.Components 1.0
26import Dekko.Lomiri.Constants 1.0
27import "../utils/UiUtils.js" as UiUtils
28
29ListItem {
30 id: messageHeader
31 property var msg
32 property bool detailsVisible: false
33 width: parent.width
34 height: defaultLayout.height
35 divider.visible: false
36
37 signal showDetails()
38
39 ListItemLayout {
40 id: defaultLayout
41 title.text: msg.from.name
42 title.elide: Text.ElideRight
43 title.wrapMode: Text.NoWrap
44 subtitle.text: msg.toRecipientsString
45 subtitle.elide: Text.ElideRight
46 subtitle.wrapMode: Text.NoWrap
47 summary.text: detailsVisible ? qsTr("Hide details") : qsTr("View details")
48 summary.color: LomiriColors.blue
49 // Hack to re-parent the mousearea to the summary label.
50 // so we can make it clickable.
51 Component.onCompleted: mouseArea.parent = defaultLayout.summary
52
53 MouseArea {
54 id: mouseArea
55 parent: defaultLayout.summary
56 anchors.fill: parent
57 onClicked: messageHeader.showDetails()
58 }
59
60 Avatar {
61 id: avatar
62 name: msg.from.name
63 initials: msg.from.initials
64 email: msg.from.address
65 validContact: true
66 fontSize: "large"
67 SlotsLayout.position: SlotsLayout.Leading
68 }
69
70 Item {
71 id: inner_infoCol
72
73 width: (zoomColumn.width + infoActionColumn.width)
74 height: zoomColumn.height
75 SlotsLayout.overrideVerticalPositioning: true
76
77 Column {
78 id: zoomColumn
79 anchors.right: infoActionColumn.left
80 anchors.bottom: parent.bottom
81 spacing: 0
82
84 id: zoomInButton
85 height: units.gu(4)
86 width: units.gu(4)
87 action: Action {
88 iconName: "zoom-in"
89 onTriggered: webview.zoomFactor = webview.zoomFactor * 1.1
90 }
91 }
92
94 id: zoomOutButton
95 height: units.gu(4)
96 width: units.gu(4)
97 action: Action {
98 iconName: "zoom-out"
99 onTriggered: webview.zoomFactor = webview.zoomFactor * 0.9
100 }
101 }
102 }
103
104 Column {
105 id: infoActionColumn
106 anchors.right: parent.right
107 anchors.bottom: parent.bottom
108 spacing: 0
109
110 // wrap Label in item with same size as upper zoom button for same vertical aligment
111 Item {
112 width: inner_timeLabel.implicitWidth
113 height: zoomInButton.height
114 anchors.right: parent.right
115
116 Label {
117 id: inner_timeLabel
118 anchors.verticalCenter: parent.verticalCenter
119 text: msg ? msg.prettyDate : ""
120 fontSize: "small"
121 }
122 }
123
124 Row {
125 id: buttonRow
126 anchors.right: parent.right
127 anchors.rightMargin: -units.gu(0.5)
128 spacing: 0
129
131 id: reply
132 height: units.gu(4)
133 width: units.gu(4)
134 iconColor: LomiriColors.ash
135 action: Action {
136 iconSource: Paths.actionIconUrl(Icons.MailReplyIcon)
137 onTriggered: ComposerActions.respondToMessage(msg.isListPost ? SubmissionManager.ReplyList : SubmissionManager.Reply, msg.messageId)
138 }
139 }
140
142 id: contextmenu
143 height: units.gu(4)
144 width: units.gu(4)
145 iconColor: LomiriColors.ash
146 action: Action {
147 iconSource: Paths.actionIconUrl(Icons.ContextMenuIcon)
148 onTriggered: PopupUtils.open(Qt.resolvedUrl("../popovers/MessageActionPopover.qml"), contextmenu, {msg: msg})
149 }
150 }
151 }
152 }
153 }
154 }
155}
156