Reworked QML capabilities.
authorMohammed Sameer <msameer@foolab.org>
Sat, 8 Dec 2012 17:01:49 +0000 (19:01 +0200)
committerMohammed Sameer <msameer@foolab.org>
Sat, 8 Dec 2012 17:01:49 +0000 (19:01 +0200)
various capabilities are now properties of Camera and cannot be constructed
manually.
This fixes the issue with various properties not being set correctly upon startup.

40 files changed:
imports/aperture.cpp
imports/aperture.h
imports/autofocus.cpp
imports/autofocus.h
imports/camera.cpp
imports/camera.h
imports/capability.h [deleted file]
imports/colortone.cpp
imports/colortone.h
imports/evcomp.cpp
imports/evcomp.h
imports/exposure.cpp
imports/exposure.h
imports/flash.cpp
imports/flash.h
imports/flickerreduction.cpp
imports/flickerreduction.h
imports/focus.cpp
imports/focus.h
imports/imports.pro
imports/iso.cpp
imports/iso.h
imports/noisereduction.cpp
imports/noisereduction.h
imports/plugin.cpp
imports/scene.cpp
imports/scene.h
imports/whitebalance.cpp
imports/whitebalance.h
imports/zoom.cpp
imports/zoom.h
qml/FlashButton.qml
qml/ImageEvCompButton.qml [moved from qml/EvCompButton.qml with 69% similarity]
qml/ImagePage.qml
qml/ImageSceneButton.qml
qml/VideoEvCompButton.qml [moved from imports/capability.cpp with 50% similarity]
qml/VideoPage.qml
qml/VideoSceneButton.qml
qml/ZoomSlider.qml
qml/main.qml

index 0ce661a..94eb995 100644 (file)
  */
 
 #include "aperture.h"
-#include "camera.h"
 #include "qtcamaperture.h"
 
