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
28 property Camera camera: null
29 property bool pressed: view.currentItem ? view.currentItem.playing : false
30 property int policyMode: view.currentItem && view.currentItem.playing ?
31 CameraResources.Player : settings.mode == Camera.VideoMode ? CameraResources.Video :
33 property bool available: view.currentItem ? view.currentItem.itemData.available : false
37 settings: platformSettings
42 settings: platformSettings
48 snapMode: ListView.SnapOneItem
49 cacheBuffer: height * 3
50 model: postCaptureModel
51 highlightRangeMode: ListView.StrictlyEnforceRange
52 interactive: view.currentItem && view.currentItem.playing ? false : true
54 delegate: PostCaptureItem {
57 onClicked: hideTimer.running = !hideTimer.running
61 if (flicking && hideTimer.running) {
67 property variant postCaptureModel: postCaptureModelLoader.item ?
68 postCaptureModelLoader.item.model : null
69 property bool loadModel: mainView.currentIndex == 2 && Qt.application.active
72 id: postCaptureModelLoader
73 sourceComponent: loadModel ? postCaptureModelComponent : undefined
76 // We have to do it that way because Loader does not support non-visual elements.
78 id: postCaptureModelComponent
81 property alias model: postCaptureModel
85 manufacturer: deviceInfo.manufacturer
86 model: deviceInfo.model
87 Component.onCompleted: reload()
89 console.log("Error populating model " + msg)
90 showError(qsTr("Failed to load captures"))
106 anchors.bottom: parent.bottom
107 anchors.bottomMargin: show ? 20 : -1 * (height + 20)
108 anchors.left: parent.left
109 anchors.leftMargin: 20
112 property bool show: deleteDialog.isOpen || deleteDialog.isOpening ||
113 hideTimer.running || menu.isOpen || menu.isOpening ||
114 (view.currentItem && view.currentItem.error) && !view.currentItem.playing
116 Behavior on anchors.bottomMargin {
117 PropertyAnimation { duration: 200; }
122 iconId: !available ? "icon-m-toolbar-favorite-mark-dimmed-white" : view.currentItem.itemData.favorite ? "icon-m-toolbar-favorite-mark-white" : "icon-m-toolbar-favorite-unmark-white"
124 addOrRemoveFavorite()
129 iconId: available ? "icon-m-toolbar-share-white" : "icon-m-toolbar-share-dimmed-white"
136 iconId: available ? "icon-m-toolbar-delete-white" : "icon-m-toolbar-delete-dimmed-white"
143 iconId: "icon-m-toolbar-view-menu-white"
154 titleText: qsTr("Delete item?");
155 acceptButtonText: qsTr("Yes");
156 rejectButtonText: qsTr("No");
158 onStatusChanged: restartTimer()
161 if (!remove.remove(view.currentItem.itemData.url)) {
162 showError(qsTr("Failed to delete item"))
164 postCaptureModel.remove(view.currentItem.itemData);
175 onStatusChanged: restartTimer()
179 text: qsTr("Captures in gallery")
180 onClicked: launchGallery()
183 // TODO: this is not working...
184 text: qsTr("View in gallery")
186 onClicked: showInGallery()
192 opacity: toolBar.opacity
193 anchors.top: parent.top
194 anchors.topMargin: toolBar.show ? 20 : -1 * (height + 20)
195 anchors.left: parent.left
196 anchors.leftMargin: 20
197 anchors.right: parent.right
198 anchors.rightMargin: 20
199 visible: toolBar.visible
200 height: screen.isPortrait ? toolBar.height * 2 : toolBar.height
202 border.color: toolBar.border.color
203 radius: toolBar.radius
205 Behavior on anchors.topMargin {
206 PropertyAnimation { duration: 200; }
210 width: parent.width - 40
212 height: parent.height
215 text: view.currentItem ? view.currentItem.itemData.title : ""
216 width: parent.width / 2
217 height: parent.height
219 verticalAlignment: Text.AlignVCenter
220 horizontalAlignment: Text.AlignLeft
224 text: view.currentItem ? view.currentItem.itemData.created : ""
225 width: parent.width / 2
226 height: parent.height
228 verticalAlignment: Text.AlignVCenter
229 horizontalAlignment: Text.AlignRight
234 function launchGallery() {
235 if (!gallery.launch()) {
236 showError(qsTr("Failed to launch gallery"))
240 function showInGallery() {
245 if (!gallery.show(view.currentItem.itemUrl)) {
246 showError(qsTr("Failed to launch gallery"))
250 function deleteCurrentItem() {
255 deleteDialog.message = view.currentItem.itemData.fileName
259 function shareCurrentItem() {
264 if (!share.share(view.currentItem.itemData.url)) {
265 showError(qsTr("Failed to launch share service"))
269 function addOrRemoveFavorite() {
274 if (view.currentItem.itemData.favorite) {
275 if (!trackerStore.removeFromFavorites(view.currentItem.itemData.url)) {
276 showError(qsTr("Failed to remove favorite"))
278 view.currentItem.itemData.favorite = false
281 if (!trackerStore.addToFavorites(view.currentItem.itemData.url)) {
282 showError(qsTr("Failed to add favorite"))
284 view.currentItem.itemData.favorite = true
289 function restartTimer() {
293 function policyLost() {
294 if (view.currentItem && view.currentItem.playing) {
295 view.currentItem.stopPlayback()