From cfd928f873feadc44b25b2988eb34794e106a421 Mon Sep 17 00:00:00 2001 From: Mohammed Sameer Date: Wed, 17 Jul 2013 02:30:38 +0300 Subject: [PATCH] Added CameraConfig to QtCamera declarative module --- declarative/camera.cpp | 8 ++++- declarative/camera.h | 8 +++++ declarative/cameraconfig.cpp | 68 ++++++++++++++++++++++++++++++++++++ declarative/cameraconfig.h | 56 +++++++++++++++++++++++++++++ declarative/declarative.pro | 4 +-- declarative/plugin.cpp | 4 +-- 6 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 declarative/cameraconfig.cpp create mode 100644 declarative/cameraconfig.h diff --git a/declarative/camera.cpp b/declarative/camera.cpp index 64aa6b9..86ccaa4 100644 --- a/declarative/camera.cpp +++ b/declarative/camera.cpp @@ -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; +} diff --git a/declarative/camera.h b/declarative/camera.h index f7af0ac..37665ac 100644 --- a/declarative/camera.h +++ b/declarative/camera.h @@ -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 index 0000000..b247d62 --- /dev/null +++ b/declarative/cameraconfig.cpp @@ -0,0 +1,68 @@ +// -*- c++ -*- + +/*! + * This file is part of CameraPlus. + * + * Copyright (C) 2012-2013 Mohammed Sameer + * + * 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 + +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 index 0000000..71da9ba --- /dev/null +++ b/declarative/cameraconfig.h @@ -0,0 +1,56 @@ +// -*- c++ -*- + +/*! + * This file is part of CameraPlus. + * + * Copyright (C) 2012-2013 Mohammed Sameer + * + * 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 +#include + +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 */ diff --git a/declarative/declarative.pro b/declarative/declarative.pro index d5ae42c..8b8c3a3 100644 --- a/declarative/declarative.pro +++ b/declarative/declarative.pro @@ -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 diff --git a/declarative/plugin.cpp b/declarative/plugin.cpp index d94d8b2..56c23e2 100644 --- a/declarative/plugin.cpp +++ b/declarative/plugin.cpp @@ -46,10 +46,9 @@ #include "videoresolutionmodel.h" #include "declarativeqtcameranotifications.h" #include "sounds.h" - +#include "cameraconfig.h" #include -#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(); + qmlRegisterType(uri, MAJOR, MINOR, "CameraConfig"); } Q_EXPORT_PLUGIN2(declarativeqtcamera, Plugin); -- 2.34.1