Dekko
Loading...
Searching...
No Matches
BottomEdgeComposer.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.Controls.Suru 2.2
20import Lomiri.Components 1.3
21import Lomiri.Components.Popups 1.3
22import Dekko.Components 1.0
23import Dekko.Mail.API 1.0
24import Dekko.Mail.Stores.Composer 1.0
25import QuickFlux 1.0
26import Dekko.Lomiri.Components 1.0
27import Dekko.Lomiri.Constants 1.0
29BottomEdgeConfiguration {
30 id: bc
31 sourceComponent: DekkoPage {
32 width: dekkoPage.width
33 height: dekkoPage.height
34 Rectangle {
35 anchors.fill: parent
36 color: Suru.backgroundColor
37 }
38 pageHeader.title: qsTr("New message")
39 pageHeader.backAction: Action {
40 iconName: "down"
41 onTriggered: ComposerActions.discardMessage()
42 }
43 pageHeader.primaryAction: ComposerStore.actions.attachmentsAction
44 pageHeader.secondaryActions: [
45 Action {
46 iconName: "contact"
47 text: qsTr("Contacts")
48 onTriggered: PopupUtils.open(Qt.resolvedUrl("./ComposerOverflowMenu.qml"), composer)
49 },
50 ComposerStore.actions.toggleComposeModeAction,
51 Action {
52 iconName: ComposerStore.actions.sendAction.iconName
53 text: ComposerStore.actions.sendAction.text
54 enabled: ComposerStore.actions.sendAction.enabled
55 onTriggered: ComposerStore.actions.sendAction.trigger()
56 }
57 ]
58
59 MessageComposer {
60 id: composer
61 anchors {
62 left: parent.left
63 top: parent.top
64 right: parent.right
65 bottom: ap.visible ? ap.top : parent.bottom
66 }
67 }
68
70 id: ap
71 anchors {
72 left: parent.left
73 bottom: parent.bottom
74 right: parent.right
75 }
76 maxHeight: composer.height - Style.defaultSpacing
77 visible: ComposerStore.attachments.count > 0 && !Qt.inputMethod.visible
78 countText: ComposerStore.attachments.count
79 text: qsTr("Attachments")
80 iconName: Icons.AttachmentIcon
81 Repeater {
82 model: ComposerStore.attachments
83 delegate: ListItemWithActions {
84 id: ad
85 property Component openItem: Item{}
86 property var attachment: model.qtObject
87 height: aLayout.implicitHeight
88 width: parent.width
89 showDivider: true
90 triggerIndex: model.index
91 leftSideAction: ComposerStore.actions.deleteAttachment
92 onItemClicked: {
93 if (mouse.button === Qt.RightButton) {
94 PopupUtils.open(Qt.resolvedUrl("../popovers/AttachmentPopover.qml"),
95 ad,
96 {
97 index: model.index,
98 attachment: model.qtObject
99 })
100 return;
101 }
102 Log.logInfo("AttachmentList::openAttachment", "Attachment octet size is: %1".arg(model.qtObject.sizeInBytes))
103 Qt.openUrlExternally("file:///%1".arg(attachment.url))
104 }
105 ListItemLayout {
106 id: aLayout
107 title.text: attachment.displayName
108 subtitle.text: attachment.size
109
110 Icon {
111 source: Paths.mimeIconForUrl("file:///%1".arg(attachment.url))
112 color: LomiriColors.ash
113 height: Style.largeSpacing; width: height
114 SlotsLayout.position: SlotsLayout.Leading
115 }
116
117 Connections {
118 target: model.qtObject
119 onReadyToOpen: {
120 Qt.openUrlExternally(url)
121 }
122 }
123 }
124 }
125 }
126 }
127
128 AppScript {
129 runWhen: ViewKeys.closeComposer
130 enabled: listenerEnabled
131 script: {
132 if (!dekko.isLargeFF) {
133 bottomEdge.collapse()
134 } else {
135 exit.bind(this, 0)
136 }
137 }
138 }
139 AppListener {
140 enabled: !dekko.isLargeFF
141 filter: ViewKeys.closeComposer
142 onDispatched: {
143 bottomEdge.collapse()
144 }
145 }
146 }
147}