Patch Detail
Show a patch.
GET /api/1.1/patches/2219/?format=api
{ "id": 2219, "url": "https://patchwork.libcamera.org/api/1.1/patches/2219/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2219/", "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": "<20191025110224.25604-1-kieran.bingham@ideasonboard.com>", "date": "2019-10-25T11:02:24", "name": "[libcamera-devel,v2] qcam: Don't ask for a camera when only one exists", "commit_ref": "74208ea5d110530cb1fea6e724d85bb8685a896b", "pull_url": null, "state": "accepted", "archived": false, "hash": "27914bc73176ecb12757aa8e82ef79f8d223cdc7", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2219/mbox/", "series": [ { "id": 547, "url": "https://patchwork.libcamera.org/api/1.1/series/547/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=547", "date": "2019-10-25T11:02:24", "name": "[libcamera-devel,v2] qcam: Don't ask for a camera when only one exists", "version": 2, "mbox": "https://patchwork.libcamera.org/series/547/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2219/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2219/checks/", "tags": {}, "headers": { "Return-Path": "<kieran.bingham@ideasonboard.com>", "Received": [ "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 F0DDA61378\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Oct 2019 13:02:28 +0200 (CEST)", "from Q.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net\n\t[86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 56C2E33A;\n\tFri, 25 Oct 2019 13:02:28 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1572001348;\n\tbh=9ga87JOwdahmqd8pYF/fVRL7KeQ1unYNRpSuMLfjqtM=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=vUe6EJSrSYjins5kDAJgDmTxfh3bXuQzEnBHmOJGQ8uZ8Q/akK2nEq2zPn816NEyR\n\tsU8sKIIc35jg8b92sk/RsoWRDDc2r7MzJH0Pv3RMwZTulxAMEeSivCnuT8GSxhpSdd\n\tF/Arck7+DMwOq+W4g7hsVpK+T2wE5jCP7plWtUr4=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>", "Date": "Fri, 25 Oct 2019 12:02:24 +0100", "Message-Id": "<20191025110224.25604-1-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.20.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2] qcam: Don't ask for a camera when only\n\tone exists", "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>", "X-List-Received-Date": "Fri, 25 Oct 2019 11:02:29 -0000" }, "content": "If there is only one camera exposed by libcamera, there is little value\nin asking the user to choose it.\n\nAutomatically select it, and remove the need to ask the user to select\n'ok' from a Dialog box.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n--\nv2:\n - I have no idea what (or rather why) I screwed up the preivous but it\n was very wrong.\n - I think I saw the loop and for some reason thought I copy/pasted it\n wrong and it was supposed to contain the whole block - so I\n (erroneously) expanded the scope of the loop.. Ooops. I'll go back to\n sleep.\n\n - This one works and is tested on a single, and multiple cameras ;-D\n---\n src/qcam/main_window.cpp | 40 +++++++++++++++++++++++++---------------\n src/qcam/main_window.h | 1 +\n 2 files changed, 26 insertions(+), 15 deletions(-)", "diff": "diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex ef4ad4a22dca..3d5630922723 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -66,27 +66,37 @@ void MainWindow::updateTitle()\n \tsetWindowTitle(title_ + \" : \" + QString::number(fps, 'f', 2) + \" fps\");\n }\n \n-int MainWindow::openCamera(CameraManager *cm)\n+std::string MainWindow::chooseCamera(CameraManager *cm)\n {\n-\tstd::string cameraName;\n+\tQStringList cameras;\n+\tbool result;\n+\n+\tif (cm->cameras().size() == 1)\n+\t\treturn cm->cameras()[0]->name();\n \n-\tif (!options_.isSet(OptCamera)) {\n-\t\tQStringList cameras;\n-\t\tbool result;\n+\tfor (const std::shared_ptr<Camera> &cam : cm->cameras())\n+\t\tcameras.append(QString::fromStdString(cam->name()));\n \n-\t\tfor (const std::shared_ptr<Camera> &cam : cm->cameras())\n-\t\t\tcameras.append(QString::fromStdString(cam->name()));\n+\tQString name = 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-\t\tQString name = QInputDialog::getItem(this, \"Select Camera\",\n-\t\t\t\t\t\t \"Camera:\", cameras, 0,\n-\t\t\t\t\t\t false, &result);\n-\t\tif (!result)\n-\t\t\treturn -EINVAL;\n+\treturn name.toStdString();\n+}\n \n-\t\tcameraName = name.toStdString();\n-\t} else {\n+int MainWindow::openCamera(CameraManager *cm)\n+{\n+\tstd::string cameraName;\n+\n+\tif (options_.isSet(OptCamera))\n \t\tcameraName = static_cast<std::string>(options_[OptCamera]);\n-\t}\n+\telse\n+\t\tcameraName = chooseCamera(cm);\n+\n+\tif (cameraName == \"\")\n+\t\treturn -EINVAL;\n \n \tcamera_ = cm->get(cameraName);\n \tif (!camera_) {\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex 6873155aaa03..30dd8743104d 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -43,6 +43,7 @@ private Q_SLOTS:\n \tvoid updateTitle();\n \n private:\n+\tstd::string chooseCamera(CameraManager *cm);\n \tint openCamera(CameraManager *cm);\n \n \tint startCapture();\n", "prefixes": [ "libcamera-devel", "v2" ] }