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"
28 // TODO: try to reload the preview thumbnail when the picture becomes available
33 property Camera camera: null
34 property bool pressed: view.currentItem ? view.currentItem.playing : false
35 property int policyMode: view.currentItem && view.currentItem.playing ?
36 CameraResources.Player : settings.mode == Camera.VideoMode ? CameraResources.Video :
38 property bool available: view.currentItem ? view.currentItem.itemData.available : false
41 target: view.currentItem
43 if (view.currentItem.playing) {
44 hideTimer.running = false
51 settings: platformSettings
56 settings: platformSettings
62 snapMode: ListView.SnapOneItem
63 cacheBuffer: height * 3
64 model: postCaptureModel
65 highlightRangeMode: ListView.StrictlyEnforceRange
66 interactive: view.currentItem && view.currentItem.playing ? false : true
68 delegate: PostCaptureItem {
71 onClicked: hideTimer.running = !hideTimer.running
75 if (flicking && hideTimer.running) {
81 property variant postCaptureModel: postCaptureModelLoader.item ?
82 postCaptureModelLoader.item.model : null
83 property bool loadModel: mainView.currentIndex == 2 && Qt.application.active
86 id: postCaptureModelLoader
87 sourceComponent: loadModel ? postCaptureModelComponent : undefined
90 // We have to do it that way because Loader does not support non-visual elements.
92 id: postCaptureModelComponent
95 property alias model: postCaptureModel
99 manufacturer: deviceInfo.manufacturer
100 model: deviceInfo.model
101 Component.onCompleted: reload()
103 console.log("Error populating model " + msg)
104 showError(qsTr("Failed to load captures"))
120 anchors.bottom: parent.bottom
121 anchors.bottomMargin: show ? 20 : -1 * (height + 20)
122 anchors.left: parent.left
123 anchors.leftMargin: 20
124 anchors.right: parent.right
125 anchors.rightMargin: 20
128 property bool show: deleteDialog.isOpen || deleteDialog.isOpening ||
130 (view.currentItem && view.currentItem.error) && !view.currentItem.playing
132 Behavior on anchors.bottomMargin {
133 PropertyAnimation { duration: view.currentItem && view.currentItem.playing ? 0 : 200 }
136 tools: CameraToolBarTools {
138 iconSource: available && view.currentItem.itemData.favorite ? cameraTheme.favoriteMarkIconId : cameraTheme.favoriteUnmarkIconId
139 opacity: available ? 1.0 : 0.4
141 addOrRemoveFavorite()
147 iconSource: cameraTheme.shareIconId
148 opacity: available ? 1.0 : 0.4
156 iconSource: cameraTheme.deleteIconId
157 opacity: available ? 1.0 : 0.4
165 iconSource: cameraTheme.galleryIconId
176 titleText: qsTr("Delete item?");
177 acceptButtonText: qsTr("Yes");
178 rejectButtonText: qsTr("No");
180 onStatusChanged: restartTimer()
183 if (!remove.remove(view.currentItem.itemData.url)) {
184 showError(qsTr("Failed to delete item"))
186 postCaptureModel.remove(view.currentItem.itemData);
196 opacity: toolBar.opacity
197 anchors.top: parent.top
198 anchors.topMargin: toolBar.show ? 20 : -1 * (height + 20)
199 anchors.left: parent.left
200 anchors.leftMargin: 20
201 anchors.right: parent.right
202 anchors.rightMargin: 20
203 visible: toolBar.visible
204 height: screen.isPortrait ? toolBar.height * 2 : toolBar.height
206 border.color: toolBar.border.color
207 radius: toolBar.radius
209 Behavior on anchors.topMargin {
210 PropertyAnimation { duration: view.currentItem && view.currentItem.playing ? 0 : 200 }
214 width: parent.width - 40
216 height: parent.height
219 text: view.currentItem ? view.currentItem.itemData.title : ""
220 width: parent.width / 2
221 height: parent.height
223 verticalAlignment: Text.AlignVCenter
224 horizontalAlignment: Text.AlignLeft
228 text: view.currentItem ? view.currentItem.itemData.created : ""
229 width: parent.width / 2
230 height: parent.height
232 verticalAlignment: Text.AlignVCenter
233 horizontalAlignment: Text.AlignRight
238 function launchGallery() {
239 if (!gallery.launch()) {
240 showError(qsTr("Failed to launch gallery"))
244 function deleteCurrentItem() {
249 deleteDialog.message = view.currentItem.itemData.fileName
253 function shareCurrentItem() {
258 if (!share.share(view.currentItem.itemData.url)) {
259 showError(qsTr("Failed to launch share service"))
263 function addOrRemoveFavorite() {
268 if (view.currentItem.itemData.favorite) {
269 if (!trackerStore.removeFromFavorites(view.currentItem.itemData.url)) {
270 showError(qsTr("Failed to remove favorite"))
272 view.currentItem.itemData.favorite = false
275 if (!trackerStore.addToFavorites(view.currentItem.itemData.url)) {
276 showError(qsTr("Failed to add favorite"))
278 view.currentItem.itemData.favorite = true
283 function restartTimer() {
287 function policyLost() {
288 if (view.currentItem && view.currentItem.playing) {
289 view.currentItem.stopPlayback()