setIntValue does not set the value if it's equal to the old one. Added a force flag...
authorMohammed Sameer <msameer@foolab.org>
Sat, 8 Sep 2012 11:23:08 +0000 (14:23 +0300)
committerMohammed Sameer <msameer@foolab.org>
Sat, 8 Sep 2012 11:23:08 +0000 (14:23 +0300)
lib/qtcamcapability_p.h
lib/qtcamcolortone.cpp
lib/qtcamflash.cpp
lib/qtcamscene.cpp
lib/qtcamwhitebalance.cpp

index b060ef3..54d9829 100644 (file)
@@ -57,12 +57,22 @@ public:
     return true;
   }
 
-  bool setIntValue(int val) {
+  bool setIntValue(int val, bool force) {
     if (!src) {
       return false;
     }
 
-    g_object_set(src, prop.toAscii().data(), val, NULL);
+    if (force) {
+      g_object_set(src, prop.toAscii().data(), val, NULL);
+      return true;
+    }
+
+    int old = 0;
+    g_object_get(src, prop.toAscii().data(), &old, NULL);
+
+    if (old != val) {
+      g_object_set(src, prop.toAscii().data(), val, NULL);
+    }
 
     return true;
   }
index a396845..14487f1 100644 (file)
@@ -37,5 +37,5 @@ QtCamColorTone::ColorToneMode QtCamColorTone::value() {
 }
 
 bool QtCamColorTone::setValue(const QtCamColorTone::ColorToneMode& mode) {
-  return d_ptr->setIntValue(mode);
+  return d_ptr->setIntValue(mode, false);
 }
index c83ff54..97e76c3 100644 (file)
@@ -29,5 +29,5 @@ QtCamFlash::FlashMode QtCamFlash::value() {
 }
 
 bool QtCamFlash::setValue(const QtCamFlash::FlashMode& mode) {
-  return d_ptr->setIntValue(mode);
+  return d_ptr->setIntValue(mode, false);
 }
index 333697c..b0f6bf8 100644 (file)
@@ -31,5 +31,6 @@ QtCamScene::SceneMode QtCamScene::value() {
 }
 
 bool QtCamScene::setValue(const QtCamScene::SceneMode& mode) {
-  return d_ptr->setIntValue(mode);
+  // Scene mode is always forced in order to reset the other capabilities.
+  return d_ptr->setIntValue(mode, true);
 }
index 665d91c..f39fe3c 100644 (file)
@@ -32,5 +32,5 @@ QtCamWhiteBalance::WhiteBalanceMode QtCamWhiteBalance::value() {
 }
 
 bool QtCamWhiteBalance::setValue(const QtCamWhiteBalance::WhiteBalanceMode& mode) {
-  return d_ptr->setIntValue(mode);
+  return d_ptr->setIntValue(mode, false);
 }