Added an error() signal to declarative Camera and show an error when it gets emitted
authorMohammed Sameer <msameer@foolab.org>
Fri, 14 Sep 2012 10:19:45 +0000 (13:19 +0300)
committerMohammed Sameer <msameer@foolab.org>
Fri, 14 Sep 2012 10:19:45 +0000 (13:19 +0300)
imports/camera.cpp
imports/camera.h
qml/main.qml

index 470afa2..4e6c2e5 100644 (file)
@@ -75,6 +75,8 @@ void Camera::setDeviceId(const QVariant& id) {
   QObject::connect(m_dev, SIGNAL(runningStateChanged(bool)),
                      this, SIGNAL(runningStateChanged()));
   QObject::connect(m_dev, SIGNAL(idleStateChanged(bool)), this, SIGNAL(idleStateChanged()));
+  QObject::connect(m_dev, SIGNAL(error(const QString&, int, const QString&)),
+                  this, SIGNAL(error(const QString&, int, const QString&)));
 
   emit deviceIdChanged();
   emit deviceChanged();
index a9507ff..81e9d5d 100644 (file)
@@ -61,6 +61,7 @@ signals:
   void modeChanged();
   void idleStateChanged();
   void runningStateChanged();
+  void error(const QString& message, int code, const QString& debug);
 
 protected:
   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
index 7b836eb..2825765 100644 (file)
@@ -124,6 +124,12 @@ PageStackWindow {
                 id: cam
                 anchors.fill: parent
 
+                onError: {
+                        console.log("Camera error (" + code + "): " + message + " " + debug);
+                        showError(qsTr("Camera error. Please restart the application."));
+                        cam.stop();
+                }
+
                 // TODO: hardcoding device id
                 Component.onCompleted: { cam.deviceId = 0; mode = settings.mode; }