summaryrefslogtreecommitdiff
path: root/src/apps/qcam
diff options
context:
space:
mode:
authorStanislaw Gruszka <stanislaw.gruszka@linux.intel.com>2024-10-22 12:24:48 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-10-25 01:13:32 +0300
commit80a7ccd3add45eb56fda6f1fb445017ac01fea7a (patch)
tree6804b9ae7f0f48be8855c86f8f97daeea9e6ec0f /src/apps/qcam
parent12b553d691d4b0e23838655663363136c82848f6 (diff)
qcam: Automatically select the camera if only one is availableHEADmaster
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 <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/apps/qcam')
-rw-r--r--src/apps/qcam/main_window.cpp16
1 files changed, 11 insertions, 5 deletions
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<std::string>(options_[OptCamera]);
- else
- cameraName = chooseCamera();
+ } else {
+ std::vector<std::shared_ptr<Camera>> cameras = cm_->cameras();
+ if (cameras.size() == 1)
+ cameraName = cameras[0]->id();
+ else
+ cameraName = chooseCamera();
+ }
if (cameraName == "")
return -EINVAL;