Added an option to disable (mute) camera sound
authorMohammed Sameer <msameer@foolab.org>
Thu, 27 Sep 2012 20:54:37 +0000 (23:54 +0300)
committerMohammed Sameer <msameer@foolab.org>
Thu, 27 Sep 2012 20:54:37 +0000 (23:54 +0300)
qml/CameraSettings.qml
qml/main.qml
src/settings.cpp
src/settings.h

index 8a14614..0982165 100644 (file)
@@ -75,6 +75,26 @@ Column {
                 onTextChanged: settings.creatorName = text;
         }
 
+        Item {
+                width: parent.width
+                height: Math.max(enableCameraSoundsLabel.height, enableCameraSounds.height);
+
+                Label {
+                        id: enableCameraSoundsLabel
+                        anchors.left: parent.left
+                        text: qsTr("Enable camera sounds");
+                }
+
+                Switch {
+                        id: enableCameraSounds
+                        anchors.right: parent.right
+                        // 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.soundEnabled;
+                        onCheckedChanged: settings.soundEnabled = checked;
+                }
+        }
+
         Item {
                 width: parent.width
                 height: Math.max(useGpsLabel.height, useGps.height);
index 4e0592d..3759b2d 100644 (file)
@@ -247,6 +247,7 @@ PageStackWindow {
 
                 notifications: Sounds {
                         id: sounds
+                        mute: !settings.soundEnabled
                 }
         }
 
index 0cecbef..8918770 100644 (file)
@@ -37,6 +37,7 @@
 #define DEFAULT_IMAGE_RESOLUTION   "high"
 #define DEFAULT_IMAGE_ASPECT_RATIO "16:9"
 #define DEFAULT_VIDEO_RESOLUTION   "high"
+#define DEFAULT_SOUND_ENABLED      true
 
 Settings::Settings(QObject *parent) :
   QObject(parent),
@@ -272,3 +273,14 @@ void Settings::setVideoResolution(const QString& resolution) {
     emit videoResolutionChanged();
   }
 }
+
+bool Settings::isSoundEnabled() const {
+  return m_settings->value("camera/soundEnabled", DEFAULT_SOUND_ENABLED).toBool();
+}
+
+void Settings::setSoundEnabled(bool enabled) {
+  if (isSoundEnabled() != enabled) {
+    m_settings->setValue("camera/soundEnabled", enabled);
+    emit soundEnabledChanged();
+  }
+}
index f2a0fd0..684b45b 100644 (file)
@@ -54,6 +54,8 @@ class Settings : public QObject {
   Q_PROPERTY(QString videoAspectRatio READ videoAspectRatio WRITE setVideoAspectRatio NOTIFY videoAspectRatioChanged);
   Q_PROPERTY(QString videoResolution READ videoResolution WRITE setVideoResolution NOTIFY videoResolutionChanged);
 
+  Q_PROPERTY(bool soundEnabled READ isSoundEnabled WRITE setSoundEnabled NOTIFY soundEnabledChanged);
+
 public:
   Settings(QObject *parent = 0);
   ~Settings();
@@ -115,6 +117,9 @@ public:
   QString videoResolution() const;
   void setVideoResolution(const QString& resolution);
 
+  bool isSoundEnabled() const;
+  void setSoundEnabled(bool enabled);
+
 signals:
   void modeChanged();
   void creatorNameChanged();
@@ -135,6 +140,7 @@ signals:
   void imageResolutionChanged();
   void videoAspectRatioChanged();
   void videoResolutionChanged();
+  void soundEnabledChanged();
 
 private:
   QSettings *m_settings;