<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 10, 2022 at 2:23 AM Utkarsh Tiwari <<a href="mailto:utkarsh02t@gmail.com">utkarsh02t@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Add --script as an individual option to load capture scripts.<br>
Load the capture script before starting the capture.<br>
<br>
If an invalid capture script has been given, display an critical error<br>
QMessageBox and close the application.<br>
<br>
Signed-off-by: Utkarsh Tiwari <<a href="mailto:utkarsh02t@gmail.com" target="_blank">utkarsh02t@gmail.com</a>><br>
---<br>
Difference:<br>
        1. firstCameraSelect_  newly introduced to keep track if its the<br>
                first time dialog is been opened.<br></blockquote><div><br></div><div>The firstCameraSelect_ should be done in the patch 3/8<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
 src/qcam/main.cpp        |  3 +++<br>
 src/qcam/main_window.cpp | 16 ++++++++++++++--<br>
 src/qcam/main_window.h   |  2 ++<br>
 3 files changed, 19 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp<br>
index d3f01a85..91166be5 100644<br>
--- a/src/qcam/main.cpp<br>
+++ b/src/qcam/main.cpp<br>
@@ -43,6 +43,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[])<br>
                         "Set configuration of a camera stream", "stream", true);<br>
        parser.addOption(OptVerbose, OptionNone,<br>
                         "Print verbose log messages", "verbose");<br>
+       parser.addOption(OptCaptureScript, OptionString,<br>
+                        "Load a capture session configuration script from a file",<br>
+                        "script", ArgumentRequired, "script");<br>
<br>
        OptionsParser::Options options = parser.parse(argc, argv);<br>
        if (options.isSet(OptHelp))<br>
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp<br>
index f2e3c576..d6ad0083 100644<br>
--- a/src/qcam/main_window.cpp<br>
+++ b/src/qcam/main_window.cpp<br>
@@ -100,7 +100,7 @@ private:<br>
<br>
 MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)<br>
        : saveRaw_(nullptr), options_(options), cm_(cm), allocator_(nullptr),<br>
-         isCapturing_(false), captureRaw_(false)<br>
+         isCapturing_(false), captureRaw_(false), firstCameraSelect_(true)<br>
 {<br>
        int ret;<br>
<br>
@@ -146,6 +146,9 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)<br>
        cm_->cameraAdded.connect(this, &MainWindow::addCamera);<br>
        cm_->cameraRemoved.connect(this, &MainWindow::removeCamera);<br>
<br>
+       if (options_.isSet(OptCaptureScript))<br>
+               scriptPath_ = options_[OptCaptureScript].toString();<br>
+<br>
        /* Open the camera and start capture. */<br>
        ret = openCamera();<br>
        if (ret < 0) {<br>
@@ -324,6 +327,13 @@ void MainWindow::loadCaptureScript()<br>
                QMessageBox::critical(this, "Invalid Script",<br>
                                      "Couldn't load the capture script");<br>
<br>
+               /*<br>
+                * Close the camera if started by command line and its the first capture<br>
+                * script.<br>
+                */<br>
+               if (firstCameraSelect_ && options_.isSet(OptCaptureScript))<br>
+                       quit();<br>
+<br>
        } else<br>
                cameraSelectorDialog_->informScriptRunning(scriptPath_);<br>
<br>
@@ -347,8 +357,10 @@ std::string MainWindow::chooseCamera()<br>
         * Use the camera specified on the command line, if any, or display the<br>
         * camera selection dialog box otherwise.<br>
         */<br>
-       if (options_.isSet(OptCamera))<br>
+       if (firstCameraSelect_ && options_.isSet(OptCamera)) {<br>
+               firstCameraSelect_ = false;<br>
                return static_cast<std::string>(options_[OptCamera]);<br>
+       }<br>
<br>
        if (cameraSelectorDialog_->exec() == QDialog::Accepted) {<br>
                std::string cameraId = cameraSelectorDialog_->getCameraId();<br>
diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h<br>
index 887f1db1..3a264f96 100644<br>
--- a/src/qcam/main_window.h<br>
+++ b/src/qcam/main_window.h<br>
@@ -46,6 +46,7 @@ enum {<br>
        OptRenderer = 'r',<br>
        OptStream = 's',<br>
        OptVerbose = 'v',<br>
+       OptCaptureScript = 256,<br>
 };<br>
<br>
 class MainWindow : public QMainWindow<br>
@@ -123,6 +124,7 @@ private:<br>
        /* Capture state, buffers queue and statistics */<br>
        bool isCapturing_;<br>
        bool captureRaw_;<br>
+       bool firstCameraSelect_;<br>
        libcamera::Stream *vfStream_;<br>
        libcamera::Stream *rawStream_;<br>
        std::map<const libcamera::Stream *, QQueue<libcamera::FrameBuffer *>> freeBuffers_;<br>
-- <br>
2.25.1<br>
<br>
</blockquote></div></div>