video mode enhancements.
authorMohammed Sameer <msameer@foolab.org>
Wed, 29 Aug 2012 14:08:48 +0000 (17:08 +0300)
committerMohammed Sameer <msameer@foolab.org>
Thu, 6 Sep 2012 16:10:09 +0000 (19:10 +0300)
Added property (recording)
stopRecording() now returns void
monitor idle property and emit signals as needed

lib/qtcamvideomode.cpp
lib/qtcamvideomode.h

index 85b9721..7e99405 100644 (file)
@@ -15,6 +15,13 @@ public:
 
   ~QtCamVideoModePrivate() {}
 
+  void _d_idleStateChanged(bool isIdle) {
+    if (isIdle && dev->active == dev->video) {
+      QMetaObject::invokeMethod(dev->video, "recordingStateChanged");
+      QMetaObject::invokeMethod(dev->video, "canCaptureChanged");
+    }
+  }
+
   QtCamVideoSettings settings;
 };
 
@@ -32,6 +39,9 @@ QtCamVideoMode::QtCamVideoMode(QtCamDevicePrivate *d, QObject *parent) :
       setProfile(profile);
     }
   }
+
+  QObject::connect(d_ptr->dev->q_ptr, SIGNAL(idleStateChanged(bool)),
+                  this, SLOT(_d_idleStateChanged(bool)));
 }
 
 QtCamVideoMode::~QtCamVideoMode() {
@@ -76,15 +86,17 @@ bool QtCamVideoMode::startRecording(const QString& fileName) {
   g_object_set(d_ptr->dev->cameraBin, "location", fileName.toUtf8().data(), NULL);
   g_signal_emit_by_name(d_ptr->dev->cameraBin, "start-capture", NULL);
 
+  emit recordingStateChanged();
+
+  emit canCaptureChanged();
+
   return true;
 }
 
-bool QtCamVideoMode::stopRecording() {
+void QtCamVideoMode::stopRecording() {
   if (isRecording()) {
     g_signal_emit_by_name(d_ptr->dev->cameraBin, "stop-capture", NULL);
   }
-
-  return true;
 }
 
 bool QtCamVideoMode::setSettings(const QtCamVideoSettings& settings) {
@@ -99,7 +111,6 @@ bool QtCamVideoMode::setSettings(const QtCamVideoSettings& settings) {
   return true;
 }
 
-
 void QtCamVideoMode::setProfile(GstEncodingProfile *profile) {
   if (!d_ptr->dev->cameraBin) {
     gst_encoding_profile_unref(profile);
@@ -108,3 +119,5 @@ void QtCamVideoMode::setProfile(GstEncodingProfile *profile) {
 
   g_object_set(d_ptr->dev->cameraBin, "video-profile", profile, NULL);
 }
+
+#include "moc_qtcamvideomode.cpp"
index c6fb34b..6b32767 100644 (file)
@@ -13,6 +13,8 @@ class QtCamVideoSettings;
 class QtCamVideoMode : public QtCamMode {
   Q_OBJECT
 
+  Q_PROPERTY(bool recording READ isRecording NOTIFY recordingStateChanged);
+
 public:
   QtCamVideoMode(QtCamDevicePrivate *d, QObject *parent = 0);
   ~QtCamVideoMode();
@@ -21,18 +23,25 @@ public:
   virtual void applySettings();
 
   bool isRecording();
-  bool startRecording(const QString& fileName);
-  bool stopRecording();
+  Q_INVOKABLE bool startRecording(const QString& fileName);
 
   bool setSettings(const QtCamVideoSettings& settings);
 
   void setProfile(GstEncodingProfile *profile);
 
+public slots:
+  void stopRecording();
+
+signals:
+  void recordingStateChanged();
+
 protected:
   virtual void start();
   virtual void stop();
 
 private:
+  Q_PRIVATE_SLOT(d_ptr, void _d_idleStateChanged(bool));
+
   QtCamVideoModePrivate *d_ptr;
 };