// -*- qml -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
import QtQuick 1.1
import com.nokia.meego 1.1
import QtCamera 1.0
-import QtSparql 1.0
import CameraPlus 1.0
-// QML QtGallery stuff is crap.
-// Most of the ideas (and some code) for loading and displaying images are stolen from
-// N9QmlPhotoPicker https://github.com/petrumotrescu/N9QmlPhotoPicker
+CameraPage {
+ id: page
-// TODO: this is really basic.
+ controlsVisible: false
+ policyMode: CameraResources.None
+ standbyVisible: !Qt.application.active
-Page {
- id: page
- property Camera cam: null
+ property Item currentItem: null
+ property bool available: currentItem ? currentItem.itemData.available : false
+
+ Component.onCompleted: postCaptureModel.reload();
+
+ function launchGallery() {
+ if (!gallery.launch()) {
+ showError(qsTr("Failed to launch gallery"));
+ }
+ }
+
+ function showInGallery() {
+ if (!available) {
+ return;
+ }
+
+ if (!gallery.show(currentItem.itemUrl)) {
+ showError(qsTr("Failed to launch gallery"));
+ }
+ }
+
+ Menu {
+ id: menu
+ onStatusChanged: page.restartTimer();
+
+ MenuLayout {
+ MenuItem {text: qsTr("Captures in gallery"); onClicked: launchGallery(); }
+ MenuItem {text: qsTr("View in gallery"); enabled: available; onClicked: showInGallery(); }
+ }
+ }
+
+ function deleteCurrentItem() {
+ if (!available) {
+ return;
+ }
+
+ deleteDialog.message = currentItem.itemData.fileName;
+ deleteDialog.open();
+ }
+
+ QueryDialog {
+ id: deleteDialog
+ titleText: qsTr("Delete item?");
+ acceptButtonText: qsTr("Yes");
+ rejectButtonText: qsTr("No");
+
+ onStatusChanged: page.restartTimer();
+
+ onAccepted: {
+ if (!remove.remove(currentItem.itemData.url)) {
+ showError(qsTr("Failed to delete item"));
+ }
+ else {
+ postCaptureModel.remove(currentItem.itemData);
+ }
+ }
+
+ DeleteHelper {
+ id: remove
+ }
+ }
+
+ function shareCurrentItem() {
+ if (!available) {
+ return;
+ }
+
+ if (!share.share(currentItem.itemData.url)) {
+ showError(qsTr("Failed to launch share service"));
+ }
+ }
+
+ function addOrRemoveFavorite() {
+ if (!available) {
+ return;
+ }
+
+ if (currentItem.itemData.favorite) {
+ if (!trackerStore.removeFromFavorites(currentItem.itemData.url)) {
+ showError(qsTr("Failed to remove favorite"));
+ }
+ else {
+ currentItem.itemData.favorite = false;
+ }
+ }
+ else {
+ if (!trackerStore.addToFavorites(currentItem.itemData.url)) {
+ showError(qsTr("Failed to add favorite"));
+ }
+ else {
+ currentItem.itemData.favorite = true;
+ }
+ }
+ }
+
+ ShareHelper {
+ id: share
+ }
+
+ GalleryHelper {
+ id: gallery
+ }
Rectangle {
color: "black"
PathLine { x: view.width * 2; y: view.height / 2 }
}
- flickDeceleration: 999999 // Insanely high value to prevent panning multiple images
+ // Insanely high value to prevent panning multiple images
+ flickDeceleration: 999999
+
preferredHighlightBegin: 0.5
preferredHighlightEnd: 0.5
highlightRangeMode: PathView.StrictlyEnforceRange
pathItemCount: 3
- model: SparqlListModel {
- query: "SELECT nie:url(?urn) AS ?url tracker:id(?urn) AS ?trackerid nie:mimeType(?urn) AS ?mime WHERE { ?urn rdf:type nfo:Media . ?urn nfo:equipment \"urn:equipment:" + deviceInfo.manufacturer + ":" + deviceInfo.model + ":\" ; tracker:available \"true\"^^xsd:boolean OPTIONAL { ?urn nie:contentCreated ?created } } ORDER BY DESC (?created)"
-
- connection: SparqlConnection {
- id: connection
- driver: "QTRACKER_DIRECT"
- onStatusChanged: checkStatus(status)
-
- function checkStatus(status) {
- if (status == SparqlConnection.Error)
- console.log("Error = "+connection.errorString());
- }
+ model: PostCaptureModel {
+ id: postCaptureModel
+ manufacturer: deviceInfo.manufacturer
+ model: deviceInfo.model
+ onError: {
+ console.log("Error populating model " + msg);
+ showError(qsTr("Failed to load captures"));
}
}
- delegate: Item {
+ Label {
+ // TODO: Hide this when we have no items
+ text: qsTr("No captures available");
+ anchors.centerIn: parent
+ font.pixelSize: 36
+ visible: currentItem == null
+ }
+
+ delegate: PostCaptureItem {
width: view.width
height: view.height
+ onClicked: hideTimer.running = !hideTimer.running;
+ }
+ }
- Label {
- width: view.width - 10
- height: view.height
- anchors.centerIn: parent
- visible: item.error
- text: qsTr("Failed to load preview");
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- font.pixelSize: 32
- }
+ function restartTimer() {
+ hideTimer.running = true;
+ }
- QuillItem {
- id: item
- source: url
- mimeType: mime
- width: view.width - 10
- height: view.height
- anchors.centerIn: parent
- visible: !item.error
- }
- }
+ Timer {
+ id: hideTimer
+ running: false
+ interval: 3000
}
- ToolBar {
+ CameraToolBar {
id: toolBar
- opacity: 0.8
+ expanded: true
+ manualBack: true
anchors.bottom: parent.bottom
- tools: ToolBarLayout {
- id: layout
- ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
+ anchors.bottomMargin: show ? 20 : -1 * (height + 20)
+ anchors.left: parent.left
+ anchors.leftMargin: 20
+ opacity: 0.8
+
+ property bool show: deleteDialog.status == DialogStatus.Open || deleteDialog.status == DialogStatus.Opening || hideTimer.running || menu.status == DialogStatus.Open || menu.status == DialogStatus.Opening || (currentItem && currentItem.error)
+
+ onClicked: pageStack.pop();
+
+ Behavior on anchors.bottomMargin {
+ PropertyAnimation { duration: 200; }
+ }
+
+ items: [
+ 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(); } },
+ ToolIcon { iconId: available ? "icon-m-toolbar-share-white" : "icon-m-toolbar-share-dimmed-white"; onClicked: { shareCurrentItem(); page.restartTimer(); } },
+ ToolIcon { iconId: available ? "icon-m-toolbar-delete-white" : "icon-m-toolbar-delete-dimmed-white"; onClicked: { deleteCurrentItem(); page.restartTimer(); } },
+ ToolIcon { iconId: "icon-m-toolbar-view-menu-white"; onClicked: { menu.open(); page.restartTimer(); } }
+ ]
+ }
+
+ Rectangle {
+ opacity: toolBar.opacity
+ anchors.top: parent.top
+ anchors.topMargin: toolBar.show ? 20 : -1 * (height + 20)
+ anchors.left: parent.left
+ anchors.leftMargin: 20
+ anchors.right: parent.right
+ anchors.rightMargin: 20
+ visible: toolBar.visible
+ height: toolBar.height
+ color: toolBar.color
+ border.color: toolBar.border.color
+ radius: toolBar.radius
+
+ Behavior on anchors.topMargin {
+ PropertyAnimation { duration: 200; }
+ }
+
+ Label {
+ text: currentItem ? currentItem.itemData.title : ""
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.leftMargin: 20
+ font.bold: true
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ Label {
+ text: currentItem ? currentItem.itemData.created : ""
+ font.bold: true
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ anchors.rightMargin: 20
+ verticalAlignment: Text.AlignVCenter
}
}
}