Added grid lines
[harmattan/cameraplus] / src / settings.cpp
index 9eb2b49..8d16faa 100644 (file)
@@ -24,9 +24,8 @@
 
 #define PATH QString("%1%2.config%2/cameraplus.conf").arg(QDir::homePath()).arg(QDir::separator())
 
-#define DEFAULT_MODE               0
+#define DEFAULT_MODE               1
 #define DEFAULT_SCENE_MODE         6 // Auto
-#define DEFAULT_TIMEOUT            0
 #define DEFAULT_USE_GPS            true
 #define DEFAULT_USE_GEOTAGS        true
 #define DEFAULT_COLOR_FILTER       0
 #define DEFAULT_IMAGE_ISO          0
 #define DEFAULT_IMAGE_RESOLUTION   "high"
 #define DEFAULT_IMAGE_ASPECT_RATIO "16:9"
+#define DEFAULT_VIDEO_RESOLUTION   "high"
+#define DEFAULT_SOUND_ENABLED      true
+#define DEFAULT_VIDEO_TORCH_ON     false
+#define DEFAULT_SHOW_TOOL_BAR      false
+#define DEFAULT_VIDEO_MUTE         false
+#define DEFAULT_GRID_ENABLED       false
 
 Settings::Settings(QObject *parent) :
   QObject(parent),
@@ -71,18 +76,6 @@ void Settings::setCreatorName(const QString& name) {
   }
 }
 
-int Settings::postCaptureTimeout() const {
-  return m_settings->value("camera/postCaptureTimeout", DEFAULT_TIMEOUT).toInt();
-}
-
-void Settings::setPostCaptureTimeout(int timeout) {
-  if (timeout != postCaptureTimeout()) {
-    m_settings->setValue("camera/postCaptureTimeout", timeout);
-
-    emit postCaptureTimeoutChanged();
-  }
-}
-
 bool Settings::useGps() const {
   return m_settings->value("camera/useGps", DEFAULT_USE_GPS).toBool();
 }
@@ -114,9 +107,9 @@ int Settings::imageSceneMode() const {
 void Settings::setImageSceneMode(int mode) {
   if (mode != imageSceneMode()) {
     m_settings->setValue("image/sceneMode", mode);
-
-    emit imageSceneModeChanged();
   }
+
+  emit imageSceneModeChanged();
 }
 
 int Settings::imageColorFilter() const {
@@ -148,7 +141,7 @@ qreal Settings::imageEvComp() const {
 }
 
 void Settings::setImageEvComp(qreal ev) {
-  if (ev != imageEvComp()) {
+  if (!qFuzzyCompare(ev, imageEvComp())) {
     m_settings->setValue("image/evComp", ev);
 
     emit imageEvCompChanged();
@@ -162,9 +155,9 @@ int Settings::videoSceneMode() const {
 void Settings::setVideoSceneMode(int mode) {
   if (mode != videoSceneMode()) {
     m_settings->setValue("video/sceneMode", mode);
-
-    emit videoSceneModeChanged();
   }
+
+  emit videoSceneModeChanged();
 }
 
 int Settings::videoColorFilter() const {
@@ -196,7 +189,7 @@ qreal Settings::videoEvComp() const {
 }
 
 void Settings::setVideoEvComp(qreal ev) {
-  if (ev != videoEvComp()) {
+  if (!qFuzzyCompare(ev, videoEvComp())) {
     m_settings->setValue("video/evComp", ev);
 
     emit videoEvCompChanged();
@@ -247,3 +240,83 @@ void Settings::setImageResolution(const QString& resolution) {
     emit imageResolutionChanged();
   }
 }
+
+QString Settings::videoAspectRatio() const {
+  // This is not used for anything so we will return an empty string for now
+  // which will make the backend return all resolutions.
+
+  return QString();
+}
+
+void Settings::setVideoAspectRatio(const QString& aspectRatio) {
+  Q_UNUSED(aspectRatio);
+
+  // This is not used for anything so we will just ignore it.
+}
+
+QString Settings::videoResolution() const {
+  return m_settings->value("video/resolution", DEFAULT_VIDEO_RESOLUTION).toString();
+}
+
+void Settings::setVideoResolution(const QString& resolution) {
+  if (resolution != videoResolution()) {
+    m_settings->setValue("video/resolution", 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();
+  }
+}
+
+bool Settings::isVideoTorchOn() const {
+  return m_settings->value("video/torchOn", DEFAULT_VIDEO_TORCH_ON).toBool();
+}
+
+void Settings::setVideoTorchOn(bool on) {
+  if (isVideoTorchOn() != on) {
+    m_settings->setValue("video/torchOn", on);
+    emit videoTorchOnChanged();
+  }
+}
+
+bool Settings::isToolBarShown() const {
+  return m_settings->value("camera/showToolBar", DEFAULT_SHOW_TOOL_BAR).toBool();
+}
+
+void Settings::setToolBarShown(bool shown) {
+  if (isToolBarShown() != shown) {
+    m_settings->setValue("camera/showToolBar", shown);
+
+    emit toolBarShownChanged();
+  }
+}
+
+bool Settings::isVideoMuted() const {
+  return m_settings->value("video/mute", DEFAULT_VIDEO_MUTE).toBool();
+}
+
+void Settings::setVideoMuted(bool muted) {
+  if (isVideoMuted() != muted) {
+    m_settings->setValue("video/mute", muted);
+    emit videoMutedChanged();
+  }
+}
+
+bool Settings::isGridEnabled() const {
+  return m_settings->value("camera/gridEnabled", DEFAULT_GRID_ENABLED).toBool();
+}
+
+void Settings::setGridEnabled(bool enabled) {
+  if (enabled != isGridEnabled()) {
+    m_settings->setValue("camera/gridEnabled", enabled);
+    emit gridEnabledChanged();
+  }
+}