Expose capture request id in the declarative camera.

It's useful to associate imageCaptured/Saved signals data with
capture requests.

Change-Id: I3e98c4a194403bd338a1b5313d8736b4baf79961
Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
Dmytro Poplavskiy
2012-02-07 12:52:11 +10:00
committed by Qt by Nokia
parent 8b1f11b370
commit 00d1e2f65e
2 changed files with 34 additions and 28 deletions

View File

@@ -97,10 +97,13 @@ bool QDeclarativeCameraCapture::isReadyForCapture() const
Start image capture. The \l onImageCaptured() and \l onImageSaved() signals will Start image capture. The \l onImageCaptured() and \l onImageSaved() signals will
be emitted when the capture is complete. 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 Start image capture to specified \a location. The \l onImageCaptured() and \l onImageSaved() signals will
be emitted when the capture is complete. 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 \qmlproperty string CameraCapture::capturedImagePath
\property QDeclarativeCameraCapture::capturedImagePath \property QDeclarativeCameraCapture::capturedImagePath
The path to the captured image. The path to the last captured image.
*/ */
QString QDeclarativeCameraCapture::capturedImagePath() const QString QDeclarativeCameraCapture::capturedImagePath() const
{ {
@@ -143,29 +149,26 @@ void QDeclarativeCameraCapture::_q_imageCaptured(int id, const QImage &preview)
QString previewId = QString("preview_%1").arg(id); QString previewId = QString("preview_%1").arg(id);
QDeclarativeCameraPreviewProvider::registerPreview(previewId, preview); 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) void QDeclarativeCameraCapture::_q_imageSaved(int id, const QString &fileName)
{ {
Q_UNUSED(id);
m_capturedImagePath = fileName; m_capturedImagePath = fileName;
emit imageSaved(fileName); emit imageSaved(id, fileName);
} }
void QDeclarativeCameraCapture::_q_imageMetadataAvailable(int id, const QString &key, const QVariant &value) void QDeclarativeCameraCapture::_q_imageMetadataAvailable(int id, const QString &key, const QVariant &value)
{ {
Q_UNUSED(id); emit imageMetadataAvailable(id, key, value);
emit imageMetadataAvailable(key, value);
} }
void QDeclarativeCameraCapture::_q_captureFailed(int id, QCameraImageCapture::Error error, const QString &message) void QDeclarativeCameraCapture::_q_captureFailed(int id, QCameraImageCapture::Error error, const QString &message)
{ {
Q_UNUSED(id);
Q_UNUSED(error); Q_UNUSED(error);
qWarning() << "QCameraImageCapture error:" << message; 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) \qmlsignal CameraCapture::onCaptureFailed(requestId, message)
\fn QDeclarativeCameraCapture::captureFailed(const QString &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) \qmlsignal CameraCapture::onImageCaptured(requestId, preview)
\fn QDeclarativeCameraCapture::imageCaptured(const QString &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. parameter can be used as the URL supplied to an Image element.
\sa onImageSaved \sa onImageSaved
*/ */
/*! /*!
\qmlsignal CameraCapture::onImageSaved(path) \qmlsignal CameraCapture::onImageSaved(requestId, path)
\fn QDeclarativeCameraCapture::imageSaved(const QString &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 \sa onImageCaptured
*/ */

View File

@@ -86,8 +86,8 @@ public:
QString errorString() const; QString errorString() const;
public Q_SLOTS: public Q_SLOTS:
void capture(); int capture();
void captureToLocation(const QString &location); int captureToLocation(const QString &location);
void cancelCapture(); void cancelCapture();
void setResolution(const QSize &resolution); void setResolution(const QSize &resolution);
@@ -96,11 +96,11 @@ public Q_SLOTS:
Q_SIGNALS: Q_SIGNALS:
void readyForCaptureChanged(bool); void readyForCaptureChanged(bool);
void imageExposed(); void imageExposed(int requestId);
void imageCaptured(const QString &preview); void imageCaptured(int requestId, const QString &preview);
void imageMetadataAvailable(const QString &key, const QVariant &value); void imageMetadataAvailable(int requestId, const QString &key, const QVariant &value);
void imageSaved(const QString &path); void imageSaved(int requestId, const QString &path);
void captureFailed(const QString &message); void captureFailed(int requestId, const QString &message);
void resolutionChanged(const QSize &); void resolutionChanged(const QSize &);