Dekko
Loading...
Searching...
No Matches
ActionDrawer.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 QtQuick.Layouts 1.1
20import QtQuick.Controls.Suru 2.2
21import Lomiri.Components 1.3
22import Dekko.Lomiri.Constants 1.0
23
24Item {
25 id: actionsDrawer
26
27 anchors {
28 top: parent.bottom
29 right: parent.right
30 }
31 width: units.gu(22)
32 height: actionsColumn.height
33 clip: actionsColumn.y != 0
34 visible: false
35
36 actions: dekkoHeader.actions
37
38 function close() {
39 opened = false;
40 }
41
42 property bool opened: false
43 property list<Action> actions
44
45 onOpenedChanged: {
46 if (opened)
47 visible = true;
48 }
49
50 Rectangle {
51 id: btmshadow
52 anchors {
53 left: parent.left
54 right: parent.right
55 top: parent.bottom
56 }
57 height: units.gu(0.6)
58 gradient: Gradient {
59 GradientStop { position: 1.0; color: "transparent" }
60 GradientStop { position: 0.0; color: Qt.rgba(0, 0, 0, 0.2) }
61 }
62 }
63 HorizontalGradiant {
64 id: sideShadow
65 anchors {
66 right: parent.left
67 bottom: btmshadow.bottom
68 bottomMargin: units.gu(0.3)
69 top: parent.top
70 }
71 width: units.gu(0.6)
72 rightToLeft: true
73 gradient: Gradient {
74 GradientStop { position: 1.0; color: "transparent" }
75 GradientStop { position: 0.0; color: Qt.rgba(0, 0, 0, 0.2) }
76 }
77 }
78
79 InverseMouseArea {
80 anchors.fill: parent
81 onPressed: actionsDrawer.close();
82 enabled: actionsDrawer.opened
83 }
84
85 Column {
86 id: actionsColumn
87 anchors {
88 left: parent.left
89 right: parent.right
90 }
91 y: actionsDrawer.opened ? 0 : -height
92 Behavior on y { LomiriNumberAnimation {} }
93
94 onYChanged: {
95 if (y == -height)
96 actionsDrawer.visible = false;
97 }
98
99 Repeater {
100 model: actionsDrawer.actions.length > 0 ? actionsDrawer.actions : 0
101 delegate: AbstractButton {
102 id: actionButton
103 objectName: "actionButton" + label.text
104 anchors {
105 left: actionsColumn.left
106 right: actionsColumn.right
107 }
108 height: units.gu(6)
109 enabled: action.enabled
110
111 action: modelData
112 onClicked: actionsDrawer.close()
113
114 Rectangle {
115 anchors.fill: parent
116 color: actionButton.pressed ? Qt.darker(Suru.backgroundColor) : Suru.backgroundColor
117 }
118
119 Label {
120 id: label
121 anchors {
122 left: icon.right
123 leftMargin: Style.defaultSpacing
124 right: parent.right
125 rightMargin: Style.defaultSpacing
126 verticalCenter: parent.verticalCenter
127 }
128 text: model.text
129 fontSize: "medium"
130 elide: Text.ElideRight
131 }
132
133 Icon {
134 id: icon
135 anchors {
136 left: parent.left
137 leftMargin: Style.defaultSpacing
138 verticalCenter: parent.verticalCenter
139 }
140 width: height
141 height: label.paintedHeight
142 color: label.color
143 name: model.iconName
144 }
145 }
146 }
147 }
148}