Added new QML types to create VideoResolution and ImageResolution from QML
authorMohammed Sameer <msameer@foolab.org>
Tue, 13 Aug 2013 16:04:01 +0000 (19:04 +0300)
committerMohammed Sameer <msameer@foolab.org>
Tue, 13 Aug 2013 16:26:24 +0000 (19:26 +0300)
declarative/declarative.pro
declarative/imageresolution.cpp [new file with mode: 0644]
declarative/imageresolution.h [new file with mode: 0644]
declarative/plugin.cpp
declarative/videoresolution.cpp [new file with mode: 0644]
declarative/videoresolution.h [new file with mode: 0644]

index 18dcfe6..c7249f2 100644 (file)
@@ -21,7 +21,8 @@ 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 cameraconfig.h videoplayer.h viewfinder.h capability.h
+           roi.h cameraconfig.h videoplayer.h viewfinder.h capability.h \
+           imageresolution.h videoresolution.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 \
@@ -29,7 +30,8 @@ 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 cameraconfig.cpp videoplayer.cpp viewfinder.cpp capability.cpp
+           roi.cpp cameraconfig.cpp videoplayer.cpp viewfinder.cpp capability.cpp \
+           imageresolution.cpp videoresolution.cpp
 
 PLUGIN_IMPORT_PATH = QtCamera
 target.path = $$[QT_INSTALL_IMPORTS]/$$PLUGIN_IMPORT_PATH
