From 80a7ccd3add45eb56fda6f1fb445017ac01fea7a Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 22 Oct 2024 12:24:48 +0200 Subject: qcam: Automatically select the camera if only one is available When only a single camera is available, showing the camera selection dialog is unnecessary. It's better to automatically select the available camera without prompting the user for input. Co-developed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart Signed-off-by: Stanislaw Gruszka Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/apps/qcam/main_window.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/apps/qcam') diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp index 5144c6b3..de487672 100644 --- a/src/apps/qcam/main_window.cpp +++ b/src/apps/qcam/main_window.cpp @@ -298,13 +298,19 @@ int MainWindow::openCamera() std::string cameraName; /* - * Use the camera specified on the command line, if any, or display the - * camera selection dialog box otherwise. + * If a camera is specified on the command line, get it. Otherwise, if + * only one camera is available, pick it automatically, else, display + * the selector dialog box. */ - if (options_.isSet(OptCamera)) + if (options_.isSet(OptCamera)) { cameraName = static_cast(options_[OptCamera]); - else - cameraName = chooseCamera(); + } else { + std::vector> cameras = cm_->cameras(); + if (cameras.size() == 1) + cameraName = cameras[0]->id(); + else + cameraName = chooseCamera(); + } if (cameraName == "") return -EINVAL; -- cgit v1.2.1