From be6d80e57ad7bddedcceaa061027a04bbddc85bb Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Wed, 16 May 2012 13:25:38 +1000 Subject: [PATCH] Expose camera status to QML Camera element It's exposed as Camera.cameraStatus property. Change-Id: Id3b477266d3a666b7a2a61cd4579f0e3f873d3b8 Reviewed-by: Mithra Pattison Reviewed-by: Ling Hu --- src/imports/multimedia/qdeclarativecamera.cpp | 58 +++++++++++++++++++++++++++ src/imports/multimedia/qdeclarativecamera_p.h | 17 ++++++++ 2 files changed, 75 insertions(+) diff --git a/src/imports/multimedia/qdeclarativecamera.cpp b/src/imports/multimedia/qdeclarativecamera.cpp index 1e5aba2..3951f6b 100644 --- a/src/imports/multimedia/qdeclarativecamera.cpp +++ b/src/imports/multimedia/qdeclarativecamera.cpp @@ -186,6 +186,7 @@ QDeclarativeCamera::QDeclarativeCamera(QObject *parent) : connect(m_camera, SIGNAL(captureModeChanged(QCamera::CaptureModes)), this, SIGNAL(captureModeChanged())); connect(m_camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)), this, SIGNAL(lockStatusChanged())); connect(m_camera, SIGNAL(stateChanged(QCamera::State)), this, SLOT(_q_updateState(QCamera::State))); + connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SIGNAL(cameraStatusChanged())); connect(m_camera, SIGNAL(error(QCamera::Error)), this, SLOT(_q_error(QCamera::Error))); // Note we map availabilityError->availability @@ -323,6 +324,63 @@ QDeclarativeCamera::State QDeclarativeCamera::cameraState() const return m_componentComplete ? QDeclarativeCamera::State(m_camera->state()) : m_pendingState; } +/*! + \qmlproperty enumeration QtMultimedia5::Camera::cameraStatus + + The current status of the camera instance. + + \table + \header \li Value \li Description + \row \li ActiveStatus + \li The camera has been started and can produce data, + viewfinder displays video frames. + + Depending on backend, changing some camera settings like + capture mode, codecs or resolution in ActiveState may lead + to changing the camera status to LoadedStatus and StartingStatus while + the settings are applied and back to ActiveStatus when the camera is ready. + + \row \li StartingStatus + \li The camera is starting in result of state transition to Camera.ActiveState. + The camera service is not ready to capture yet. + + \row \li StoppingStatus + \li The camera is stopping in result of state transition from Camera.ActiveState + to Camera.LoadedState or Camera.UnloadedState. + + \row \li StandbyStatus + \li The camera is in the power saving standby mode. + The camera may enter standby mode after some time of inactivity + in the Camera.LoadedState state. + + \row \li LoadedStatus + \li The camera is loaded and ready to be configured. + This status indicates the camera device is opened and + it's possible to query for supported image and video capture settings, + like resolution, framerate and codecs. + + \row \li LoadingStatus + \li The camera device loading in result of state transition from + Camera.UnloadedState to Camera.LoadedState or Camera.ActiveState. + + \row \li UnloadingStatus + \li The camera device is unloading in result of state transition from + Camera.LoadedState or Camera.ActiveState to Camera.UnloadedState. + + \row \li UnloadedStatus + \li The initial camera status, with camera not loaded. + The camera capabilities including supported capture settings may be unknown. + + \row \li UnavailableStatus + \li The camera or camera backend is not available. + + \endtable +*/ +QDeclarativeCamera::Status QDeclarativeCamera::cameraStatus() const +{ + return QDeclarativeCamera::Status(m_camera->status()); +} + void QDeclarativeCamera::setCameraState(QDeclarativeCamera::State state) { if (!m_componentComplete) { diff --git a/src/imports/multimedia/qdeclarativecamera_p.h b/src/imports/multimedia/qdeclarativecamera_p.h index d6155dd..b2fe2ce 100644 --- a/src/imports/multimedia/qdeclarativecamera_p.h +++ b/src/imports/multimedia/qdeclarativecamera_p.h @@ -81,6 +81,7 @@ class QDeclarativeCamera : public QObject, public QQmlParserStatus Q_PROPERTY(CaptureMode captureMode READ captureMode WRITE setCaptureMode NOTIFY captureModeChanged) Q_PROPERTY(State cameraState READ cameraState WRITE setCameraState NOTIFY cameraStateChanged) + Q_PROPERTY(Status cameraStatus READ cameraStatus NOTIFY cameraStatusChanged) Q_PROPERTY(LockStatus lockStatus READ lockStatus NOTIFY lockStatusChanged) Q_PROPERTY(Error errorCode READ errorCode NOTIFY errorChanged) Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged) @@ -102,6 +103,7 @@ class QDeclarativeCamera : public QObject, public QQmlParserStatus Q_ENUMS(CaptureMode) Q_ENUMS(State) + Q_ENUMS(Status) Q_ENUMS(LockStatus) Q_ENUMS(Error) @@ -127,6 +129,19 @@ public: UnloadedState = QCamera::UnloadedState }; + enum Status + { + UnavailableStatus = QCamera::UnavailableStatus, + UnloadedStatus = QCamera::UnloadedStatus, + LoadingStatus = QCamera::LoadingStatus, + UnloadingStatus = QCamera::UnloadingStatus, + LoadedStatus = QCamera::LoadedStatus, + StandbyStatus = QCamera::StandbyStatus, + StartingStatus = QCamera::StartingStatus, + StoppingStatus = QCamera::StoppingStatus, + ActiveStatus = QCamera::ActiveStatus + }; + enum LockStatus { Unlocked = QCamera::Unlocked, @@ -220,6 +235,7 @@ public: CaptureMode captureMode() const; State cameraState() const; + Status cameraStatus() const; Error errorCode() const; QString errorString() const; @@ -254,6 +270,7 @@ Q_SIGNALS: void captureModeChanged(); void cameraStateChanged(QDeclarativeCamera::State); + void cameraStatusChanged(); void lockStatusChanged(); -- 2.7.4