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