VideoTorch and VideoMute are now properties of Camera
authorMohammed Sameer <msameer@foolab.org>
Sat, 8 Dec 2012 18:06:38 +0000 (20:06 +0200)
committerMohammed Sameer <msameer@foolab.org>
Sat, 8 Dec 2012 18:06:38 +0000 (20:06 +0200)
Renamed Mute to VideoMute
VideoTorch state is now stored and restored upon startup

17 files changed:
imports/camera.cpp
imports/camera.h
imports/imports.pro
imports/mute.cpp [deleted file]
imports/plugin.cpp
imports/videomute.cpp [new file with mode: 0644]
imports/videomute.h [moved from imports/mute.h with 73% similarity]
imports/videotorch.cpp
imports/videotorch.h
lib/lib.pro
lib/qtcamdevice.h
lib/qtcamvideomute.cpp [moved from lib/qtcammute.cpp with 82% similarity]
lib/qtcamvideomute.h [moved from lib/qtcammute.h with 79% similarity]
qml/VideoPage.qml
qml/VideoTorchButton.qml
src/settings.cpp
src/settings.h

index a3b1e69..833b580 100644 (file)
@@ -45,6 +45,9 @@
 #include "focus.h"
 #include "autofocus.h"
 
 #include "focus.h"
 #include "autofocus.h"
 
+#include "videomute.h"
+#include "videotorch.h"
+
 // TODO: a viewfinder class that inherits QDeclarativeItem
 
 Camera::Camera(QDeclarativeItem *parent) :
 // TODO: a viewfinder class that inherits QDeclarativeItem
 
 Camera::Camera(QDeclarativeItem *parent) :
@@ -66,8 +69,9 @@ Camera::Camera(QDeclarativeItem *parent) :
   m_noiseReduction(0),
   m_flickerReduction(0),
   m_focus(0),
   m_noiseReduction(0),
   m_flickerReduction(0),
   m_focus(0),
-  m_autoFocus(0) {
-
+  m_autoFocus(0),
+  m_videoMute(0),
+  m_videoTorch(0) {
 
   // TODO:
 }
 
   // TODO:
 }
@@ -92,7 +96,8 @@ Camera::~Camera() {
   delete m_flickerReduction;
   delete m_focus;
   delete m_autoFocus;
   delete m_flickerReduction;
   delete m_focus;
   delete m_autoFocus;
-
+  delete m_videoMute;
+  delete m_videoTorch;
   // TODO: cleanup
 }
 
   // TODO: cleanup
 }
 
