4 * This file is part of CameraPlus.
6 * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 // TODO: qrc:/qml/PostCaptureView.qml:104:5: QML CameraToolBar: Binding loop detected for property "height"
31 property Camera camera: null
32 property bool pressed: view.currentItem ? view.currentItem.playing : false
33 property int policyMode: view.currentItem && view.currentItem.playing ?
34 CameraResources.Player : settings.mode == Camera.VideoMode ? CameraResources.Video :
36 property bool available: view.currentItem ? view.currentItem.itemData.available : false
39 target: view.currentItem
41 if (view.currentItem.playing) {
42 hideTimer.running = false
49 settings: platformSettings
54 settings: platformSettings
60 snapMode: ListView.SnapOneItem
61 cacheBuffer: height * 3
62 model: postCaptureModel
63 highlightRangeMode: ListView.StrictlyEnforceRange
64 interactive: view.currentItem && view.currentItem.playing ? false : true
66 delegate: PostCaptureItem {
69 onClicked: hideTimer.running = !hideTimer.running
73 if (flicking && hideTimer.running) {
79 property variant postCaptureModel: postCaptureModelLoader.item ?
80 postCaptureModelLoader.item.model : null
81 property bool loadModel: mainView.currentIndex == 2 && Qt.application.active
84 id: postCaptureModelLoader
85 sourceComponent: loadModel ? postCaptureModelComponent : undefined
88 // We have to do it that way because Loader does not support non-visual elements.
90 id: postCaptureModelComponent
93 property alias model: postCaptureModel
97 manufacturer: deviceInfo.manufacturer
98 model: deviceInfo.model
99 Component.onCompleted: reload()
101 console.log("Error populating model " + msg)
102 showError(qsTr("Failed to load captures"))
118 anchors.bottom: parent.bottom
119 anchors.bottomMargin: show ? 20 : -1 * (height + 20)
120 anchors.left: parent.left
121 anchors.leftMargin: 20
122 anchors.right: parent.right
123 anchors.rightMargin: 20
126 property bool show: deleteDialog.isOpen || deleteDialog.isOpening ||
127 hideTimer.running || menu.isOpen || menu.isOpening ||
128 (view.currentItem && view.currentItem.error) && !view.currentItem.playing
130 Behavior on anchors.bottomMargin {
131 PropertyAnimation { duration: view.currentItem && view.currentItem.playing ? 0 : 200 }
134 tools: CameraToolBarTools {
136 iconId: !available ? cameraTheme.favoriteDisabledIconId : view.currentItem.itemData.favorite ? cameraTheme.favoriteMarkIconId : cameraTheme.favoriteUnmarkIconId
138 addOrRemoveFavorite()
144 iconId: available ? cameraTheme.shareEnabledIconId : cameraTheme.shareDisabledIconId
152 iconId: available ? cameraTheme.deleteEnabledIconId : cameraTheme.deleteDisabledIconId
160 iconId: cameraTheme.menuIconId
171 titleText: qsTr("Delete item?");
172 acceptButtonText: qsTr("Yes");
173 rejectButtonText: qsTr("No");
175 onStatusChanged: restartTimer()
178 if (!remove.remove(view.currentItem.itemData.url)) {
179 showError(qsTr("Failed to delete item"))
181 postCaptureModel.remove(view.currentItem.itemData);
192 onStatusChanged: restartTimer()
196 text: qsTr("Captures in gallery")
197 onClicked: launchGallery()
200 // TODO: this is not working...
201 text: qsTr("View in gallery")
203 onClicked: showInGallery()
209 opacity: toolBar.opacity
210 anchors.top: parent.top
211 anchors.topMargin: toolBar.show ? 20 : -1 * (height + 20)
212 anchors.left: parent.left
213 anchors.leftMargin: 20
214 anchors.right: parent.right
215 anchors.rightMargin: 20
216 visible: toolBar.visible
217 height: screen.isPortrait ? toolBar.height * 2 : toolBar.height
219 border.color: toolBar.border.color
220 radius: toolBar.radius
222 Behavior on anchors.topMargin {
223 PropertyAnimation { duration: view.currentItem && view.currentItem.playing ? 0 : 200 }
227 width: parent.width - 40
229 height: parent.height
232 text: view.currentItem ? view.currentItem.itemData.title : ""
233 width: parent.width / 2
234 height: parent.height
236 verticalAlignment: Text.AlignVCenter
237 horizontalAlignment: Text.AlignLeft
241 text: view.currentItem ? view.currentItem.itemData.created : ""
242 width: parent.width / 2
243 height: parent.height
245 verticalAlignment: Text.AlignVCenter
246 horizontalAlignment: Text.AlignRight
251 function launchGallery() {
252 if (!gallery.launch()) {
253 showError(qsTr("Failed to launch gallery"))
257 function showInGallery() {
262 if (!gallery.show(view.currentItem.itemUrl)) {
263 showError(qsTr("Failed to launch gallery"))
267 function deleteCurrentItem() {
272 deleteDialog.message = view.currentItem.itemData.fileName
276 function shareCurrentItem() {
281 if (!share.share(view.currentItem.itemData.url)) {
282 showError(qsTr("Failed to launch share service"))
286 function addOrRemoveFavorite() {
291 if (view.currentItem.itemData.favorite) {
292 if (!trackerStore.removeFromFavorites(view.currentItem.itemData.url)) {
293 showError(qsTr("Failed to remove favorite"))
295 view.currentItem.itemData.favorite = false
298 if (!trackerStore.addToFavorites(view.currentItem.itemData.url)) {
299 showError(qsTr("Failed to add favorite"))
301 view.currentItem.itemData.favorite = true
306 function restartTimer() {
310 function policyLost() {
311 if (view.currentItem && view.currentItem.playing) {
312 view.currentItem.stopPlayback()