Fix enums for QML camera types.

CameraExposure, CameraFlash and CameraFocus had signals and functions
using enum-type arguments declared in QDeclarativeCamera. This doesn't
work since an enum and a function using it both need to be declared in
the same class in order to work from QML.
The relevant enums have been duplicated (not moved, in order to
preserve QML source compatibility) from QDeclarativeCamera to
QDeclarativeCameraExposure, QDeclarativeCameraFlash and
QDeclarativeCameraFocus.

Change-Id: Ib307d7c6c9dbc59b1b82782913397160be38d4cd
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
Yoann Lopes
2014-03-13 18:07:12 +01:00
committed by The Qt Project
parent 904881d4a3
commit 4aeda4943e
6 changed files with 98 additions and 41 deletions

View File

@@ -353,12 +353,12 @@ void QDeclarativeCameraExposure::setAutoIsoSensitivity()
\endtable \endtable
*/ */
QDeclarativeCamera::ExposureMode QDeclarativeCameraExposure::exposureMode() const QDeclarativeCameraExposure::ExposureMode QDeclarativeCameraExposure::exposureMode() const
{ {
return QDeclarativeCamera::ExposureMode(m_exposure->exposureMode()); return QDeclarativeCameraExposure::ExposureMode(m_exposure->exposureMode());
} }
void QDeclarativeCameraExposure::setExposureMode(QDeclarativeCamera::ExposureMode mode) void QDeclarativeCameraExposure::setExposureMode(QDeclarativeCameraExposure::ExposureMode mode)
{ {
if (exposureMode() != mode) { if (exposureMode() != mode) {
m_exposure->setExposureMode(QCameraExposure::ExposureMode(mode)); m_exposure->setExposureMode(QCameraExposure::ExposureMode(mode));
@@ -413,14 +413,14 @@ void QDeclarativeCameraExposure::setSpotMeteringPoint(const QPointF &point)
\row \li Camera.MeteringSpot \li A specific location (\l spotMeteringPoint) is used to measure exposure. \row \li Camera.MeteringSpot \li A specific location (\l spotMeteringPoint) is used to measure exposure.
\endtable \endtable
*/ */
QDeclarativeCamera::MeteringMode QDeclarativeCameraExposure::meteringMode() const QDeclarativeCameraExposure::MeteringMode QDeclarativeCameraExposure::meteringMode() const
{ {
return QDeclarativeCamera::MeteringMode(m_exposure->meteringMode()); return QDeclarativeCameraExposure::MeteringMode(m_exposure->meteringMode());
} }
void QDeclarativeCameraExposure::setMeteringMode(QDeclarativeCamera::MeteringMode mode) void QDeclarativeCameraExposure::setMeteringMode(QDeclarativeCameraExposure::MeteringMode mode)
{ {
QDeclarativeCamera::MeteringMode oldMode = meteringMode(); QDeclarativeCameraExposure::MeteringMode oldMode = meteringMode();
m_exposure->setMeteringMode(QCameraExposure::MeteringMode(mode)); m_exposure->setMeteringMode(QCameraExposure::MeteringMode(mode));
if (oldMode != meteringMode()) if (oldMode != meteringMode())
emit meteringModeChanged(meteringMode()); emit meteringModeChanged(meteringMode());

View File

@@ -74,15 +74,38 @@ class QDeclarativeCameraExposure : public QObject
Q_PROPERTY(qreal manualAperture READ manualAperture WRITE setManualAperture NOTIFY manualApertureChanged) Q_PROPERTY(qreal manualAperture READ manualAperture WRITE setManualAperture NOTIFY manualApertureChanged)
Q_PROPERTY(qreal manualIso READ manualIsoSensitivity WRITE setManualIsoSensitivity NOTIFY manualIsoSensitivityChanged) Q_PROPERTY(qreal manualIso READ manualIsoSensitivity WRITE setManualIsoSensitivity NOTIFY manualIsoSensitivityChanged)
Q_PROPERTY(QDeclarativeCamera::ExposureMode exposureMode READ exposureMode WRITE setExposureMode NOTIFY exposureModeChanged) Q_PROPERTY(ExposureMode exposureMode READ exposureMode WRITE setExposureMode NOTIFY exposureModeChanged)
Q_PROPERTY(QPointF spotMeteringPoint READ spotMeteringPoint WRITE setSpotMeteringPoint NOTIFY spotMeteringPointChanged) Q_PROPERTY(QPointF spotMeteringPoint READ spotMeteringPoint WRITE setSpotMeteringPoint NOTIFY spotMeteringPointChanged)
Q_PROPERTY(QDeclarativeCamera::MeteringMode meteringMode READ meteringMode WRITE setMeteringMode NOTIFY meteringModeChanged) Q_PROPERTY(MeteringMode meteringMode READ meteringMode WRITE setMeteringMode NOTIFY meteringModeChanged)
Q_ENUMS(ExposureMode)
Q_ENUMS(MeteringMode)
public: public:
enum ExposureMode {
ExposureAuto = QCameraExposure::ExposureAuto,
ExposureManual = QCameraExposure::ExposureManual,
ExposurePortrait = QCameraExposure::ExposurePortrait,
ExposureNight = QCameraExposure::ExposureNight,
ExposureBacklight = QCameraExposure::ExposureBacklight,
ExposureSpotlight = QCameraExposure::ExposureSpotlight,
ExposureSports = QCameraExposure::ExposureSports,
ExposureSnow = QCameraExposure::ExposureSnow,
ExposureBeach = QCameraExposure::ExposureBeach,
ExposureLargeAperture = QCameraExposure::ExposureLargeAperture,
ExposureSmallAperture = QCameraExposure::ExposureSmallAperture,
ExposureModeVendor = QCameraExposure::ExposureModeVendor
};
enum MeteringMode {
MeteringMatrix = QCameraExposure::MeteringMatrix,
MeteringAverage = QCameraExposure::MeteringAverage,
MeteringSpot = QCameraExposure::MeteringSpot
};
~QDeclarativeCameraExposure(); ~QDeclarativeCameraExposure();
QDeclarativeCamera::ExposureMode exposureMode() const; ExposureMode exposureMode() const;
qreal exposureCompensation() const; qreal exposureCompensation() const;
int isoSensitivity() const; int isoSensitivity() const;
@@ -96,11 +119,11 @@ public:
QPointF spotMeteringPoint() const; QPointF spotMeteringPoint() const;
void setSpotMeteringPoint(const QPointF &point); void setSpotMeteringPoint(const QPointF &point);
QDeclarativeCamera::MeteringMode meteringMode() const; MeteringMode meteringMode() const;
void setMeteringMode(QDeclarativeCamera::MeteringMode mode); void setMeteringMode(MeteringMode mode);
public Q_SLOTS: public Q_SLOTS:
void setExposureMode(QDeclarativeCamera::ExposureMode); void setExposureMode(ExposureMode);
void setExposureCompensation(qreal ev); void setExposureCompensation(qreal ev);
void setManualAperture(qreal); void setManualAperture(qreal);
@@ -121,9 +144,9 @@ Q_SIGNALS:
void manualShutterSpeedChanged(qreal); void manualShutterSpeedChanged(qreal);
void exposureCompensationChanged(qreal); void exposureCompensationChanged(qreal);
void exposureModeChanged(QDeclarativeCamera::ExposureMode); void exposureModeChanged(ExposureMode);
void meteringModeChanged(QDeclarativeCamera::MeteringMode); void meteringModeChanged(MeteringMode);
void spotMeteringPointChanged(QPointF); void spotMeteringPointChanged(QPointF);
private: private:

View File

@@ -131,14 +131,14 @@ bool QDeclarativeCameraFlash::isFlashReady() const
\endtable \endtable
*/ */
int QDeclarativeCameraFlash::flashMode() const QDeclarativeCameraFlash::FlashMode QDeclarativeCameraFlash::flashMode() const
{ {
return m_exposure->flashMode(); return QDeclarativeCameraFlash::FlashMode(int(m_exposure->flashMode()));
} }
void QDeclarativeCameraFlash::setFlashMode(int mode) void QDeclarativeCameraFlash::setFlashMode(QDeclarativeCameraFlash::FlashMode mode)
{ {
if (m_exposure->flashMode() != mode) { if (flashMode() != mode) {
m_exposure->setFlashMode(QCameraExposure::FlashModes(mode)); m_exposure->setFlashMode(QCameraExposure::FlashModes(mode));
emit flashModeChanged(mode); emit flashModeChanged(mode);
} }

View File

@@ -64,19 +64,34 @@ class QDeclarativeCameraFlash : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool ready READ isFlashReady NOTIFY flashReady) Q_PROPERTY(bool ready READ isFlashReady NOTIFY flashReady)
Q_PROPERTY(int mode READ flashMode WRITE setFlashMode NOTIFY flashModeChanged) Q_PROPERTY(FlashMode mode READ flashMode WRITE setFlashMode NOTIFY flashModeChanged)
Q_ENUMS(FlashMode)
public: public:
enum FlashMode {
FlashAuto = QCameraExposure::FlashAuto,
FlashOff = QCameraExposure::FlashOff,
FlashOn = QCameraExposure::FlashOn,
FlashRedEyeReduction = QCameraExposure::FlashRedEyeReduction,
FlashFill = QCameraExposure::FlashFill,
FlashTorch = QCameraExposure::FlashTorch,
FlashVideoLight = QCameraExposure::FlashVideoLight,
FlashSlowSyncFrontCurtain = QCameraExposure::FlashSlowSyncFrontCurtain,
FlashSlowSyncRearCurtain = QCameraExposure::FlashSlowSyncRearCurtain,
FlashManual = QCameraExposure::FlashManual
};
~QDeclarativeCameraFlash(); ~QDeclarativeCameraFlash();
int flashMode() const; FlashMode flashMode() const;
bool isFlashReady() const; bool isFlashReady() const;
public Q_SLOTS: public Q_SLOTS:
void setFlashMode(int); void setFlashMode(FlashMode);
Q_SIGNALS: Q_SIGNALS:
void flashReady(bool status); void flashReady(bool status);
void flashModeChanged(int); void flashModeChanged(FlashMode);
private: private:
friend class QDeclarativeCamera; friend class QDeclarativeCamera;

View File

@@ -161,9 +161,9 @@ QDeclarativeCameraFocus::~QDeclarativeCameraFocus()
and \l focusZones property provide information and control and \l focusZones property provide information and control
over how automatic focusing is performed. over how automatic focusing is performed.
*/ */
QDeclarativeCamera::FocusMode QDeclarativeCameraFocus::focusMode() const QDeclarativeCameraFocus::FocusMode QDeclarativeCameraFocus::focusMode() const
{ {
return QDeclarativeCamera::FocusMode(int(m_focus->focusMode())); return QDeclarativeCameraFocus::FocusMode(int(m_focus->focusMode()));
} }
/*! /*!
@@ -172,12 +172,12 @@ QDeclarativeCamera::FocusMode QDeclarativeCameraFocus::focusMode() const
Returns true if the supplied \a mode is a supported focus mode, and Returns true if the supplied \a mode is a supported focus mode, and
false otherwise. false otherwise.
*/ */
bool QDeclarativeCameraFocus::isFocusModeSupported(QDeclarativeCamera::FocusMode mode) const bool QDeclarativeCameraFocus::isFocusModeSupported(QDeclarativeCameraFocus::FocusMode mode) const
{ {
return m_focus->isFocusModeSupported(QCameraFocus::FocusModes(int(mode))); return m_focus->isFocusModeSupported(QCameraFocus::FocusModes(int(mode)));
} }
void QDeclarativeCameraFocus::setFocusMode(QDeclarativeCamera::FocusMode mode) void QDeclarativeCameraFocus::setFocusMode(QDeclarativeCameraFocus::FocusMode mode)
{ {
if (mode != focusMode()) { if (mode != focusMode()) {
m_focus->setFocusMode(QCameraFocus::FocusModes(int(mode))); m_focus->setFocusMode(QCameraFocus::FocusModes(int(mode)));
@@ -221,12 +221,12 @@ void QDeclarativeCameraFocus::setFocusMode(QDeclarativeCamera::FocusMode mode)
\li Focus to the custom point, defined by the customFocusPoint property. \li Focus to the custom point, defined by the customFocusPoint property.
\endtable \endtable
*/ */
QDeclarativeCamera::FocusPointMode QDeclarativeCameraFocus::focusPointMode() const QDeclarativeCameraFocus::FocusPointMode QDeclarativeCameraFocus::focusPointMode() const
{ {
return QDeclarativeCamera::FocusPointMode(m_focus->focusPointMode()); return QDeclarativeCameraFocus::FocusPointMode(m_focus->focusPointMode());
} }
void QDeclarativeCameraFocus::setFocusPointMode(QDeclarativeCamera::FocusPointMode mode) void QDeclarativeCameraFocus::setFocusPointMode(QDeclarativeCameraFocus::FocusPointMode mode)
{ {
if (mode != focusPointMode()) { if (mode != focusPointMode()) {
m_focus->setFocusPointMode(QCameraFocus::FocusPointMode(mode)); m_focus->setFocusPointMode(QCameraFocus::FocusPointMode(mode));
@@ -240,7 +240,7 @@ void QDeclarativeCameraFocus::setFocusPointMode(QDeclarativeCamera::FocusPointMo
Returns true if the supplied \a mode is a supported focus point mode, and Returns true if the supplied \a mode is a supported focus point mode, and
false otherwise. false otherwise.
*/ */
bool QDeclarativeCameraFocus::isFocusPointModeSupported(QDeclarativeCamera::FocusPointMode mode) const bool QDeclarativeCameraFocus::isFocusPointModeSupported(QDeclarativeCameraFocus::FocusPointMode mode) const
{ {
return m_focus->isFocusPointModeSupported(QCameraFocus::FocusPointMode(mode)); return m_focus->isFocusPointModeSupported(QCameraFocus::FocusPointMode(mode));
} }

View File

@@ -66,30 +66,49 @@ class QDeclarativeCamera;
class QDeclarativeCameraFocus : public QObject class QDeclarativeCameraFocus : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QDeclarativeCamera::FocusMode focusMode READ focusMode WRITE setFocusMode NOTIFY focusModeChanged) Q_PROPERTY(FocusMode focusMode READ focusMode WRITE setFocusMode NOTIFY focusModeChanged)
Q_PROPERTY(QDeclarativeCamera::FocusPointMode focusPointMode READ focusPointMode WRITE setFocusPointMode NOTIFY focusPointModeChanged) Q_PROPERTY(FocusPointMode focusPointMode READ focusPointMode WRITE setFocusPointMode NOTIFY focusPointModeChanged)
Q_PROPERTY(QPointF customFocusPoint READ customFocusPoint WRITE setCustomFocusPoint NOTIFY customFocusPointChanged) Q_PROPERTY(QPointF customFocusPoint READ customFocusPoint WRITE setCustomFocusPoint NOTIFY customFocusPointChanged)
Q_PROPERTY(QObject *focusZones READ focusZones CONSTANT) Q_PROPERTY(QObject *focusZones READ focusZones CONSTANT)
Q_ENUMS(FocusMode)
Q_ENUMS(FocusPointMode)
public: public:
enum FocusMode {
FocusManual = QCameraFocus::ManualFocus,
FocusHyperfocal = QCameraFocus::HyperfocalFocus,
FocusInfinity = QCameraFocus::InfinityFocus,
FocusAuto = QCameraFocus::AutoFocus,
FocusContinuous = QCameraFocus::ContinuousFocus,
FocusMacro = QCameraFocus::MacroFocus
};
enum FocusPointMode {
FocusPointAuto = QCameraFocus::FocusPointAuto,
FocusPointCenter = QCameraFocus::FocusPointCenter,
FocusPointFaceDetection = QCameraFocus::FocusPointFaceDetection,
FocusPointCustom = QCameraFocus::FocusPointCustom
};
~QDeclarativeCameraFocus(); ~QDeclarativeCameraFocus();
QDeclarativeCamera::FocusMode focusMode() const; FocusMode focusMode() const;
QDeclarativeCamera::FocusPointMode focusPointMode() const; FocusPointMode focusPointMode() const;
QPointF customFocusPoint() const; QPointF customFocusPoint() const;
QAbstractListModel *focusZones() const; QAbstractListModel *focusZones() const;
Q_INVOKABLE bool isFocusModeSupported(QDeclarativeCamera::FocusMode mode) const; Q_INVOKABLE bool isFocusModeSupported(FocusMode mode) const;
Q_INVOKABLE bool isFocusPointModeSupported(QDeclarativeCamera::FocusPointMode mode) const; Q_INVOKABLE bool isFocusPointModeSupported(FocusPointMode mode) const;
public Q_SLOTS: public Q_SLOTS:
void setFocusMode(QDeclarativeCamera::FocusMode); void setFocusMode(FocusMode);
void setFocusPointMode(QDeclarativeCamera::FocusPointMode mode); void setFocusPointMode(FocusPointMode mode);
void setCustomFocusPoint(const QPointF &point); void setCustomFocusPoint(const QPointF &point);
Q_SIGNALS: Q_SIGNALS:
void focusModeChanged(QDeclarativeCamera::FocusMode); void focusModeChanged(FocusMode);
void focusPointModeChanged(QDeclarativeCamera::FocusPointMode); void focusPointModeChanged(FocusPointMode);
void customFocusPointChanged(const QPointF &); void customFocusPointChanged(const QPointF &);
private Q_SLOTS: private Q_SLOTS: