Patch Detail
Show a patch.
GET /api/1.1/patches/17053/?format=api
{ "id": 17053, "url": "https://patchwork.libcamera.org/api/1.1/patches/17053/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17053/", "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": "<20220809205042.344923-2-utkarsh02t@gmail.com>", "date": "2022-08-09T20:50:35", "name": "[libcamera-devel,v7,1/8] qcam: Use QDialog for selection of cameras at startup", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "5f3254ad8c4abd2019b97a80c87feef0d1f910cd", "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/17053/mbox/", "series": [ { "id": 3400, "url": "https://patchwork.libcamera.org/api/1.1/series/3400/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3400", "date": "2022-08-09T20:50:34", "name": "Introduce capture scripts to qcam", "version": 7, "mbox": "https://patchwork.libcamera.org/series/3400/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17053/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17053/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 E02C9BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 9 Aug 2022 20:51:00 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7E5D563328;\n\tTue, 9 Aug 2022 22:51:00 +0200 (CEST)", "from mail-pg1-x530.google.com (mail-pg1-x530.google.com\n\t[IPv6:2607:f8b0:4864:20::530])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 144F263326\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 9 Aug 2022 22:50:58 +0200 (CEST)", "by mail-pg1-x530.google.com with SMTP id r69so5913816pgr.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 09 Aug 2022 13:50:58 -0700 (PDT)", "from localhost.localdomain ([2404:bd00:3:d2bc:2358:3bcd:fb4f:cbb7])\n\tby smtp.gmail.com with ESMTPSA id\n\td3-20020a623603000000b0052d981e7842sm301936pfa.208.2022.08.09.13.50.54\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 09 Aug 2022 13:50:55 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660078260;\n\tbh=u4MTFmMccitsy66efRjXwl3R+v/Nznti/BpmNgO8DPg=;\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=mYZ4G8k4P53TFYUS2AdhoUxaxfdoOo/t2knclnpZbOmNL9xq/Cv3STByuec7tZW3M\n\tT3VwM3uJkMLJTuKy/ktJhd1+TJwPVNrq9a0+DIgpS/J9wUlCNpUNdoo9uJqaYbCLJQ\n\tjcHSmvr4c5FaDRdw+cJhReostZUa1M57qOP+3Hws3ZKmLvDJWsXHM9oU0out3ONrMm\n\tWtJ6Zx5yKF8/pK01kXGuvVVTvRnwgrhRR1xHm4CeWIH8dAddtBrrDI/xIbnfrteoAE\n\tx2d8x++B7hTrCJcUdZ33vkIGugznNPizKRbkW6CciXZPA470co4pRY/LVynrQRRcnd\n\texx0QABnOQI6A==", "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=dfYq8LWQIvsQ5s6c7P+CGWO6qRw4gGkJtVXHJcDVppQ=;\n\tb=PC+88RYDCWlkbuI1ZGci2B0lo7jyuSUAonLhW6HKobKX/cw2I2r1OVLbl6B/z4C/Mw\n\t3GicsE2Sd+TzafA+a30JmG+pnq1dkcz8oHh8aYlGLrENF4gWX4cPkUyPx8SF63+kzYG2\n\tn2AW6Z/bV0nU+74vAvpASqCQ2zSu41dYj5S1tJYqHrrww4jzRun5I39Llr/3J1RU5s+E\n\tTOt78e7NYujdVWlAp01cSwW9zSu6EKzdIfnUpGqiMLAKnXDdRZJkcxaaQ0xbfAaIsoL8\n\tK9RxEJ5oXH4tLPXzqN4WFcO35aQTJaYfezK9azrhlbqRgajzFA+w7apPEQA1VFFH2GP4\n\tAyag==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"PC+88RYD\"; 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=dfYq8LWQIvsQ5s6c7P+CGWO6qRw4gGkJtVXHJcDVppQ=;\n\tb=4mhOQ8A8azZFDhjBkyNiHBiwevuIO31JQTYwcT2BoKmM6OroNv8GWhKYLM7iq+ofdt\n\tHs0Y/CnRSEioYeDeKCn95lWdTvrWvmYEyJRbvfjzp3xFbg+5wP49+ugXoZLhUFuSSKG8\n\tu0v+0Ntbe2rFPPLSK9Ala89YsEaG7WWOomHsSAzSJgxyW6uyZ61BHJzsCdEgI9iyuCub\n\tW+zYTW+I1ptZk1sBAnNykP3ZCkM4hX29DHFGbndqzjD98fpXRU9b6CQwFXp3v8w76pia\n\tIHk2qUr9LZmDHy4gKYmRf7sqpcenPfmckZcJ2WSOho7vKQQawOLF/SeBnnWyQ3zRDIdE\n\tSlkg==", "X-Gm-Message-State": "ACgBeo3eYTwcUTFW8Y0+JnXaaT7/2RxxAICMG+drwQ+c1BmExc4iYAu/\n\tRfwghg3GAtjCItTnIm0r+iZPEHzPuUs=", "X-Google-Smtp-Source": "AA6agR4U7mHh6tlaqB5K8XMCugqer/529ygfmo5MYIe7JdXDxygoyrSETYFgpZJlWOa8bk8zh0axLQ==", "X-Received": "by 2002:a65:6398:0:b0:415:7d00:c1de with SMTP id\n\th24-20020a656398000000b004157d00c1demr20996195pgv.610.1660078256368; \n\tTue, 09 Aug 2022 13:50:56 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 10 Aug 2022 02:20:35 +0530", "Message-Id": "<20220809205042.344923-2-utkarsh02t@gmail.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20220809205042.344923-1-utkarsh02t@gmail.com>", "References": "<20220809205042.344923-1-utkarsh02t@gmail.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v7 1/8] 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\nSigned-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\nDifference\n\t1. Renamed dialogButtonBox to buttonBox\n\t2. Removed spaces\n\t3. Renamed to just layout\n\t4. No longer use the QPointer\n\t5. 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", "diff": "diff --git a/src/qcam/cam_select_dialog.cpp b/src/qcam/cam_select_dialog.cpp\nnew file mode 100644\nindex 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+\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+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..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+\tQ_OBJECT\n+public:\n+\tCameraSelectorDialog(libcamera::CameraManager *cameraManager,\n+\t\t\t QWidget *parent);\n+\n+\t~CameraSelectorDialog() = default;\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..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-\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-\t\treturn std::string();\n-\n-\treturn id.toStdString();\n-}\n-\n-int MainWindow::openCamera()\n-{\n-\tstd::string cameraName;\n+\t/* Construct the selection dialog, unconditionally. */\n+\tcameraSelectorDialog_ = new CameraSelectorDialog(cm_, this);\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 \tif (options_.isSet(OptCamera))\n-\t\tcameraName = static_cast<std::string>(options_[OptCamera]);\n+\t\treturn static_cast<std::string>(options_[OptCamera]);\n+\n+\tif (cameraSelectorDialog_->exec() == QDialog::Accepted)\n+\t\treturn cameraSelectorDialog_->getCameraId();\n \telse\n-\t\tcameraName = chooseCamera();\n+\t\treturn std::string();\n+}\n+\n+int MainWindow::openCamera()\n+{\n+\tstd::string cameraName = chooseCamera();\n \n \tif (cameraName == \"\")\n \t\treturn -EINVAL;\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex 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 \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", "v7", "1/8" ] }