Patch Detail
Show a patch.
GET /api/patches/16994/?format=api
{ "id": 16994, "url": "https://patchwork.libcamera.org/api/patches/16994/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16994/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20220806190433.59128-2-utkarsh02t@gmail.com>", "date": "2022-08-06T19:04:30", "name": "[libcamera-devel,v2,1/4] qcam: Use QDialog for selection of cameras at startup", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "feaace783bd32b0de53787ceb35d80e586a236b4", "submitter": { "id": 114, "url": "https://patchwork.libcamera.org/api/people/114/?format=api", "name": "Utkarsh Tiwari", "email": "utkarsh02t@gmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16994/mbox/", "series": [ { "id": 3379, "url": "https://patchwork.libcamera.org/api/series/3379/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3379", "date": "2022-08-06T19:04:29", "name": "Improve Camera Selection GUI in QCam", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3379/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16994/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16994/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 919E9C3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 6 Aug 2022 19:04:54 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4BE5763313;\n\tSat, 6 Aug 2022 21:04:54 +0200 (CEST)", "from mail-pl1-x631.google.com (mail-pl1-x631.google.com\n\t[IPv6:2607:f8b0:4864:20::631])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2AE516332B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 6 Aug 2022 21:04:52 +0200 (CEST)", "by mail-pl1-x631.google.com with SMTP id t2so5331249ply.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 06 Aug 2022 12:04:52 -0700 (PDT)", "from localhost.localdomain ([2404:bd00:3:daa9:adf3:a099:1bff:e55])\n\tby smtp.gmail.com with ESMTPSA id\n\tz17-20020aa79911000000b0052f20d70845sm406025pff.150.2022.08.06.12.04.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 06 Aug 2022 12:04:49 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659812694;\n\tbh=7d4DgRBK36XXC05mClFv2k3rijGpz/Zg/AJ+NsNoglI=;\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=oo7V1vXaXSOygJ6lWfPmqBGIf7S2YN/hkxkvdWqFNFkdn5vtqTWVFnZ0n63esffVM\n\tZ8KoUxiccg6QPU93QcRUw4UC1qzFBKVd7qWV3mYXORjE3PJv46d+IG/oHy5ovyvM0g\n\tVVjY/F6PCStOgM1PlvMRhD1N4Vz4GuSY8v6cxuBdXIDpgyzRTXePxBPd+q8llumkug\n\tP3xlku6wwVX6tetsuW/DpB04lpWVZvL2WzP6UQYgFHlKKGEjVTA1EOWvcCVAXZDBLl\n\tlCmG+qFzH3c85LJbo7QGWWyBtj3AlA2ZDqDMVeyA/mRKg2P6RA1rJjjWI9eJuOoy50\n\tikNyZ9JL47ODQ==", "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=dpfpf09IEIUwxuA/C+IBy9n5tZOTeXXc4N1nwXYN5jg=;\n\tb=Q2RmZ1MG3gBHxsvA/RbsAQfDfHq5ij7vdID9W42Rp3T0i/qWOXQclFxDRJG9v00Ozz\n\tYlcmgEIclR+fvE8WTrSdw5uZORKD7Qf8S8135rv9/bGemggVYihhyE0hBnFbJdD8Fcsn\n\t/Y7j9f/Obg+FsemIRugIpTqFKjHuhu3Bcip9b1cQV/gx16LrN7bih0t+laWm9J/VI9Bm\n\tjmbsHrhyYuuDfhMTAlm6E7bRe8Q05IIjjvQOUmsyX/xYE94xAerRlf7CXZtn81ZN3TMu\n\tr3rpkccO8P2r92myHuuLmzk6e4NJ9pLKNV7LzqMAvWk9wtA3eau+7279+T/UW0JX+2GA\n\tT0NA==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"Q2RmZ1MG\"; 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=dpfpf09IEIUwxuA/C+IBy9n5tZOTeXXc4N1nwXYN5jg=;\n\tb=7Z2nFoU4L87nA+Vgdur3vlBirMESH9OQMdoTtU5/fBaf6Rvg/hwYSGXFLgqESXzdNm\n\t2GAlL0LBhR4cP7PQSaiJ2CXmRxum19OQSSgYLhBjJWiC9AXEFFDAgJVCZe36enyGY7eS\n\tbztqAG/ROfhqhhc4b+PlvlsQWw3L3eHkG4yq44jITf592046bOb/S0Y6KfXp+udByqoc\n\tgnGK60KL66Kxyjok08NoB7ecFTiL7exsxQLgNDe6OahCz+xdMWEkT0fJQ8h/tdS74Yh6\n\t9tBxpPYWhTpcKxmjPBaOq2RmxwUh5aJjVJCS1zZsQuGEpgY7V4PYjhbiZwRwrqHhuwmP\n\tbpyg==", "X-Gm-Message-State": "ACgBeo1Dy2daVEVvldy63r439fF0PmjY8JV6jcv+3Ete7i8BiG3Qx1YG\n\tnyGp+QR28YA3+KQMV61UO0vhcb/Y+dY=", "X-Google-Smtp-Source": "AA6agR4gs+zwEsdxxWaNrp2ihus4LHrf1UYX/2/VzAgqNSUR+TtA0n6Hv9cFNvfFqJkkfYUnFvBkgw==", "X-Received": "by 2002:a17:90a:fc2:b0:1f3:20d0:2e47 with SMTP id\n\t60-20020a17090a0fc200b001f320d02e47mr13368102pjz.117.1659812690296; \n\tSat, 06 Aug 2022 12:04:50 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sun, 7 Aug 2022 00:34:30 +0530", "Message-Id": "<20220806190433.59128-2-utkarsh02t@gmail.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20220806190433.59128-1-utkarsh02t@gmail.com>", "References": "<20220806190433.59128-1-utkarsh02t@gmail.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 1/4] 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>\n---\nDifference from V1:\nThe biggest change here is the introduction of class, inside of\nthe class the layout remains same.\n src/qcam/cam_select_dialog.h | 64 ++++++++++++++++++++++++++++++++++++\n src/qcam/main_window.cpp | 22 +++----------\n src/qcam/main_window.h | 4 +++\n src/qcam/meson.build | 1 +\n 4 files changed, 74 insertions(+), 17 deletions(-)\n create mode 100644 src/qcam/cam_select_dialog.h", "diff": "diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h\nnew file mode 100644\nindex 00000000..c23bad59\n--- /dev/null\n+++ b/src/qcam/cam_select_dialog.h\n@@ -0,0 +1,64 @@\n+\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\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 CamSelectDialog : public QDialog\n+{\n+\tQ_OBJECT\n+public:\n+\tCamSelectDialog(libcamera::CameraManager *cameraManager, QWidget *parent)\n+\t\t: QDialog(parent), cm_(cameraManager)\n+\t{\n+\t\t/* Use a QFormLayout for the dialog. */\n+\t\tQFormLayout *camSelectDialogLayout = new QFormLayout(this);\n+\n+\t\t/* Setup the camera id combo-box. */\n+\t\tcameraIdComboBox_ = new QComboBox;\n+\t\tfor (const auto &cam : cm_->cameras())\n+\t\t\tcameraIdComboBox_->addItem(QString::fromStdString(cam->id()));\n+\n+\t\t/* Setup the QDialogButton Box */\n+\t\tQDialogButtonBox *dialogButtonBox =\n+\t\t\tnew QDialogButtonBox(QDialogButtonBox::Ok |\n+\t\t\t\t\t QDialogButtonBox::Cancel);\n+\n+\t\tconnect(dialogButtonBox, &QDialogButtonBox::accepted,\n+\t\t\tthis, &QDialog::accept);\n+\t\tconnect(dialogButtonBox, &QDialogButtonBox::rejected,\n+\t\t\tthis, &QDialog::reject);\n+\n+\t\t/* Set the layout. */\n+\t\tcamSelectDialogLayout->addRow(\"Camera: \", cameraIdComboBox_);\n+\t\tcamSelectDialogLayout->addWidget(dialogButtonBox);\n+\t}\n+\n+\t~CamSelectDialog() = default;\n+\n+\tstd::string getCameraId()\n+\t{\n+\t\treturn cameraIdComboBox_->currentText().toStdString();\n+\t}\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..758e2c94 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,24 +290,12 @@ void MainWindow::switchCamera(int index)\n \n std::string MainWindow::chooseCamera()\n {\n-\tQStringList cameras;\n-\tbool result;\n+\tcamSelectDialog_ = new CamSelectDialog(cm_, this);\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 (camSelectDialog_->exec() == QDialog::Accepted)\n+\t\treturn camSelectDialog_->getCameraId();\n+\telse\n \t\treturn std::string();\n-\n-\treturn id.toStdString();\n }\n \n int MainWindow::openCamera()\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex fc70920f..6d80b5be 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+\tQPointer<CamSelectDialog> camSelectDialog_;\n+\n \t/* Options */\n \tconst OptionsParser::Options &options_;\n \ndiff --git a/src/qcam/meson.build b/src/qcam/meson.build\nindex c46f4631..70615e92 100644\n--- a/src/qcam/meson.build\n+++ b/src/qcam/meson.build\n@@ -26,6 +26,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", "v2", "1/4" ] }