summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-02-10 16:15:46 +0100
committerLars Knoll <lars.knoll@qt.io>2021-02-17 08:26:40 +0000
commitf2607d51bba3076e51ff9f67cdbcee793c4f54d0 (patch)
tree947471211fbb2732dcbdbbe5cff3d5fc8505dd66 /examples
parenta8eb585f239c2e5c0a5fed8a1a279fbd076c8446 (diff)
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 <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/multimedia/declarative-camera/declarative-camera.qml3
-rw-r--r--examples/multimediawidgets/camera/camera.cpp20
-rw-r--r--examples/multimediawidgets/camera/camera.h1
3 files changed, 5 insertions, 19 deletions
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<int, QCameraImageCapture::Error, const QString &>::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