From 6026ebd7af864912aa37faa3c15d43195c650d82 Mon Sep 17 00:00:00 2001 From: Jochen Seemann Date: Tue, 30 Aug 2016 22:43:28 +0200 Subject: add property supportedExposureModes to CameraExposure Task-number: QTBUG-45336 Change-Id: I9b4f3271f7f56b88f2484f56dd1d37e2e97f5118 Reviewed-by: Christian Stromme --- src/imports/multimedia/multimedia.cpp | 2 ++ .../multimedia/qdeclarativecameraexposure.cpp | 29 ++++++++++++++++++++++ .../multimedia/qdeclarativecameraexposure_p.h | 3 +++ 3 files changed, 34 insertions(+) (limited to 'src/imports') diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp index 96994b9bf..28829adfb 100644 --- a/src/imports/multimedia/multimedia.cpp +++ b/src/imports/multimedia/multimedia.cpp @@ -156,6 +156,8 @@ public: qmlRegisterType(uri, 5, 11, "MediaPlayer"); qmlRegisterUncreatableType(uri, 5, 11, "CameraFocus", trUtf8("CameraFocus is provided by Camera")); + qmlRegisterUncreatableType(uri, 5, 11, "CameraExposure", + trUtf8("CameraExposure is provided by Camera")); qmlRegisterType(); qmlRegisterType(); diff --git a/src/imports/multimedia/qdeclarativecameraexposure.cpp b/src/imports/multimedia/qdeclarativecameraexposure.cpp index 92972e512..af8c6acf6 100644 --- a/src/imports/multimedia/qdeclarativecameraexposure.cpp +++ b/src/imports/multimedia/qdeclarativecameraexposure.cpp @@ -107,6 +107,14 @@ QDeclarativeCameraExposure::QDeclarativeCameraExposure(QCamera *camera, QObject connect(m_exposure, SIGNAL(shutterSpeedChanged(qreal)), this, SIGNAL(shutterSpeedChanged(qreal))); connect(m_exposure, SIGNAL(exposureCompensationChanged(qreal)), this, SIGNAL(exposureCompensationChanged(qreal))); + connect(camera, &QCamera::statusChanged, [this](QCamera::Status status) { + if (status != QCamera::UnloadedStatus && status != QCamera::LoadedStatus + && status != QCamera::ActiveStatus) { + return; + } + + emit supportedExposureModesChanged(); + }); } QDeclarativeCameraExposure::~QDeclarativeCameraExposure() @@ -369,6 +377,27 @@ void QDeclarativeCameraExposure::setExposureMode(QDeclarativeCameraExposure::Exp emit exposureModeChanged(exposureMode()); } } + +/*! + \qmlproperty list QtMultimedia::CameraExposure::supportedExposureModes + + This property holds the supported exposure modes of the camera. + + \since 5.11 + \sa exposureMode + */ +QVariantList QDeclarativeCameraExposure::supportedExposureModes() const +{ + QVariantList supportedModes; + + for (int i = int(ExposureAuto); i <= int(QCameraExposure::ExposureBarcode); ++i) { + if (m_exposure->isExposureModeSupported((QCameraExposure::ExposureMode) i)) + supportedModes.append(QVariant(i)); + } + + return supportedModes; +} + /*! \property QDeclarativeCameraExposure::spotMeteringPoint diff --git a/src/imports/multimedia/qdeclarativecameraexposure_p.h b/src/imports/multimedia/qdeclarativecameraexposure_p.h index 806cb775e..ef99b1ce9 100644 --- a/src/imports/multimedia/qdeclarativecameraexposure_p.h +++ b/src/imports/multimedia/qdeclarativecameraexposure_p.h @@ -73,6 +73,7 @@ class QDeclarativeCameraExposure : public QObject Q_PROPERTY(qreal manualIso READ manualIsoSensitivity WRITE setManualIsoSensitivity NOTIFY manualIsoSensitivityChanged) Q_PROPERTY(ExposureMode exposureMode READ exposureMode WRITE setExposureMode NOTIFY exposureModeChanged) + Q_PROPERTY(QVariantList supportedExposureModes READ supportedExposureModes NOTIFY supportedExposureModesChanged REVISION 1) Q_PROPERTY(QPointF spotMeteringPoint READ spotMeteringPoint WRITE setSpotMeteringPoint NOTIFY spotMeteringPointChanged) Q_PROPERTY(MeteringMode meteringMode READ meteringMode WRITE setMeteringMode NOTIFY meteringModeChanged) @@ -114,6 +115,7 @@ public: ~QDeclarativeCameraExposure(); ExposureMode exposureMode() const; + QVariantList supportedExposureModes() const; qreal exposureCompensation() const; int isoSensitivity() const; @@ -153,6 +155,7 @@ Q_SIGNALS: void exposureCompensationChanged(qreal); void exposureModeChanged(ExposureMode); + void supportedExposureModesChanged(); void meteringModeChanged(MeteringMode); void spotMeteringPointChanged(QPointF); -- cgit v1.2.3