Added reset button to exposure settings
[harmattan/cameraplus] / lib / qtcamzoom.cpp
index 5bf0d8a..4eaa481 100644 (file)
@@ -1,3 +1,23 @@
+/*!
+ * 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
+ */
+
 #include "qtcamzoom.h"
 #include "qtcamcapability_p.h"
 #include "qtcamdevice_p.h"
@@ -78,7 +98,7 @@ public:
 QtCamZoom::QtCamZoom(QtCamDevice *dev, QObject *parent) :
   QtCamCapability(new QtCamZoomPrivate(dev, this), parent) {
 
-  ((QtCamZoomPrivate *) d_ptr)->init();
+  dynamic_cast<QtCamZoomPrivate *>(d_ptr)->init();
 }
 
 QtCamZoom::~QtCamZoom() {
@@ -86,11 +106,11 @@ QtCamZoom::~QtCamZoom() {
 }
 
 qreal QtCamZoom::value() {
-  return ((QtCamZoomPrivate *) d_ptr)->zoom();
+  return dynamic_cast<QtCamZoomPrivate *>(d_ptr)->zoom();
 }
 
 bool QtCamZoom::setValue(qreal zoom) {
-  if (((QtCamZoomPrivate *) d_ptr)->setZoom(zoom)) {
+  if (dynamic_cast<QtCamZoomPrivate *>(d_ptr)->setZoom(zoom)) {
     emit valueChanged();
     return true;
   }
@@ -99,9 +119,18 @@ bool QtCamZoom::setValue(qreal zoom) {
 }
 
 qreal QtCamZoom::minimumValue() {
+  if (!d_ptr->bin) {
+    return 1.0;
+  }
+
+  GParamSpec *pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(d_ptr->bin), "max-zoom");
+  if (pspec && G_IS_PARAM_SPEC_FLOAT(pspec)) {
+    return G_PARAM_SPEC_FLOAT(pspec)->minimum;
+  }
+
   return 1.0;
 }
 
 qreal QtCamZoom::maximumValue() {
-  return ((QtCamZoomPrivate *) d_ptr)->maxZoom();
+  return dynamic_cast<QtCamZoomPrivate *>(d_ptr)->maxZoom();
 }