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
24 import com.nokia.meego 1.1
31 controlsVisible: false
32 policyMode: CameraResources.None
33 activationData: ControlsActivationData {standbyVisible: !Qt.application.active}
35 property Item currentItem: null
36 property bool available: currentItem ? currentItem.itemData.available : false
38 Component.onCompleted: postCaptureModel.reload();
40 function launchGallery() {
41 if (!gallery.launch()) {
42 showError(qsTr("Failed to launch gallery"));
46 function showInGallery() {
51 if (!gallery.show(currentItem.itemUrl)) {
52 showError(qsTr("Failed to launch gallery"));
58 onStatusChanged: page.restartTimer();
61 MenuItem {text: qsTr("Captures in gallery"); onClicked: launchGallery(); }
62 MenuItem {text: qsTr("View in gallery"); enabled: available; onClicked: showInGallery(); }
66 function deleteCurrentItem() {
71 deleteDialog.message = currentItem.itemData.fileName;
77 titleText: qsTr("Delete item?");
78 acceptButtonText: qsTr("Yes");
79 rejectButtonText: qsTr("No");
81 onStatusChanged: page.restartTimer();
84 if (!remove.remove(currentItem.itemData.url)) {
85 showError(qsTr("Failed to delete item"));
88 postCaptureModel.remove(currentItem.itemData);
97 function shareCurrentItem() {
102 if (!share.share(currentItem.itemData.url)) {
103 showError(qsTr("Failed to launch share service"));
107 function addOrRemoveFavorite() {
112 if (currentItem.itemData.favorite) {
113 if (!trackerStore.removeFromFavorites(currentItem.itemData.url)) {
114 showError(qsTr("Failed to remove favorite"));
117 currentItem.itemData.favorite = false;
121 if (!trackerStore.addToFavorites(currentItem.itemData.url)) {
122 showError(qsTr("Failed to add favorite"));
125 currentItem.itemData.favorite = true;
149 startY: view.height / 2
150 PathLine { x: view.width * 2; y: view.height / 2 }
153 // Insanely high value to prevent panning multiple images
154 flickDeceleration: 999999
156 preferredHighlightBegin: 0.5
157 preferredHighlightEnd: 0.5
158 highlightRangeMode: PathView.StrictlyEnforceRange
161 model: PostCaptureModel {
163 manufacturer: deviceInfo.manufacturer
164 model: deviceInfo.model
166 console.log("Error populating model " + msg);
167 showError(qsTr("Failed to load captures"));
172 // TODO: Hide this when we have no items
173 text: qsTr("No captures available");
174 anchors.centerIn: parent
176 visible: currentItem == null
179 delegate: PostCaptureItem {
182 onClicked: hideTimer.running = !hideTimer.running;
186 function restartTimer() {
187 hideTimer.running = true;
200 anchors.bottom: parent.bottom
201 anchors.bottomMargin: show ? 20 : -1 * (height + 20)
202 anchors.left: parent.left
203 anchors.leftMargin: 20
206 property bool show: deleteDialog.status == DialogStatus.Open || deleteDialog.status == DialogStatus.Opening || hideTimer.running || menu.status == DialogStatus.Open || menu.status == DialogStatus.Opening || (currentItem && currentItem.error)
208 onClicked: pageStack.pop();
210 Behavior on anchors.bottomMargin {
211 PropertyAnimation { duration: 200; }
215 ToolIcon { iconId: !available ? "icon-m-toolbar-favorite-mark-dimmed-white" : currentItem.itemData.favorite ? "icon-m-toolbar-favorite-mark-white" : "icon-m-toolbar-favorite-unmark-white"; onClicked: { addOrRemoveFavorite(); page.restartTimer(); } },
216 ToolIcon { iconId: available ? "icon-m-toolbar-share-white" : "icon-m-toolbar-share-dimmed-white"; onClicked: { shareCurrentItem(); page.restartTimer(); } },
217 ToolIcon { iconId: available ? "icon-m-toolbar-delete-white" : "icon-m-toolbar-delete-dimmed-white"; onClicked: { deleteCurrentItem(); page.restartTimer(); } },
218 ToolIcon { iconId: "icon-m-toolbar-view-menu-white"; onClicked: { menu.open(); page.restartTimer(); } }
223 opacity: toolBar.opacity
224 anchors.top: parent.top
225 anchors.topMargin: toolBar.show ? 20 : -1 * (height + 20)
226 anchors.left: parent.left
227 anchors.leftMargin: 20
228 anchors.right: parent.right
229 anchors.rightMargin: 20
230 visible: toolBar.visible
231 height: screen.isPortrait ? toolBar.height * 2 : toolBar.height
233 border.color: toolBar.border.color
234 radius: toolBar.radius
236 Behavior on anchors.topMargin {
237 PropertyAnimation { duration: 200; }
241 width: parent.width - 40
243 height: parent.height
246 text: currentItem ? currentItem.itemData.title : ""
247 width: parent.width / 2
248 height: parent.height
250 verticalAlignment: Text.AlignVCenter
251 horizontalAlignment: Text.AlignLeft
255 text: currentItem ? currentItem.itemData.created : ""
256 width: parent.width / 2
257 height: parent.height
259 verticalAlignment: Text.AlignVCenter
260 horizontalAlignment: Text.AlignRight