From f2607d51bba3076e51ff9f67cdbcee793c4f54d0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 10 Feb 2021 16:15:46 +0100 Subject: Get rid of QCamera::CaptureMode Whether we capture still images or Video should only depend on the outputs we have attached to the camera (QMediaRecoder and QCameraImageCapture). There's no need for a separate enum here. Change-Id: I852f5c752abd1184680ca868cb90e995d6d68b27 Reviewed-by: Doris Verria Reviewed-by: Lars Knoll --- .../declarative-camera/declarative-camera.qml | 3 --- examples/multimediawidgets/camera/camera.cpp | 20 ++++---------------- examples/multimediawidgets/camera/camera.h | 1 + 3 files changed, 5 insertions(+), 19 deletions(-) (limited to 'examples') diff --git a/examples/multimedia/declarative-camera/declarative-camera.qml b/examples/multimedia/declarative-camera/declarative-camera.qml index 87dee35f3..29640b82b 100644 --- a/examples/multimedia/declarative-camera/declarative-camera.qml +++ b/examples/multimedia/declarative-camera/declarative-camera.qml @@ -65,7 +65,6 @@ Rectangle { name: "PhotoCapture" StateChangeScript { script: { - camera.captureMode = Camera.CaptureStillImage camera.start() } } @@ -77,7 +76,6 @@ Rectangle { name: "VideoCapture" StateChangeScript { script: { - camera.captureMode = Camera.CaptureVideo camera.start() } } @@ -94,7 +92,6 @@ Rectangle { Camera { id: camera - captureMode: Camera.CaptureStillImage imageCapture { onImageCaptured: { diff --git a/examples/multimediawidgets/camera/camera.cpp b/examples/multimediawidgets/camera/camera.cpp index 014c07fc0..28f4f5071 100644 --- a/examples/multimediawidgets/camera/camera.cpp +++ b/examples/multimediawidgets/camera/camera.cpp @@ -129,9 +129,6 @@ void Camera::setCamera(const QCameraInfo &cameraInfo) connect(m_imageCapture, QOverload::of(&QCameraImageCapture::error), this, &Camera::displayCaptureError); - ui->captureWidget->setTabEnabled(0, (m_camera->isCaptureModeSupported(QCamera::CaptureStillImage))); - ui->captureWidget->setTabEnabled(1, (m_camera->isCaptureModeSupported(QCamera::CaptureVideo))); - updateCaptureMode(); m_camera->start(); } @@ -147,7 +144,7 @@ void Camera::keyPressEvent(QKeyEvent * event) event->accept(); break; case Qt::Key_Camera: - if (m_camera->captureMode() == QCamera::CaptureStillImage) { + if (m_doImageCapture) { takeImage(); } else { if (m_mediaRecorder->state() == QMediaRecorder::RecordingState) @@ -189,16 +186,10 @@ void Camera::processCapturedImage(int requestId, const QImage& img) void Camera::configureCaptureSettings() { - switch (m_camera->captureMode()) { - case QCamera::CaptureStillImage: + if (m_doImageCapture) configureImageSettings(); - break; - case QCamera::CaptureVideo: + else configureVideoSettings(); - break; - default: - break; - } } void Camera::configureVideoSettings() @@ -279,10 +270,7 @@ void Camera::stopCamera() void Camera::updateCaptureMode() { int tabIndex = ui->captureWidget->currentIndex(); - QCamera::CaptureModes captureMode = tabIndex == 0 ? QCamera::CaptureStillImage : QCamera::CaptureVideo; - - if (m_camera->isCaptureModeSupported(captureMode)) - m_camera->setCaptureMode(captureMode); + m_doImageCapture = (tabIndex == 0); } void Camera::updateCameraState(QCamera::State state) diff --git a/examples/multimediawidgets/camera/camera.h b/examples/multimediawidgets/camera/camera.h index 5ccac9165..66cc6eee3 100644 --- a/examples/multimediawidgets/camera/camera.h +++ b/examples/multimediawidgets/camera/camera.h @@ -128,6 +128,7 @@ private: QMediaEncoderSettings m_encoderSettings; bool m_isCapturingImage = false; bool m_applicationExiting = false; + bool m_doImageCapture = true; }; #endif -- cgit v1.2.3