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
32 property Camera camera: null
33 property bool pressed: view.currentItem ? view.currentItem.playing : false
34 property int policyMode: view.currentItem && view.currentItem.playing ?
35 CameraResources.Player : settings.mode == Camera.VideoMode ? CameraResources.Video :
37 property bool available: view.currentItem ? view.currentItem.itemData.available : false
40 target: view.currentItem
42 if (view.currentItem.playing) {
43 hideTimer.running = false
50 settings: platformSettings
55 settings: platformSettings
61 snapMode: ListView.SnapOneItem
62 cacheBuffer: height * 3
63 model: postCaptureModel
64 highlightRangeMode: ListView.StrictlyEnforceRange
65 interactive: view.currentItem && view.currentItem.playing ? false : true
67 delegate: PostCaptureItem {
70 onClicked: hideTimer.running = !hideTimer.running
74 if (flicking && hideTimer.running) {
80 property variant postCaptureModel: postCaptureModelLoader.item ?
81 postCaptureModelLoader.item.model : null
82 property bool loadModel: mainView.currentIndex == 2 && Qt.application.active
85 id: postCaptureModelLoader
86 sourceComponent: loadModel ? postCaptureModelComponent : undefined
89 // We have to do it that way because Loader does not support non-visual elements.
91 id: postCaptureModelComponent
94 property alias model: postCaptureModel
98 manufacturer: deviceInfo.manufacturer
99 model: deviceInfo.model
100 Component.onCompleted: reload()
102 console.log("Error populating model " + msg)
103 showError(qsTr("Failed to load captures"))
119 anchors.bottom: parent.bottom
120 anchors.bottomMargin: show ? 20 : -1 * (height + 20)
121 anchors.left: parent.left
122 anchors.leftMargin: 20
123 anchors.right: parent.right
124 anchors.rightMargin: 20
127 property bool show: deleteDialog.isOpen || deleteDialog.isOpening ||
128 hideTimer.running || menu.isOpen || menu.isOpening ||
129 (view.currentItem && view.currentItem.error) && !view.currentItem.playing
131 Behavior on anchors.bottomMargin {
132 PropertyAnimation { duration: view.currentItem && view.currentItem.playing ? 0 : 200 }
135 tools: CameraToolBarTools {
137 iconId: available && view.currentItem.itemData.favorite ? cameraTheme.favoriteMarkIconId : cameraTheme.favoriteUnmarkIconId
138 opacity: available ? 1.0 : 0.4
140 addOrRemoveFavorite()
146 iconId: cameraTheme.shareIconId
147 opacity: available ? 1.0 : 0.4
155 iconId: cameraTheme.deleteIconId
156 opacity: available ? 1.0 : 0.4
164 iconId: cameraTheme.menuIconId
175 titleText: qsTr("Delete item?");
176 acceptButtonText: qsTr("Yes");
177 rejectButtonText: qsTr("No");
179 onStatusChanged: restartTimer()
182 if (!remove.remove(view.currentItem.itemData.url)) {
183 showError(qsTr("Failed to delete item"))
185 postCaptureModel.remove(view.currentItem.itemData);
196 onStatusChanged: restartTimer()
200 text: qsTr("Captures in gallery")
201 onClicked: launchGallery()
204 // TODO: this is not working...
205 text: qsTr("View in gallery")
207 onClicked: showInGallery()
213 opacity: toolBar.opacity
214 anchors.top: parent.top
215 anchors.topMargin: toolBar.show ? 20 : -1 * (height + 20)
216 anchors.left: parent.left
217 anchors.leftMargin: 20
218 anchors.right: parent.right
219 anchors.rightMargin: 20
220 visible: toolBar.visible
221 height: screen.isPortrait ? toolBar.height * 2 : toolBar.height
223 border.color: toolBar.border.color
224 radius: toolBar.radius
226 Behavior on anchors.topMargin {
227 PropertyAnimation { duration: view.currentItem && view.currentItem.playing ? 0 : 200 }
231 width: parent.width - 40
233 height: parent.height
236 text: view.currentItem ? view.currentItem.itemData.title : ""
237 width: parent.width / 2
238 height: parent.height
240 verticalAlignment: Text.AlignVCenter
241 horizontalAlignment: Text.AlignLeft
245 text: view.currentItem ? view.currentItem.itemData.created : ""
246 width: parent.width / 2
247 height: parent.height
249 verticalAlignment: Text.AlignVCenter
250 horizontalAlignment: Text.AlignRight
255 function launchGallery() {
256 if (!gallery.launch()) {
257 showError(qsTr("Failed to launch gallery"))
261 function showInGallery() {
266 if (!gallery.show(view.currentItem.itemUrl)) {
267 showError(qsTr("Failed to launch gallery"))
271 function deleteCurrentItem() {
276 deleteDialog.message = view.currentItem.itemData.fileName
280 function shareCurrentItem() {
285 if (!share.share(view.currentItem.itemData.url)) {
286 showError(qsTr("Failed to launch share service"))
290 function addOrRemoveFavorite() {
295 if (view.currentItem.itemData.favorite) {
296 if (!trackerStore.removeFromFavorites(view.currentItem.itemData.url)) {
297 showError(qsTr("Failed to remove favorite"))
299 view.currentItem.itemData.favorite = false
302 if (!trackerStore.addToFavorites(view.currentItem.itemData.url)) {
303 showError(qsTr("Failed to add favorite"))
305 view.currentItem.itemData.favorite = true
310 function restartTimer() {
314 function policyLost() {
315 if (view.currentItem && view.currentItem.playing) {
316 view.currentItem.stopPlayback()