Dekko
Loading...
Searching...
No Matches
NavigationDrawer.qml
1/* Copyright (C) 2014-2016 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 QuickFlux 1.0
20import Lomiri.Components 1.3
21import Lomiri.Components.ListItems 1.0 as ListItem
22import Dekko.Mail.API 1.0
23
24Panel {
25 id: accountsDrawer
26 anchors {
27 left: parent.left
28 top: parent.top
29 bottom: parent.bottom
30 }
31 animate: true
32 width: units.gu(25)
33 property bool enabled: false
34 default property alias data: content.data
35
36 property Action action: Action {
37 id: drawerAction
38 iconName: "navigation-menu"
39 onTriggered: accountsDrawer.opened ? accountsDrawer.close() : accountsDrawer.open()
40 }
41
42 property int maxHeight
43
44 function delayClose() {
45 delayCloseTimer.start()
46 }
47
48 AppListener {
49 Filter {
50 type: ViewKeys.toggleNavDrawer
51 onDispatched: accountsDrawer.opened ? accountsDrawer.close() : accountsDrawer.open()
52 }
53 Filter {
54 type: MessageKeys.openFolder
55 onDispatched: {
56 if (accountsDrawer.opened) {
57 accountsDrawer.delayClose()
58 }
59 }
60 }
61
62 Filter {
63 type: ViewKeys.closeNavDrawer
64 onDispatched: {
65 if (accountsDrawer.opened) {
66 delayClose()
67 }
68 }
69 }
70 }
71
72 // Don't let the event propogate to the page below
73 MouseArea {
74 anchors.fill: parent
75 acceptedButtons: Qt.LeftButton | Qt.RightButton
76 onClicked: mouse.accepted = true
77 onWheel: wheel.accepted = true
78 }
79
80 Timer {
81 id: delayCloseTimer
82 interval: 100
83 repeat: false
84 onTriggered: accountsDrawer.close()
85 }
86
87 visible: opened || animating
88 align: Qt.AlignLeading
89
90 InverseMouseArea {
91 visible: accountsDrawer.opened
92 anchors.fill: parent
93 acceptedButtons: Qt.LeftButton
94 onPressed: accountsDrawer.close()
95 }
96 // FIXME: where this meets the btmShadow there is a clear difference
97 // in the way it looks where they join. How to wrap a gradient round a corner??
98 // NOTE it's only really visible to the eye if you are looking for it
99 HorizontalGradiant {
100 id: sideShadow
101 anchors {
102 left: parent.right
103 bottom: parent.bottom
104 top: parent.top
105 }
106 width: units.gu(0.8)
107 gradient: Gradient {
108 GradientStop { position: 0.0; color: Qt.rgba(0, 0, 0, 0.1) }
109 GradientStop { position: 1.0; color: "transparent" }
110 }
111 }
112 Item {
113 id: content
114 anchors.fill: parent
115 }
116}