diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-01-05 12:03:12 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-01-22 06:59:57 +0000 |
commit | 856c37844b831b7786e05efd7bbc1edc5c78b564 (patch) | |
tree | 0c4b9a34c1ea0f6641c9d26159fae6fcc058e8c0 | |
parent | 9d1defda0d278cbec775087edc26fc72ea72b0ba (diff) |
Clean up QCamera error enum
We only really need two error values, the others don't
make a whole lot of sense.
Change-Id: I8f798b1ed930ea876442390776528a32b3532e30
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r-- | src/imports/multimedia/plugins.qmltypes | 10 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativecamera.cpp | 6 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativecamera_p.h | 5 | ||||
-rw-r--r-- | src/multimedia/camera/qcamera.cpp | 9 | ||||
-rw-r--r-- | src/multimedia/camera/qcamera.h | 5 | ||||
-rw-r--r-- | src/plugins/avfoundation/camera/avfcameracontrol.mm | 8 | ||||
-rw-r--r-- | src/plugins/gstreamer/mediacapture/qgstreamercameracontrol.cpp | 2 | ||||
-rw-r--r-- | tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp | 7 | ||||
-rw-r--r-- | tests/auto/unit/qcamera/tst_qcamera.cpp | 24 | ||||
-rw-r--r-- | tests/auto/unit/qmultimedia_common/mockcameracontrol.h | 3 |
10 files changed, 23 insertions, 56 deletions
diff --git a/src/imports/multimedia/plugins.qmltypes b/src/imports/multimedia/plugins.qmltypes index 3e3298969..2450865d5 100644 --- a/src/imports/multimedia/plugins.qmltypes +++ b/src/imports/multimedia/plugins.qmltypes @@ -342,10 +342,7 @@ Module { name: "Error" values: { "NoError": 0, - "CameraError": 1, - "InvalidRequestError": 2, - "ServiceMissingError": 3, - "NotSupportedFeatureError": 4 + "CameraError": 1 } } Enum { @@ -626,10 +623,7 @@ Module { name: "Error" values: { "NoError": 0, - "CameraError": 1, - "InvalidRequestError": 2, - "ServiceMissingError": 3, - "NotSupportedFeatureError": 4 + "CameraError": 1 } } Enum { diff --git a/src/imports/multimedia/qdeclarativecamera.cpp b/src/imports/multimedia/qdeclarativecamera.cpp index f36c0c6af..769c0960f 100644 --- a/src/imports/multimedia/qdeclarativecamera.cpp +++ b/src/imports/multimedia/qdeclarativecamera.cpp @@ -738,12 +738,6 @@ void QDeclarativeCamera::setDigitalZoom(qreal value) No errors have occurred. \value Camera.CameraError An error has occurred. - \value Camera.InvalidRequestError - System resources do not support the requested functionality. - \value Camera.ServiceMissingError - No camera service available. - \value Camera.NotSupportedFeatureError - The feature is not supported. \sa errorOccurred, errorString */ diff --git a/src/imports/multimedia/qdeclarativecamera_p.h b/src/imports/multimedia/qdeclarativecamera_p.h index 62454aeb6..f2cb38b51 100644 --- a/src/imports/multimedia/qdeclarativecamera_p.h +++ b/src/imports/multimedia/qdeclarativecamera_p.h @@ -164,10 +164,7 @@ public: enum Error { NoError = QCamera::NoError, - CameraError = QCamera::CameraError, - InvalidRequestError = QCamera::InvalidRequestError, - ServiceMissingError = QCamera::ServiceMissingError, - NotSupportedFeatureError = QCamera::NotSupportedFeatureError + CameraError = QCamera::CameraError }; enum FlashMode { diff --git a/src/multimedia/camera/qcamera.cpp b/src/multimedia/camera/qcamera.cpp index a4af35510..6efe844d8 100644 --- a/src/multimedia/camera/qcamera.cpp +++ b/src/multimedia/camera/qcamera.cpp @@ -113,7 +113,7 @@ void QCameraPrivate::setState(QCamera::State newState) unsetError(); if (!control) { - _q_error(QCamera::ServiceMissingError, QCamera::tr("The camera service is missing")); + _q_error(QCamera::CameraError, QCamera::tr("The camera service is missing")); return; } @@ -196,7 +196,7 @@ void QCameraPrivate::initControls() control = nullptr; deviceControl = nullptr; - error = QCamera::ServiceMissingError; + error = QCamera::CameraError; errorString = QCamera::tr("The camera service is missing"); } } @@ -340,7 +340,7 @@ QCamera::QCamera(const QByteArray& deviceName, QObject *parent): } d->control = nullptr; d->deviceControl = nullptr; - d->error = QCamera::ServiceMissingError; + d->error = QCamera::CameraError; d->errorString = QCamera::tr("The camera service is missing"); } } @@ -1139,9 +1139,6 @@ void QCamera::unlock() \value NoError No errors have occurred. \value CameraError An error has occurred. - \value InvalidRequestError System resource doesn't support requested functionality. - \value ServiceMissingError No camera service available. - \value NotSupportedFeatureError The feature is not supported. */ /*! diff --git a/src/multimedia/camera/qcamera.h b/src/multimedia/camera/qcamera.h index b90cb7ec9..13e88b576 100644 --- a/src/multimedia/camera/qcamera.h +++ b/src/multimedia/camera/qcamera.h @@ -124,10 +124,7 @@ public: enum Error { NoError, - CameraError, - InvalidRequestError, - ServiceMissingError, - NotSupportedFeatureError + CameraError }; enum LockStatus diff --git a/src/plugins/avfoundation/camera/avfcameracontrol.mm b/src/plugins/avfoundation/camera/avfcameracontrol.mm index b36e4935d..a6bc91995 100644 --- a/src/plugins/avfoundation/camera/avfcameracontrol.mm +++ b/src/plugins/avfoundation/camera/avfcameracontrol.mm @@ -112,19 +112,13 @@ void AVFCameraControl::setCaptureMode(QCamera::CaptureModes mode) if (m_captureMode == mode) return; - if (!isCaptureModeSupported(mode)) { - Q_EMIT error(QCamera::NotSupportedFeatureError, tr("Requested capture mode is not supported")); - return; - } - m_captureMode = mode; Q_EMIT captureModeChanged(mode); } bool AVFCameraControl::isCaptureModeSupported(QCamera::CaptureModes mode) const { - //all the capture modes are supported, including QCamera::CaptureStillImage | QCamera::CaptureVideo - return (mode & (QCamera::CaptureStillImage | QCamera::CaptureVideo)) == mode; + return true; } bool AVFCameraControl::canChangeProperty(QCameraControl::PropertyChangeType changeType, QCamera::Status status) const diff --git a/src/plugins/gstreamer/mediacapture/qgstreamercameracontrol.cpp b/src/plugins/gstreamer/mediacapture/qgstreamercameracontrol.cpp index 601a09e31..5afbdd7cf 100644 --- a/src/plugins/gstreamer/mediacapture/qgstreamercameracontrol.cpp +++ b/src/plugins/gstreamer/mediacapture/qgstreamercameracontrol.cpp @@ -122,8 +122,6 @@ void QGstreamerCameraControl::setState(QCamera::State state) #endif } break; - default: - emit error(QCamera::NotSupportedFeatureError, tr("State not supported.")); } updateStatus(); diff --git a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp index c52f574b7..8813858ab 100644 --- a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp +++ b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp @@ -123,8 +123,7 @@ void tst_QCameraBackend::testCtorWithDevice() //loading non existing camera should fail camera = new QCamera(QUuid::createUuid().toByteArray()); - QCOMPARE(camera->error(), QCamera::ServiceMissingError); - + QCOMPARE(camera->error(), QCamera::CameraError); delete camera; } @@ -148,14 +147,14 @@ void tst_QCameraBackend::testCtorWithCameraInfo() { // loading an invalid CameraInfo should fail QCamera *camera = new QCamera(QCameraInfo()); - QCOMPARE(camera->error(), QCamera::ServiceMissingError); + QCOMPARE(camera->error(), QCamera::CameraError); QVERIFY(QCameraInfo(*camera).isNull()); delete camera; } { // loading non existing camera should fail QCamera camera(QCameraInfo(QUuid::createUuid().toByteArray())); - QCOMPARE(camera.error(), QCamera::ServiceMissingError); + QCOMPARE(camera.error(), QCamera::CameraError); QVERIFY(QCameraInfo(camera).isNull()); } } diff --git a/tests/auto/unit/qcamera/tst_qcamera.cpp b/tests/auto/unit/qcamera/tst_qcamera.cpp index 7e7b3c2d5..f2b55e9f7 100644 --- a/tests/auto/unit/qcamera/tst_qcamera.cpp +++ b/tests/auto/unit/qcamera/tst_qcamera.cpp @@ -1783,7 +1783,7 @@ void tst_QCamera::testQCameraIsNotAvailable() provider->service = nullptr; QCamera camera("random"); - QCOMPARE(camera.error(), QCamera::ServiceMissingError); + QCOMPARE(camera.error(), QCamera::CameraError); QVERIFY(!camera.isAvailable()); QCOMPARE(camera.availability(), QMultimedia::ServiceMissing); } @@ -1961,18 +1961,18 @@ void tst_QCamera::testErrorSignal() spyError.clear(); /* Set the QCameraControl error and verify if the signal is emitted correctly in QCamera */ - service.mockControl->setError(QCamera::InvalidRequestError,QString("InvalidRequestError Error")); + service.mockControl->setError(QCamera::CameraError,QString("InvalidRequestError Error")); QVERIFY(spyError.count() == 1); err = qvariant_cast<QCamera::Error >(spyError.at(0).at(0)); - QVERIFY(err == QCamera::InvalidRequestError); + QVERIFY(err == QCamera::CameraError); spyError.clear(); /* Set the QCameraControl error and verify if the signal is emitted correctly in QCamera */ - service.mockControl->setError(QCamera::NotSupportedFeatureError,QString("NotSupportedFeatureError Error")); + service.mockControl->setError(QCamera::CameraError,QString("NotSupportedFeatureError Error")); QVERIFY(spyError.count() == 1); err = qvariant_cast<QCamera::Error >(spyError.at(0).at(0)); - QVERIFY(err == QCamera::NotSupportedFeatureError); + QVERIFY(err == QCamera::CameraError); } @@ -1989,12 +1989,12 @@ void tst_QCamera::testError() QVERIFY(camera.error() == QCamera::CameraError); /* Set the QCameraControl error and verify if it is set correctly in QCamera */ - service.mockControl->setError(QCamera::InvalidRequestError,QString("InvalidRequestError Error")); - QVERIFY(camera.error() == QCamera::InvalidRequestError); + service.mockControl->setError(QCamera::CameraError,QString("InvalidRequestError Error")); + QVERIFY(camera.error() == QCamera::CameraError); /* Set the QCameraControl error and verify if it is set correctly in QCamera */ - service.mockControl->setError(QCamera::NotSupportedFeatureError,QString("NotSupportedFeatureError Error")); - QVERIFY(camera.error() == QCamera::NotSupportedFeatureError); + service.mockControl->setError(QCamera::CameraError,QString("CameraError Error")); + QVERIFY(camera.error() == QCamera::CameraError); } @@ -2011,12 +2011,12 @@ void tst_QCamera::testErrorString() QVERIFY(camera.errorString() == QString("Camera Error")); /* Set the QCameraControl error and verify if it is set correctly in QCamera */ - service.mockControl->setError(QCamera::InvalidRequestError,QString("InvalidRequestError Error")); + service.mockControl->setError(QCamera::CameraError,QString("InvalidRequestError Error")); QVERIFY(camera.errorString() == QString("InvalidRequestError Error")); /* Set the QCameraControl error and verify if it is set correctly in QCamera */ - service.mockControl->setError(QCamera::NotSupportedFeatureError,QString("NotSupportedFeatureError Error")); - QVERIFY(camera.errorString() == QString("NotSupportedFeatureError Error")); + service.mockControl->setError(QCamera::CameraError,QString("CameraError Error")); + QVERIFY(camera.errorString() == QString("CameraError Error")); } /* Test case for verifying Status of QCamera. */ diff --git a/tests/auto/unit/qmultimedia_common/mockcameracontrol.h b/tests/auto/unit/qmultimedia_common/mockcameracontrol.h index 3c8172be4..5f9ed6c9f 100644 --- a/tests/auto/unit/qmultimedia_common/mockcameracontrol.h +++ b/tests/auto/unit/qmultimedia_common/mockcameracontrol.h @@ -107,9 +107,6 @@ public: case QCamera::ActiveState: m_status = QCamera::ActiveStatus; break; - default: - emit error(QCamera::NotSupportedFeatureError, "State not supported."); - return; } emit stateChanged(m_state); |