Added Focus classes
authorMohammed Sameer <msameer@foolab.org>
Sun, 28 Oct 2012 22:15:22 +0000 (00:15 +0200)
committerMohammed Sameer <msameer@foolab.org>
Sun, 28 Oct 2012 22:15:22 +0000 (00:15 +0200)
imports/focus.cpp [new file with mode: 0644]
imports/focus.h [new file with mode: 0644]
imports/imports.pro
imports/plugin.cpp
lib/lib.pro
lib/qtcamfocus.cpp [new file with mode: 0644]
lib/qtcamfocus.h [new file with mode: 0644]

diff --git a/imports/focus.cpp b/imports/focus.cpp
new file mode 100644 (file)
index 0000000..99e6dc1
--- /dev/null
@@ -0,0 +1,57 @@
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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 "focus.h"
+#include "camera.h"
+
+Focus::Focus(QObject *parent) :
+  Capability(parent),
+  m_f(0) {
+
+}
+
+Focus::~Focus() {
+  if (m_f) {
+    delete m_f; m_f = 0;
+  }
+}
+
+void Focus::deviceChanged() {
+  if (m_f) {
+    delete m_f; m_f = 0;
+  }
+
+  if (m_cam->device()) {
+    m_f = new QtCamFocus(m_cam->device(), this);
+    QObject::connect(m_f, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
+  }
+
+  emit valueChanged();
+}
+
+Focus::FocusMode Focus::value() {
+  return m_f ? (FocusMode)m_f->value() : Focus::Auto;
+}
+
+void Focus::setValue(const Focus::FocusMode& mode) {
+  if (m_f) {
+    m_f->setValue((QtCamFocus::FocusMode)mode);
+  }
+}
diff --git a/imports/focus.h b/imports/focus.h
new file mode 100644 (file)
index 0000000..634aa59
--- /dev/null
@@ -0,0 +1,63 @@
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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
+ */
+
+#ifndef FOCUS_H
+#define FOCUS_H
+
+#include "capability.h"
+#include "qtcamfocus.h"
+
+class Focus : public Capability {
+  Q_OBJECT
+
+  Q_PROPERTY(FocusMode value READ value WRITE setValue NOTIFY valueChanged);
+  Q_ENUMS(FocusMode);
+
+public:
+  typedef enum {
+    Auto = QtCamFocus::Auto,
+    Macro = QtCamFocus::Macro,
+    Portrait = QtCamFocus::Portrait,
+    Infinity = QtCamFocus::Infinity,
+    Hyperfocal = QtCamFocus::Hyperfocal,
+    Extended = QtCamFocus::Extended,
+    ContinuousNormal = QtCamFocus::ContinuousNormal,
+    ContinuousExtended = QtCamFocus::ContinuousExtended,
+    Sport = QtCamFocus::Sport,
+  } FocusMode;
+
+  Focus(QObject *parent = 0);
+  ~Focus();
+
+  FocusMode value();
+  void setValue(const FocusMode& mode);
+
+signals:
+  void valueChanged();
+
+private:
+  virtual void deviceChanged();
+
+  QtCamFocus *m_f;
+};
+
+#endif /* FOCUS_H */
index b55a8d0..65b67ab 100644 (file)
@@ -15,11 +15,11 @@ HEADERS += plugin.h previewprovider.h camera.h mode.h imagemode.h videomode.h \
            colortone.h exposure.h aperture.h iso.h noisereduction.h \
            flickerreduction.h mute.h metadata.h imagesettings.h imageresolutionmodel.h \
            videosettings.h videoresolutionmodel.h notifications.h \
-           notificationscontainer.h sounds.h
+           notificationscontainer.h sounds.h focus.h
 
 SOURCES += plugin.cpp previewprovider.cpp camera.cpp mode.cpp imagemode.cpp videomode.cpp \
            capability.cpp zoom.cpp flash.cpp scene.cpp evcomp.cpp videotorch.cpp whitebalance.cpp \
            colortone.cpp exposure.cpp aperture.cpp iso.cpp noisereduction.cpp \
            flickerreduction.cpp mute.cpp metadata.cpp imagesettings.cpp imageresolutionmodel.cpp \
            videosettings.cpp videoresolutionmodel.cpp notifications.cpp \
-           notificationscontainer.cpp sounds.cpp
+           notificationscontainer.cpp sounds.cpp focus.cpp
index 1046c12..3585312 100644 (file)
@@ -36,6 +36,7 @@
 #include "iso.h"
 #include "noisereduction.h"
 #include "flickerreduction.h"
+#include "focus.h"
 #include "mute.h"
 #include "metadata.h"
 #include "imagesettings.h"
@@ -67,6 +68,7 @@ void Plugin::registerTypes(QDeclarativeEngine *engine) {
   qmlRegisterType<Iso>(URI, MAJOR, MINOR, "Iso");
   qmlRegisterType<NoiseReduction>(URI, MAJOR, MINOR, "NoiseReduction");
   qmlRegisterType<FlickerReduction>(URI, MAJOR, MINOR, "FlickerReduction");
+  qmlRegisterType<Focus>(URI, MAJOR, MINOR, "Focus");
   qmlRegisterType<Mute>(URI, MAJOR, MINOR, "Mute");
   qmlRegisterType<MetaData>(URI, MAJOR, MINOR, "MetaData");
   qmlRegisterType<ImageSettings>(URI, MAJOR, MINOR, "ImageSettings");
index 820fc85..1fad500 100644 (file)
@@ -18,7 +18,7 @@ HEADERS += qtcamconfig.h qtcamera.h qtcamscanner.h qtcamdevice.h qtcamviewfinder
            qtcamzoom.h qtcamflash.h qtcamscene.h qtcamevcomp.h qtcamvideotorch.h \
            qtcamwhitebalance.h qtcamcolortone.h qtcamflickerreduction.h \
            qtcamnoisereduction.h qtcamiso.h qtcamaperture.h qtcamexposure.h \
-           qtcammute.h qtcamnotifications.h
+           qtcammute.h qtcamnotifications.h qtcamfocus.h
 
 SOURCES += qtcamconfig.cpp qtcamera.cpp qtcamscanner.cpp qtcamdevice.cpp qtcamviewfinder.cpp \
            qtcammode.cpp qtcamgstreamermessagehandler.cpp qtcamgstreamermessagelistener.cpp \
@@ -28,7 +28,7 @@ SOURCES += qtcamconfig.cpp qtcamera.cpp qtcamscanner.cpp qtcamdevice.cpp qtcamvi
            qtcamzoom.cpp qtcamflash.cpp qtcamscene.cpp qtcamevcomp.cpp qtcamvideotorch.cpp \
            qtcamwhitebalance.cpp qtcamcolortone.cpp qtcamflickerreduction.cpp \
            qtcamnoisereduction.cpp qtcamiso.cpp qtcamaperture.cpp qtcamexposure.cpp \
-           qtcammute.cpp qtcamnotifications.cpp
+           qtcammute.cpp qtcamnotifications.cpp qtcamfocus.cpp
 
 HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h
 
diff --git a/lib/qtcamfocus.cpp b/lib/qtcamfocus.cpp
new file mode 100644 (file)
index 0000000..67cbb27
--- /dev/null
@@ -0,0 +1,57 @@
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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 "qtcamfocus.h"
+#include "qtcamcapability_p.h"
+
+QtCamFocus::QtCamFocus(QtCamDevice *dev, QObject *parent) :
+  QtCamCapability(new QtCamCapabilityPrivate(dev, QtCamCapability::Focus, "focus-mode"), parent) {
+
+}
+
+QtCamFocus::~QtCamFocus() {
+
+}
+
+QtCamFocus::FocusMode QtCamFocus::value() {
+  int val = 0;
+  if (!d_ptr->intValue(&val)) {
+    return QtCamFocus::Auto;
+  }
+
+  switch (val) {
+  case QtCamFocus::Macro:
+  case QtCamFocus::Portrait:
+  case QtCamFocus::Infinity:
+  case QtCamFocus::Hyperfocal:
+  case QtCamFocus::Extended:
+  case QtCamFocus::ContinuousNormal:
+  case QtCamFocus::ContinuousExtended:
+  case QtCamFocus::Sport:
+    return (QtCamFocus::FocusMode)val;
+
+  default:
+    return QtCamFocus::Auto;
+  }
+}
+
+bool QtCamFocus::setValue(const FocusMode& mode) {
+  return d_ptr->setIntValue(mode, false);
+}
diff --git a/lib/qtcamfocus.h b/lib/qtcamfocus.h
new file mode 100644 (file)
index 0000000..899cc83
--- /dev/null
@@ -0,0 +1,51 @@
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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
+ */
+
+#ifndef QT_CAM_FOCUS_H
+#define QT_CAM_FOCUS_H
+
+#include "qtcamcapability.h"
+
+class QtCamFocus : public QtCamCapability {
+  Q_OBJECT
+
+public:
+  typedef enum {
+    Auto = 0,
+    Macro = 1,
+    Portrait = 2,
+    Infinity = 3,
+    Hyperfocal = 4,
+    Extended = 5,
+    ContinuousNormal = 6,
+    ContinuousExtended = 7,
+    Sport = 8,
+  } FocusMode;
+
+  QtCamFocus(QtCamDevice *dev, QObject *parent = 0);
+  ~QtCamFocus();
+
+  FocusMode value();
+  bool setValue(const FocusMode& mode);
+};
+
+#endif /* QT_CAM_FOCUS_H */