Show a patch.

GET /api/1.1/patches/17265/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 17265,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/17265/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17265/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20220831054938.21617-2-utkarsh02t@gmail.com>",
    "date": "2022-08-31T05:49:32",
    "name": "[libcamera-devel,v9,1/7] qcam: Use QDialog for selection of cameras at startup",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "023e2849f0d4164df919c99248b2d652a53dad48",
    "submitter": {
        "id": 114,
        "url": "https://patchwork.libcamera.org/api/1.1/people/114/?format=api",
        "name": "Utkarsh Tiwari",
        "email": "utkarsh02t@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17265/mbox/",
    "series": [
        {
            "id": 3457,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3457/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3457",
            "date": "2022-08-31T05:49:31",
            "name": "Introduce capture scripts to qcam",
            "version": 9,
            "mbox": "https://patchwork.libcamera.org/series/3457/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17265/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17265/checks/",
    "tags": {},
    "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 65BAAC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 31 Aug 2022 05:49:56 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 158F361FC0;\n\tWed, 31 Aug 2022 07:49:56 +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 B2C7061FC0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 31 Aug 2022 07:49:53 +0200 (CEST)",
            "by mail-pf1-x42e.google.com with SMTP id 72so13434650pfx.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Aug 2022 22:49:53 -0700 (PDT)",
            "from devut-HP-Laptop-14q-cs0xxx.. ([103.36.82.122])\n\tby smtp.gmail.com with ESMTPSA id\n\tq19-20020aa79833000000b00537eacc8fa6sm8307333pfl.40.2022.08.30.22.49.49\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 30 Aug 2022 22:49:51 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661924996;\n\tbh=pBtWysisUXQZjFS1DaxfJbevz+8j9IQ0PqWmQ3oVr+g=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=RC1kYB701+h1IHOnnBh7lTAaVBC5PNdp+cfIEVepipK0GphMuHN7qPNeAX4UYN2C1\n\tsuqqPTaM301pH8fvuyhCcOx71CoKXJnnwbSSElEf6hA9zUnFDGpmQRInr1hMIRLs5P\n\tUSrrr961Qm/vnTSEOyO3OWNd7fRDxhkP+kx5UzRAqDT8jqNEXEg/pyQRKrHd+hVQU2\n\tmUUJzMPPfj6iOs1pkznfF/jZZa7K2qErWSvCk6Y3MkK8Skj7Dj9PfpG95C8cPpeFeX\n\tX2KTc5gOCKLGMP7bu6b7lw8CR5B1uY9hnlf6qee0BSZkPWmYhXzbH5NLxBobIwRB6E\n\tXa681tFMT7/LA==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc;\n\tbh=B9kMzQ/ssEmSlT0Blg3p++oQte936a/cWGLiumonPLE=;\n\tb=FCZFzW7tAhsfDivh6CQfSFEnA8TEREwijBL3ApZBAvIiATMalmqGbFDdpLlQUQlW2I\n\t5ehDiwwLFaRk+ziO9L6sOZpjSAxbBhRhOCSiYL3bpclZ7BbdRDz6+n6MpjBnN/dV0tml\n\tGJZo4jUNDRAHz5XTjsZEDTNuJXEVcarYyW7Ug0sufmLGMpEXI2NuYMymRpJk6treopMH\n\tQxa84LBa+oiydPW5Fh8klgwJ7C0uoxl2a/A+mU6ZxKJUzulb/a/yg/+l9KBDB3iER7cH\n\tUC9Q0wflMEPckBo0s5UQObj5v2ntreLo88mLwXQoYvil0SrvF+rrIlVX2f1NJigtUw8j\n\tPvXQ=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"FCZFzW7t\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc;\n\tbh=B9kMzQ/ssEmSlT0Blg3p++oQte936a/cWGLiumonPLE=;\n\tb=l2H+dileZP9PI0Up4rmx7Mw+tTOpvaYApRXFm7vX+Cns6y2dvLCoRF17hrXx+CyJRZ\n\txhecJmkBXIPptF3CsxZPUZvWAK2q6by39HBQb8wFXNZGlwboPpHjL0wJcCpOhz6a/Nox\n\tR0sEVz2VBMloIOwyZRk60vdeHchyLErk4ypomYssujuUyBk4NTGdzOd5nxjYC4ymh3S8\n\tRqk+Ud8EdASA93Ob/ztlwWwcqC5dEQ+0Yp0VtCGfKlwYFuFihCd/2GNmFeff7ANFE2W1\n\tW+qT8zgahuV9Qx2JBZ13ZzNgVu4fniacpF9de7UFyP003eeO5Iti5X4BMXc3VBZWdIlk\n\tZluQ==",
        "X-Gm-Message-State": "ACgBeo0akT2zl8B/B15wmTK9DyWSbtrWWLMRyL+Zm6A2mIi3hazvPRo9\n\tq9CpK1bJum/K7/NGpOik6okDteYRjXs=",
        "X-Google-Smtp-Source": "AA6agR7+0ZiNetMTj2+XSfdbs33U41OJvWKKldSRnFS3q5ri7u281d/pNNtB82FtYzK1iUu9Xj1mGg==",
        "X-Received": "by 2002:a05:6a00:1384:b0:538:73c5:91ff with SMTP id\n\tt4-20020a056a00138400b0053873c591ffmr8888834pfg.54.1661924991961; \n\tTue, 30 Aug 2022 22:49:51 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 31 Aug 2022 11:19:32 +0530",
        "Message-Id": "<20220831054938.21617-2-utkarsh02t@gmail.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20220831054938.21617-1-utkarsh02t@gmail.com>",
        "References": "<20220831054938.21617-1-utkarsh02t@gmail.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v9 1/7] qcam: Use QDialog for selection of\n\tcameras 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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Currently we use QInputDialog convenience dialogs to allow the user to\nselect a camera. This doesn't allow adding of more information (such as\ncamera location, model etc).\n\nCreate a QDialog with a QFormLayout that shows a QComboBox with camera\nIds. Use a QDialogButtonBox to provide buttons for accepting and\ncancelling the action.\n\nThe CameraSelectorDialog is only initialized the first time when the\nMainWindow is created.\n\nFrom this commit we cease to auto select the camera if only a single\ncamera is available to libcamera. We would always display the selection\ndialog with the exception being that being if the camera is supplied on\nthe command line.\n\nSigned-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nDifference from v8:\n    1. s/by the console/on the command line in the commit msg\n    2. Removed <string> header from cam_select_dialog.cpp\n    3. Drop <QDialog> from cam_select_dialog.cpp\n    4. QComboBox is forward-declared in cam_select_dialog.h\n    5. ~CameraSelectorDialog() implementation now resides in .cpp\n    6. CameraSelectorDialog is forward-declared in main_window.h\n src/qcam/cam_select_dialog.cpp | 50 ++++++++++++++++++++++++++++++++++\n src/qcam/cam_select_dialog.h   | 35 ++++++++++++++++++++++++\n src/qcam/main_window.cpp       | 27 ++++--------------\n src/qcam/main_window.h         |  3 ++\n src/qcam/meson.build           |  2 ++\n 5 files changed, 96 insertions(+), 21 deletions(-)\n create mode 100644 src/qcam/cam_select_dialog.cpp\n create mode 100644 src/qcam/cam_select_dialog.h",
    "diff": "diff --git a/src/qcam/cam_select_dialog.cpp b/src/qcam/cam_select_dialog.cpp\nnew file mode 100644\nindex 00000000..a49d822b\n--- /dev/null\n+++ b/src/qcam/cam_select_dialog.cpp\n@@ -0,0 +1,50 @@\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 <libcamera/camera.h>\n+#include <libcamera/camera_manager.h>\n+\n+#include <QComboBox>\n+#include <QDialogButtonBox>\n+#include <QFormLayout>\n+#include <QString>\n+\n+CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManager,\n+\t\t\t\t\t   QWidget *parent)\n+\t: QDialog(parent), cm_(cameraManager)\n+{\n+\t/* Use a QFormLayout for the dialog. */\n+\tQFormLayout *layout = new QFormLayout(this);\n+\n+\t/* Setup the camera id combo-box. */\n+\tcameraIdComboBox_ = new QComboBox;\n+\tfor (const auto &cam : cm_->cameras())\n+\t\tcameraIdComboBox_->addItem(QString::fromStdString(cam->id()));\n+\n+\t/* Setup the QDialogButton Box */\n+\tQDialogButtonBox *buttonBox =\n+\t\tnew QDialogButtonBox(QDialogButtonBox::Ok |\n+\t\t\t\t     QDialogButtonBox::Cancel);\n+\n+\tconnect(buttonBox, &QDialogButtonBox::accepted,\n+\t\tthis, &QDialog::accept);\n+\tconnect(buttonBox, &QDialogButtonBox::rejected,\n+\t\tthis, &QDialog::reject);\n+\n+\t/* Set the layout. */\n+\tlayout->addRow(\"Camera:\", cameraIdComboBox_);\n+\tlayout->addWidget(buttonBox);\n+}\n+\n+CameraSelectorDialog::~CameraSelectorDialog() = default;\n+\n+std::string CameraSelectorDialog::getCameraId()\n+{\n+\treturn cameraIdComboBox_->currentText().toStdString();\n+}\ndiff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h\nnew file mode 100644\nindex 00000000..c31f4f82\n--- /dev/null\n+++ b/src/qcam/cam_select_dialog.h\n@@ -0,0 +1,35 @@\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 <QDialog>\n+\n+class QComboBox;\n+\n+class CameraSelectorDialog : public QDialog\n+{\n+\tQ_OBJECT\n+public:\n+\tCameraSelectorDialog(libcamera::CameraManager *cameraManager,\n+\t\t\t     QWidget *parent);\n+\n+\t~CameraSelectorDialog();\n+\n+\tstd::string getCameraId();\n+\n+private:\n+\tlibcamera::CameraManager *cm_;\n+\n+\t/* UI elements. */\n+\tQComboBox *cameraIdComboBox_;\n+};\ndiff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 7433d647..14bcf03e 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@@ -144,6 +144,8 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n \tcm_->cameraAdded.connect(this, &MainWindow::addCamera);\n \tcm_->cameraRemoved.connect(this, &MainWindow::removeCamera);\n \n+\tcameraSelectorDialog_ = new CameraSelectorDialog(cm_, this);\n+\n \t/* Open the camera and start capture. */\n \tret = openCamera();\n \tif (ret < 0) {\n@@ -290,34 +292,17 @@ void MainWindow::switchCamera(int index)\n \n std::string MainWindow::chooseCamera()\n {\n-\tQStringList cameras;\n-\tbool result;\n-\n-\t/* If only one camera is available, use it automatically. */\n-\tif (cm_->cameras().size() == 1)\n-\t\treturn cm_->cameras()[0]->id();\n-\n-\t/* Present a dialog box to pick a camera. */\n-\tfor (const std::shared_ptr<Camera> &cam : cm_->cameras())\n-\t\tcameras.append(QString::fromStdString(cam->id()));\n-\n-\tQString id = QInputDialog::getItem(this, \"Select Camera\",\n-\t\t\t\t\t   \"Camera:\", cameras, 0,\n-\t\t\t\t\t   false, &result);\n-\tif (!result)\n+\tif (cameraSelectorDialog_->exec() != QDialog::Accepted)\n \t\treturn std::string();\n \n-\treturn id.toStdString();\n+\treturn cameraSelectorDialog_->getCameraId();\n }\n \n int MainWindow::openCamera()\n {\n \tstd::string cameraName;\n \n-\t/*\n-\t * Use the camera specified on the command line, if any, or display the\n-\t * camera selection dialog box otherwise.\n-\t */\n+\t/* Use camera provided on the command line else prompt for selection.*/\n \tif (options_.isSet(OptCamera))\n \t\tcameraName = static_cast<std::string>(options_[OptCamera]);\n \telse\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex fc70920f..def44605 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -35,6 +35,7 @@ class QComboBox;\n \n class Image;\n class HotplugEvent;\n+class CameraSelectorDialog;\n \n enum {\n \tOptCamera = 'c',\n@@ -99,6 +100,8 @@ private:\n \tQString title_;\n \tQTimer titleTimer_;\n \n+\tCameraSelectorDialog *cameraSelectorDialog_;\n+\n \t/* Options */\n \tconst OptionsParser::Options &options_;\n \ndiff --git a/src/qcam/meson.build b/src/qcam/meson.build\nindex 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",
    "prefixes": [
        "libcamera-devel",
        "v9",
        "1/7"
    ]
}