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
53 delegate: PostCaptureItem {
56 onClicked: hideTimer.running = !hideTimer.running
60 if (flicking && hideTimer.running) {
66 property variant postCaptureModel: postCaptureModelLoader.item ?
67 postCaptureModelLoader.item.model : null
68 property bool loadModel: mainView.currentIndex == 2 && Qt.application.active
71 id: postCaptureModelLoader
72 sourceComponent: loadModel ? postCaptureModelComponent : undefined
75 // We have to do it that way because Loader does not support non-visual elements.
77 id: postCaptureModelComponent
80 property alias model: postCaptureModel
84 manufacturer: deviceInfo.manufacturer
85 model: deviceInfo.model
86 Component.onCompleted: reload()
88 console.log("Error populating model " + msg)
89 showError(qsTr("Failed to load captures"))
105 anchors.bottom: parent.bottom
106 anchors.bottomMargin: show ? 20 : -1 * (height + 20)
107 anchors.left: parent.left
108 anchors.leftMargin: 20
111 property bool show: deleteDialog.isOpen || deleteDialog.isOpening ||
112 hideTimer.running || menu.isOpen || menu.isOpening ||
113 (view.currentItem && view.currentItem.error) && !view.currentItem.playing
115 Behavior on anchors.bottomMargin {
116 PropertyAnimation { duration: 200; }
121 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"
123 addOrRemoveFavorite()
128 iconId: available ? "icon-m-toolbar-share-white" : "icon-m-toolbar-share-dimmed-white"
135 iconId: available ? "icon-m-toolbar-delete-white" : "icon-m-toolbar-delete-dimmed-white"
142 iconId: "icon-m-toolbar-view-menu-white"
153 titleText: qsTr("Delete item?");
154 acceptButtonText: qsTr("Yes");
155 rejectButtonText: qsTr("No");
157 onStatusChanged: restartTimer()
160 if (!remove.remove(view.currentItem.itemData.url)) {
161 showError(qsTr("Failed to delete item"))
163 postCaptureModel.remove(view.currentItem.itemData);
174 onStatusChanged: restartTimer()
178 text: qsTr("Captures in gallery")
179 onClicked: launchGallery()
182 // TODO: this is not working...
183 text: qsTr("View in gallery")
185 onClicked: showInGallery()
191 opacity: toolBar.opacity
192 anchors.top: parent.top
193 anchors.topMargin: toolBar.show ? 20 : -1 * (height + 20)
194 anchors.left: parent.left
195 anchors.leftMargin: 20
196 anchors.right: parent.right
197 anchors.rightMargin: 20
198 visible: toolBar.visible
199 height: screen.isPortrait ? toolBar.height * 2 : toolBar.height
201 border.color: toolBar.border.color
202 radius: toolBar.radius
204 Behavior on anchors.topMargin {
205 PropertyAnimation { duration: 200; }
209 width: parent.width - 40
211 height: parent.height
214 text: view.currentItem ? view.currentItem.itemData.title : ""
215 width: parent.width / 2
216 height: parent.height
218 verticalAlignment: Text.AlignVCenter
219 horizontalAlignment: Text.AlignLeft
223 text: view.currentItem ? view.currentItem.itemData.created : ""
224 width: parent.width / 2
225 height: parent.height
227 verticalAlignment: Text.AlignVCenter
228 horizontalAlignment: Text.AlignRight
233 function launchGallery() {
234 if (!gallery.launch()) {
235 showError(qsTr("Failed to launch gallery"))
239 function showInGallery() {
244 if (!gallery.show(view.currentItem.itemUrl)) {
245 showError(qsTr("Failed to launch gallery"))
249 function deleteCurrentItem() {
254 deleteDialog.message = view.currentItem.itemData.fileName
258 function shareCurrentItem() {
263 if (!share.share(view.currentItem.itemData.url)) {
264 showError(qsTr("Failed to launch share service"))
268 function addOrRemoveFavorite() {
273 if (view.currentItem.itemData.favorite) {
274 if (!trackerStore.removeFromFavorites(view.currentItem.itemData.url)) {
275 showError(qsTr("Failed to remove favorite"))
277 view.currentItem.itemData.favorite = false
280 if (!trackerStore.addToFavorites(view.currentItem.itemData.url)) {
281 showError(qsTr("Failed to add favorite"))
283 view.currentItem.itemData.favorite = true
288 function restartTimer() {
292 function policyLost() {
293 if (view.currentItem && view.currentItem.playing) {
294 view.currentItem.stopPlayback()