Added a signal idleStateChanged() to QtCamDevice
authorMohammed Sameer <msameer@foolab.org>
Sun, 26 Aug 2012 08:46:05 +0000 (11:46 +0300)
committerMohammed Sameer <msameer@foolab.org>
Thu, 6 Sep 2012 16:10:09 +0000 (19:10 +0300)
lib/qtcamdevice.cpp
lib/qtcamdevice.h
lib/qtcamdevice_p.h

index 17620bc..f93efb3 100644 (file)
@@ -51,6 +51,9 @@ QtCamDevice::QtCamDevice(QtCamConfig *config, const QString& name,
   QObject::connect(d_ptr->listener, SIGNAL(started()), this, SIGNAL(started()));
   QObject::connect(d_ptr->listener, SIGNAL(stopped()), this, SIGNAL(stopped()));
 
+  g_signal_connect(d_ptr->cameraBin, "notify::idle",
+                  G_CALLBACK(QtCamDevicePrivate::on_idle_changed), d_ptr);
+
   d_ptr->image = new QtCamImageMode(d_ptr, this);
   d_ptr->video = new QtCamVideoMode(d_ptr, this);
 }
index 59d7421..b5c7ae5 100644 (file)
@@ -43,6 +43,7 @@ signals:
   void error(const QString& message, int code, const QString& debug);
   void started();
   void stopped();
+  void idleStateChanged(bool isIdle);
 
 private:
   Q_PRIVATE_SLOT(d_ptr, void _d_error(const QString&, int, const QString&))
index e31fdfb..34d7022 100644 (file)
@@ -121,6 +121,14 @@ public:
     }
   }
 
+  static void on_idle_changed(GObject *obj, GParamSpec *pspec, QtCamDevicePrivate *d) {
+    Q_UNUSED(obj);
+    Q_UNUSED(pspec);
+
+    QMetaObject::invokeMethod(d->q_ptr, "idleStateChanged", Qt::QueuedConnection,
+                             Q_ARG(bool, d->q_ptr->isIdle()));
+  }
+
   QString name;
   QVariant id;