Show a patch.

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

{
    "id": 15482,
    "url": "https://patchwork.libcamera.org/api/patches/15482/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15482/",
    "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": "<20220319142545.40433-1-utkarsh02t@gmail.com>",
    "date": "2022-03-19T14:25:45",
    "name": "[libcamera-devel,RFC] Add CameraName to the MainWindow",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "85c6220ff1eab3b7dbdabc281a35d2b42ede841a",
    "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/15482/mbox/",
    "series": [
        {
            "id": 2976,
            "url": "https://patchwork.libcamera.org/api/series/2976/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2976",
            "date": "2022-03-19T14:25:45",
            "name": "[libcamera-devel,RFC] Add CameraName to the MainWindow",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2976/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15482/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15482/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 64F42BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 20 Mar 2022 10:31:05 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8E005604DC;\n\tSun, 20 Mar 2022 11:31:04 +0100 (CET)",
            "from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com\n\t[IPv6:2607:f8b0:4864:20::102e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 08D2A604D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 19 Mar 2022 15:26:00 +0100 (CET)",
            "by mail-pj1-x102e.google.com with SMTP id\n\tmz9-20020a17090b378900b001c657559290so10369589pjb.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 19 Mar 2022 07:25:59 -0700 (PDT)",
            "from localhost.localdomain ([2404:bd00:3:dfd0:b6a5:262b:9d92:c4b6])\n\tby smtp.gmail.com with ESMTPSA id\n\tz14-20020aa7888e000000b004f79f59827asm13416664pfe.139.2022.03.19.07.25.56\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 19 Mar 2022 07:25:57 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647772264;\n\tbh=41CrP/Dwo1WfgZMQgjQMK+ciITil5bXJaFsoTDWMe9w=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=DJkE8s+AQoFwkqmtPyIECMEyFSJET2/V1r+r8P0H2MmsvObl1sqmUxEFe8snW5P4h\n\t+Q2oe4VjRe9j8hcrSH6aVt+J0jrq12/0ZZT7ZfZRrOlEReBRHOT3NNs8zWxBMSeNni\n\tVt5iXhxC9+pmc/XR6H54Pg4ltQa3de9wRQZ42fcLMsrSZbtrQuU7+q1zXdKqRUd1gP\n\tAJNQjqWXpcB+6O20Pny8O/IQYV/8IUcaxFvoG02WWG1D9rrCtaD9mmkaHtOQOMopIC\n\tgijozqZ/Kq+FyBGK5w4ishzza1Hpkbs7SyYfgZH9gEIaxwMibcSTNKXHhXYMhHyDd5\n\tqOd0oaDrfJwqg==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=xchwSc2ENjpqAF/HQOuqXny7d7mfVk4GV/bEoL+wsas=;\n\tb=enZF1L3+nTeLEKaJ1mjbyGbgaJbN8m7ju+O0f9EA1e/pDQbY+i0InxSHGk5X4RA16B\n\txPT5+0mgBhQk2I6X2bHouOleZkJXfiVf3fbnNCGblpNFbBWtIo6fVT7SYCMdS7obT2jT\n\tb+BLPud2WKS/EGctXS+QH26VxsmIQiDpBUjk+kPWKCEB3tqt8bHJvLClcTYZdjQWh6iw\n\t1Aw+TKwmR8u9AZVwflQdJZPiG6Y9aqslfkIFGzUKdLFEY2G/HyCkht7pKnj51l74w13i\n\tcSe2FO5zjJF1FCyb3UUsaoB/rszwpMA7ndNPICOkMfGU5ZSwYAODUrF5QmMy2Qdt1q89\n\tqAxg=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"enZF1L3+\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=xchwSc2ENjpqAF/HQOuqXny7d7mfVk4GV/bEoL+wsas=;\n\tb=KW0Tp4zdx+hx0V6od9xEmcoVRZ0QT0pONpd9Yq+XyVXvJTCsgNxDt2NQ2iWJ0wAKwP\n\tz8on/OUp9cM8Q1bcyfEu4lDDzpx3+BoSxXAwQGA4QOM2MW7C6WWCZpugsFwwSh1TlSnt\n\t+pm+vd3ZxsTXYvMLLyFkujLHc6inwKm2GZZuwHfWZj8NoPsWGi1K64/4LqWCPIzzqJQT\n\tzrPlL0uSu7mzQ+BWTp7zDea2y3guRSFVzal18LmU+b0xG1Zqd9M+8tSlbyOshCSZEUSj\n\tiz9U5ZAVJ8dAy7Sk2DQpr11vrGEYamn7Tx2+4O2XvSOMFgeFbgB2xTnLC8dxEOrL2KB0\n\tWsXg==",
        "X-Gm-Message-State": "AOAM530lk8KeicZe4zaCU4H3GnwDkCn+Z7zvLhxzGLSOD2Xm1BHxRElu\n\tMObXV4+/2qfAIA6ilYhL9k4bW5x4+NQGNQ==",
        "X-Google-Smtp-Source": "ABdhPJwTyXZczdHmlIaKgwulagGZQMdjxZRcs18nDs1MUOoW8ZKTgFhosHQ/yqqKkxR/H9VtV+9qBA==",
        "X-Received": "by 2002:a17:90b:3846:b0:1c6:841b:7470 with SMTP id\n\tnl6-20020a17090b384600b001c6841b7470mr14920217pjb.193.1647699958122; \n\tSat, 19 Mar 2022 07:25:58 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 19 Mar 2022 19:55:45 +0530",
        "Message-Id": "<20220319142545.40433-1-utkarsh02t@gmail.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Mailman-Approved-At": "Sun, 20 Mar 2022 11:31:02 +0100",
        "Subject": "[libcamera-devel] [RFC PATCH] Add CameraName to the MainWindow",
        "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": "Utkarsh Tiwari <utkarsh02t@gmail.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Showing Camera Id on the main window is quite non-intuitive for the user\n\nImplementation: A duplicate function exists in cam/main.cpp . There must be a better way to do this instead of duplication of code\nSigned-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\n---\n src/qcam/main_window.cpp | 61 +++++++++++++++++++++++++++++++++-------\n src/qcam/main_window.h   |  2 +-\n 2 files changed, 52 insertions(+), 11 deletions(-)",
    "diff": "diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex dd0e51f5..35e737c7 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -12,8 +12,10 @@\n #include <string>\n \n #include <libcamera/camera_manager.h>\n+#include <libcamera/property_ids.h>\n #include <libcamera/version.h>\n \n+\n #include <QComboBox>\n #include <QCoreApplication>\n #include <QFileDialog>\n@@ -197,7 +199,7 @@ int MainWindow::createToolbars()\n \t\tthis, &MainWindow::switchCamera);\n \n \tfor (const std::shared_ptr<Camera> &cam : cm_->cameras())\n-\t\tcameraCombo_->addItem(QString::fromStdString(cam->id()));\n+\t\tcameraCombo_->addItem(QString::fromStdString(cameraName(cam.get())));\n \n \ttoolbar_->addWidget(cameraCombo_);\n \n@@ -287,6 +289,45 @@ void MainWindow::switchCamera(int index)\n \tstartStopAction_->setChecked(true);\n }\n \n+std::string MainWindow::cameraName(const libcamera::Camera *camera)\n+{\n+\tconst ControlList &props = camera->properties();\n+\tbool addModel = true;\n+\tstd::string name;\n+\n+\t/*\n+\t * Construct the name from the camera location, model and ID. The model\n+\t * is only used if the location isn't present or is set to External.\n+\t */\n+\tif (props.contains(properties::Location)) {\n+\t\tswitch (props.get(properties::Location)) {\n+\t\tcase properties::CameraLocationFront:\n+\t\t\taddModel = false;\n+\t\t\tname = \"Internal front camera \";\n+\t\t\tbreak;\n+\t\tcase properties::CameraLocationBack:\n+\t\t\taddModel = false;\n+\t\t\tname = \"Internal back camera \";\n+\t\t\tbreak;\n+\t\tcase properties::CameraLocationExternal:\n+\t\t\tname = \"External camera \";\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tif (addModel && props.contains(properties::Model)) {\n+\t\t/*\n+\t\t * If the camera location is not availble use the camera model\n+\t\t * to build the camera name.\n+\t\t */\n+\t\tname = \"'\" + props.get(properties::Model) + \"' \";\n+\t}\n+\n+\tname += \"(\" + camera->id() + \")\";\n+\n+\treturn name;\n+}\n+\n std::string MainWindow::chooseCamera()\n {\n \tQStringList cameras;\n@@ -311,24 +352,24 @@ std::string MainWindow::chooseCamera()\n \n int MainWindow::openCamera()\n {\n-\tstd::string cameraName;\n+\tstd::string cameraId;\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\tcameraId = static_cast<std::string>(options_[OptCamera]);\n \telse\n-\t\tcameraName = chooseCamera();\n+\t\tcameraId = chooseCamera();\n \n-\tif (cameraName == \"\")\n+\tif (cameraId == \"\")\n \t\treturn -EINVAL;\n \n \t/* Get and acquire the camera. */\n-\tcamera_ = cm_->get(cameraName);\n+\tcamera_ = cm_->get(cameraId);\n \tif (!camera_) {\n-\t\tqInfo() << \"Camera\" << cameraName.c_str() << \"not found\";\n+\t\tqInfo() << \"Camera\" << cameraId.c_str() << \"not found\";\n \t\treturn -ENODEV;\n \t}\n \n@@ -339,7 +380,7 @@ int MainWindow::openCamera()\n \t}\n \n \t/* Set the combo-box entry with the currently selected Camera. */\n-\tcameraCombo_->setCurrentText(QString::fromStdString(cameraName));\n+\tcameraCombo_->setCurrentText(QString::fromStdString(cameraName(camera_.get())));\n \n \treturn 0;\n }\n@@ -604,7 +645,7 @@ void MainWindow::processHotplug(HotplugEvent *e)\n \tHotplugEvent::PlugEvent event = e->hotplugEvent();\n \n \tif (event == HotplugEvent::HotPlug) {\n-\t\tcameraCombo_->addItem(QString::fromStdString(camera->id()));\n+\t\tcameraCombo_->addItem(QString::fromStdString(cameraName(camera)));\n \t} else if (event == HotplugEvent::HotUnplug) {\n \t\t/* Check if the currently-streaming camera is removed. */\n \t\tif (camera == camera_.get()) {\n@@ -614,7 +655,7 @@ void MainWindow::processHotplug(HotplugEvent *e)\n \t\t\tcameraCombo_->setCurrentIndex(0);\n \t\t}\n \n-\t\tint camIndex = cameraCombo_->findText(QString::fromStdString(camera->id()));\n+\t\tint camIndex = cameraCombo_->findText(QString::fromStdString(cameraName(camera)));\n \t\tcameraCombo_->removeItem(camIndex);\n \t}\n }\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex 3fbe872c..b31c584f 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -70,7 +70,7 @@ private Q_SLOTS:\n \n private:\n \tint createToolbars();\n-\n+\tstd::string cameraName(const libcamera::Camera *camera);\n \tstd::string chooseCamera();\n \tint openCamera();\n \n",
    "prefixes": [
        "libcamera-devel",
        "RFC"
    ]
}