Added CameraConfig to QtCamera declarative module
authorMohammed Sameer <msameer@foolab.org>
Tue, 16 Jul 2013 23:30:38 +0000 (02:30 +0300)
committerMohammed Sameer <msameer@foolab.org>
Tue, 16 Jul 2013 23:30:38 +0000 (02:30 +0300)
declarative/camera.cpp
declarative/camera.h
declarative/cameraconfig.cpp [new file with mode: 0644]
declarative/cameraconfig.h [new file with mode: 0644]
declarative/declarative.pro
declarative/plugin.cpp

index 64aa6b9..86ccaa4 100644 (file)
@@ -48,6 +48,7 @@
 
 #include "videomute.h"
 #include "videotorch.h"
+#include "cameraconfig.h"
 
 Camera::Camera(QDeclarativeItem *parent) :
   QDeclarativeItem(parent),
@@ -71,7 +72,8 @@ Camera::Camera(QDeclarativeItem *parent) :
   m_autoFocus(0),
   m_roi(0),
   m_videoMute(0),
-  m_videoTorch(0) {
+  m_videoTorch(0),
+  m_config(new CameraConfig(this)) {
 
   QObject::connect(m_vf, SIGNAL(renderAreaChanged()), this, SIGNAL(renderAreaChanged()));
   QObject::connect(m_vf, SIGNAL(videoResolutionChanged()), this, SIGNAL(videoResolutionChanged()));
@@ -439,3 +441,7 @@ bool Camera::isRenderingEnabled() const {
 void Camera::setRenderingEnabled(bool enabled) {
   m_vf->setRenderingEnabled(enabled);
 }
+
+CameraConfig *Camera::cameraConfig() const {
+  return m_config;
+}
index f7af0ac..37665ac 100644 (file)
@@ -48,6 +48,7 @@ class AutoFocus;
 class Roi;
 class VideoMute;
 class VideoTorch;
+class CameraConfig;
 
 class Camera : public QDeclarativeItem {
   Q_OBJECT
@@ -83,6 +84,8 @@ class Camera : public QDeclarativeItem {
   Q_PROPERTY(VideoTorch *videoTorch READ videoTorch NOTIFY videoTorchChanged);
 
   Q_PROPERTY(bool renderingEnabled READ isRenderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged);
+  // TODO: We need a setter here too.
+  Q_PROPERTY(CameraConfig *cameraConfig READ cameraConfig CONSTANT);
 
   Q_ENUMS(CameraMode);
 
@@ -146,6 +149,8 @@ public:
   bool isRenderingEnabled() const;
   void setRenderingEnabled(bool enabled);
 
+  CameraConfig *cameraConfig() const;
+
 signals:
   void deviceCountChanged();
   void deviceIdChanged();
@@ -177,6 +182,8 @@ signals:
   void videoTorchChanged();
   void renderingEnabledChanged();
 
+  void cameraConfigChanged();
+
 protected:
   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
 
@@ -211,6 +218,7 @@ private:
 
   VideoMute *m_videoMute;
   VideoTorch *m_videoTorch;
+  CameraConfig *m_config;
 };
 
 #endif /* CAMERA_H */
diff --git a/declarative/cameraconfig.cpp b/declarative/cameraconfig.cpp
new file mode 100644 (file)
index 0000000..b247d62
--- /dev/null
@@ -0,0 +1,68 @@
+// -*- c++ -*-
+
+/*!
+ * 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 "cameraconfig.h"
+#include "qtcamconfig.h"
+#include <QDeclarativeInfo>
+
+CameraConfig::CameraConfig(QObject *parent) :
+  QObject(parent),
+  m_config(0) {
+
+}
+
+CameraConfig::~CameraConfig() {
+  m_config = 0;
+}
+
+QString CameraConfig::configPath() const {
+  return m_path;
+}
+
+void CameraConfig::setConfigPath(const QString& configPath) {
+  if (m_config) {
+    qmlInfo(this) << "configPath cannot be changed after initialization";
+    return;
+  }
+
+  if (m_path != configPath) {
+    m_path = configPath;
+    emit configPathChanged();
+  }
+}
+
+QtCamConfig *CameraConfig::config() const {
+  return m_config;
+}
+
+void CameraConfig::classBegin() {
+  // Nothing
+}
+
+void CameraConfig::componentComplete() {
+  if (m_path.isEmpty()) {
+    m_config = new QtCamConfig(this);
+  }
+  else {
+    m_config = new QtCamConfig(m_path, this);
+  }
+}
diff --git a/declarative/cameraconfig.h b/declarative/cameraconfig.h
new file mode 100644 (file)
index 0000000..71da9ba
--- /dev/null
@@ -0,0 +1,56 @@
+// -*- c++ -*-
+
+/*!
+ * 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
+ */
+
+#ifndef CAMERA_CONFIG_H
+#define CAMERA_CONFIG_H
+
+#include <QObject>
+#include <QDeclarativeParserStatus>
+
+class QtCamConfig;
+
+class CameraConfig : public QObject, public QDeclarativeParserStatus {
+  Q_OBJECT
+
+  Q_PROPERTY(QString configPath READ configPath WRITE setConfigPath NOTIFY configPathChanged);
+
+public:
+  CameraConfig(QObject *parent = 0);
+  ~CameraConfig();
+
+  QString configPath() const;
+  void setConfigPath(const QString& configPath);
+
+  QtCamConfig *config() const;
+
+  virtual void classBegin();
+  virtual void componentComplete();
+
+signals:
+  void configPathChanged();
+
+private:
+  QString m_path;
+  QtCamConfig *m_config;
+};
+
+#endif /* CAMERA_CONFIG_H */
index d5ae42c..8b8c3a3 100644 (file)
@@ -17,7 +17,7 @@ HEADERS += plugin.h previewprovider.h camera.h mode.h imagemode.h videomode.h \
            flickerreduction.h videomute.h metadata.h imagesettings.h \
            imageresolutionmodel.h videosettings.h videoresolutionmodel.h \
            notificationscontainer.h sounds.h focus.h autofocus.h \
-           roi.h
+           roi.h cameraconfig.h
 
 SOURCES += plugin.cpp previewprovider.cpp camera.cpp mode.cpp imagemode.cpp videomode.cpp \
            zoom.cpp flash.cpp scene.cpp evcomp.cpp videotorch.cpp whitebalance.cpp \
@@ -25,7 +25,7 @@ SOURCES += plugin.cpp previewprovider.cpp camera.cpp mode.cpp imagemode.cpp vide
            flickerreduction.cpp videomute.cpp metadata.cpp imagesettings.cpp \
            imageresolutionmodel.cpp videosettings.cpp videoresolutionmodel.cpp \
            notificationscontainer.cpp sounds.cpp focus.cpp autofocus.cpp \
-           roi.cpp
+           roi.cpp cameraconfig.cpp
 
 HEADERS += declarativeqtcameranotifications.h
 
index d94d8b2..56c23e2 100644 (file)
 #include "videoresolutionmodel.h"
 #include "declarativeqtcameranotifications.h"
 #include "sounds.h"
-
+#include "cameraconfig.h"
 #include <QtDeclarative>
 
-#define URI "QtCamera"
 #define MAJOR 1
 #define MINOR 0
 
@@ -103,6 +102,7 @@ void Plugin::registerTypes(const char *uri) {
                          "VideoResolutionModel can be obtained from VideoSettings");
 
   qmlRegisterType<Mode>();
+  qmlRegisterType<CameraConfig>(uri, MAJOR, MINOR, "CameraConfig");
 }
 
 Q_EXPORT_PLUGIN2(declarativeqtcamera, Plugin);