[libcamera-devel,v6,4/4] qcam: Add --script to load capture script
diff mbox series

Message ID 20220807203204.152358-5-utkarsh02t@gmail.com
State Superseded
Headers show
Series
  • Introduce capture scripts to qcam
Related show

Commit Message

Utkarsh Tiwari Aug. 7, 2022, 8:32 p.m. UTC
Add --script as an individual option to load capture scripts.
Load the capture script before starting the capture.

If an invalid capture script has been given, quit the application.

Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>
---
 src/qcam/main.cpp        | 3 +++
 src/qcam/main_window.cpp | 6 ++++++
 src/qcam/main_window.h   | 1 +
 3 files changed, 10 insertions(+)

Patch
diff mbox series

diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp
index d3f01a85..91166be5 100644
--- a/src/qcam/main.cpp
+++ b/src/qcam/main.cpp
@@ -43,6 +43,9 @@  OptionsParser::Options parseOptions(int argc, char *argv[])
 			 "Set configuration of a camera stream", "stream", true);
 	parser.addOption(OptVerbose, OptionNone,
 			 "Print verbose log messages", "verbose");
+	parser.addOption(OptCaptureScript, OptionString,
+			 "Load a capture session configuration script from a file",
+			 "script", ArgumentRequired, "script");
 
 	OptionsParser::Options options = parser.parse(argc, argv);
 	if (options.isSet(OptHelp))
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index e354ba10..51088658 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -146,6 +146,9 @@  MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)
 	cm_->cameraAdded.connect(this, &MainWindow::addCamera);
 	cm_->cameraRemoved.connect(this, &MainWindow::removeCamera);
 
+	if (options_.isSet(OptCaptureScript))
+		scriptPath_ = options_[OptCaptureScript].toString();
+
 	/* Open the camera and start capture. */
 	ret = openCamera();
 	if (ret < 0) {
@@ -320,6 +323,9 @@  void MainWindow::loadCaptureScript()
 	if (!script_->valid()) {
 		script_.reset();
 
+		if (options_.isSet(OptCaptureScript))
+			quit();
+
 		QMessageBox::critical(this, "Invalid Script",
 				      "Couldn't load the capture script");
 	}
diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
index 01466e28..fe4dba8d 100644
--- a/src/qcam/main_window.h
+++ b/src/qcam/main_window.h
@@ -46,6 +46,7 @@  enum {
 	OptRenderer = 'r',
 	OptStream = 's',
 	OptVerbose = 'v',
+	OptCaptureScript = 256,
 };
 
 class MainWindow : public QMainWindow