diff --git a/declarative/imageresolution.cpp b/declarative/imageresolution.cpp
new file mode 100644 (file)
index 0000000..fdfd862
--- /dev/null
@@ -0,0 +1,163 @@
+// -*- 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 "imageresolution.h"
+
+ImageResolution::ImageResolution(QObject *parent) :
+  QObject(parent),
+  m_fps(-1),
+  m_nightFps(-1),
+  m_megaPixels(-1) {
+
+}
+
+ImageResolution::ImageResolution(const QtCamImageResolution& resolution, QObject *parent) :
+  QObject(parent),
+  m_resolutionId(resolution.id()),
+  m_name(resolution.name()),
+  m_aspectRatio(resolution.aspectRatio()),
+  m_capture(resolution.captureResolution()),
+  m_preview(resolution.previewResolution()),
+  m_viewfinder(resolution.viewfinderResolution()),
+  m_fps(resolution.frameRate()),
+  m_nightFps(resolution.nightFrameRate()),
+  m_megaPixels(resolution.megaPixels()) {
+
+}
+
+ImageResolution::~ImageResolution() {
+
+}
+
+QtCamImageResolution ImageResolution::resolution() {
+  return QtCamImageResolution(m_resolutionId, m_name, m_capture,
+                             m_preview, m_viewfinder, m_fps,
+                             m_nightFps, m_megaPixels, m_aspectRatio);
+}
+
+QString ImageResolution::resolutionId() const {
+  return m_resolutionId;
+}
+
+void ImageResolution::setResolutionId(const QString& resolutionId) {
+  if (m_resolutionId != resolutionId) {
+    m_resolutionId = resolutionId;
+
+    emit resolutionIdChanged();
+  }
+}
+
+QString ImageResolution::name() const {
+  return m_name;
+}
+
+void ImageResolution::setName(const QString& name) {
+  if (m_name != name) {
+    m_name = name;
+
+    emit nameChanged();
+  }
+}
+
+QString ImageResolution::aspectRatio() const {
+  return m_aspectRatio;
+}
+
+void ImageResolution::setAspectRatio(const QString& aspectRatio) {
+  if (m_aspectRatio != aspectRatio) {
+    m_aspectRatio = aspectRatio;
+
+    emit aspectRatioChanged();
+  }
+}
+
+QSize ImageResolution::capture() const {
+  return m_capture;
+}
+
+void ImageResolution::setCapture(const QSize& capture) {
+  if (m_capture != capture) {
+    m_capture = capture;
+
+    emit captureChanged();
+  }
+}
+
+QSize ImageResolution::preview() const {
+  return m_preview;
+}
+
+void ImageResolution::setPreview(const QSize& preview) {
+  if (m_preview != preview) {
+    m_preview = preview;
+
+    emit previewChanged();
+  }
+}
+
+QSize ImageResolution::viewfinder() const {
+  return m_viewfinder;
+}
+
+void ImageResolution::setViewfinder(const QSize& viewfinder) {
+  if (m_viewfinder != viewfinder) {
+    m_viewfinder = viewfinder;
+
+    emit viewfinderChanged();
+  }
+}
+
+int ImageResolution::fps() const {
+  return m_fps;
+}
+
+void ImageResolution::setFps(int fps) {
+  if (m_fps != fps) {
+    m_fps = fps;
+
+    emit fpsChanged();
+  }
+}
+
+int ImageResolution::nightFps() const {
+  return m_nightFps;
+}
+
+void ImageResolution::setNightFps(int nightFps) {
+  if (m_nightFps != nightFps) {
+    m_nightFps = nightFps;
+
+    emit nightFpsChanged();
+  }
+}
+
+int ImageResolution::megaPixels() const {
+  return m_megaPixels;
+}
+
+void ImageResolution::setMegaPixels(int megaPixels) {
+  if (m_megaPixels != megaPixels) {
+    m_megaPixels = megaPixels;
+
+    emit megaPixelsChanged();
+  }
+}
diff --git a/declarative/imageresolution.h b/declarative/imageresolution.h
new file mode 100644 (file)
index 0000000..7d71b88
--- /dev/null
@@ -0,0 +1,99 @@
+// -*- 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 IMAGE_RESOLUTION_H
+#define IMAGE_RESOLUTION_H
+
+#include <QObject>
+#include "qtcamimagesettings.h"
+
+class ImageResolution : public QObject {
+  Q_OBJECT
+
+  Q_PROPERTY(QString resolutionLd READ resolutionId WRITE setResolutionId NOTIFY resolutionIdChanged);
+  Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged);
+  Q_PROPERTY(QString aspectRatio READ aspectRatio WRITE setAspectRatio NOTIFY aspectRatioChanged);
+  Q_PROPERTY(QSize captureResolution READ capture WRITE setCapture NOTIFY captureChanged);
+  Q_PROPERTY(QSize previewResolution READ preview WRITE setPreview NOTIFY previewChanged);
+  Q_PROPERTY(QSize viewfinderResolution READ viewfinder WRITE setViewfinder NOTIFY viewfinderChanged);
+  Q_PROPERTY(int frameRate READ fps WRITE setFps NOTIFY fpsChanged);
+  Q_PROPERTY(int nightFrameRate READ nightFps WRITE setNightFps NOTIFY nightFpsChanged);
+  Q_PROPERTY(int megaPixels READ megaPixels WRITE setMegaPixels NOTIFY megaPixelsChanged);
+
+public:
+  ImageResolution(QObject *parent = 0);
+  ImageResolution(const QtCamImageResolution& resolution, QObject *parent = 0);
+  ~ImageResolution();
+
+  QtCamImageResolution resolution();
+
+  QString resolutionId() const;
+  void setResolutionId(const QString& resolutionId);
+
+  QString name() const;
+  void setName(const QString& name);
+
+  QString aspectRatio() const;
+  void setAspectRatio(const QString& aspectRatio);
+
+  QSize capture() const;
+  void setCapture(const QSize& capture);
+
+  QSize preview() const;
+  void setPreview(const QSize& preview);
+
+  QSize viewfinder() const;
+  void setViewfinder(const QSize& viewfinder);
+
+  int fps() const;
+  void setFps(int fps);
+
+  int nightFps() const;
+  void setNightFps(int nightFps);
+
+  int megaPixels() const;
+  void setMegaPixels(int megaPixels);
+
+signals:
+  void resolutionIdChanged();
+  void nameChanged();
+  void captureChanged();
+  void previewChanged();
+  void viewfinderChanged();
+  void fpsChanged();
+  void nightFpsChanged();
+  void megaPixelsChanged();
+  void aspectRatioChanged();
+
+private:
+  QString m_resolutionId;
+  QString m_name;
+  QString m_aspectRatio;
+  QSize m_capture;
+  QSize m_preview;
+  QSize m_viewfinder;
+  int m_fps;
+  int m_nightFps;
+  int m_megaPixels;
+};
+
+#endif /* IMAGE_RESOLUTION_H */
index dbc34ff..b510a73 100644 (file)
@@ -49,6 +49,8 @@
 #include "videoplayer.h"
 #include "viewfinder.h"
 #include "capability.h"
