Expose capture request id in the declarative camera.
authorDmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
Tue, 7 Feb 2012 02:52:11 +0000 (12:52 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 7 Feb 2012 04:01:24 +0000 (05:01 +0100)
It's useful to associate imageCaptured/Saved signals data with
capture requests.

Change-Id: I3e98c4a194403bd338a1b5313d8736b4baf79961
Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
src/imports/multimedia/qdeclarativecameracapture.cpp
src/imports/multimedia/qdeclarativecameracapture_p.h

index 11a3784..af2198f 100644 (file)
@@ -97,10 +97,13 @@ bool QDeclarativeCameraCapture::isReadyForCapture() const
 
     Start image capture.  The \l onImageCaptured() and \l onImageSaved() signals will
     be emitted when the capture is complete.
+
+    CameraCapture::capture returns the capture requestId parameter, used with
+    imageExposed(), imageCaptured(), imageMetadataAvailable() and imageSaved() signals.
 */
-void QDeclarativeCameraCapture::capture()
+int QDeclarativeCameraCapture::capture()
 {
-    m_capture->capture();
+    return m_capture->capture();
 }
 
 /*!
@@ -109,10 +112,13 @@ void QDeclarativeCameraCapture::capture()
 
     Start image capture to specified \a location.  The \l onImageCaptured() and \l onImageSaved() signals will
     be emitted when the capture is complete.
+
+    CameraCapture::captureToLocation returns the capture requestId parameter, used with
+    imageExposed(), imageCaptured(), imageMetadataAvailable() and imageSaved() signals.
 */
-void QDeclarativeCameraCapture::captureToLocation(const QString &location)
+int QDeclarativeCameraCapture::captureToLocation(const QString &location)
 {
-    m_capture->capture(location);
+    return m_capture->capture(location);
 }
 
 /*!
@@ -131,7 +137,7 @@ void QDeclarativeCameraCapture::cancelCapture()
     \qmlproperty string CameraCapture::capturedImagePath
     \property QDeclarativeCameraCapture::capturedImagePath
 
-    The path to the captured image.
+    The path to the last captured image.
 */
 QString QDeclarativeCameraCapture::capturedImagePath() const
 {
@@ -143,29 +149,26 @@ void QDeclarativeCameraCapture::_q_imageCaptured(int id, const QImage &preview)
     QString previewId = QString("preview_%1").arg(id);
     QDeclarativeCameraPreviewProvider::registerPreview(previewId, preview);
 
-    emit imageCaptured(QLatin1String("image://camera/")+previewId);
+    emit imageCaptured(id, QLatin1String("image://camera/")+previewId);
 }
 
 void QDeclarativeCameraCapture::_q_imageSaved(int id, const QString &fileName)
 {
-    Q_UNUSED(id);
     m_capturedImagePath = fileName;
-    emit imageSaved(fileName);
+    emit imageSaved(id, fileName);
 }
 
 void QDeclarativeCameraCapture::_q_imageMetadataAvailable(int id, const QString &key, const QVariant &value)
 {
-    Q_UNUSED(id);
-    emit imageMetadataAvailable(key, value);
+    emit imageMetadataAvailable(id, key, value);
 }
 
 
 void QDeclarativeCameraCapture::_q_captureFailed(int id, QCameraImageCapture::Error error, const QString &message)
 {
-    Q_UNUSED(id);
     Q_UNUSED(error);
     qWarning() << "QCameraImageCapture error:" << message;
-    emit captureFailed(message);
+    emit captureFailed(id, message);
 }
 
 /*!
@@ -214,27 +217,30 @@ void QDeclarativeCameraCapture::setMetadata(const QString &key, const QVariant &
 }
 
 /*!
-    \qmlsignal CameraCapture::onCaptureFailed(message)
-    \fn QDeclarativeCameraCapture::captureFailed(const QString &message)
+    \qmlsignal CameraCapture::onCaptureFailed(requestId, message)
+    \fn QDeclarativeCameraCapture::captureFailed(int requestId, const QString &message)
 
-    This handler is called when an error occurs during capture.  A descriptive message is available in \a message.
+    This handler is called when an error occurs during capture with \a requestId.
+    A descriptive message is available in \a message.
 */
 
 /*!
-    \qmlsignal CameraCapture::onImageCaptured(preview)
-    \fn QDeclarativeCameraCapture::imageCaptured(const QString &preview)
+    \qmlsignal CameraCapture::onImageCaptured(requestId, preview)
+    \fn QDeclarativeCameraCapture::imageCaptured(int requestId, const QString &preview)
 
-    This handler is called when an image has been captured but not yet saved to the filesystem.  The \a preview
+    This handler is called when an image with \a requestId has been captured
+    but not yet saved to the filesystem.  The \a preview
     parameter can be used as the URL supplied to an Image element.
 
     \sa onImageSaved
 */
 
 /*!
-    \qmlsignal CameraCapture::onImageSaved(path)
-    \fn QDeclarativeCameraCapture::imageSaved(const QString &path)
+    \qmlsignal CameraCapture::onImageSaved(requestId, path)
+    \fn QDeclarativeCameraCapture::imageSaved(int requestId, const QString &path)
 
-    This handler is called after the image has been written to the filesystem.  The \a path is a local file path, not a URL.
+    This handler is called after the image with \a requestId has been written to the filesystem.
+    The \a path is a local file path, not a URL.
 
     \sa onImageCaptured
 */
index 17881a4..3d80965 100644 (file)
@@ -86,8 +86,8 @@ public:
     QString errorString() const;
 
 public Q_SLOTS:
-    void capture();
-    void captureToLocation(const QString &location);
+    int capture();
+    int captureToLocation(const QString &location);
     void cancelCapture();
 
     void setResolution(const QSize &resolution);
@@ -96,11 +96,11 @@ public Q_SLOTS:
 Q_SIGNALS:
     void readyForCaptureChanged(bool);
 
-    void imageExposed();
-    void imageCaptured(const QString &preview);
-    void imageMetadataAvailable(const QString &key, const QVariant &value);
-    void imageSaved(const QString &path);
-    void captureFailed(const QString &message);
+    void imageExposed(int requestId);
+    void imageCaptured(int requestId, const QString &preview);
+    void imageMetadataAvailable(int requestId, const QString &key, const QVariant &value);
+    void imageSaved(int requestId, const QString &path);
+    void captureFailed(int requestId, const QString &message);
 
     void resolutionChanged(const QSize &);