[{"id":24366,"web_url":"https://patchwork.libcamera.org/comment/24366/","msgid":"<38ed2193-8e5f-c99c-a77f-36076095d5b7@ideasonboard.com>","date":"2022-08-04T12:06:09","subject":"Re: [libcamera-devel] [PATCH 3/4] qcam: CameraSelectDialog: Display\n\tLocation and Model propety of camera","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Utkarsh,\n\nThank you for the patch.\n\nOn 8/3/22 23:25, Utkarsh Tiwari via libcamera-devel wrote:\n> The camera selection dialog currently only displays the camera Id.\n> Display the camera location and camera model if available.\n>\n> Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\n> ---\n>   src/qcam/main_window.cpp | 69 ++++++++++++++++++++++++++++++++++++++++\n>   src/qcam/main_window.h   |  7 ++++\n>   2 files changed, 76 insertions(+)\n>\n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index 80a73b68..81fa3e60 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -12,6 +12,7 @@\n>   #include <string>\n>   \n>   #include <libcamera/camera_manager.h>\n> +#include <libcamera/property_ids.h>\n>   #include <libcamera/version.h>\n>   \n>   #include <QComboBox>\n> @@ -23,6 +24,7 @@\n>   #include <QImage>\n>   #include <QImageWriter>\n>   #include <QInputDialog>\n> +#include <QLabel>\n>   #include <QMutexLocker>\n>   #include <QStandardPaths>\n>   #include <QStringList>\n> @@ -291,6 +293,47 @@ void MainWindow::switchCamera(int index)\n>   \tstartStopAction_->setChecked(true);\n>   }\n>   \n> +QString MainWindow::getCameraLocation(const std::shared_ptr<Camera> &camera)\n> +{\n> +\tif (camera == nullptr)\n> +\t\treturn QString();\n> +\n> +\tconst ControlList &cameraProperties = camera->properties();\n> +\tconst auto &location = cameraProperties.get(properties::Location);\n> +\n> +\tif (location) {\n> +\t\tswitch (*location) {\n> +\t\tcase properties::CameraLocationFront:\n> +\t\t\treturn \"Internal front camera \";\n> +\t\tcase properties::CameraLocationBack:\n> +\t\t\treturn \"Internal back camera \";\n> +\t\tcase properties::CameraLocationExternal:\n> +\t\t\treturn \"External camera \";\n> +\t\t}\n> +\t}\n> +\treturn QString();\n> +}\n> +\n> +QString MainWindow::getCameraModel(const std::shared_ptr<Camera> &camera)\n> +{\n> +\tif (camera == nullptr)\n> +\t\treturn QString();\n> +\n> +\tconst ControlList &cameraProperties = camera->properties();\n> +\tconst auto &model = cameraProperties.get(properties::Model);\n> +\n> +\tif (model)\n> +\t\treturn QString::fromStdString(*model);\n> +\n> +\treturn QString();\n> +}\n> +\n> +void MainWindow::updateCameraInfo(const std::shared_ptr<libcamera::Camera> &camera)\n> +{\n> +\tcameraLocation_->setText(getCameraLocation(camera));\n> +\tcameraModel_->setText(getCameraModel(camera));\n\n\nThe getCameramodel() and getCameraLocation are concise helpers which can \nbe subsumed under updateCameraInfo() itself.\n\n> +}\n> +\n>   std::string MainWindow::chooseCamera()\n>   {\n>   \tstd::string result;\n> @@ -303,6 +346,29 @@ std::string MainWindow::chooseCamera()\n>   \tfor (const std::shared_ptr<Camera> &cam : cm_->cameras())\n>   \t\tcameraIdComboBox_->addItem(QString::fromStdString(cam->id()));\n>   \n> +\t/* Display Camera Informtion in the Selection Dialog. */\n\n\n\t/* Display camera information in the selection dialog. */\n\n> +\tcameraLocation_ = new QLabel;\n> +\tcameraModel_ = new QLabel;\n> +\n> +\tstd::shared_ptr<Camera> currentCamera;\n> +\n> +\t/*\n> +\t * When the Qdialog starts, the QComboBox would have the first\n\n     s/Qdialog/QDialog/\n\n     s/would/should/\n\n> +\t * camera's Id as its currentText.\n> +\t */\n> +\tif (cm_->cameras().size())\n> +\t\tcurrentCamera = cm_->cameras()[0];\n> +\telse\n> +\t\tcurrentCamera = nullptr;\n\n\ncurrentCamera is a shared_ptr above which doesn't yet manage an object \nwhich means it's nullptr unless it's assigned. Hence, you can drop the \nelse block here.\n\nRest looks good to me!\n\n> +\n> +\tif (currentCamera)\n> +\t\tupdateCameraInfo(currentCamera);\n> +\n> +\tconnect(cameraIdComboBox_, &QComboBox::currentTextChanged,\n> +\t\tthis, [&]() {\n> +\t\t\tupdateCameraInfo(cm_->get(cameraIdComboBox_->currentText().toStdString()));\n> +\t\t});\n> +\n>   \t/* Setup QDialogButtonBox. */\n>   \tQDialogButtonBox *dialogButtonBox = new QDialogButtonBox;\n>   \tdialogButtonBox->addButton(QDialogButtonBox::Cancel);\n> @@ -323,6 +389,9 @@ std::string MainWindow::chooseCamera()\n>   \t/* Setup the layout for the dialog. */\n>   \tQFormLayout *cameraSelectLayout = new QFormLayout(cameraSelectDialog);\n>   \tcameraSelectLayout->addRow(\"Camera: \", cameraIdComboBox_);\n> +\tcameraSelectLayout->addRow(\"Location: \", cameraLocation_);\n> +\tcameraSelectLayout->addRow(\"Model: \", cameraModel_);\n> +\n>   \tcameraSelectLayout->addWidget(dialogButtonBox);\n>   \n>   \tcameraSelectDialog->exec();\n> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> index b8122eb9..3a1c6156 100644\n> --- a/src/qcam/main_window.h\n> +++ b/src/qcam/main_window.h\n> @@ -20,6 +20,7 @@\n>   \n>   #include <QElapsedTimer>\n>   #include <QIcon>\n> +#include <QLabel>\n>   #include <QMainWindow>\n>   #include <QMutex>\n>   #include <QObject>\n> @@ -88,6 +89,10 @@ private:\n>   \tvoid processHotplug(HotplugEvent *e);\n>   \tvoid processViewfinder(libcamera::FrameBuffer *buffer);\n>   \n> +\tQString getCameraLocation(const std::shared_ptr<libcamera::Camera> &camera);\n> +\tQString getCameraModel(const std::shared_ptr<libcamera::Camera> &camera);\n> +\tvoid updateCameraInfo(const std::shared_ptr<libcamera::Camera> &camera);\n> +\n>   \t/* UI elements */\n>   \tQToolBar *toolbar_;\n>   \tQAction *startStopAction_;\n> @@ -102,6 +107,8 @@ private:\n>   \tQTimer titleTimer_;\n>   \n>   \tQPointer<QComboBox> cameraIdComboBox_;\n> +\tQLabel *cameraLocation_;\n> +\tQLabel *cameraModel_;\n>   \n>   \t/* Options */\n>   \tconst OptionsParser::Options &options_;","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 4F84AC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Aug 2022 12:06:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 96F6A63311;\n\tThu,  4 Aug 2022 14:06:17 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 79AAB6330D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Aug 2022 14:06:15 +0200 (CEST)","from [IPV6:2401:4900:1f3e:69e0:a479:4ccc:ab2a:bf48] (unknown\n\t[IPv6:2401:4900:1f3e:69e0:a479:4ccc:ab2a:bf48])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4CD56481;\n\tThu,  4 Aug 2022 14:06:14 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659614777;\n\tbh=1RDV1XR2Ay3F2T2tulAcVt3kUMj5kUh3WLfxKFrl9S8=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=bY2CfM8mWB0MgvhcNPCfCT3FlYzWnBg29YvsRsG9Q6IfYNE2DPR4m2F9azJs0KI2X\n\t0etqvX2NGFM9VhKHT/zeBi9PPDIHvIkRb6R3+xr5UkRO7nQ5tanHIG6q6xoNlXloTG\n\twrrPSmuL7oYcKCQZ2USrvFC1IyiifIvv8Vaqr9gUJA+eYGOMOhtyquSn1iV4bywg1e\n\tu6GLODzDTtH5p5sF8azcIiWj5Ux0wfRl+MYDCEiRHxb3aDwoqHmJioU1B4viFOcoUc\n\tFIGUHA/c7mo2ZojZSb9d5rxLqubcxCyucr8gY/gmQB1ug+nxbunfgce1upErfbXAIe\n\tHhd9993JqyRqg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1659614775;\n\tbh=1RDV1XR2Ay3F2T2tulAcVt3kUMj5kUh3WLfxKFrl9S8=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=USTk9QoIe1h2zn2Q3Ns0K3ADFRceiplUFl2M6dTC5KkxIfyqA0bK8UTK48+tfuhJL\n\t4+KgUXhHDqcOH0clAdOkh0YfxkFfQR6xaqHV+pv9Sarh2uQvUaD8feoJmvuiSBjsnq\n\t1UdmEc4USvlJj3VAHmJs/eaUWegaemxQ9iFsyLZE="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"USTk9QoI\"; dkim-atps=neutral","Message-ID":"<38ed2193-8e5f-c99c-a77f-36076095d5b7@ideasonboard.com>","Date":"Thu, 4 Aug 2022 17:36:09 +0530","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.4.1","Content-Language":"en-US","To":"Utkarsh Tiwari <utkarsh02t@gmail.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20220803175517.175332-1-utkarsh02t@gmail.com>\n\t<20220803175517.175332-4-utkarsh02t@gmail.com>","In-Reply-To":"<20220803175517.175332-4-utkarsh02t@gmail.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH 3/4] qcam: CameraSelectDialog: Display\n\tLocation and Model propety of camera","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":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]