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 bool pressed: view.currentItem ? view.currentItem.playing : false
29 property int policyMode: view.currentItem && view.currentItem.playing ?
30 CameraResources.Player : settings.mode == Camera.VideoMode ? CameraResources.Video :
32 property bool available: view.currentItem ? view.currentItem.itemData.available : false
36 settings: platformSettings
41 settings: platformSettings
47 snapMode: ListView.SnapOneItem
48 cacheBuffer: height * 3
49 model: postCaptureModel
50 highlightRangeMode: ListView.StrictlyEnforceRange
52 delegate: PostCaptureItem {
55 onClicked: hideTimer.running = !hideTimer.running
59 if (flicking && hideTimer.running) {
65 property variant postCaptureModel: postCaptureModelLoader.item ?
66 postCaptureModelLoader.item.model : null
67 property bool loadModel: mainView.currentIndex == 2 && Qt.application.active
70 id: postCaptureModelLoader
71 sourceComponent: loadModel ? postCaptureModelComponent : undefined
74 // We have to do it that way because Loader does not support non-visual elements.
76 id: postCaptureModelComponent
79 property alias model: postCaptureModel
83 manufacturer: deviceInfo.manufacturer
84 model: deviceInfo.model
85 Component.onCompleted: reload()
87 console.log("Error populating model " + msg)
88 showError(qsTr("Failed to load captures"))
104 anchors.bottom: parent.bottom
105 anchors.bottomMargin: show ? 20 : -1 * (height + 20)
106 anchors.left: parent.left
107 anchors.leftMargin: 20
110 property bool show: deleteDialog.isOpen || deleteDialog.isOpening ||
111 hideTimer.running || menu.isOpen || menu.isOpening ||
112 (view.currentItem && view.currentItem.error) && !view.currentItem.playing
114 Behavior on anchors.bottomMargin {
115 PropertyAnimation { duration: 200; }
120 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"
122 addOrRemoveFavorite()
127 iconId: available ? "icon-m-toolbar-share-white" : "icon-m-toolbar-share-dimmed-white"
134 iconId: available ? "icon-m-toolbar-delete-white" : "icon-m-toolbar-delete-dimmed-white"
141 iconId: "icon-m-toolbar-view-menu-white"
152 titleText: qsTr("Delete item?");
153 acceptButtonText: qsTr("Yes");
154 rejectButtonText: qsTr("No");
156 onStatusChanged: restartTimer()
159 if (!remove.remove(view.currentItem.itemData.url)) {
160 showError(qsTr("Failed to delete item"))
162 postCaptureModel.remove(view.currentItem.itemData);
173 onStatusChanged: restartTimer()
177 text: qsTr("Captures in gallery")
178 onClicked: launchGallery()
181 // TODO: this is not working...
182 text: qsTr("View in gallery")
184 onClicked: showInGallery()
190 opacity: toolBar.opacity
191 anchors.top: parent.top
192 anchors.topMargin: toolBar.show ? 20 : -1 * (height + 20)
193 anchors.left: parent.left
194 anchors.leftMargin: 20
195 anchors.right: parent.right
196 anchors.rightMargin: 20
197 visible: toolBar.visible
198 height: screen.isPortrait ? toolBar.height * 2 : toolBar.height
200 border.color: toolBar.border.color
201 radius: toolBar.radius
203 Behavior on anchors.topMargin {
204 PropertyAnimation { duration: 200; }
208 width: parent.width - 40
210 height: parent.height
213 text: view.currentItem ? view.currentItem.itemData.title : ""
214 width: parent.width / 2
215 height: parent.height
217 verticalAlignment: Text.AlignVCenter
218 horizontalAlignment: Text.AlignLeft
222 text: view.currentItem ? view.currentItem.itemData.created : ""
223 width: parent.width / 2
224 height: parent.height
226 verticalAlignment: Text.AlignVCenter
227 horizontalAlignment: Text.AlignRight
232 function launchGallery() {
233 if (!gallery.launch()) {
234 showError(qsTr("Failed to launch gallery"))
238 function showInGallery() {
243 if (!gallery.show(view.currentItem.itemUrl)) {
244 showError(qsTr("Failed to launch gallery"))
248 function deleteCurrentItem() {
253 deleteDialog.message = view.currentItem.itemData.fileName
257 function shareCurrentItem() {
262 if (!share.share(view.currentItem.itemData.url)) {
263 showError(qsTr("Failed to launch share service"))
267 function addOrRemoveFavorite() {
272 if (view.currentItem.itemData.favorite) {
273 if (!trackerStore.removeFromFavorites(view.currentItem.itemData.url)) {
274 showError(qsTr("Failed to remove favorite"))
276 view.currentItem.itemData.favorite = false
279 if (!trackerStore.addToFavorites(view.currentItem.itemData.url)) {
280 showError(qsTr("Failed to add favorite"))
282 view.currentItem.itemData.favorite = true
287 function restartTimer() {
291 function policyLost() {
292 if (view.currentItem && view.currentItem.playing) {
293 view.currentItem.stopPlayback()