Move all zoom cancellation functionality to its own component
authorMohammed Sameer <msameer@foolab.org>
Sun, 24 Mar 2013 12:38:08 +0000 (14:38 +0200)
committerMohammed Sameer <msameer@foolab.org>
Sun, 24 Mar 2013 12:38:08 +0000 (14:38 +0200)
qml/ImagePage.qml
qml/RecordingPage.qml
qml/VideoPage.qml
qml/ZoomCaptureCancel.qml [new file with mode: 0644]
qml/qml.qrc

index 38d95b6..65950de 100644 (file)
@@ -103,12 +103,11 @@ CameraPage {
                 onReleased: page.captureImage();
         }
 
-        MouseArea {
+        ZoomCaptureCancel {
                 anchors.fill: parent
-                enabled: zoomCapture.zoomPressed
-                z: 100
-                onPressed: {
-                        zoomCapture.zoomPressed = false;
+                page: page
+                zoomCapture: zoomCapture
+                onCanceled: {
                         if (!autoFocusTimer.running) {
                                 cam.autoFocus.stopAutoFocus();
                         }
index d317c59..89f27ed 100644 (file)
@@ -106,11 +106,10 @@ CameraPage {
                 onReleased: page.stopRecording();
         }
 
-        MouseArea {
+        ZoomCaptureCancel {
                 anchors.fill: parent
-                enabled: zoomCapture.zoomPressed
-                z: 100
-                onPressed: zoomCapture.zoomPressed = false;
+                page: page
+                zoomCapture: zoomCapture
         }
 
         CaptureButton {
index 347a247..c2dd5f8 100644 (file)
@@ -61,11 +61,10 @@ CameraPage {
                 onReleased: page.startRecording();
         }
 
-        MouseArea {
+        ZoomCaptureCancel {
                 anchors.fill: parent
-                enabled: zoomCapture.zoomPressed
-                z: 100
-                onPressed: zoomCapture.zoomPressed = false;
+                page: page
+                zoomCapture: zoomCapture
         }
 
         CaptureButton {
diff --git a/qml/ZoomCaptureCancel.qml b/qml/ZoomCaptureCancel.qml
new file mode 100644 (file)
index 0000000..ac33496
--- /dev/null
@@ -0,0 +1,67 @@
+// -*- qml -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012-2013 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 CameraPlus 1.0
+
+MouseArea {
+        id: zoomCancel
+        property Item page
+        property Item zoomCapture
+
+        signal canceled
+
+        z: 100
+        enabled: zoomCapture.zoomPressed
+
+        onPressed: {
+                zoomCancel.zoomCapture.zoomPressed = false;
+                zoomCancel.canceled();
+        }
+
+        Rectangle {
+                anchors.top: parent.top
+                opacity: parent.enabled ? 0.5 : 0
+                anchors.topMargin: 20
+                anchors.horizontalCenter: parent.horizontalCenter
+                visible: opacity > 0
+                height: label.height * 2
+                width: parent.width * 0.7
+                color: "black"
+                border.color: "gray"
+                radius: 20
+
+                Behavior on opacity {
+                        PropertyAnimation { duration: 100; }
+                }
+
+                Label {
+                        id: label
+                        anchors.verticalCenter: parent.verticalCenter
+                        width: parent.width
+                        text: qsTr("Tap anywhere to cancel");
+                        font.pixelSize: 24
+                        horizontalAlignment: Text.AlignHCenter
+                }
+        }
+}
index a45898b..73b838e 100644 (file)
@@ -42,5 +42,6 @@
        <file>VideoSettingsDialog.qml</file>
        <file>VideoResolutionSettings.qml</file>
        <file>ZoomCaptureButton.qml</file>
+       <file>ZoomCaptureCancel.qml</file>
     </qresource>
 </RCC>