-Aperture::Aperture(QObject *parent) :
-  Capability(parent),
-  m_aperture(0) {
+Aperture::Aperture(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_aperture(new QtCamAperture(dev, this)) {
 
+  QObject::connect(m_aperture, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
+  QObject::connect(m_aperture, SIGNAL(minimumValueChanged()), this, SIGNAL(minimumChanged()));
+  QObject::connect(m_aperture, SIGNAL(maximumValueChanged()), this, SIGNAL(maximunmChanged()));
 }
 
 Aperture::~Aperture() {
-  if (m_aperture) {
-    delete m_aperture; m_aperture = 0;
-  }
-}
-
-void Aperture::deviceChanged() {
-  if (m_aperture) {
-    delete m_aperture; m_aperture = 0;
-  }
-
-  if (m_cam->device()) {
-    m_aperture = new QtCamAperture(m_cam->device(), this);
-    QObject::connect(m_aperture, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
-    QObject::connect(m_aperture, SIGNAL(minimumValueChanged()), this, SIGNAL(minimumChanged()));
-    QObject::connect(m_aperture, SIGNAL(maximumValueChanged()), this, SIGNAL(maximunmChanged()));
-  }
-
-  emit valueChanged();
-  emit minimumChanged();
-  emit maximunmChanged();
+  delete m_aperture; m_aperture = 0;
 }
 
 unsigned int Aperture::value() {
-  return m_aperture ? m_aperture->value() : 0;
+  return m_aperture->value();
 }
 
 void Aperture::setValue(unsigned int val) {
-  if (m_aperture) {
-    m_aperture->setValue(val);
-  }
+  m_aperture->setValue(val);
 }
 
 unsigned int Aperture::minimum() {
-  return m_aperture ? m_aperture->minimumValue() : 0;
+  return m_aperture->minimumValue();
 }
 
 unsigned int Aperture::maximum() {
-  return m_aperture ? m_aperture->maximumValue() : 0;
+  return m_aperture->maximumValue();
 }
index 721a62f..9be77fe 100644 (file)
 #ifndef APERTURE_H
 #define APERTURE_H
 
-#include "capability.h"
+#include <QObject>
 
 class QtCamAperture;
+class QtCamDevice;
 
-class Aperture : public Capability {
+class Aperture : public QObject {
   Q_OBJECT
 
   Q_PROPERTY(unsigned int value READ value WRITE setValue NOTIFY valueChanged);
@@ -35,7 +36,7 @@ class Aperture : public Capability {
   Q_PROPERTY(unsigned int maximum READ maximum NOTIFY maximunmChanged);
 
 public:
-  Aperture(QObject *parent = 0);
+  Aperture(QtCamDevice *dev, QObject *parent = 0);
   ~Aperture();
 
   unsigned int value();
@@ -50,8 +51,6 @@ signals:
   void maximunmChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamAperture *m_aperture;
 };
 
index aedfd33..e27b89c 100644 (file)
  */
 
 #include "autofocus.h"
-#include "camera.h"
 
-AutoFocus::AutoFocus(QObject *parent) :
-  Capability(parent),
-  m_af(0) {
+AutoFocus::AutoFocus(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_af(new QtCamAutoFocus(dev, this)) {
 
+  QObject::connect(m_af, SIGNAL(statusChanged()), this, SIGNAL(valueChanged()));
+  QObject::connect(m_af, SIGNAL(cafStatusChanged()), this, SIGNAL(cafValueChanged()));
 }
-AutoFocus::~AutoFocus() {
-  if (m_af) {
-    delete m_af; m_af = 0;
-  }
-}
-
-void AutoFocus::deviceChanged() {
-  if (m_af) {
-    delete m_af; m_af = 0;
-  }
-
-  if (m_cam->device()) {
-    m_af = new QtCamAutoFocus(m_cam->device(), this);
-    QObject::connect(m_af, SIGNAL(statusChanged()), this, SIGNAL(valueChanged()));
-    QObject::connect(m_af, SIGNAL(cafStatusChanged()), this, SIGNAL(cafValueChanged()));
-  }
 
-  emit valueChanged();
-  emit cafValueChanged();
+AutoFocus::~AutoFocus() {
+  delete m_af; m_af = 0;
 }
 
 AutoFocus::Status AutoFocus::status() {
-  return m_af ? (AutoFocus::Status)m_af->status() : AutoFocus::None;
+  return (AutoFocus::Status)m_af->status();
 }
 
 AutoFocus::Status AutoFocus::cafStatus() {
-  return m_af ? (AutoFocus::Status)m_af->cafStatus() : AutoFocus::None;
+  return (AutoFocus::Status)m_af->cafStatus();
 }
 
 bool AutoFocus::startAutoFocus() {
-  if (m_af) {
-    return m_af->startAutoFocus();
-  }
-
-  return false;
+  return m_af->startAutoFocus();
 }
 
 bool AutoFocus::stopAutoFocus() {
-  if (m_af) {
-    return m_af->stopAutoFocus();
-  }
-
-  return false;
+  return m_af->stopAutoFocus();
 }
index ffa9512..680e21c 100644 (file)
 #ifndef AUTO_FOCUS_H
 #define AUTO_FOCUS_H
 
-#include "capability.h"
+#include <QObject>
 #include "qtcamautofocus.h"
 
-class AutoFocus : public Capability {
+class QtCamDevice;
+
+class AutoFocus : public QObject {
   Q_OBJECT
   Q_PROPERTY(Status status READ status NOTIFY valueChanged);
   Q_PROPERTY(Status cafStatus READ cafStatus NOTIFY cafValueChanged);
@@ -40,7 +42,7 @@ public:
     Success = QtCamAutoFocus::Success,
   } Status;
 
-  AutoFocus(QObject *parent = 0);
+  AutoFocus(QtCamDevice *dev, QObject *parent = 0);
   ~AutoFocus();
 
   Q_INVOKABLE bool startAutoFocus();
@@ -54,8 +56,6 @@ signals:
   void cafValueChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamAutoFocus *m_af;
 };
 
index 66d5912..a3b1e69 100644 (file)
 #include "sounds.h"
 #include <QDeclarativeInfo>
 
+#include "zoom.h"
+#include "flash.h"
+#include "scene.h"
+#include "evcomp.h"
+#include "whitebalance.h"
+#include "colortone.h"
+#include "iso.h"
+#include "exposure.h"
+#include "aperture.h"
+#include "noisereduction.h"
+#include "flickerreduction.h"
+#include "focus.h"
+#include "autofocus.h"
+
 // TODO: a viewfinder class that inherits QDeclarativeItem
 
 Camera::Camera(QDeclarativeItem *parent) :
@@ -39,7 +53,21 @@ Camera::Camera(QDeclarativeItem *parent) :
   m_dev(0),
   m_vf(new QtCamGraphicsViewfinder(m_cam->config(), this)),
   m_mode(Camera::UnknownMode),
-  m_notifications(new NotificationsContainer(this)) {
+  m_notifications(new NotificationsContainer(this)),
+  m_zoom(0),
+  m_flash(0),
+  m_scene(0),
+  m_evComp(0),
+  m_whiteBalance(0),
+  m_colorTone(0),
+  m_iso(0),
+  m_exposure(0),
+  m_aperture(0),
+  m_noiseReduction(0),
+  m_flickerReduction(0),
+  m_focus(0),
+  m_autoFocus(0) {
+
 
   // TODO:
 }
@@ -51,6 +79,20 @@ Camera::~Camera() {
     m_dev = 0;
   }
 
+  delete m_zoom;
+  delete m_flash;
+  delete m_scene;
+  delete m_evComp;
+  delete m_whiteBalance;
+  delete m_colorTone;
+  delete m_iso;
+  delete m_exposure;
+  delete m_aperture;
+  delete m_noiseReduction;
+  delete m_flickerReduction;
+  delete m_focus;
+  delete m_autoFocus;
+
   // TODO: cleanup
 }
 
@@ -90,6 +132,8 @@ bool Camera::reset(const QVariant& deviceId, const CameraMode& mode) {
     if (oldId != m_id) {
       emit deviceIdChanged();
       emit deviceChanged();
+
+      resetCapabilities();
     }
 
     if (oldMode != m_mode) {
@@ -234,3 +278,111 @@ void Camera::setNotifications(Notifications *notifications) {
     emit notificationsChanged();
   }
 }
+
+void Camera::resetCapabilities() {
+  QtCamDevice *dev = device();
+
+  delete m_zoom;
+  m_zoom = new Zoom(dev, this);
+  emit zoomChanged();
+
+  delete m_flash;
+  m_flash = new Flash(dev, this);
+  emit flashChanged();
+
+  delete m_scene;
+  m_scene = new Scene(dev, this);
+  emit sceneChanged();
+
+  delete m_evComp;
+  m_evComp = new EvComp(dev, this);
+  emit evCompChanged();
+
+  delete m_whiteBalance;
+  m_whiteBalance = new WhiteBalance(dev, this);
+  emit whiteBalanceChanged();
+
+  delete m_colorTone;
+  m_colorTone = new ColorTone(dev, this);
+  emit colorToneChanged();
+
+  delete m_iso;
+  m_iso = new Iso(dev, this);
+  emit isoChanged();
+
+  delete m_exposure;
+  m_exposure = new Exposure(dev, this);
+  emit exposureChanged();
+
+  delete m_aperture;
+  m_aperture = new Aperture(dev, this);
+  emit apertureChanged();
+
+  delete m_noiseReduction;
+  m_noiseReduction = new NoiseReduction(dev, this);
+  emit noiseReductionChanged();
+
+  delete m_flickerReduction;
+  m_flickerReduction = new FlickerReduction(dev, this);
+  emit flickerReductionChanged();
+
+  delete m_focus;
+  m_focus = new Focus(dev, this);
+  emit focusChanged();
+
+  delete m_autoFocus;
+  m_autoFocus = new AutoFocus(dev, this);
+  emit autoFocusChanged();
+}
+
+Zoom *Camera::zoom() const {
+  return m_zoom;
+}
+
+Flash *Camera::flash() const {
+  return m_flash;
+}
+
+Scene *Camera::scene() const {
+  return m_scene;
+}
+
+EvComp *Camera::evComp() const {
+  return m_evComp;
+}
+
+WhiteBalance *Camera::whiteBalance() const {
+  return m_whiteBalance;
+}
+
+ColorTone *Camera::colorTone() const {
+  return m_colorTone;
+}
+
+Iso *Camera::iso() const {
+  return m_iso;
+}
+
+Exposure *Camera::exposure() const {
+  return m_exposure;
+}
+
+Aperture *Camera::aperture() const {
+  return m_aperture;
+}
+
+NoiseReduction *Camera::noiseReduction() const {
+  return m_noiseReduction;
+}
+
+FlickerReduction *Camera::flickerReduction() const {
+  return m_flickerReduction;
+}
+
+Focus *Camera::focus() const {
+  return m_focus;
+}
+
+AutoFocus *Camera::autoFocus() const {
+  return m_autoFocus;
+}
index 6c3b88b..a393aff 100644 (file)
@@ -32,6 +32,19 @@ class QtCamDevice;
 class QtCamGraphicsViewfinder;
 class Notifications;
 class NotificationsContainer;
+class Zoom;
+class Flash;
+class Scene;
+class EvComp;
+class WhiteBalance;
+class ColorTone;
+class Iso;
+class Exposure;
+class Aperture;
+class NoiseReduction;
+class FlickerReduction;
+class Focus;
+class AutoFocus;
 
 class Camera : public QDeclarativeItem {
   Q_OBJECT
@@ -45,6 +58,20 @@ class Camera : public QDeclarativeItem {
   Q_PROPERTY(QString videoSuffix READ videoSuffix CONSTANT);
   Q_PROPERTY(Notifications *notifications READ notifications WRITE setNotifications NOTIFY notificationsChanged);
 
+  Q_PROPERTY(Zoom *zoom READ zoom NOTIFY zoomChanged);
+  Q_PROPERTY(Flash *flash READ flash NOTIFY flashChanged);
+  Q_PROPERTY(Scene *scene READ scene NOTIFY sceneChanged);
+  Q_PROPERTY(EvComp *evComp READ evComp NOTIFY evCompChanged);
+  Q_PROPERTY(WhiteBalance *whiteBalance READ whiteBalance NOTIFY whiteBalanceChanged);
+  Q_PROPERTY(ColorTone *colorTone READ colorTone NOTIFY colorToneChanged);
+  Q_PROPERTY(Iso *iso READ iso NOTIFY isoChanged);
+  Q_PROPERTY(Exposure *exposure READ exposure NOTIFY exposureChanged);
+  Q_PROPERTY(Aperture *aperture READ aperture NOTIFY apertureChanged);
+  Q_PROPERTY(NoiseReduction *noiseReduction READ noiseReduction NOTIFY noiseReductionChanged);
+  Q_PROPERTY(FlickerReduction *flickerReduction READ flickerReduction NOTIFY flickerReductionChanged);
+  Q_PROPERTY(Focus *focus READ focus NOTIFY focusChanged);
+  Q_PROPERTY(AutoFocus *autoFocus READ autoFocus NOTIFY autoFocusChanged);
+
   Q_ENUMS(CameraMode);
 
 public:
@@ -83,6 +110,20 @@ public:
   Notifications *notifications() const;
   void setNotifications(Notifications *notifications);
 
+  Zoom *zoom() const;
+  Flash *flash() const;
+  Scene *scene() const;
+  EvComp *evComp() const;
+  WhiteBalance *whiteBalance() const;
+  ColorTone *colorTone() const;
+  Iso *iso() const;
+  Exposure *exposure() const;
+  Aperture *aperture() const;
+  NoiseReduction *noiseReduction() const;
+  FlickerReduction *flickerReduction() const;
+  Focus *focus() const;
+  AutoFocus *autoFocus() const;
+
 signals:
   void deviceCountChanged();
   void deviceIdChanged();
@@ -93,6 +134,20 @@ signals:
   void error(const QString& message, int code, const QString& debug);
   void notificationsChanged();
 
+  void zoomChanged();
+  void flashChanged();
+  void sceneChanged();
+  void evCompChanged();
+  void whiteBalanceChanged();
+  void colorToneChanged();
+  void isoChanged();
+  void exposureChanged();
+  void apertureChanged();
+  void noiseReductionChanged();
+  void flickerReductionChanged();
+  void focusChanged();
+  void autoFocusChanged();
+
 protected:
   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
 
@@ -101,12 +156,28 @@ private:
   bool setDeviceId(const QVariant& deviceId);
   bool setMode(const CameraMode& mode);
 
+  void resetCapabilities();
+
   QtCamera *m_cam;
   QtCamDevice *m_dev;
   QVariant m_id;
   QtCamGraphicsViewfinder *m_vf;
   CameraMode m_mode;
   NotificationsContainer *m_notifications;
+
+  Zoom *m_zoom;
+  Flash *m_flash;
+  Scene *m_scene;
+  EvComp *m_evComp;
+  WhiteBalance *m_whiteBalance;
+  ColorTone *m_colorTone;
+  Iso *m_iso;
+  Exposure *m_exposure;
+  Aperture *m_aperture;
+  NoiseReduction *m_noiseReduction;
+  FlickerReduction *m_flickerReduction;
+  Focus *m_focus;
+  AutoFocus *m_autoFocus;
 };
 
 #endif /* CAMERA_H */
diff --git a/imports/capability.h b/imports/capability.h
deleted file mode 100644 (file)
index 93b54a9..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-// -*- 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 CAPABILITY_H
-#define CAPABILITY_H
-
-#include <QObject>
-
-class Camera;
-
-class Capability : public QObject {
-  Q_OBJECT
-  Q_PROPERTY(Camera* camera READ camera WRITE setCamera NOTIFY cameraChanged);
-  Q_PROPERTY(bool ready READ isReady NOTIFY isReadyChanged);
-
-public:
-  Capability(QObject *parent = 0);
-  virtual ~Capability();
-
-  Camera *camera();
-  void setCamera(Camera *cam);
-
-  bool isReady() const;
-
-signals:
-  void cameraChanged();
-  void isReadyChanged();
-
-private slots:
-  virtual void deviceChanged() = 0;
-
-protected:
-  Camera *m_cam;
-};
-
-#endif /* CAPABILITY_H */
index 8dc1b80..75d9c6e 100644 (file)
  */
 
 #include "colortone.h"
-#include "camera.h"
 
-ColorTone::ColorTone(QObject *parent) :
-  Capability(parent),
-  m_color(0) {
+ColorTone::ColorTone(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_color(new QtCamColorTone(dev, this)) {
 
+  QObject::connect(m_color, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
 }
 
 ColorTone::~ColorTone() {
-  if (m_color) {
-    delete m_color; m_color = 0;
-  }
-}
-
-void ColorTone::deviceChanged() {
-  if (m_color) {
-    delete m_color; m_color = 0;
-  }
-
-  if (m_cam->device()) {
-    m_color = new QtCamColorTone(m_cam->device(), this);
-    QObject::connect(m_color, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
-  }
-
-  emit valueChanged();
+  delete m_color; m_color = 0;
 }
 
 ColorTone::ColorToneMode ColorTone::value() {
-  return m_color ? (ColorToneMode)m_color->value() : ColorTone::Normal;
+  return (ColorToneMode)m_color->value();
 }
 
 void ColorTone::setValue(const ColorTone::ColorToneMode& mode) {
-  if (m_color) {
-    m_color->setValue((QtCamColorTone::ColorToneMode)mode);
-  }
+  m_color->setValue((QtCamColorTone::ColorToneMode)mode);
 }
index 62a89a9..0e60407 100644 (file)
 #ifndef COLOR_TONE_H
 #define COLOR_TONE_H
 
-#include "capability.h"
+#include <QObject>
 #include "qtcamcolortone.h"
 
-class ColorTone : public Capability {
+class QtCamDevice;
+
+class ColorTone : public QObject {
   Q_OBJECT
 
   Q_PROPERTY(ColorToneMode value READ value WRITE setValue NOTIFY valueChanged);
@@ -48,7 +50,7 @@ public:
     SkinWhite = QtCamColorTone::SkinWhite,
   } ColorToneMode;
 
-  ColorTone(QObject *parent = 0);
+  ColorTone(QtCamDevice *dev, QObject *parent = 0);
   ~ColorTone();
 
   ColorToneMode value();
@@ -58,8 +60,6 @@ signals:
   void valueChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamColorTone *m_color;
 };
 
index 89a9a0f..ed91ec7 100644 (file)
  */
 
 #include "evcomp.h"
-#include "camera.h"
 #include "qtcamevcomp.h"
 
-EvComp::EvComp(QObject *parent) :
-  Capability(parent),
-  m_evComp(0) {
+EvComp::EvComp(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_evComp(new QtCamEvComp(dev, this)) {
 
+  QObject::connect(m_evComp, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
+  QObject::connect(m_evComp, SIGNAL(minimumValueChanged()), this, SIGNAL(minimumChanged()));
+  QObject::connect(m_evComp, SIGNAL(maximumValueChanged()), this, SIGNAL(maximunmChanged()));
 }
 
 EvComp::~EvComp() {
-  if (m_evComp) {
-    delete m_evComp; m_evComp = 0;
-  }
-}
-
-void EvComp::deviceChanged() {
-  if (m_evComp) {
-    delete m_evComp; m_evComp = 0;
-  }
-
-  if (m_cam->device()) {
-    m_evComp = new QtCamEvComp(m_cam->device(), this);
-    QObject::connect(m_evComp, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
-    QObject::connect(m_evComp, SIGNAL(minimumValueChanged()), this, SIGNAL(minimumChanged()));
-    QObject::connect(m_evComp, SIGNAL(maximumValueChanged()), this, SIGNAL(maximunmChanged()));
-  }
-
-  emit valueChanged();
-  emit minimumChanged();
-  emit maximunmChanged();
+  delete m_evComp; m_evComp = 0;
 }
 
 qreal EvComp::value() {
-  return m_evComp ? m_evComp->value() : 0.0;
+  return m_evComp->value();
 }
 
 void EvComp::setValue(qreal val) {
-  if (m_evComp) {
-    m_evComp->setValue(val);
-  }
+  m_evComp->setValue(val);
 }
 
 qreal EvComp::minimum() {
-  return m_evComp ? m_evComp->minimumValue() : 0.0;
+  return m_evComp->minimumValue();
 }
 
 qreal EvComp::maximum() {
-  return m_evComp ? m_evComp->maximumValue() : 0.0;
+  return m_evComp->maximumValue();
 }
index 42e9d42..23207c6 100644 (file)
 #ifndef EV_COMP_H
 #define EV_COMP_H
 
-#include "capability.h"
+#include <QObject>
 
 class QtCamEvComp;
+class QtCamDevice;
 
-class EvComp : public Capability {
+class EvComp : public QObject {
   Q_OBJECT
 
   Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged);
@@ -35,7 +36,7 @@ class EvComp : public Capability {
   Q_PROPERTY(qreal maximum READ maximum NOTIFY maximunmChanged);
 
 public:
-  EvComp(QObject *parent = 0);
+  EvComp(QtCamDevice *dev, QObject *parent = 0);
   ~EvComp();
 
   qreal value();
@@ -50,8 +51,6 @@ signals:
   void maximunmChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamEvComp *m_evComp;
 };
 
index 8cdaa31..1db2397 100644 (file)
 #include "camera.h"
 #include "qtcamexposure.h"
 
-Exposure::Exposure(QObject *parent) :
-  Capability(parent),
-  m_exposure(0) {
+Exposure::Exposure(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_exposure(new QtCamExposure(dev, this)) {
 
+  QObject::connect(m_exposure, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
+  QObject::connect(m_exposure, SIGNAL(minimumValueChanged()), this, SIGNAL(minimumChanged()));
+  QObject::connect(m_exposure, SIGNAL(maximumValueChanged()), this, SIGNAL(maximunmChanged()));
 }
 
 Exposure::~Exposure() {
-  if (m_exposure) {
-    delete m_exposure; m_exposure = 0;
-  }
-}
-
-void Exposure::deviceChanged() {
-  if (m_exposure) {
-    delete m_exposure; m_exposure = 0;
-  }
-
-  if (m_cam->device()) {
-    m_exposure = new QtCamExposure(m_cam->device(), this);
-    QObject::connect(m_exposure, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
-    QObject::connect(m_exposure, SIGNAL(minimumValueChanged()), this, SIGNAL(minimumChanged()));
-    QObject::connect(m_exposure, SIGNAL(maximumValueChanged()), this, SIGNAL(maximunmChanged()));
-  }
-
-  emit valueChanged();
-  emit minimumChanged();
-  emit maximunmChanged();
+  delete m_exposure; m_exposure = 0;
 }
 
 unsigned int Exposure::value() {
-  return m_exposure ? m_exposure->value() : 0;
+  return m_exposure->value();
 }
 
 void Exposure::setValue(unsigned int val) {
-  if (m_exposure) {
-    m_exposure->setValue(val);
-  }
+  m_exposure->setValue(val);
 }
 
 unsigned int Exposure::minimum() {
-  return m_exposure ? m_exposure->minimumValue() : 0;
+  return m_exposure->minimumValue();
 }
 
 unsigned int Exposure::maximum() {
-  return m_exposure ? m_exposure->maximumValue() : 0;
+  return m_exposure->maximumValue();
 }
index b5dc860..0b2c9ed 100644 (file)
 #ifndef EXPOSURE_H
 #define EXPOSURE_H
 
-#include "capability.h"
+#include <QObject>
 
 class QtCamExposure;
+class QtCamDevice;
 
-class Exposure : public Capability {
+class Exposure : public QObject {
   Q_OBJECT
 
   Q_PROPERTY(unsigned int value READ value WRITE setValue NOTIFY valueChanged);
@@ -35,7 +36,7 @@ class Exposure : public Capability {
   Q_PROPERTY(unsigned int maximum READ maximum NOTIFY maximunmChanged);
 
 public:
-  Exposure(QObject *parent = 0);
+  Exposure(QtCamDevice *dev, QObject *parent = 0);
   ~Exposure();
 
   unsigned int value();
@@ -50,8 +51,6 @@ signals:
   void maximunmChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamExposure *m_exposure;
 };
 
index 09f45a4..fa90764 100644 (file)
  */
 
 #include "flash.h"
-#include "camera.h"
 
-Flash::Flash(QObject *parent) :
-  Capability(parent),
-  m_flash(0) {
+Flash::Flash(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_flash(new QtCamFlash(dev, this)) {
 
+  QObject::connect(m_flash, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
 }
 
 Flash::~Flash() {
-  if (m_flash) {
-    delete m_flash; m_flash = 0;
-  }
-}
-
-void Flash::deviceChanged() {
-  if (m_flash) {
-    delete m_flash; m_flash = 0;
-  }
-
-  if (m_cam->device()) {
-    m_flash = new QtCamFlash(m_cam->device(), this);
-    QObject::connect(m_flash, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
-  }
-
-  emit valueChanged();
+  delete m_flash; m_flash = 0;
 }
 
 Flash::FlashMode Flash::value() {
-  return m_flash ? (FlashMode)m_flash->value() : Flash::Auto;
+  return (FlashMode)m_flash->value();
 }
 
 void Flash::setValue(const Flash::FlashMode& mode) {
-  if (m_flash) {
-    m_flash->setValue((QtCamFlash::FlashMode)mode);
-  }
+  m_flash->setValue((QtCamFlash::FlashMode)mode);
 }
index ff79eca..916a936 100644 (file)
 #ifndef FLASH_H
 #define FLASH_H
 
-#include "capability.h"
+#include <QObject>
 #include "qtcamflash.h"
 
-class Flash : public Capability {
+class QtCamDevice;
+
+class Flash : public QObject {
   Q_OBJECT
 
   Q_PROPERTY(FlashMode value READ value WRITE setValue NOTIFY valueChanged);
@@ -41,7 +43,7 @@ public:
     RedEye = QtCamFlash::RedEye
   } FlashMode;
 
-  Flash(QObject *parent = 0);
+  Flash(QtCamDevice *dev, QObject *parent = 0);
   ~Flash();
 
   FlashMode value();
@@ -51,8 +53,6 @@ signals:
   void valueChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamFlash *m_flash;
 };
 
index 401110e..3e5d16b 100644 (file)
  */
 
 #include "flickerreduction.h"
-#include "camera.h"
 
-FlickerReduction::FlickerReduction(QObject *parent) :
-  Capability(parent),
-  m_fr(0) {
+FlickerReduction::FlickerReduction(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_fr(new QtCamFlickerReduction(dev, this)) {
 
+  QObject::connect(m_fr, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
 }
 
 FlickerReduction::~FlickerReduction() {
-  if (m_fr) {
-    delete m_fr; m_fr = 0;
-  }
-}
-
-void FlickerReduction::deviceChanged() {
-  if (m_fr) {
-    delete m_fr; m_fr = 0;
-  }
-
-  if (m_cam->device()) {
-    m_fr = new QtCamFlickerReduction(m_cam->device(), this);
-    QObject::connect(m_fr, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
-  }
-
-  emit valueChanged();
+  delete m_fr; m_fr = 0;
 }
 
 FlickerReduction::FlickerReductionMode FlickerReduction::value() {
-  return m_fr ? (FlickerReductionMode)m_fr->value() : FlickerReduction::Off;
+  return (FlickerReductionMode)m_fr->value();
 }
 
 void FlickerReduction::setValue(const FlickerReduction::FlickerReductionMode& mode) {
-  if (m_fr) {
-    m_fr->setValue((QtCamFlickerReduction::FlickerReductionMode)mode);
-  }
+  m_fr->setValue((QtCamFlickerReduction::FlickerReductionMode)mode);
 }
index 804539b..e5bf2d5 100644 (file)
 #ifndef FLICKER_REDUCTION_H
 #define FLICKER_REDUCTION_H
 
-#include "capability.h"
+#include <QObject>
 #include "qtcamflickerreduction.h"
 
-class FlickerReduction : public Capability {
+class QtCamDevice;
+
+class FlickerReduction : public QObject {
   Q_OBJECT
 
   Q_PROPERTY(FlickerReductionMode value READ value WRITE setValue NOTIFY valueChanged);
@@ -40,7 +42,7 @@ public:
     Auto = QtCamFlickerReduction::Auto
   } FlickerReductionMode;
 
-  FlickerReduction(QObject *parent = 0);
+  FlickerReduction(QtCamDevice *dev, QObject *parent = 0);
   ~FlickerReduction();
 
   FlickerReductionMode value();
@@ -50,8 +52,6 @@ signals:
   void valueChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamFlickerReduction *m_fr;
 };
 
index 99e6dc1..de762fd 100644 (file)
  */
 
 #include "focus.h"
-#include "camera.h"
 
-Focus::Focus(QObject *parent) :
-  Capability(parent),
-  m_f(0) {
+Focus::Focus(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_f(new QtCamFocus(dev, this)) {
 
+  QObject::connect(m_f, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
 }
 
 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();
+  delete m_f; m_f = 0;
 }
 
 Focus::FocusMode Focus::value() {
-  return m_f ? (FocusMode)m_f->value() : Focus::Auto;
+  return (FocusMode)m_f->value();
 }
 
 void Focus::setValue(const Focus::FocusMode& mode) {
-  if (m_f) {
-    m_f->setValue((QtCamFocus::FocusMode)mode);
-  }
+  m_f->setValue((QtCamFocus::FocusMode)mode);
 }
index 634aa59..cc63f53 100644 (file)
 #ifndef FOCUS_H
 #define FOCUS_H
 
-#include "capability.h"
+#include <QObject>
 #include "qtcamfocus.h"
 
-class Focus : public Capability {
+class QtCamDevice;
+
+class Focus : public QObject {
   Q_OBJECT
 
   Q_PROPERTY(FocusMode value READ value WRITE setValue NOTIFY valueChanged);
@@ -45,7 +47,7 @@ public:
     Sport = QtCamFocus::Sport,
   } FocusMode;
 
-  Focus(QObject *parent = 0);
+  Focus(QtCamDevice *dev, QObject *parent = 0);
   ~Focus();
 
   FocusMode value();
@@ -55,8 +57,6 @@ signals:
   void valueChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamFocus *m_f;
 };
 
index 7c186b8..11ea5ec 100644 (file)
@@ -11,14 +11,14 @@ PKGCONFIG = gstreamer-0.10 gstreamer-interfaces-0.10 gstreamer-video-0.10 gstrea
 QT += declarative
 
 HEADERS += plugin.h previewprovider.h camera.h mode.h imagemode.h videomode.h \
-           capability.h zoom.h flash.h scene.h evcomp.h videotorch.h whitebalance.h \
+           zoom.h flash.h scene.h evcomp.h videotorch.h whitebalance.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 focus.h autofocus.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 \
+           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 \
index 14b3da5..0dd16f5 100644 (file)
  */
 
 #include "iso.h"
-#include "camera.h"
 #include "qtcamiso.h"
 
-Iso::Iso(QObject *parent) :
-  Capability(parent),
-  m_iso(0) {
+Iso::Iso(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_iso(new QtCamIso(dev, this)) {
 
+  QObject::connect(m_iso, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
+  QObject::connect(m_iso, SIGNAL(minimumValueChanged()), this, SIGNAL(minimumChanged()));
+  QObject::connect(m_iso, SIGNAL(maximumValueChanged()), this, SIGNAL(maximunmChanged()));
 }
 
 Iso::~Iso() {
-  if (m_iso) {
-    delete m_iso; m_iso = 0;
-  }
-}
-
-void Iso::deviceChanged() {
-  if (m_iso) {
-    delete m_iso; m_iso = 0;
-  }
-
-  if (m_cam->device()) {
-    m_iso = new QtCamIso(m_cam->device(), this);
-    QObject::connect(m_iso, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
-    QObject::connect(m_iso, SIGNAL(minimumValueChanged()), this, SIGNAL(minimumChanged()));
-    QObject::connect(m_iso, SIGNAL(maximumValueChanged()), this, SIGNAL(maximunmChanged()));
-  }
-
-  emit valueChanged();
-  emit minimumChanged();
-  emit maximunmChanged();
+  delete m_iso; m_iso = 0;
 }
 
 unsigned int Iso::value() {
-  return m_iso ? m_iso->value() : 0;
+  return m_iso->value();
 }
 
 void Iso::setValue(unsigned int val) {
-  if (m_iso) {
-    m_iso->setValue(val);
-  }
+  m_iso->setValue(val);
 }
 
 unsigned int Iso::minimum() {
-  return m_iso ? m_iso->minimumValue() : 0;
+  return m_iso->minimumValue();
 }
 
 unsigned int Iso::maximum() {
-  return m_iso ? m_iso->maximumValue() : 0;
+  return m_iso->maximumValue();
 }
index b2e7b90..fd0831f 100644 (file)
 #ifndef ISO_H
 #define ISO_H
 
-#include "capability.h"
+#include <QObject>
 
 class QtCamIso;
+class QtCamDevice;
 
-class Iso : public Capability {
+class Iso : public QObject {
   Q_OBJECT
 
   Q_PROPERTY(unsigned int value READ value WRITE setValue NOTIFY valueChanged);
@@ -35,7 +36,7 @@ class Iso : public Capability {
   Q_PROPERTY(unsigned int maximum READ maximum NOTIFY maximunmChanged);
 
 public:
-  Iso(QObject *parent = 0);
+  Iso(QtCamDevice *dev, QObject *parent = 0);
   ~Iso();
 
   unsigned int value();
@@ -50,8 +51,6 @@ signals:
   void maximunmChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamIso *m_iso;
 };
 
index f58f493..44d1aa2 100644 (file)
  */
 
 #include "noisereduction.h"
-#include "camera.h"
 
-NoiseReduction::NoiseReduction(QObject *parent) :
-  Capability(parent),
-  m_nr(0) {
+NoiseReduction::NoiseReduction(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_nr(new QtCamNoiseReduction(dev, this)) {
 
+  QObject::connect(m_nr, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
 }
 
 NoiseReduction::~NoiseReduction() {
-  if (m_nr) {
-    delete m_nr; m_nr = 0;
-  }
+  delete m_nr; m_nr = 0;
 }
 
-void NoiseReduction::deviceChanged() {
-  if (m_nr) {
-    delete m_nr; m_nr = 0;
-  }
-
-  if (m_cam->device()) {
-    m_nr = new QtCamNoiseReduction(m_cam->device(), this);
-    QObject::connect(m_nr, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
-  }
-
-  emit valueChanged();
-}
 
 NoiseReduction::NoiseReductionMode NoiseReduction::value() {
-  return m_nr ? (NoiseReductionMode)m_nr->value() : NoiseReduction::None;
+  return (NoiseReductionMode)m_nr->value();
 }
 
 void NoiseReduction::setValue(const NoiseReduction::NoiseReductionMode& mode) {
-  if (m_nr) {
-    m_nr->setValue((QtCamNoiseReduction::NoiseReductionMode)mode);
-  }
+  m_nr->setValue((QtCamNoiseReduction::NoiseReductionMode)mode);
 }
index 0d3cd38..5d8d676 100644 (file)
 #ifndef NOISE_REDUCTION_H
 #define NOISE_REDUCTION_H
 
-#include "capability.h"
+#include <QObject>
 #include "qtcamnoisereduction.h"
 
-class NoiseReduction : public Capability {
+class QtCamDevice;
+
+class NoiseReduction : public QObject {
   Q_OBJECT
 
   Q_PROPERTY(NoiseReductionMode value READ value WRITE setValue NOTIFY valueChanged);
@@ -42,7 +44,7 @@ public:
     Extra = QtCamNoiseReduction::Extra
   } NoiseReductionMode;
 
-  NoiseReduction(QObject *parent = 0);
+  NoiseReduction(QtCamDevice *dev, QObject *parent = 0);
   ~NoiseReduction();
 
   NoiseReductionMode value();
@@ -52,8 +54,6 @@ signals:
   void valueChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamNoiseReduction *m_nr;
 };
 
index b58c065..571eb95 100644 (file)
@@ -23,7 +23,6 @@
 #include "videomode.h"
 #include "camera.h"
 #include "previewprovider.h"
-#include "capability.h"
 #include "zoom.h"
 #include "flash.h"
 #include "scene.h"
@@ -57,21 +56,24 @@ void Plugin::registerTypes(QDeclarativeEngine *engine) {
   qmlRegisterType<Camera>(URI, MAJOR, MINOR, "Camera");
   qmlRegisterType<ImageMode>(URI, MAJOR, MINOR, "ImageMode");
   qmlRegisterType<VideoMode>(URI, MAJOR, MINOR, "VideoMode");
-  qmlRegisterType<Zoom>(URI, MAJOR, MINOR, "Zoom");
-  qmlRegisterType<Flash>(URI, MAJOR, MINOR, "Flash");
-  qmlRegisterType<Scene>(URI, MAJOR, MINOR, "Scene");
-  qmlRegisterType<EvComp>(URI, MAJOR, MINOR, "EvComp");
-  qmlRegisterType<VideoTorch>(URI, MAJOR, MINOR, "VideoTorch");
-  qmlRegisterType<WhiteBalance>(URI, MAJOR, MINOR, "WhiteBalance");
-  qmlRegisterType<ColorTone>(URI, MAJOR, MINOR, "ColorTone");
-  qmlRegisterType<Exposure>(URI, MAJOR, MINOR, "Exposure");
-  qmlRegisterType<Aperture>(URI, MAJOR, MINOR, "Aperture");
-  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<AutoFocus>(URI, MAJOR, MINOR, "AutoFocus");
+
+  qmlRegisterUncreatableType<Zoom>(URI, MAJOR, MINOR, "Zoom", QObject::tr("Cannot create separate instance of Zoom"));
+  qmlRegisterUncreatableType<Flash>(URI, MAJOR, MINOR, "Flash", QObject::tr("Cannot create separate instance of Flash"));
+  qmlRegisterUncreatableType<Scene>(URI, MAJOR, MINOR, "Scene", QObject::tr("Cannot create separate instance of Scene"));
+  qmlRegisterUncreatableType<EvComp>(URI, MAJOR, MINOR, "EvComp", QObject::tr("Cannot create separate instance of EvComp"));
+  qmlRegisterUncreatableType<WhiteBalance>(URI, MAJOR, MINOR, "WhiteBalance", QObject::tr("Cannot create separate instance of WhiteBalance"));
+  qmlRegisterUncreatableType<ColorTone>(URI, MAJOR, MINOR, "ColorTone", QObject::tr("Cannot create separate instance of ColorTone"));
+  qmlRegisterUncreatableType<Exposure>(URI, MAJOR, MINOR, "Exposure", QObject::tr("Cannot create separate instance of Exposure"));
+  qmlRegisterUncreatableType<Aperture>(URI, MAJOR, MINOR, "Aperture", QObject::tr("Cannot create separate instance of Iso"));
+  qmlRegisterUncreatableType<Iso>(URI, MAJOR, MINOR, "Iso", QObject::tr("Cannot create separate instance of Iso"));
+  qmlRegisterUncreatableType<NoiseReduction>(URI, MAJOR, MINOR, "NoiseReduction", QObject::tr("Cannot create separate instance of NoiseReduction"));
+  qmlRegisterUncreatableType<FlickerReduction>(URI, MAJOR, MINOR, "FlickerReduction", QObject::tr("Cannot create separate instance of FlickerReduction"));
+  qmlRegisterUncreatableType<Focus>(URI, MAJOR, MINOR, "Focus", QObject::tr("Cannot create separate instance of Focus"));
+  qmlRegisterUncreatableType<AutoFocus>(URI, MAJOR, MINOR, "AutoFocus", QObject::tr("Cannot create separate instance of AutoFocus"));
+
   qmlRegisterType<Mute>(URI, MAJOR, MINOR, "Mute");
+  qmlRegisterType<VideoTorch>(URI, MAJOR, MINOR, "VideoTorch");
+
   qmlRegisterType<MetaData>(URI, MAJOR, MINOR, "MetaData");
   qmlRegisterType<ImageSettings>(URI, MAJOR, MINOR, "ImageSettings");
   qmlRegisterType<VideoSettings>(URI, MAJOR, MINOR, "VideoSettings");
@@ -84,7 +86,6 @@ void Plugin::registerTypes(QDeclarativeEngine *engine) {
                          "VideoResolutionModel can be obtained from VideoSettings");
 
   qmlRegisterType<Mode>();
-  qmlRegisterType<Capability>();
 
   engine->addImageProvider("preview", new PreviewProvider);
 }
index c67f110..9b5004f 100644 (file)
  */
 
 #include "scene.h"
-#include "camera.h"
-#include <QDebug>
 
-Scene::Scene(QObject *parent) :
-  Capability(parent),
-  m_scene(0) {
+Scene::Scene(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_scene(new QtCamScene(dev, this)) {
 
+  QObject::connect(m_scene, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
 }
 
 Scene::~Scene() {
-  if (m_scene) {
-    delete m_scene; m_scene = 0;
-  }
+  delete m_scene; m_scene = 0;
 }
 
-void Scene::deviceChanged() {
-  if (m_scene) {
-    delete m_scene; m_scene = 0;
-  }
-
-  if (m_cam->device()) {
-    m_scene = new QtCamScene(m_cam->device(), this);
-    QObject::connect(m_scene, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
-  }
-
-  emit valueChanged();
-}
-
-Scene::SceneMode Scene::value() {
-  return m_scene ? (SceneMode)m_scene->value() : Scene::Auto;
+Scene::SceneMode Scene::value() const {
+  return (SceneMode)m_scene->value();
 }
 
 void Scene::setValue(const Scene::SceneMode& mode) {
-  if (m_scene) {
-    m_scene->setValue((QtCamScene::SceneMode)mode);
-  }
+  m_scene->setValue((QtCamScene::SceneMode)mode);
 }
index c32dd6a..772cbc2 100644 (file)
 #ifndef SCENE_H
 #define SCENE_H
 
-#include "capability.h"
+#include <QObject>
 #include "qtcamscene.h"
 
-class Scene : public Capability {
+class QtCamDevice;
+
+class Scene : public QObject {
   Q_OBJECT
 
   Q_PROPERTY(SceneMode value READ value WRITE setValue NOTIFY valueChanged);
@@ -43,18 +45,16 @@ public:
     Auto = QtCamScene::Auto
   } SceneMode;
 
-  Scene(QObject *parent = 0);
+  Scene(QtCamDevice *dev, QObject *parent = 0);
   ~Scene();
 
-  SceneMode value();
+  SceneMode value() const;
   void setValue(const SceneMode& mode);
 
 signals:
   void valueChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamScene *m_scene;
 };
 
index 8e150ca..2951bbe 100644 (file)
  */
 
 #include "whitebalance.h"
-#include "camera.h"
-#include <QDebug>
 
-WhiteBalance::WhiteBalance(QObject *parent) :
-  Capability(parent),
-  m_wb(0) {
+WhiteBalance::WhiteBalance(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_wb(new QtCamWhiteBalance(dev, this)) {
 
+  QObject::connect(m_wb, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
 }
 
 WhiteBalance::~WhiteBalance() {
-  if (m_wb) {
-    delete m_wb; m_wb = 0;
-  }
-}
-
-void WhiteBalance::deviceChanged() {
-  if (m_wb) {
-    delete m_wb; m_wb = 0;
-  }
-
-  if (m_cam->device()) {
-    m_wb = new QtCamWhiteBalance(m_cam->device(), this);
-    QObject::connect(m_wb, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
-  }
-
-  emit valueChanged();
+  delete m_wb; m_wb = 0;
 }
 
 WhiteBalance::WhiteBalanceMode WhiteBalance::value() {
-  return m_wb ? (WhiteBalanceMode)m_wb->value() : WhiteBalance::Auto;
+  return (WhiteBalanceMode)m_wb->value();
 }
 
 void WhiteBalance::setValue(const WhiteBalance::WhiteBalanceMode& mode) {
-  if (m_wb) {
-    m_wb->setValue((QtCamWhiteBalance::WhiteBalanceMode)mode);
-  }
+  m_wb->setValue((QtCamWhiteBalance::WhiteBalanceMode)mode);
 }
index e713c7b..fe46d2b 100644 (file)
 #ifndef WHITE_BALANCE_H
 #define WHITE_BALANCE_H
 
-#include "capability.h"
+#include <QObject>
 #include "qtcamwhitebalance.h"
 
-class WhiteBalance : public Capability {
+class QtCamDevice;
+
+class WhiteBalance : public QObject {
   Q_OBJECT
 
   Q_PROPERTY(WhiteBalanceMode value READ value WRITE setValue NOTIFY valueChanged);
@@ -42,7 +44,7 @@ public:
     Flourescent = QtCamWhiteBalance::Flourescent
   } WhiteBalanceMode;
 
-  WhiteBalance(QObject *parent = 0);
+  WhiteBalance(QtCamDevice *dev, QObject *parent = 0);
   ~WhiteBalance();
 
   WhiteBalanceMode value();
@@ -52,8 +54,6 @@ signals:
   void valueChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamWhiteBalance *m_wb;
 };
 
index cfd052f..da87ef0 100644 (file)
  */
 
 #include "zoom.h"
-#include "camera.h"
 #include "qtcamzoom.h"
 
-Zoom::Zoom(QObject *parent) :
-  Capability(parent),
-  m_zoom(0) {
+Zoom::Zoom(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_zoom(new QtCamZoom(dev, this)) {
 
+  QObject::connect(m_zoom, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
+  QObject::connect(m_zoom, SIGNAL(minimumValueChanged()), this, SIGNAL(minimumChanged()));
+  QObject::connect(m_zoom, SIGNAL(maximumValueChanged()), this, SIGNAL(maximunmChanged()));
 }
 
 Zoom::~Zoom() {
-  if (m_zoom) {
-    delete m_zoom; m_zoom = 0;
-  }
-}
-
-void Zoom::deviceChanged() {
-  if (m_zoom) {
-    delete m_zoom; m_zoom = 0;
-  }
-
-  if (m_cam->device()) {
-    m_zoom = new QtCamZoom(m_cam->device(), this);
-    QObject::connect(m_zoom, SIGNAL(valueChanged()), this, SIGNAL(valueChanged()));
-    QObject::connect(m_zoom, SIGNAL(minimumValueChanged()), this, SIGNAL(minimumChanged()));
-    QObject::connect(m_zoom, SIGNAL(maximumValueChanged()), this, SIGNAL(maximunmChanged()));
-  }
-
-  emit valueChanged();
-  emit minimumChanged();
-  emit maximunmChanged();
+  delete m_zoom; m_zoom = 0;
 }
 
 qreal Zoom::value() {
-  return m_zoom ? m_zoom->value() : 1.0;
+  return m_zoom->value();
 }
 
 void Zoom::setValue(qreal val) {
-  if (m_zoom) {
-    m_zoom->setValue(val);
-  }
+  m_zoom->setValue(val);
 }
 
 qreal Zoom::minimum() {
-  return m_zoom ? m_zoom->minimumValue() : 1.0;
+  return m_zoom->minimumValue();
 }
 
 qreal Zoom::maximum() {
-  return m_zoom ? m_zoom->maximumValue() : 1.0;
+  return m_zoom->maximumValue();
 }
index 23e576c..cb17131 100644 (file)
 #ifndef ZOOM_H
 #define ZOOM_H
 
-#include "capability.h"
+#include <QObject>
 
 class QtCamZoom;
+class QtCamDevice;
 
-class Zoom : public Capability {
+class Zoom : public QObject {
   Q_OBJECT
 
   Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged);
@@ -35,7 +36,7 @@ class Zoom : public Capability {
   Q_PROPERTY(qreal maximum READ maximum NOTIFY maximunmChanged);
 
 public:
-  Zoom(QObject *parent = 0);
+  Zoom(QtCamDevice *dev, QObject *parent = 0);
   ~Zoom();
 
   qreal value();
@@ -50,8 +51,6 @@ signals:
   void maximunmChanged();
 
 private:
-  virtual void deviceChanged();
-
   QtCamZoom *m_zoom;
 };
 
index 08bfd9e..32ca39d 100644 (file)
@@ -28,21 +28,10 @@ import "data.js" as Data
 Selector {
         id: button
 
-        property alias value: flash.value
-
         iconSource: "image://theme/" + Data.flashIcon(settings.imageFlashMode)
 
         title: qsTr("Flash mode");
 
-        Flash {
-                // TODO: move this out of here.
-                id: flash
-                camera: cam
-                value: settings.imageFlashMode
-                       // TODO: scene modes can change flash value. what to do here ?
-                onValueChanged: settings.imageFlashMode = value;
-        }
-
         widget: Row {
                 id: row
                 height: button.checked ? 64 : 0
similarity index 69%
rename from qml/EvCompButton.qml
rename to qml/ImageEvCompButton.qml
index edb118a..781dabc 100644 (file)
@@ -27,31 +27,22 @@ import QtCamera 1.0
 Selector {
         id: button
 
-        property alias value: evComp.value
-
-        iconSource: evComp.value == 0 ? "image://theme/icon-m-camera-manual-exposure" : ""
-        text: evComp.value == 0 ? "" : evComp.value.toFixed(1);
+        iconSource: settings.imageEvComp == 0 ? "image://theme/icon-m-camera-manual-exposure" : ""
+        text: settings.imageEvComp == 0 ? "" : settings.imageEvComp.toFixed(1);
         font.pixelSize: 19
         timerConstraints: slider.pressed
 
         title: qsTr("Exposure compensation");
 
-        EvComp {
-                id: evComp
-                camera: cam
-
-                // TODO: hardcoding
-                value: slider.value
-        }
-
         widget: Slider {
                 id: slider
                 width: 500
                 orientation: Qt.Horizontal
-                minimumValue: evComp.minimum
-                maximumValue: evComp.maximum
-                value: evComp.value
+                minimumValue: cam.evComp.minimum
+                maximumValue: cam.evComp.maximum
+                value: settings.imageEvComp
                 stepSize: 0.1
-                Component.onCompleted: { slider.value = evComp.value; }
+                onValueChanged: settings.imageEvComp = value;
+                Component.onCompleted: { slider.value = settings.imageEvComp; }
         }
 }
index 817b930..d0a6133 100644 (file)
@@ -99,7 +99,7 @@ CameraPage {
                 anchors.leftMargin: 20
         }
 
-        EvCompButton {
+        ImageEvCompButton {
                 id: evComp
                 visible: controlsVisible
                 anchors.top: scene.bottom
index c15d2c0..59ba290 100644 (file)
@@ -28,9 +28,7 @@ import "data.js" as Data
 Selector {
         id: button
 
-        property int value: settings.imageSceneMode
-
-        iconSource: "image://theme/" + Data.ismIcon(scene.value);
+        iconSource: "image://theme/" + Data.ismIcon(settings.imageSceneMode);
 
         title: qsTr("Scene mode");
 
similarity index 50%
rename from imports/capability.cpp
rename to qml/VideoEvCompButton.qml
index 890fe8a..c4a2416 100644 (file)
@@ -1,3 +1,5 @@
+// -*- qml -*-
+
 /*!
  * This file is part of CameraPlus.
  *
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "capability.h"
-#include "camera.h"
-
-Capability::Capability(QObject *parent) :
-  QObject(parent),
-  m_cam(0) {
-
-}
-
-Capability::~Capability() {
-
-}
-
-Camera *Capability::camera() {
-  return m_cam;
-}
-
-void Capability::setCamera(Camera *cam) {
-  if (cam == m_cam) {
-    return;
-  }
-
-  if (m_cam) {
-    QObject::disconnect(m_cam, SIGNAL(deviceChanged()), this, SLOT(deviceChanged()));
-    QObject::disconnect(m_cam, SIGNAL(deviceChanged()), this, SIGNAL(isReadyChanged()));
-  }
-
-  m_cam = cam;
-
-  if (m_cam) {
-    QObject::connect(m_cam, SIGNAL(deviceChanged()), this, SLOT(deviceChanged()));
-    QObject::connect(m_cam, SIGNAL(deviceChanged()), this, SIGNAL(isReadyChanged()));
-  }
-
-  emit cameraChanged();
-
-  deviceChanged();
-
-  emit isReadyChanged();
-}
-
-bool Capability::isReady() const {
-  return m_cam && m_cam->device();
+import QtQuick 1.1
+import com.nokia.meego 1.1
+import QtCamera 1.0
+
+Selector {
+        id: button
+
+        iconSource: settings.videoEvComp == 0 ? "image://theme/icon-m-camera-manual-exposure" : ""
+        text: settings.videoEvComp == 0 ? "" : settings.videoEvComp.toFixed(1);
+        font.pixelSize: 19
+        timerConstraints: slider.pressed
+
+        title: qsTr("Exposure compensation");
+
+        widget: Slider {
+                id: slider
+                width: 500
+                orientation: Qt.Horizontal
+                minimumValue: cam.evComp.minimum
+                maximumValue: cam.evComp.maximum
+                value: settings.videoEvComp
+                stepSize: 0.1
+                onValueChanged: settings.videoEvComp = value;
+                Component.onCompleted: { slider.value = settings.videoEvComp; }
+        }
 }
index f88dcaa..ec09db0 100644 (file)
@@ -165,7 +165,7 @@ CameraPage {
                 anchors.leftMargin: 20
         }
 
-        EvCompButton {
+        VideoEvCompButton {
                 id: evComp
                 visible: videoControlsVisible
                 anchors.top: scene.bottom
index b085fea..3e5d1d7 100644 (file)
@@ -28,9 +28,7 @@ import "data.js" as Data
 Selector {
         id: button
 
-        property int value: settings.videoSceneMode
-
-        iconSource: sceneIcon(scene.value);
+        iconSource: sceneIcon(settings.videoSceneMode);
 
         title: qsTr("Scene mode");
 
index 3d340d8..85e74e7 100644 (file)
@@ -26,29 +26,31 @@ import QtCamera 1.0
 
 Slider {
         id: slider
-        property alias camera: zoom.camera
+        property Camera camera: null
+
         platformStyle: SliderStyle {
                 // HACK
                 handleBackground: " "
                 handleBackgroundPressed: " "
         }
 
-        Zoom {
-                id: zoom
+        Binding {
+                target: camera.zoom
+                property: "value"
                 value: slider.value
         }
 
         Connections {
                 target: camera
-                onModeChanged: slider.value = zoom.minimum;
+                onModeChanged: slider.value = camera.zoom.minimum;
         }
 
         orientation: Qt.Horizontal
         width: 500
         height: 50
         stepSize:0.1
-        minimumValue: zoom.minimum
-        maximumValue: zoom.maximum
+        minimumValue: camera.zoom.minimum
+        maximumValue: camera.zoom.maximum
 
         state: "hidden"
         states: [
index 0766c9f..fb484fb 100644 (file)
@@ -39,8 +39,6 @@ import QtMobility.location 1.2
 // TODO: disable debug builds.
 // TODO: a way to get buffers to the application
 // TODO: fcam like functionality (precise control over capture parameters).
-// TODO: changing scene mode doesn't affect the existing properties ?
-// TODO: upon startup all properties don't load correct values.
 
 PageStackWindow {
         id: root
@@ -252,25 +250,105 @@ PageStackWindow {
                         id: sounds
                         mute: !settings.soundEnabled
                 }
+
         }
 
-        Scene {
-                id: sceneController
-                camera: cam
-                value: ready ? camera.mode == Camera.VideoMode ? settings.videoSceneMode : settings.imageSceneMode : 0
-                onValueChanged: console.log("New scene value " + value);
+        Binding {
+                target: cam.flash
+                property: "value"
+                when: cam.mode == Camera.ImageMode
+                value: settings.imageFlashMode
         }
 
-        ColorTone {
-                id: colorToneController
-                camera: cam
-                value: ready ? camera.mode == Camera.VideoMode ? settings.videoColorFilter : settings.imageColorFilter : 0
+        Binding {
+                target: settings
+                property: "imageFlashMode"
+                when: cam.mode == Camera.ImageMode
+                value: cam.flash.value
         }
 
-        WhiteBalance {
-                id: whiteBalanceController
-                camera: cam
-                value: ready ? camera.mode == Camera.VideoMode ? settings.videoWhiteBalance : settings.imageWhiteBalance : 0
+        Binding {
+                target: cam.scene
+                property: "value"
+                when: cam.mode == Camera.VideoMode
+                value: settings.videoSceneMode
+        }
+
+        Binding {
+                target: cam.scene
+                property: "value"
+                when: cam.mode == Camera.ImageMode
+                value: settings.imageSceneMode
+        }
+
+        Binding {
+                target: cam.evComp
+                property: "value"
+                when: cam.mode == Camera.ImageMode
+                value: settings.imageEvComp
+        }
+
+        Binding {
+                target: cam.evComp
+                property: "value"
+                when: cam.mode == Camera.VideoMode
+                value: settings.videoEvComp
+        }
+
+        Binding {
+                target: settings
+                property: "imageEvComp"
+                when: cam.mode == Camera.ImageMode
+                value: cam.evComp.value
+        }
+
+        Binding {
+                target: settings
+                property: "videoEvComp"
+                when: cam.mode == Camera.VideoMode
+                value: cam.evComp.value
+        }
+
+        Binding {
+                target: cam.whiteBalance
+                property: "value"
+                when: cam.mode == Camera.ImageMode
+                value: settings.imageWhiteBalance
+        }
+
+        Binding {
+                target: cam.whiteBalance
+                property: "value"
+                when: cam.mode == Camera.VideoMode
+                value: settings.videoWhiteBalance
+        }
+
+        Binding {
+                target: cam.colorTone
+                property: "value"
+                when: cam.mode == Camera.ImageMode
+                value: settings.imageColorFilter
+        }
+
+        Binding {
+                target: cam.colorTone
+                property: "value"
+                when: cam.mode == Camera.VideoMode
+                value: settings.videoColorFilter
+        }
+
+        Binding {
+                target: cam.iso
+                property: "value"
+                when: cam.mode == Camera.ImageMode
+                value: settings.imageIso
+        }
+
+        Binding {
+                target: settings
+                property: "imageIso"
+                when: cam.mode == Camera.ImageMode
+                value: cam.iso.value
         }
 
         ModeController {
@@ -279,12 +357,6 @@ PageStackWindow {
                 dimmer: root.dimmer
         }
 
-        Iso {
-                id: iso
-                camera: cam
-                value: ready ? settings.imageIso : 0
-        }
-
         Connections {
                 target: cam
                 onModeChanged: {