@@ -333,6 +338,14 @@ void Camera::resetCapabilities() {
   delete m_autoFocus;
   m_autoFocus = new AutoFocus(dev, this);
   emit autoFocusChanged();
   delete m_autoFocus;
   m_autoFocus = new AutoFocus(dev, this);
   emit autoFocusChanged();
+
+  delete m_videoMute;
+  m_videoMute = new VideoMute(dev, this);
+  emit videoMuteChanged();
+
+  delete m_videoTorch;
+  m_videoTorch = new VideoTorch(dev, this);
+  emit videoTorchChanged();
 }
 
 Zoom *Camera::zoom() const {
 }
 
 Zoom *Camera::zoom() const {
@@ -386,3 +399,11 @@ Focus *Camera::focus() const {
 AutoFocus *Camera::autoFocus() const {
   return m_autoFocus;
 }
 AutoFocus *Camera::autoFocus() const {
   return m_autoFocus;
 }
+
+VideoMute *Camera::videoMute() const {
+  return m_videoMute;
+}
+
+VideoTorch *Camera::videoTorch() const {
+return m_videoTorch;
+}
index a393aff..13bcb30 100644 (file)
@@ -45,6 +45,8 @@ class NoiseReduction;
 class FlickerReduction;
 class Focus;
 class AutoFocus;
 class FlickerReduction;
 class Focus;
 class AutoFocus;
+class VideoMute;
+class VideoTorch;
 
 class Camera : public QDeclarativeItem {
   Q_OBJECT
 
 class Camera : public QDeclarativeItem {
   Q_OBJECT
@@ -72,6 +74,9 @@ class Camera : public QDeclarativeItem {
   Q_PROPERTY(Focus *focus READ focus NOTIFY focusChanged);
   Q_PROPERTY(AutoFocus *autoFocus READ autoFocus NOTIFY autoFocusChanged);
 
   Q_PROPERTY(Focus *focus READ focus NOTIFY focusChanged);
   Q_PROPERTY(AutoFocus *autoFocus READ autoFocus NOTIFY autoFocusChanged);
 
+  Q_PROPERTY(VideoMute *videoMute READ videoMute NOTIFY videoMuteChanged);
+  Q_PROPERTY(VideoTorch *videoTorch READ videoTorch NOTIFY videoTorchChanged);
+
   Q_ENUMS(CameraMode);
 
 public:
   Q_ENUMS(CameraMode);
 
 public:
@@ -124,6 +129,9 @@ public:
   Focus *focus() const;
   AutoFocus *autoFocus() const;
 
   Focus *focus() const;
   AutoFocus *autoFocus() const;
 
+  VideoMute *videoMute() const;
+  VideoTorch *videoTorch() const;
+
 signals:
   void deviceCountChanged();
   void deviceIdChanged();
 signals:
   void deviceCountChanged();
   void deviceIdChanged();
@@ -148,6 +156,9 @@ signals:
   void focusChanged();
   void autoFocusChanged();
 
   void focusChanged();
   void autoFocusChanged();
 
+  void videoMuteChanged();
+  void videoTorchChanged();
+
 protected:
   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
 
 protected:
   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
 
@@ -178,6 +189,9 @@ private:
   FlickerReduction *m_flickerReduction;
   Focus *m_focus;
   AutoFocus *m_autoFocus;
   FlickerReduction *m_flickerReduction;
   Focus *m_focus;
   AutoFocus *m_autoFocus;
+
+  VideoMute *m_videoMute;
+  VideoTorch *m_videoTorch;
 };
 
 #endif /* CAMERA_H */
 };
 
 #endif /* CAMERA_H */
index 11ea5ec..097fa5f 100644 (file)
@@ -13,13 +13,13 @@ QT += declarative
 HEADERS += plugin.h previewprovider.h camera.h mode.h imagemode.h videomode.h \
            zoom.h flash.h scene.h evcomp.h videotorch.h whitebalance.h \
            colortone.h exposure.h aperture.h iso.h noisereduction.h \
 HEADERS += plugin.h previewprovider.h camera.h mode.h imagemode.h videomode.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
+           flickerreduction.h videomute.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 \
            zoom.cpp flash.cpp scene.cpp evcomp.cpp videotorch.cpp whitebalance.cpp \
            colortone.cpp exposure.cpp aperture.cpp iso.cpp noisereduction.cpp \
 
 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 \
            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 focus.cpp autofocus.cpp
+           flickerreduction.cpp videomute.cpp metadata.cpp imagesettings.cpp \
+           imageresolutionmodel.cpp videosettings.cpp videoresolutionmodel.cpp \
+           notifications.cpp notificationscontainer.cpp sounds.cpp focus.cpp autofocus.cpp
diff --git a/imports/mute.cpp b/imports/mute.cpp
deleted file mode 100644 (file)
index b9b5f72..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*!
- * 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 "mute.h"
-#include "qtcammute.h"
-#include "camera.h"
-#include "qtcamdevice.h"
-
-Mute::Mute(QObject *parent) :
-  QObject(parent), m_cam(0), m_mute(0) {
-
-}
-
-Mute::~Mute() {
-  m_cam = 0;
-}
-
-Camera *Mute::camera() {
-  return m_cam;
-}
-
-void Mute::setCamera(Camera *camera) {
-  if (camera == m_cam) {
-    return;
-  }
-
-  if (m_cam) {
-    QObject::disconnect(m_cam, SIGNAL(deviceChanged()), this, SLOT(deviceChanged()));
-  }
-
-  m_cam = camera;
-
-  if (m_cam) {
-    QObject::connect(m_cam, SIGNAL(deviceChanged()), this, SLOT(deviceChanged()));
-  }
-
-  emit cameraChanged();
-
-  deviceChanged();
-}
-
-bool Mute::isEnabled() const {
-  return m_mute ? m_mute->isEnabled() : false;
-}
-
-void Mute::setEnabled(bool enabled) {
-  if (m_mute) {
-    m_mute->setEnabled(enabled);
-  }
-}
-
-void Mute::deviceChanged() {
-  if (m_mute) {
-    delete m_mute; m_mute = 0;
-  }
-
-  if (m_cam->device()) {
-    m_mute = new QtCamMute(m_cam->device(), this);
-    QObject::connect(m_mute, SIGNAL(stateChanged()), this, SIGNAL(stateChanged()));
-
-    emit stateChanged();
-  }
-}
index 571eb95..08ef8df 100644 (file)
@@ -37,7 +37,7 @@
 #include "flickerreduction.h"
 #include "focus.h"
 #include "autofocus.h"
 #include "flickerreduction.h"
 #include "focus.h"
 #include "autofocus.h"
-#include "mute.h"
+#include "videomute.h"
 #include "metadata.h"
 #include "imagesettings.h"
 #include "imageresolutionmodel.h"
 #include "metadata.h"
 #include "imagesettings.h"
 #include "imageresolutionmodel.h"
@@ -71,8 +71,8 @@ void Plugin::registerTypes(QDeclarativeEngine *engine) {
   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"));
 
   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");
+  qmlRegisterUncreatableType<VideoMute>(URI, MAJOR, MINOR, "VideoMute", QObject::tr("Cannot create separate instance of VideoMute"));
+  qmlRegisterUncreatableType<VideoTorch>(URI, MAJOR, MINOR, "VideoTorch", QObject::tr("Cannot create separate instance of VideoTorch"));
 
   qmlRegisterType<MetaData>(URI, MAJOR, MINOR, "MetaData");
   qmlRegisterType<ImageSettings>(URI, MAJOR, MINOR, "ImageSettings");
 
   qmlRegisterType<MetaData>(URI, MAJOR, MINOR, "MetaData");
   qmlRegisterType<ImageSettings>(URI, MAJOR, MINOR, "ImageSettings");
diff --git a/imports/videomute.cpp b/imports/videomute.cpp
new file mode 100644 (file)
index 0000000..7fbe4e1
--- /dev/null
@@ -0,0 +1,41 @@
+/*!
+ * 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 "videomute.h"
+#include "qtcamvideomute.h"
+
+VideoMute::VideoMute(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_mute(new QtCamVideoMute(dev, this)) {
+
+  QObject::connect(m_mute, SIGNAL(stateChanged()), this, SIGNAL(stateChanged()));
+}
+
+VideoMute::~VideoMute() {
+  delete m_mute; m_mute = 0;
+}
+
+bool VideoMute::isEnabled() const {
+  return m_mute->isEnabled();
+}
+
+void VideoMute::setEnabled(bool enabled) {
+  m_mute->setEnabled(enabled);
+}
similarity index 73%
rename from imports/mute.h
rename to imports/videomute.h
index b453153..8ae471b 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef MUTE_H
-#define MUTE_H
+#ifndef VIDEO_MUTE_H
+#define VIDEO_MUTE_H
 
 #include <QObject>
 
 
 #include <QObject>
 
-class Camera;
-class QtCamMute;
+class QtCamVideoMute;
+class QtCamDevice;
 
 
-class Mute : public QObject {
+class VideoMute : public QObject {
   Q_OBJECT
   Q_OBJECT
-  Q_PROPERTY(Camera* camera READ camera WRITE setCamera NOTIFY cameraChanged);
   Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY stateChanged);
 
 public:
   Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY stateChanged);
 
 public:
-  Mute(QObject *parent = 0);
-  ~Mute();
-
-  Camera *camera();
-  void setCamera(Camera *camera);
+  VideoMute(QtCamDevice *dev, QObject *parent = 0);
+  ~VideoMute();
 
   bool isEnabled() const;
   void setEnabled(bool enabled);
 
 signals:
   void stateChanged();
 
   bool isEnabled() const;
   void setEnabled(bool enabled);
 
 signals:
   void stateChanged();
-  void cameraChanged();
-
-private slots:
-  void deviceChanged();
 
 private:
 
 private:
-  Camera *m_cam;
-  QtCamMute *m_mute;
+  QtCamVideoMute *m_mute;
 };
 
 };
 
-#endif /* MUTE_H */
+#endif /* VIDEO_MUTE_H */
index f5fb1b2..4dce14e 100644 (file)
 
 #include "videotorch.h"
 #include "qtcamvideotorch.h"
 
 #include "videotorch.h"
 #include "qtcamvideotorch.h"
-#include "camera.h"
-#include "qtcamdevice.h"
-#include "qtcamvideomode.h"
 
 
-VideoTorch::VideoTorch(QObject *parent) :
-  QObject(parent), m_cam(0), m_torch(0) {
+VideoTorch::VideoTorch(QtCamDevice *dev, QObject *parent) :
+  QObject(parent),
+  m_torch(new QtCamVideoTorch(dev, this)) {
 
 
+  QObject::connect(m_torch, SIGNAL(stateChanged()), this, SIGNAL(stateChanged()));
 }
 
 VideoTorch::~VideoTorch() {
 }
 
 VideoTorch::~VideoTorch() {
-  m_cam = 0;
-}
-
-Camera *VideoTorch::camera() {
-  return m_cam;
-}
-
-void VideoTorch::setCamera(Camera *camera) {
-  if (camera == m_cam) {
-    return;
-  }
-
-  if (m_cam) {
-    QObject::disconnect(m_cam, SIGNAL(deviceChanged()), this, SLOT(deviceChanged()));
-  }
-
-  m_cam = camera;
-
-  if (m_cam) {
-    QObject::connect(m_cam, SIGNAL(deviceChanged()), this, SLOT(deviceChanged()));
-  }
-
-  emit cameraChanged();
-
-  deviceChanged();
+  delete m_torch; m_torch = 0;
 }
 
 bool VideoTorch::isOn() const {
 }
 
 bool VideoTorch::isOn() const {
-  return m_torch ? m_torch->isOn() : false;
+  return m_torch->isOn();
 }
 
 void VideoTorch::setOn(bool on) {
 }
 
 void VideoTorch::setOn(bool on) {
-  if (m_torch) {
-    m_torch->setOn(on);
-  }
-}
-
-void VideoTorch::deviceChanged() {
-  if (m_torch) {
-    delete m_torch; m_torch = 0;
-  }
-
-  if (m_cam->device()) {
-    m_torch = new QtCamVideoTorch(m_cam->device(), this);
-    QObject::connect(m_torch, SIGNAL(stateChanged()), this, SIGNAL(stateChanged()));
-
-    emit stateChanged();
-  }
+  m_torch->setOn(on);
 }
 }
index c833aca..5c5397a 100644 (file)
 
 #include <QObject>
 
 
 #include <QObject>
 
-class Camera;
 class QtCamVideoTorch;
 class QtCamVideoTorch;
+class QtCamDevice;
 
 class VideoTorch : public QObject {
   Q_OBJECT
 
 class VideoTorch : public QObject {
   Q_OBJECT
-  Q_PROPERTY(Camera* camera READ camera WRITE setCamera NOTIFY cameraChanged);
   Q_PROPERTY(bool on READ isOn WRITE setOn NOTIFY stateChanged);
 
 public:
   Q_PROPERTY(bool on READ isOn WRITE setOn NOTIFY stateChanged);
 
 public:
-  VideoTorch(QObject *parent = 0);
+  VideoTorch(QtCamDevice *dev, QObject *parent = 0);
   ~VideoTorch();
 
   ~VideoTorch();
 
-  Camera *camera();
-  void setCamera(Camera *camera);
-
   bool isOn() const;
   void setOn(bool on);
 
 signals:
   void stateChanged();
   bool isOn() const;
   void setOn(bool on);
 
 signals:
   void stateChanged();
-  void cameraChanged();
-
-private slots:
-  void deviceChanged();
 
 private:
 
 private:
-  Camera *m_cam;
   QtCamVideoTorch *m_torch;
 };
 
   QtCamVideoTorch *m_torch;
 };
 
index 163c55b..17f6b05 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 \
            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 qtcamfocus.h qtcamautofocus.h
+           qtcamvideomute.h qtcamnotifications.h qtcamfocus.h qtcamautofocus.h
 
 SOURCES += qtcamconfig.cpp qtcamera.cpp qtcamscanner.cpp qtcamdevice.cpp qtcamviewfinder.cpp \
            qtcammode.cpp qtcamgstreamermessagehandler.cpp qtcamgstreamermessagelistener.cpp \
 
 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 \
            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 qtcamfocus.cpp qtcamautofocus.cpp
+           qtcamvideomute.cpp qtcamnotifications.cpp qtcamfocus.cpp qtcamautofocus.cpp
 
 HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h qtcamautofocus_p.h
 
 
 HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h qtcamautofocus_p.h
 
index 0428f4d..692c401 100644 (file)
@@ -81,7 +81,7 @@ private:
   friend class QtCamMetaData;
   friend class QtCamCapability;
   friend class QtCamVideoTorch;
   friend class QtCamMetaData;
   friend class QtCamCapability;
   friend class QtCamVideoTorch;
-  friend class QtCamMute;
+  friend class QtCamVideoMute;
   friend class QtCamAutoFocusPrivate;
 
   QtCamDevicePrivate *d_ptr;
   friend class QtCamAutoFocusPrivate;
 
   QtCamDevicePrivate *d_ptr;
similarity index 82%
rename from lib/qtcammute.cpp
rename to lib/qtcamvideomute.cpp
index bdc5848..21de3fa 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "qtcammute.h"
+#include "qtcamvideomute.h"
 #include "qtcamdevice.h"
 #include "qtcamdevice_p.h"
 #include <QPointer>
 
 #include "qtcamdevice.h"
 #include "qtcamdevice_p.h"
 #include <QPointer>
 
-class QtCamMutePrivate {
+class QtCamVideoMutePrivate {
 public:
 public:
-  static void mute_notify(GObject *gobject, GParamSpec *pspec, QtCamMute *q) {
+  static void mute_notify(GObject *gobject, GParamSpec *pspec, QtCamVideoMute *q) {
     Q_UNUSED(gobject);
     Q_UNUSED(pspec);
 
     Q_UNUSED(gobject);
     Q_UNUSED(pspec);
 
@@ -36,8 +36,8 @@ public:
   gulong handler;
 };
 
   gulong handler;
 };
 
-QtCamMute::QtCamMute(QtCamDevice *dev, QObject *parent) :
-  QObject(parent), d_ptr(new QtCamMutePrivate) {
+QtCamVideoMute::QtCamVideoMute(QtCamDevice *dev, QObject *parent) :
+  QObject(parent), d_ptr(new QtCamVideoMutePrivate) {
 
   d_ptr->dev = dev;
   d_ptr->handler = 0;
 
   d_ptr->dev = dev;
   d_ptr->handler = 0;
@@ -45,11 +45,11 @@ QtCamMute::QtCamMute(QtCamDevice *dev, QObject *parent) :
   if (d_ptr->dev->d_ptr->cameraBin) {
     d_ptr->handler = g_signal_connect(d_ptr->dev->d_ptr->cameraBin,
                                      "notify::mute",
   if (d_ptr->dev->d_ptr->cameraBin) {
     d_ptr->handler = g_signal_connect(d_ptr->dev->d_ptr->cameraBin,
                                      "notify::mute",
-                                     G_CALLBACK(QtCamMutePrivate::mute_notify), this);
+                                     G_CALLBACK(QtCamVideoMutePrivate::mute_notify), this);
   }
 }
 
   }
 }
 
-QtCamMute::~QtCamMute() {
+QtCamVideoMute::~QtCamVideoMute() {
   if (d_ptr->dev && d_ptr->handler) {
     g_signal_handler_disconnect(d_ptr->dev->d_ptr->cameraBin, d_ptr->handler);
   }
   if (d_ptr->dev && d_ptr->handler) {
     g_signal_handler_disconnect(d_ptr->dev->d_ptr->cameraBin, d_ptr->handler);
   }
@@ -57,7 +57,7 @@ QtCamMute::~QtCamMute() {
   delete d_ptr; d_ptr = 0;
 }
 
   delete d_ptr; d_ptr = 0;
 }
 
-void QtCamMute::setEnabled(bool enabled) {
+void QtCamVideoMute::setEnabled(bool enabled) {
   gboolean val = enabled ? TRUE : FALSE;
 
   if (d_ptr->dev->d_ptr->cameraBin) {
   gboolean val = enabled ? TRUE : FALSE;
 
   if (d_ptr->dev->d_ptr->cameraBin) {
@@ -65,7 +65,7 @@ void QtCamMute::setEnabled(bool enabled) {
   }
 }
 
   }
 }
 
-bool QtCamMute::isEnabled() const {
+bool QtCamVideoMute::isEnabled() const {
   gboolean val = FALSE;
 
   if (d_ptr->dev->d_ptr->cameraBin) {
   gboolean val = FALSE;
 
   if (d_ptr->dev->d_ptr->cameraBin) {
similarity index 79%
rename from lib/qtcammute.h
rename to lib/qtcamvideomute.h
index 3732e93..60466bf 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef QT_CAM_MUTE_H
-#define QT_CAM_MUTE_H
+#ifndef QT_CAM_VIDEO_MUTE_H
+#define QT_CAM_VIDEO_MUTE_H
 
 #include <QObject>
 
 class QtCamDevice;
 
 #include <QObject>
 
 class QtCamDevice;
-class QtCamMutePrivate;
+class QtCamVideoMutePrivate;
 
 
-class QtCamMute : public QObject {
+class QtCamVideoMute : public QObject {
   Q_OBJECT
 
 public:
   Q_OBJECT
 
 public:
-  QtCamMute(QtCamDevice *dev, QObject *parent = 0);
-  ~QtCamMute();
+  QtCamVideoMute(QtCamDevice *dev, QObject *parent = 0);
+  ~QtCamVideoMute();
 
   void setEnabled(bool enabled);
   bool isEnabled() const;
 
   void setEnabled(bool enabled);
   bool isEnabled() const;
@@ -42,7 +42,7 @@ signals:
   void stateChanged();
 
 private:
   void stateChanged();
 
 private:
-  QtCamMutePrivate *d_ptr;
+  QtCamVideoMutePrivate *d_ptr;
 };
 
 };
 
-#endif /* QT_CAM_MUTE_H */
+#endif /* QT_CAM_VIDEO_MUTE_H */
index ec09db0..85c14cf 100644 (file)
@@ -148,6 +148,7 @@ CameraPage {
 
         VideoTorchButton {
                 id: torch
 
         VideoTorchButton {
                 id: torch
+                camera: cam
                 visible: videoControlsVisible
                 anchors.top: parent.top
                 anchors.left: parent.left
                 visible: videoControlsVisible
                 anchors.top: parent.top
                 anchors.left: parent.left
index 786e94b..3e820a6 100644 (file)
@@ -30,10 +30,14 @@ Button {
         height: 56
         opacity: 0.5
 
         height: 56
         opacity: 0.5
 
-        iconSource: torch.on ? "image://theme/icon-m-camera-torch-on" : "image://theme/icon-m-camera-torch-off"
-        onClicked: torch.on = !torch.on
-        VideoTorch {
-                id: torch
-                camera: cam
+        property Camera camera: null
+
+        iconSource: settings.videoTorchOn ? "image://theme/icon-m-camera-torch-on" : "image://theme/icon-m-camera-torch-off"
+        onClicked: settings.videoTorchOn = !settings.videoTorchOn
+
+        Binding {
+                target: camera.videoTorch
+                property: "on"
+                value: settings.videoTorchOn
         }
 }
         }
 }
index 5eaabbf..3114e50 100644 (file)
@@ -38,6 +38,7 @@
 #define DEFAULT_IMAGE_ASPECT_RATIO "16:9"
 #define DEFAULT_VIDEO_RESOLUTION   "high"
 #define DEFAULT_SOUND_ENABLED      true
 #define DEFAULT_IMAGE_ASPECT_RATIO "16:9"
 #define DEFAULT_VIDEO_RESOLUTION   "high"
 #define DEFAULT_SOUND_ENABLED      true
+#define DEFAULT_VIDEO_TORCH_ON     false
 
 Settings::Settings(QObject *parent) :
   QObject(parent),
 
 Settings::Settings(QObject *parent) :
   QObject(parent),
@@ -284,3 +285,14 @@ void Settings::setSoundEnabled(bool enabled) {
     emit soundEnabledChanged();
   }
 }
     emit soundEnabledChanged();
   }
 }
+
+bool Settings::isVideoTorchOn() const {
+  return m_settings->value("video/torchOn", DEFAULT_VIDEO_TORCH_ON).toBool();
+}
+
+void Settings::setVideoTorchOn(bool on) {
+  if (isVideoTorchOn() != on) {
+    m_settings->setValue("video/torchOn", on);
+    emit videoTorchOnChanged();
+  }
+}
index 684b45b..4ccafc0 100644 (file)
@@ -55,6 +55,7 @@ class Settings : public QObject {
   Q_PROPERTY(QString videoResolution READ videoResolution WRITE setVideoResolution NOTIFY videoResolutionChanged);
 
   Q_PROPERTY(bool soundEnabled READ isSoundEnabled WRITE setSoundEnabled NOTIFY soundEnabledChanged);
   Q_PROPERTY(QString videoResolution READ videoResolution WRITE setVideoResolution NOTIFY videoResolutionChanged);
 
   Q_PROPERTY(bool soundEnabled READ isSoundEnabled WRITE setSoundEnabled NOTIFY soundEnabledChanged);
+  Q_PROPERTY(bool videoTorchOn READ isVideoTorchOn WRITE setVideoTorchOn NOTIFY videoTorchOnChanged);
 
 public:
   Settings(QObject *parent = 0);
 
 public:
   Settings(QObject *parent = 0);
@@ -120,6 +121,9 @@ public:
   bool isSoundEnabled() const;
   void setSoundEnabled(bool enabled);
 
   bool isSoundEnabled() const;
   void setSoundEnabled(bool enabled);
 
+  bool isVideoTorchOn() const;
+  void setVideoTorchOn(bool on);
+
 signals:
   void modeChanged();
   void creatorNameChanged();
 signals:
   void modeChanged();
   void creatorNameChanged();
@@ -141,6 +145,7 @@ signals:
   void videoAspectRatioChanged();
   void videoResolutionChanged();
   void soundEnabledChanged();
   void videoAspectRatioChanged();
   void videoResolutionChanged();
   void soundEnabledChanged();
+  void videoTorchOnChanged();
 
 private:
   QSettings *m_settings;
 
 private:
   QSettings *m_settings;