+#include "imageresolution.h"
+#include "videoresolution.h"
 #if defined(QT4)
 #include <QDeclarativeEngine>
 #elif defined(QT5)
@@ -122,6 +124,9 @@ void Plugin::registerTypes(const char *uri) {
   qmlRegisterType<VideoPlayer>("QtCameraExtras", MAJOR, MINOR, "VideoPlayer");
   qmlRegisterType<Viewfinder>(uri, MAJOR, MINOR, "Viewfinder");
   qmlRegisterType<Capability>();
+
+  qmlRegisterType<ImageResolution>(uri, MAJOR, MINOR, "ImageResolution");
+  qmlRegisterType<VideoResolution>(uri, MAJOR, MINOR, "VideoResolution");
 }
 
 #if defined(QT4)
diff --git a/declarative/videoresolution.cpp b/declarative/videoresolution.cpp
new file mode 100644 (file)
index 0000000..ba91869
--- /dev/null
@@ -0,0 +1,149 @@
+// -*- 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 "videoresolution.h"
+
+VideoResolution::VideoResolution(QObject *parent) :
+  QObject(parent),
+  m_fps(-1),
+  m_nightFps(-1) {
+
+}
+
+VideoResolution::VideoResolution(const QtCamVideoResolution& resolution, QObject *parent) :
+  QObject(parent),
+  m_resolutionId(resolution.id()),
+  m_name(resolution.name()),
+  m_aspectRatio(resolution.aspectRatio()),
+  m_commonName(resolution.resolution()),
+  m_capture(resolution.captureResolution()),
+  m_preview(resolution.previewResolution()),
+  m_fps(resolution.frameRate()),
+  m_nightFps(resolution.nightFrameRate()) {
+
+}
+
+VideoResolution::~VideoResolution() {
+
+}
+
+QtCamVideoResolution VideoResolution::resolution() {
+  return QtCamVideoResolution(m_resolutionId, m_name, m_capture,
+                             m_preview, m_fps, m_nightFps,
+                             m_aspectRatio, m_commonName);
+}
+
+QString VideoResolution::resolutionId() const {
+  return m_resolutionId;
+}
+
+void VideoResolution::setResolutionId(const QString& resolutionId) {
+  if (m_resolutionId != resolutionId) {
+    m_resolutionId = resolutionId;
+
+    emit resolutionIdChanged();
+  }
+}
+
+QString VideoResolution::name() const {
+  return m_name;
+}
+
+void VideoResolution::setName(const QString& name) {
+  if (m_name != name) {
+    m_name = name;
+
+    emit nameChanged();
+  }
+}
+
+QString VideoResolution::aspectRatio() const {
+  return m_aspectRatio;
+}
+
+void VideoResolution::setAspectRatio(const QString& aspectRatio) {
+  if (m_aspectRatio != aspectRatio) {
+    m_aspectRatio = aspectRatio;
+
+    emit aspectRatioChanged();
+  }
+}
+
+QSize VideoResolution::capture() const {
+  return m_capture;
+}
+
+void VideoResolution::setCapture(const QSize& capture) {
+  if (m_capture != capture) {
+    m_capture = capture;
+
+    emit captureChanged();
+  }
+}
+
+QSize VideoResolution::preview() const {
+  return m_preview;
+}
+
+void VideoResolution::setPreview(const QSize& preview) {
+  if (m_preview != preview) {
+    m_preview = preview;
+
+    emit previewChanged();
+  }
+}
+
+int VideoResolution::fps() const {
+  return m_fps;
+}
+
+void VideoResolution::setFps(int fps) {
+  if (m_fps != fps) {
+    m_fps = fps;
+
+    emit fpsChanged();
+  }
+}
+
+int VideoResolution::nightFps() const {
+  return m_nightFps;
+}
+
+void VideoResolution::setNightFps(int nightFps) {
+  if (m_nightFps != nightFps) {
+    m_nightFps = nightFps;
+
+    emit nightFpsChanged();
+  }
+}
+
+QString VideoResolution::commonName() const {
+  return m_commonName;
+}
+
+void VideoResolution::setCommonName(const QString& commonName) {
+  if (m_commonName != commonName) {
+    m_commonName = commonName;
+
+    emit commonNameChanged();
+  }
+}
diff --git a/declarative/videoresolution.h b/declarative/videoresolution.h
new file mode 100644 (file)
index 0000000..3327afa
--- /dev/null
@@ -0,0 +1,93 @@
+// -*- 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 VIDEO_RESOLUTION_H
+#define VIDEO_RESOLUTION_H
+
+#include <QObject>
+#include "qtcamvideosettings.h"
+
+class VideoResolution : public QObject {
+  Q_OBJECT
+
+  Q_PROPERTY(QString resolutionLd READ resolutionId WRITE setResolutionId NOTIFY resolutionIdChanged);
+  Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged);
+  Q_PROPERTY(QString aspectRatio READ aspectRatio WRITE setAspectRatio NOTIFY aspectRatioChanged);
+  Q_PROPERTY(QSize captureResolution READ capture WRITE setCapture NOTIFY captureChanged);
+  Q_PROPERTY(QSize previewResolution READ preview WRITE setPreview NOTIFY previewChanged);
+  Q_PROPERTY(int frameRate READ fps WRITE setFps NOTIFY fpsChanged);
+  Q_PROPERTY(int nightFrameRate READ nightFps WRITE setNightFps NOTIFY nightFpsChanged);
+  Q_PROPERTY(QString commonName READ commonName WRITE setCommonName NOTIFY commonNameChanged);
+
+public:
+  VideoResolution(QObject *parent = 0);
+  VideoResolution(const QtCamVideoResolution& resolution, QObject *parent = 0);
+  ~VideoResolution();
+
+  QtCamVideoResolution resolution();
+
+  QString resolutionId() const;
+  void setResolutionId(const QString& resolutionId);
+
+  QString name() const;
+  void setName(const QString& name);
+
+  QString aspectRatio() const;
+  void setAspectRatio(const QString& aspectRatio);
+
+  QSize capture() const;
+  void setCapture(const QSize& capture);
+
+  QSize preview() const;
+  void setPreview(const QSize& preview);
+
+  int fps() const;
+  void setFps(int fps);
+
+  int nightFps() const;
+  void setNightFps(int nightFps);
+
+  QString commonName() const;
+  void setCommonName(const QString& commonName);
+
+signals:
+  void resolutionIdChanged();
+  void nameChanged();
+  void captureChanged();
+  void previewChanged();
+  void fpsChanged();
+  void nightFpsChanged();
+  void aspectRatioChanged();
+  void commonNameChanged();
+
+private:
+  QString m_resolutionId;
+  QString m_name;
+  QString m_aspectRatio;
+  QString m_commonName;
+  QSize m_capture;
+  QSize m_preview;
+  int m_fps;
+  int m_nightFps;
+};
+
+#endif /* VIDEO_RESOLUTION_H */