[{"id":24490,"web_url":"https://patchwork.libcamera.org/comment/24490/","msgid":"<166008112552.2423137.17818413588201223240@Monstersaurus>","date":"2022-08-09T21:38:45","subject":"Re: [libcamera-devel] [PATCH v7 1/8] qcam: Use QDialog for\n\tselection of cameras at startup","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Utkarsh Tiwari (2022-08-09 21:50:35)\n> Currently we use QInputDialog convenience dialogs to allow the user to\n> select a camera. This doesn't allow adding of more information (such as\n> camera location, model etc).\n> \n> Create a QDialog with a QFormLayout that shows a QComboBox with camera\n> Ids. Use a QDialogButtonBox to provide buttons for accepting and\n> cancelling the action.\n> \n> Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nThis hasn't been given yet on this patch. Please take care to only apply\ntags on patches that are given.\n\n> ---\n> Difference\n>         1. Renamed dialogButtonBox to buttonBox\n>         2. Removed spaces\n>         3. Renamed to just layout\n>         4. No longer use the QPointer\n>         5. The dialog is always constructed now\n>  src/qcam/cam_select_dialog.cpp | 51 ++++++++++++++++++++++++++++++++++\n>  src/qcam/cam_select_dialog.h   | 37 ++++++++++++++++++++++++\n>  src/qcam/main_window.cpp       | 39 +++++++++-----------------\n>  src/qcam/main_window.h         |  4 +++\n>  src/qcam/meson.build           |  2 ++\n>  5 files changed, 107 insertions(+), 26 deletions(-)\n>  create mode 100644 src/qcam/cam_select_dialog.cpp\n>  create mode 100644 src/qcam/cam_select_dialog.h\n> \n> diff --git a/src/qcam/cam_select_dialog.cpp b/src/qcam/cam_select_dialog.cpp\n> new file mode 100644\n> index 00000000..dceaa590\n> --- /dev/null\n> +++ b/src/qcam/cam_select_dialog.cpp\n> @@ -0,0 +1,51 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2022, Utkarsh Tiwari <utkarsh02t@gmail.com>\n> + *\n> + * cam_select_dialog.cpp - qcam - Camera Selection dialog\n> + */\n> +\n> +#include \"cam_select_dialog.h\"\n> +\n> +#include <string>\n> +\n> +#include <libcamera/camera.h>\n> +#include <libcamera/camera_manager.h>\n> +\n> +#include <QComboBox>\n> +#include <QDialog>\n> +#include <QDialogButtonBox>\n> +#include <QFormLayout>\n> +#include <QString>\n> +\n> +CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManager,\n> +                                          QWidget *parent)\n> +       : QDialog(parent), cm_(cameraManager)\n> +{\n> +       /* Use a QFormLayout for the dialog. */\n> +       QFormLayout *layout = new QFormLayout(this);\n> +\n> +       /* Setup the camera id combo-box. */\n> +       cameraIdComboBox_ = new QComboBox;\n> +       for (const auto &cam : cm_->cameras())\n> +               cameraIdComboBox_->addItem(QString::fromStdString(cam->id()));\n> +\n> +       /* Setup the QDialogButton Box */\n> +       QDialogButtonBox *buttonBox =\n> +               new QDialogButtonBox(QDialogButtonBox::Ok |\n> +                                    QDialogButtonBox::Cancel);\n> +\n> +       connect(buttonBox, &QDialogButtonBox::accepted,\n> +               this, &QDialog::accept);\n> +       connect(buttonBox, &QDialogButtonBox::rejected,\n> +               this, &QDialog::reject);\n> +\n> +       /* Set the layout. */\n> +       layout->addRow(\"Camera:\", cameraIdComboBox_);\n> +       layout->addWidget(buttonBox);\n> +}\n> +\n> +std::string CameraSelectorDialog::getCameraId()\n> +{\n> +       return cameraIdComboBox_->currentText().toStdString();\n> +}\n> diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h\n> new file mode 100644\n> index 00000000..8e54f916\n> --- /dev/null\n> +++ b/src/qcam/cam_select_dialog.h\n> @@ -0,0 +1,37 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2022, Utkarsh Tiwari <utkarsh02t@gmail.com>\n> + *\n> + * cam_select_dialog.h - qcam - Camera Selection dialog\n> + */\n> +\n> +#pragma once\n> +\n> +#include <string>\n> +\n> +#include <libcamera/camera.h>\n> +#include <libcamera/camera_manager.h>\n> +\n> +#include <QComboBox>\n> +#include <QDialog>\n> +#include <QDialogButtonBox>\n> +#include <QFormLayout>\n> +#include <QString>\n> +\n> +class CameraSelectorDialog : public QDialog\n> +{\n> +       Q_OBJECT\n> +public:\n> +       CameraSelectorDialog(libcamera::CameraManager *cameraManager,\n> +                            QWidget *parent);\n> +\n> +       ~CameraSelectorDialog() = default;\n> +\n> +       std::string getCameraId();\n> +\n> +private:\n> +       libcamera::CameraManager *cm_;\n> +\n> +       /* UI elements. */\n> +       QComboBox *cameraIdComboBox_;\n> +};\n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index 7433d647..48479f35 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -19,7 +19,6 @@\n>  #include <QFileDialog>\n>  #include <QImage>\n>  #include <QImageWriter>\n> -#include <QInputDialog>\n>  #include <QMutexLocker>\n>  #include <QStandardPaths>\n>  #include <QStringList>\n> @@ -30,6 +29,7 @@\n>  \n>  #include \"../cam/image.h\"\n>  \n> +#include \"cam_select_dialog.h\"\n>  #include \"dng_writer.h\"\n>  #ifndef QT_NO_OPENGL\n>  #include \"viewfinder_gl.h\"\n> @@ -290,38 +290,25 @@ void MainWindow::switchCamera(int index)\n>  \n>  std::string MainWindow::chooseCamera()\n>  {\n> -       QStringList cameras;\n> -       bool result;\n> -\n> -       /* If only one camera is available, use it automatically. */\n> -       if (cm_->cameras().size() == 1)\n> -               return cm_->cameras()[0]->id();\n\nWe've now lost this behaviour that if there is only one camera it will\nautomatically be chosen when the application is started.\n\nWhile that might be fine, as we expect this to grow to support more\nconfiguration of the camera before it starts, it should at least be\ndocumented in the commit message.\n\nWith the commit message updated, you can keep the tag:\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> -\n> -       /* Present a dialog box to pick a camera. */\n> -       for (const std::shared_ptr<Camera> &cam : cm_->cameras())\n> -               cameras.append(QString::fromStdString(cam->id()));\n> -\n> -       QString id = QInputDialog::getItem(this, \"Select Camera\",\n> -                                          \"Camera:\", cameras, 0,\n> -                                          false, &result);\n> -       if (!result)\n> -               return std::string();\n> -\n> -       return id.toStdString();\n> -}\n> -\n> -int MainWindow::openCamera()\n> -{\n> -       std::string cameraName;\n> +       /* Construct the selection dialog, unconditionally. */\n> +       cameraSelectorDialog_ = new CameraSelectorDialog(cm_, this);\n>  \n>         /*\n>          * Use the camera specified on the command line, if any, or display the\n>          * camera selection dialog box otherwise.\n>          */\n>         if (options_.isSet(OptCamera))\n> -               cameraName = static_cast<std::string>(options_[OptCamera]);\n> +               return static_cast<std::string>(options_[OptCamera]);\n> +\n> +       if (cameraSelectorDialog_->exec() == QDialog::Accepted)\n> +               return cameraSelectorDialog_->getCameraId();\n>         else\n> -               cameraName = chooseCamera();\n> +               return std::string();\n> +}\n> +\n> +int MainWindow::openCamera()\n> +{\n> +       std::string cameraName = chooseCamera();\n>  \n>         if (cameraName == \"\")\n>                 return -EINVAL;\n> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> index fc70920f..b01d2e59 100644\n> --- a/src/qcam/main_window.h\n> +++ b/src/qcam/main_window.h\n> @@ -23,11 +23,13 @@\n>  #include <QMainWindow>\n>  #include <QMutex>\n>  #include <QObject>\n> +#include <QPointer>\n>  #include <QQueue>\n>  #include <QTimer>\n>  \n>  #include \"../cam/stream_options.h\"\n>  \n> +#include \"cam_select_dialog.h\"\n>  #include \"viewfinder.h\"\n>  \n>  class QAction;\n> @@ -99,6 +101,8 @@ private:\n>         QString title_;\n>         QTimer titleTimer_;\n>  \n> +       CameraSelectorDialog *cameraSelectorDialog_;\n> +\n>         /* Options */\n>         const OptionsParser::Options &options_;\n>  \n> diff --git a/src/qcam/meson.build b/src/qcam/meson.build\n> index c46f4631..61861ea6 100644\n> --- a/src/qcam/meson.build\n> +++ b/src/qcam/meson.build\n> @@ -18,6 +18,7 @@ qcam_sources = files([\n>      '../cam/image.cpp',\n>      '../cam/options.cpp',\n>      '../cam/stream_options.cpp',\n> +    'cam_select_dialog.cpp',\n>      'format_converter.cpp',\n>      'main.cpp',\n>      'main_window.cpp',\n> @@ -26,6 +27,7 @@ qcam_sources = files([\n>  ])\n>  \n>  qcam_moc_headers = files([\n> +    'cam_select_dialog.h',\n>      'main_window.h',\n>      'viewfinder_qt.h',\n>  ])\n> -- \n> 2.25.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 49C69BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Aug 2022 21:38:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A38FA63326;\n\tTue,  9 Aug 2022 23:38:49 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F17661FAA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Aug 2022 23:38:48 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0AF39481;\n\tTue,  9 Aug 2022 23:38:48 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660081129;\n\tbh=l7HyWZQRJm2RajYgk/h1o4RXLHoUtpKgHLrbYPjRUs0=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=M7ucNSFdwJIU93Z/LiPmg1tlaPEkpeLv0VvIQQMGG0wIf8sXJy98VZTzaamHWJGEx\n\tTlDHv/7MTU5k0Pj75Ww2HfaERUfBxSMakM+U/0Qd3/OKZPEHFezPBxKvwlsth1xt2N\n\tdQv2mX5FcZ1YAZUQykzw3H0VNerETZHA9nhtxfkaRdIbuW6k4dtGvkJUYjpIV0WkeT\n\trCCGGHgBODCOxnzo71jc01AwyUYdHWBb1TWAy5muqdD2kwzTa72OQ+Pk++GBoENWTm\n\tereWcxfU2A3zs0M+m5y3750OP+VSzgBnEBnThTWiQ1L1XN2ip07/jxAN/JSoQfcZEZ\n\tcLvqc0UAFUfdw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660081128;\n\tbh=l7HyWZQRJm2RajYgk/h1o4RXLHoUtpKgHLrbYPjRUs0=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=cCWFnDJnHA0Jgf/AdsK0SPhO2z5xyEL0wxDKT5WjVOOPNg/X+eT4Jk/5toBx8qRI/\n\t0Kz/EDrWf7jzx9jVrc8vwHQV/SFKQ5y28TbGb29pFpNkueEbGq5ORVzxu8Sz9aGnDz\n\twwKOyct3hpe55CeVnwQfOhoI8PamxcHXzecH6egw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"cCWFnDJn\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220809205042.344923-2-utkarsh02t@gmail.com>","References":"<20220809205042.344923-1-utkarsh02t@gmail.com>\n\t<20220809205042.344923-2-utkarsh02t@gmail.com>","To":"Utkarsh Tiwari <utkarsh02t@gmail.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 09 Aug 2022 22:38:45 +0100","Message-ID":"<166008112552.2423137.17818413588201223240@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v7 1/8] qcam: Use QDialog for\n\tselection of cameras at startup","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24493,"web_url":"https://patchwork.libcamera.org/comment/24493/","msgid":"<CAHbe+E0Q=P31zpW_JVw5Lf=ir=0ygr7N1aRKHWKzn7Fi+cmKew@mail.gmail.com>","date":"2022-08-09T21:46:58","subject":"Re: [libcamera-devel] [PATCH v7 1/8] qcam: Use QDialog for\n\tselection of cameras at startup","submitter":{"id":114,"url":"https://patchwork.libcamera.org/api/people/114/","name":"Utkarsh Tiwari","email":"utkarsh02t@gmail.com"},"content":"Hi Kieran, thanks for the review.\n\nOn Wed, 10 Aug, 2022, 03:08 Kieran Bingham, <kieran.bingham@ideasonboard.com>\nwrote:\n\n> Quoting Utkarsh Tiwari (2022-08-09 21:50:35)\n> > Currently we use QInputDialog convenience dialogs to allow the user to\n> > select a camera. This doesn't allow adding of more information (such as\n> > camera location, model etc).\n> >\n> > Create a QDialog with a QFormLayout that shows a QComboBox with camera\n> > Ids. Use a QDialogButtonBox to provide buttons for accepting and\n> > cancelling the action.\n> >\n> > Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>\n> This hasn't been given yet on this patch. Please take care to only apply\n> tags on patches that are given.\n\nOops, I apologise I mistakenly added it here.\n\n> > ---\n> > Difference\n> >         1. Renamed dialogButtonBox to buttonBox\n> >         2. Removed spaces\n> >         3. Renamed to just layout\n> >         4. No longer use the QPointer\n> >         5. The dialog is always constructed now\n> >  src/qcam/cam_select_dialog.cpp | 51 ++++++++++++++++++++++++++++++++++\n> >  src/qcam/cam_select_dialog.h   | 37 ++++++++++++++++++++++++\n> >  src/qcam/main_window.cpp       | 39 +++++++++-----------------\n> >  src/qcam/main_window.h         |  4 +++\n> >  src/qcam/meson.build           |  2 ++\n> >  5 files changed, 107 insertions(+), 26 deletions(-)\n> >  create mode 100644 src/qcam/cam_select_dialog.cpp\n> >  create mode 100644 src/qcam/cam_select_dialog.h\n> >\n> > diff --git a/src/qcam/cam_select_dialog.cpp\n> b/src/qcam/cam_select_dialog.cpp\n> > new file mode 100644\n> > index 00000000..dceaa590\n> > --- /dev/null\n> > +++ b/src/qcam/cam_select_dialog.cpp\n> > @@ -0,0 +1,51 @@\n> > +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> > +/*\n> > + * Copyright (C) 2022, Utkarsh Tiwari <utkarsh02t@gmail.com>\n> > + *\n> > + * cam_select_dialog.cpp - qcam - Camera Selection dialog\n> > + */\n> > +\n> > +#include \"cam_select_dialog.h\"\n> > +\n> > +#include <string>\n> > +\n> > +#include <libcamera/camera.h>\n> > +#include <libcamera/camera_manager.h>\n> > +\n> > +#include <QComboBox>\n> > +#include <QDialog>\n> > +#include <QDialogButtonBox>\n> > +#include <QFormLayout>\n> > +#include <QString>\n> > +\n> > +CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager\n> *cameraManager,\n> > +                                          QWidget *parent)\n> > +       : QDialog(parent), cm_(cameraManager)\n> > +{\n> > +       /* Use a QFormLayout for the dialog. */\n> > +       QFormLayout *layout = new QFormLayout(this);\n> > +\n> > +       /* Setup the camera id combo-box. */\n> > +       cameraIdComboBox_ = new QComboBox;\n> > +       for (const auto &cam : cm_->cameras())\n> > +\n>  cameraIdComboBox_->addItem(QString::fromStdString(cam->id()));\n> > +\n> > +       /* Setup the QDialogButton Box */\n> > +       QDialogButtonBox *buttonBox =\n> > +               new QDialogButtonBox(QDialogButtonBox::Ok |\n> > +                                    QDialogButtonBox::Cancel);\n> > +\n> > +       connect(buttonBox, &QDialogButtonBox::accepted,\n> > +               this, &QDialog::accept);\n> > +       connect(buttonBox, &QDialogButtonBox::rejected,\n> > +               this, &QDialog::reject);\n> > +\n> > +       /* Set the layout. */\n> > +       layout->addRow(\"Camera:\", cameraIdComboBox_);\n> > +       layout->addWidget(buttonBox);\n> > +}\n> > +\n> > +std::string CameraSelectorDialog::getCameraId()\n> > +{\n> > +       return cameraIdComboBox_->currentText().toStdString();\n> > +}\n> > diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h\n> > new file mode 100644\n> > index 00000000..8e54f916\n> > --- /dev/null\n> > +++ b/src/qcam/cam_select_dialog.h\n> > @@ -0,0 +1,37 @@\n> > +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> > +/*\n> > + * Copyright (C) 2022, Utkarsh Tiwari <utkarsh02t@gmail.com>\n> > + *\n> > + * cam_select_dialog.h - qcam - Camera Selection dialog\n> > + */\n> > +\n> > +#pragma once\n> > +\n> > +#include <string>\n> > +\n> > +#include <libcamera/camera.h>\n> > +#include <libcamera/camera_manager.h>\n> > +\n> > +#include <QComboBox>\n> > +#include <QDialog>\n> > +#include <QDialogButtonBox>\n> > +#include <QFormLayout>\n> > +#include <QString>\n> > +\n> > +class CameraSelectorDialog : public QDialog\n> > +{\n> > +       Q_OBJECT\n> > +public:\n> > +       CameraSelectorDialog(libcamera::CameraManager *cameraManager,\n> > +                            QWidget *parent);\n> > +\n> > +       ~CameraSelectorDialog() = default;\n> > +\n> > +       std::string getCameraId();\n> > +\n> > +private:\n> > +       libcamera::CameraManager *cm_;\n> > +\n> > +       /* UI elements. */\n> > +       QComboBox *cameraIdComboBox_;\n> > +};\n> > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> > index 7433d647..48479f35 100644\n> > --- a/src/qcam/main_window.cpp\n> > +++ b/src/qcam/main_window.cpp\n> > @@ -19,7 +19,6 @@\n> >  #include <QFileDialog>\n> >  #include <QImage>\n> >  #include <QImageWriter>\n> > -#include <QInputDialog>\n> >  #include <QMutexLocker>\n> >  #include <QStandardPaths>\n> >  #include <QStringList>\n> > @@ -30,6 +29,7 @@\n> >\n> >  #include \"../cam/image.h\"\n> >\n> > +#include \"cam_select_dialog.h\"\n> >  #include \"dng_writer.h\"\n> >  #ifndef QT_NO_OPENGL\n> >  #include \"viewfinder_gl.h\"\n> > @@ -290,38 +290,25 @@ void MainWindow::switchCamera(int index)\n> >\n> >  std::string MainWindow::chooseCamera()\n> >  {\n> > -       QStringList cameras;\n> > -       bool result;\n> > -\n> > -       /* If only one camera is available, use it automatically. */\n> > -       if (cm_->cameras().size() == 1)\n> > -               return cm_->cameras()[0]->id();\n>\n> We've now lost this behaviour that if there is only one camera it will\n> automatically be chosen when the application is started.\n>\n> While that might be fine, as we expect this to grow to support more\n> configuration of the camera before it starts, it should at least be\n> documented in the commit message.\n>\n> With the commit message updated, you can keep the tag:\n>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>\n> > -\n> > -       /* Present a dialog box to pick a camera. */\n> > -       for (const std::shared_ptr<Camera> &cam : cm_->cameras())\n> > -               cameras.append(QString::fromStdString(cam->id()));\n> > -\n> > -       QString id = QInputDialog::getItem(this, \"Select Camera\",\n> > -                                          \"Camera:\", cameras, 0,\n> > -                                          false, &result);\n> > -       if (!result)\n> > -               return std::string();\n> > -\n> > -       return id.toStdString();\n> > -}\n> > -\n> > -int MainWindow::openCamera()\n> > -{\n> > -       std::string cameraName;\n> > +       /* Construct the selection dialog, unconditionally. */\n> > +       cameraSelectorDialog_ = new CameraSelectorDialog(cm_, this);\n> >\n> >         /*\n> >          * Use the camera specified on the command line, if any, or\n> display the\n> >          * camera selection dialog box otherwise.\n> >          */\n> >         if (options_.isSet(OptCamera))\n> > -               cameraName =\n> static_cast<std::string>(options_[OptCamera]);\n> > +               return static_cast<std::string>(options_[OptCamera]);\n> > +\n> > +       if (cameraSelectorDialog_->exec() == QDialog::Accepted)\n> > +               return cameraSelectorDialog_->getCameraId();\n> >         else\n> > -               cameraName = chooseCamera();\n> > +               return std::string();\n> > +}\n> > +\n> > +int MainWindow::openCamera()\n> > +{\n> > +       std::string cameraName = chooseCamera();\n> >\n> >         if (cameraName == \"\")\n> >                 return -EINVAL;\n> > diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> > index fc70920f..b01d2e59 100644\n> > --- a/src/qcam/main_window.h\n> > +++ b/src/qcam/main_window.h\n> > @@ -23,11 +23,13 @@\n> >  #include <QMainWindow>\n> >  #include <QMutex>\n> >  #include <QObject>\n> > +#include <QPointer>\n> >  #include <QQueue>\n> >  #include <QTimer>\n> >\n> >  #include \"../cam/stream_options.h\"\n> >\n> > +#include \"cam_select_dialog.h\"\n> >  #include \"viewfinder.h\"\n> >\n> >  class QAction;\n> > @@ -99,6 +101,8 @@ private:\n> >         QString title_;\n> >         QTimer titleTimer_;\n> >\n> > +       CameraSelectorDialog *cameraSelectorDialog_;\n> > +\n> >         /* Options */\n> >         const OptionsParser::Options &options_;\n> >\n> > diff --git a/src/qcam/meson.build b/src/qcam/meson.build\n> > index c46f4631..61861ea6 100644\n> > --- a/src/qcam/meson.build\n> > +++ b/src/qcam/meson.build\n> > @@ -18,6 +18,7 @@ qcam_sources = files([\n> >      '../cam/image.cpp',\n> >      '../cam/options.cpp',\n> >      '../cam/stream_options.cpp',\n> > +    'cam_select_dialog.cpp',\n> >      'format_converter.cpp',\n> >      'main.cpp',\n> >      'main_window.cpp',\n> > @@ -26,6 +27,7 @@ qcam_sources = files([\n> >  ])\n> >\n> >  qcam_moc_headers = files([\n> > +    'cam_select_dialog.h',\n> >      'main_window.h',\n> >      'viewfinder_qt.h',\n> >  ])\n> > --\n> > 2.25.1\n> >\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 11553C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Aug 2022 21:47:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C13F563326;\n\tTue,  9 Aug 2022 23:47:14 +0200 (CEST)","from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com\n\t[IPv6:2607:f8b0:4864:20::42e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F9ED61FAA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Aug 2022 23:47:12 +0200 (CEST)","by mail-pf1-x42e.google.com with SMTP id z187so11947137pfb.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 09 Aug 2022 14:47:12 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660081634;\n\tbh=8tr8guMkS02tQ+OXojpznczrVyajoFXPYgJ0y5SUPiU=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=goXrpICJqaQuZFo/gAa1BOBTy8Q7iKPPmzI3YQClrCKCcOqXGQI+aht6WMxDsuGC6\n\t8FOj6OJlTtIYGUEOtL6I970Luc5Adtpq1kbeEH4543NcHxqDXIuzdA2QhWV9Ddn4yy\n\tVKW/YqqYpCI5m8PtsG6CGjv+Pr+0LYwBrqeWCPyG4KboCIjMo0sKOFkp289PvDPpQo\n\tHXlxf41rY4JJPyHhfBJw2SJdLtc+wNtnl+1nLieAuNcNzoptvOqZRYgbrr1khz3jlL\n\thovBZf4KK48aPQV6LZ/EjTAp2DIU3iShdD6xkPjbWuA7mTnE1Bx2/+BgJ/SNu9bD9q\n\tGvLZ1v4wlGFMA==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc;\n\tbh=FODC1VucNYSnB+8o4v/WU0mgrwb1CRrGWPZIDMMg134=;\n\tb=G1wdCx6oRI0NBtbzKsE/PDLCHbIGbYtQCCz462F6Sf8CP4dWS0Kq2nadz0CykE6qG+\n\tDa7ufajyIwfwh9QJpA6boX8OeXRqOGXcY+4SjL1ov0TZ9SIerJt4wQyqniMZsgFqwHLb\n\tT9xXDvesuzPtgNN/kgNQb/nvTgsnsQwvEVajGHN9jjr3Sob+TRepkPkggE5j7eO3TwqN\n\tCyLJIjD8QFXvO75z/y1Z/PJ7nxchNussEw+Bh5LEB48QfuuTeXwgoZlEaaf+/Sy+i4gi\n\t+AEDHitEGSSpbVTgn9z76xUD/CrPBYaObRvP4ABBArPnMwU0GePdlZShosY67WpP79ji\n\tS2Mg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"G1wdCx6o\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc;\n\tbh=FODC1VucNYSnB+8o4v/WU0mgrwb1CRrGWPZIDMMg134=;\n\tb=75ifs/kIpypgWTtvblUcTglYlSxehl5pmcIOp2x19InCYgdSHNctrWM2bBuWTWkBha\n\tfTMhUKRd2EYVu4K/pfXhvP895PZTWhkGRT36ns26tdn8zMuTWyPGl4q5wW4YEDA8aCFf\n\tg3w4FHzCR3NVxReQa7/Z7z9PVX0dyRII8uT149m2h0AKywyLEFiwD7/U0SiNSx7XrJuW\n\tYUHkpq6cMssa9YLBo8fngQxUN1qpA72qSD+PnwsZM9jRdQKfEkywD8Y+KOwcMpmfX5DS\n\tZVnDenVgBx5ybuVY+I4pqyEoLLNoGeoONsPfoFWOhcijRTxfVi7PCsR6SCWN1v4ubiu6\n\t/15w==","X-Gm-Message-State":"ACgBeo3EnIwbnF5Gx7wbWYsS9+Q3kbUme58bMrBOVUjYL0OGJznGc+QS\n\tcDOtHLsoiwIfmZ4xWEBlgSfWnrbEFJ1O+Q6Fnm2vDDOp","X-Google-Smtp-Source":"AA6agR6Xu/GSSnoC+zVoG6Fn5Uz56P1x9JvHQzqesO7MbW/58uBRy6JxHty9I/hGkw9S4oHOD00ncyYj4fW6FC62D3w=","X-Received":"by 2002:a05:6a00:15c3:b0:52e:677b:7026 with SMTP id\n\to3-20020a056a0015c300b0052e677b7026mr24917170pfu.75.1660081630770;\n\tTue, 09 Aug 2022 14:47:10 -0700 (PDT)","MIME-Version":"1.0","References":"<20220809205042.344923-1-utkarsh02t@gmail.com>\n\t<20220809205042.344923-2-utkarsh02t@gmail.com>\n\t<166008112552.2423137.17818413588201223240@Monstersaurus>","In-Reply-To":"<166008112552.2423137.17818413588201223240@Monstersaurus>","Date":"Wed, 10 Aug 2022 03:16:58 +0530","Message-ID":"<CAHbe+E0Q=P31zpW_JVw5Lf=ir=0ygr7N1aRKHWKzn7Fi+cmKew@mail.gmail.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"000000000000e67b2e05e5d5dfaa\"","Subject":"Re: [libcamera-devel] [PATCH v7 1/8] qcam: Use QDialog for\n\tselection of cameras at startup","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Utkarsh Tiwari via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Utkarsh Tiwari <utkarsh02t@gmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]