From: Mohammed Sameer Date: Sat, 24 Aug 2013 09:18:00 +0000 (+0300) Subject: Added an option to enable using proximity sensor to capture X-Git-Url: http://cgit.sxemacs.org/?a=commitdiff_plain;h=e50fd1f3afa92b8edf2f9028c6c72d15e4538bdc;p=harmattan%2Fcameraplus Added an option to enable using proximity sensor to capture --- diff --git a/qml/CameraSettings.qml b/qml/CameraSettings.qml index 1a504a3..993c262 100644 --- a/qml/CameraSettings.qml +++ b/qml/CameraSettings.qml @@ -91,6 +91,15 @@ Column { onCheckedChanged: settings.zoomAsShutter = checked } + TextSwitch { + text: qsTr("Use proximity sensor for capture") + + // We have to do it that way because QML complains about a binding + // loop for checked if we bind the checked property to the settings value. + Component.onCompleted: checked = settings.proximityAsShutter + onCheckedChanged: settings.proximityAsShutter = checked + } + TextSwitch { text: qsTr("Enable camera sounds") diff --git a/qml/MainPage.qml b/qml/MainPage.qml index 37f80c5..151b55a 100644 --- a/qml/MainPage.qml +++ b/qml/MainPage.qml @@ -276,6 +276,12 @@ CameraPage { repeat: !settings.zoomAsShutter } + CameraProximitySensor { + id: proximitySensor + active: Qt.application.active && viewfinder.camera.running && settings.proximityAsShutter + } + + // TODO: Standby { policyLost: pipelineManager.state == "policyLost" show: !Qt.application.active || pipelineManager.showStandBy || diff --git a/qml/harmattan/CameraProximitySensor.qml b/qml/harmattan/CameraProximitySensor.qml new file mode 100644 index 0000000..2f7857c --- /dev/null +++ b/qml/harmattan/CameraProximitySensor.qml @@ -0,0 +1,31 @@ +// -*- qml -*- + +/*! + * This file is part of CameraPlus. + * + * Copyright (C) 2012-2013 Mohammed Sameer + * + * 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 QtMobility.sensors 1.2 + +ProximitySensor { + property bool close + onReadingChanged: close = reading.close + Component.onCompleted: close = reading.close + onActiveChanged: close = false +} diff --git a/qml/harmattan/harmattan.qrc b/qml/harmattan/harmattan.qrc index bbe0dfe..be7d401 100644 --- a/qml/harmattan/harmattan.qrc +++ b/qml/harmattan/harmattan.qrc @@ -15,5 +15,6 @@ FullScreenThumbnail.qml CameraPositionSource.qml CameraPage.qml + CameraProximitySensor.qml diff --git a/src/settings.cpp b/src/settings.cpp index 05ae2bc..dff01d0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -34,6 +34,7 @@ #define DEFAULT_GRID_ENABLED false #define DEFAULT_FACE_DETECTION_ENABLED true #define DEFAULT_ZOOM_AS_SHUTTER false +#define DEFAULT_PROXIMITY_AS_SHUTTER false #define DEFAULT_DEVICE 0 Settings::Settings(QObject *parent) : @@ -164,6 +165,18 @@ void Settings::setZoomAsShutterEnabled(bool enabled) { } } +bool Settings::isProximityAsShutterEnabled() const { + return m_settings->value("camera/proximityAsShutter", DEFAULT_PROXIMITY_AS_SHUTTER).toBool(); +} + +void Settings::setProximityAsShutterEnabled(bool enabled) { + if (isProximityAsShutterEnabled() != enabled) { + m_settings->setValue("camera/proximityAsShutter", enabled); + + emit proximityAsShutterChanged(); + } +} + int Settings::device() const { return m_settings->value("camera/device", DEFAULT_DEVICE).toInt(); } diff --git a/src/settings.h b/src/settings.h index 6b16cdc..b6ccaac 100644 --- a/src/settings.h +++ b/src/settings.h @@ -64,6 +64,7 @@ class Settings : public QObject { Q_PROPERTY(bool faceDetectionEnabled READ isFaceDetectionEnabled WRITE setFaceDetectionEnabled NOTIFY faceDetectionEnabledChanged); Q_PROPERTY(bool zoomAsShutter READ isZoomAsShutterEnabled WRITE setZoomAsShutterEnabled NOTIFY zoomAsShutterChanged); + Q_PROPERTY(bool proximityAsShutter READ isProximityAsShutterEnabled WRITE setProximityAsShutterEnabled NOTIFY proximityAsShutterChanged); Q_PROPERTY(int device READ device WRITE setDevice NOTIFY deviceChanged); public: @@ -145,6 +146,9 @@ public: bool isZoomAsShutterEnabled() const; void setZoomAsShutterEnabled(bool enabled); + bool isProximityAsShutterEnabled() const; + void setProximityAsShutterEnabled(bool enabled); + int device() const; void setDevice(int device); @@ -180,6 +184,7 @@ signals: void gridEnabledChanged(); void faceDetectionEnabledChanged(); void zoomAsShutterChanged(); + void proximityAsShutterChanged(); void deviceAboutToChange(); void deviceChanged();