Dekko
Loading...
Searching...
No Matches
DefaultMessagePageHeader.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 QtQuick.Layouts 1.1
20import Lomiri.Components 1.3
21import Dekko.Components 1.0
22import Dekko.Mail 1.0
23import Dekko.Lomiri.Components 1.0
24import Dekko.Mail.API 1.0
25import Dekko.Lomiri.Constants 1.0
27Item {
28 id: header
29
30 property var msg
31
32 height: dekko.isSmallFF ? units.gu(6) : units.gu(9.075)
33 anchors {
34 left: parent.left
35 right: parent.right
36 top: parent.top
37 }
38
39 property bool showBack: dekko.isSmallFF
40
41 HeaderButton {
42 id: inner_button
43 anchors {
44 top: parent.top
45 left: parent.left
46 }
47 visible: showBack
48
49 height: units.gu(6)
50 width: showBack ? units.gu(4) : 0
51 action: Action {
52 iconName: "back"
53 onTriggered: {
54 // Back button is only shown in the message list stack
55 ViewActions.popStageArea(ViewKeys.messageListStack)
56 ViewActions.delayCall('resetSelectedMsgIndex')
57 }
58 }
59 }
60
61 Label {
62 id: fromLabel
63 anchors {
64 left: inner_button.right
65 leftMargin: showBack ? 0 : Style.defaultSpacing
66 top: parent.top
67 topMargin: units.gu(1.5)
68 right: starButton.left
69 rightMargin: Style.smallSpacing
70 }
71 clip: true
72 text: msg.subject
73 elide: Text.ElideRight
74 font.weight: Font.Light
75 fontSize: "large"
76 }
77
78 RowLayout {
79 anchors {
80 left: fromLabel.left
81 top: fromLabel.bottom
82 topMargin: Style.smallSpacing
83 right: starButton.left
84 rightMargin: Style.smallSpacing
85 }
86
87 Label {
88 id: subjectLabel
89 text: msg.from.name
90 clip: true
91 elide: Text.ElideRight
92 visible: !dekko.isSmallFF
93 font.weight: Font.Normal
94
95 }
96 }
97
99 id: starButton
100 anchors {
101 right: deleteButton.left
102 top: parent.top
103 }
104 height: units.gu(6)
105 width: units.gu(4)
106 iconColor: msg.isImportant ? "#f0e442" : "#888888"
107 action: Action {
108 iconSource: msg.isImportant ? Paths.actionIconUrl(Icons.StarredIcon) : Paths.actionIconUrl(Icons.UnStarredIcon)
109 onTriggered: MessageActions.markMessageImportant(msg.messageId, !msg.isImportant)
110 }
111 }
112
114 id: deleteButton
115 anchors {
116 right: parent.right
117 rightMargin: Style.smallSpacing
118 top: parent.top
119 }
120 height: units.gu(6)
121 width: units.gu(4)
122 action: Action {
123 iconName: "delete"
124 shortcut: "Delete"
125 onTriggered: {
126 if (dekko.isSmallFF) {
127 ViewActions.popStageArea(ViewKeys.messageListStack)
128 ViewActions.delayCall('resetSelectedMsgIndex')
129 ViewActions.delayCallWithArgs('deleteMessage', {msgId: msg.messageId})
130 } else {
131 MessageActions.deleteMessage(msg.messageId)
132 }
133 }
134 }
135 }
136
137 Line {
138 id: btmMargin
139 anchors {
140 left: parent.left
141 right: parent.right
142 bottom: header.bottom
143 }
144 visible: true
145 }
146}