Message ID | 20220810150349.414043-9-utkarsh02t@gmail.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Quoting Utkarsh Tiwari via libcamera-devel (2022-08-10 16:03:49) > 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, display an critical error > QMessageBox and close the application. > > Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com> > --- > Difference from v7: > 1. Moved firstCameraSelect_ to 3/8 > src/qcam/main.cpp | 3 +++ > src/qcam/main_window.cpp | 10 ++++++++++ > src/qcam/main_window.h | 1 + > 3 files changed, 14 insertions(+) > > 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 753e1af9..ce70cc02 100644 > --- a/src/qcam/main_window.cpp > +++ b/src/qcam/main_window.cpp > @@ -147,6 +147,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) { > @@ -325,6 +328,13 @@ void MainWindow::loadCaptureScript() > QMessageBox::critical(this, "Invalid Script", > "Couldn't load the capture script"); > > + /* > + * Close the camera if started by command line and its the first capture > + * script. > + */ > + if (firstCameraSelect_ && options_.isSet(OptCaptureScript)) > + quit(); This feels clunky. It might be better if loadCaptureScript() had a return value, that the call from command line could check and quit if it didn't load successfully. But - Does the loadCaptureScript only get called from the MainWindow contrustructor ? I think I'd have it called directly from the dialog acceptance, and here. > + > } else > cameraSelectorDialog_->informScriptRunning(scriptPath_); > > diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h > index 10994b67..c7cba5e9 100644 > --- a/src/qcam/main_window.h > +++ b/src/qcam/main_window.h > @@ -45,6 +45,7 @@ enum { > OptRenderer = 'r', > OptStream = 's', > OptVerbose = 'v', > + OptCaptureScript = 256, > }; > > class MainWindow : public QMainWindow > -- > 2.25.1 >
On Mon, Aug 22, 2022 at 11:41:59PM +0100, Kieran Bingham via libcamera-devel wrote: > Quoting Utkarsh Tiwari via libcamera-devel (2022-08-10 16:03:49) > > 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, display an critical error > > QMessageBox and close the application. > > > > Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com> > > --- > > Difference from v7: > > 1. Moved firstCameraSelect_ to 3/8 > > src/qcam/main.cpp | 3 +++ > > src/qcam/main_window.cpp | 10 ++++++++++ > > src/qcam/main_window.h | 1 + > > 3 files changed, 14 insertions(+) > > > > 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 753e1af9..ce70cc02 100644 > > --- a/src/qcam/main_window.cpp > > +++ b/src/qcam/main_window.cpp > > @@ -147,6 +147,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) { > > @@ -325,6 +328,13 @@ void MainWindow::loadCaptureScript() > > QMessageBox::critical(this, "Invalid Script", > > "Couldn't load the capture script"); > > > > + /* > > + * Close the camera if started by command line and its the first capture > > + * script. > > + */ > > + if (firstCameraSelect_ && options_.isSet(OptCaptureScript)) > > + quit(); > > This feels clunky. It might be better if loadCaptureScript() had a > return value, that the call from command line could check and quit if it > didn't load successfully. I like that better too. > But - Does the loadCaptureScript only get called from the MainWindow > contrustructor ? > > I think I'd have it called directly from the dialog acceptance, and > here. > > > + > > } else > > cameraSelectorDialog_->informScriptRunning(scriptPath_); > > > > diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h > > index 10994b67..c7cba5e9 100644 > > --- a/src/qcam/main_window.h > > +++ b/src/qcam/main_window.h > > @@ -45,6 +45,7 @@ enum { > > OptRenderer = 'r', > > OptStream = 's', > > OptVerbose = 'v', > > + OptCaptureScript = 256, > > }; > > > > class MainWindow : public QMainWindow
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 753e1af9..ce70cc02 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -147,6 +147,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) { @@ -325,6 +328,13 @@ void MainWindow::loadCaptureScript() QMessageBox::critical(this, "Invalid Script", "Couldn't load the capture script"); + /* + * Close the camera if started by command line and its the first capture + * script. + */ + if (firstCameraSelect_ && options_.isSet(OptCaptureScript)) + quit(); + } else cameraSelectorDialog_->informScriptRunning(scriptPath_); diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 10994b67..c7cba5e9 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -45,6 +45,7 @@ enum { OptRenderer = 'r', OptStream = 's', OptVerbose = 'v', + OptCaptureScript = 256, }; class MainWindow : public QMainWindow
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, display an critical error QMessageBox and close the application. Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com> --- Difference from v7: 1. Moved firstCameraSelect_ to 3/8 src/qcam/main.cpp | 3 +++ src/qcam/main_window.cpp | 10 ++++++++++ src/qcam/main_window.h | 1 + 3 files changed, 14 insertions(+)