Debian Codegraph @

qml/components/GalleryViewHeader.qml

raw
1 /*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.12
18 import Lomiri.Components 1.3
19 import QtQuick.Layouts 1.1
20 import QtGraphicalEffects 1.0
21
22 Item {
23 id: header
24 anchors {
25 left: parent.left
26 right: parent.right
27 }
28 y: shown ? 0 : -height
29 Behavior on y { LomiriNumberAnimation {} }
30 opacity: shown ? 1.0 : 0.0
31 Behavior on opacity { LomiriNumberAnimation {} }
32
33 height: units.gu(7)
34
35 property bool shown: true
36 property list<Action> actions
37 property list<Action> editModeActions
38 property bool gridMode: false
39 property bool editMode: false
40 property bool validationVisible
41 property bool userSelectionMode: false
42
43 signal exit
44 signal exitEditor
45 signal toggleViews
46 signal toggleSelectAll
47 signal validationClicked
48 signal advanceSettingsToggle
49 signal drawerToggle( bool isOpen )
50
51 function show() {
52 shown = true;
53 }
54
55 function toggle() {
56 if (shown) {
57 actionsDrawer.close();
58 }
59 shown = !shown;
60 }
61
62 // Rectangle {
63 // id:headerBkRect
64 // anchors.fill: parent
65 // color: Qt.rgba(0,0,0,0.6)
66 // }
67
68 RowLayout {
69 anchors.fill: parent
70 spacing: 0
71
72 IconButton {
73 objectName: "backButton"
74 width: units.gu(8)
75 Layout.fillHeight: true
76 iconName: editMode ? "save" : "back"
77 iconColor: theme.palette.normal.backgroundText
78 onClicked: editMode ? header.exitEditor() : header.exit()
79 }
80
81 Label {
82 text: main.contentExportMode || userSelectionMode ? i18n.tr("Select") :
83 (editMode ? i18n.tr("Edit Photo") : i18n.tr("Photo Roll"))
84 fontSize: "x-large"
85 color: theme.palette.normal.backgroundText
86 elide: Text.ElideRight
87 horizontalAlignment:Text.AlignLeft
88 Layout.fillWidth: true
89 }
90
91 //-------------------------------------------------------------------------------
92
93 IconButton {
94 objectName: "viewToggleButton"
95 Layout.fillHeight: true
96 iconName: header.gridMode ? "stock_image" : "view-grid-symbolic"
97 iconColor: theme.palette.normal.backgroundText
98 onClicked: header.toggleViews()
99 visible: !main.contentExportMode && !userSelectionMode && !editMode
100 }
101
102 IconButton {
103 objectName: "galleryLink"
104 Layout.fillHeight: true
105 iconName: "gallery-app-symbolic"
106 iconColor: theme.palette.normal.backgroundText
107 onClicked: { Qt.openUrlExternally("appid://gallery.ubports/gallery/current-user-version") }
108 visible: !main.contentExportMode && !userSelectionMode && !editMode
109 }
110 //-------------------------------------------------------------------------
111
112 IconButton {
113 objectName: "selectAllButton"
114 Layout.fillHeight: true
115 iconName: "select"
116 iconColor: theme.palette.normal.backgroundText
117 onClicked: header.toggleSelectAll()
118 visible: header.gridMode && userSelectionMode
119 }
120
121 IconButton {
122 objectName: "singleActionButton"
123 Layout.fillHeight: true
124 action: actionsDrawer.actions[0] ? actionsDrawer.actions[0] : null
125 iconColor: theme.palette.normal.backgroundText
126 visible: actionsDrawer.actions.length == 1 && !editMode
127 onTriggered: if (action) action.triggered()
128 }
129
130 IconButton {
131 objectName: "additionalActionsButton"
132 Layout.fillHeight: true
133 iconName: "contextual-menu"
134 iconColor: theme.palette.normal.backgroundText
135 visible: actionsDrawer.actions.length > 1 && !editMode
136 onClicked: actionsDrawer.opened = !actionsDrawer.opened
137 }
138
139 IconButton {
140 objectName: "validationButton"
141 Layout.fillHeight: true
142 iconName: "ok"
143 iconColor: theme.palette.normal.backgroundText
144 onClicked: header.validationClicked()
145 visible: header.validationVisible
146 }
147
148 Repeater {
149 model: header.editMode ? header.editModeActions : null
150 IconButton {
151 Layout.fillHeight: true
152 visible: header.editMode
153 iconColor: theme.palette.normal.backgroundText
154 action: modelData
155 }
156 }
157 }
158
159 Item {
160 id: actionsDrawer
161 objectName: "actionsDrawer"
162
163 anchors {
164 top: parent.bottom
165 right: parent.right
166 }
167 width: units.gu(20)
168 height: actionsColumn.height
169 clip: actionsColumn.y != 0
170 visible: false
171 z:-1
172
173 actions: header.actions
174
175 function close() {
176 opened = false;
177 }
178
179 property bool opened: false
180 property bool fullyOpened: actionsColumn.y == 0
181 property bool fullyClosed: actionsColumn.y == -actionsColumn.height
182 property list<Action> actions
183
184 onOpenedChanged: {
185 if (opened)
186 visible = true;
187
188 drawerToggle(opened);
189 }
190
191 InverseMouseArea {
192 anchors.fill: parent
193 onPressed: actionsDrawer.close();
194 enabled: actionsDrawer.opened
195 }
196
197 Column {
198 id: actionsColumn
199 anchors {
200 left: parent.left
201 right: parent.right
202 }
203 y: actionsDrawer.opened ? 0 : -height
204 Behavior on y { LomiriNumberAnimation {} }
205
206 onYChanged: {
207 if (y == -height)
208 actionsDrawer.visible = false;
209 }
210
211 Repeater {
212 model: actionsDrawer.actions.length > 0 ? actionsDrawer.actions : 0
213 delegate: AbstractButton {
214 id: actionButton
215 objectName: "actionButton" + label.text
216 anchors {
217 left: actionsColumn.left
218 right: actionsColumn.right
219 }
220 height: units.gu(6)
221 enabled: action.enabled
222
223 action: modelData
224 onClicked: actionsDrawer.close()
225
226 Rectangle {
227 anchors.fill: parent
228 visible: actionButton.pressed
229 color: theme.palette.selected.background
230 }
231
232 Label {
233 id: label
234 anchors {
235 left: icon.right
236 leftMargin: units.gu(2)
237 right: parent.right
238 rightMargin: units.gu(2)
239 verticalCenter: parent.verticalCenter
240 }
241 text: model.text
242 elide: Text.ElideRight
243 color: action.enabled ? theme.palette.normal.backgroundText : theme.palette.disabled.backgroundText
244 }
245
246 Icon {
247 id: icon
248 anchors {
249 left: parent.left
250 leftMargin: units.gu(2)
251 verticalCenter: parent.verticalCenter
252 }
253 width: height
254 height: label.paintedHeight
255 color: label.color
256 name: model.iconName
257 asynchronous: true
258 }
259 }
260 }
261 }
262 OverlayPanel {
263 overlayItem: actionsColumn
264 visible: actionsColumn.visible
265
266 blur.visible: appSettings.blurEffects && !appSettings.blurEffectsPreviewOnly
267 blur.backgroundItem: slideshowView
268 blur.transparentBorder:false
269 z:-1
270 }
271 }
272
273 }