<div dir="ltr">On Wed, Aug 10, 2022 at 8:34 PM Utkarsh Tiwari <<a href="mailto:utkarsh02t@gmail.com">utkarsh02t@gmail.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The camera selection dialog currently only displays the camera Id.<br>
Display the camera location and camera model if available.<br>
<br>
Signed-off-by: Utkarsh Tiwari <<a href="mailto:utkarsh02t@gmail.com" target="_blank">utkarsh02t@gmail.com</a>><br>
Reviewed-by: Kieran Bingham <<a href="mailto:kieran.bingham@ideasonboard.com" target="_blank">kieran.bingham@ideasonboard.com</a>><br>
---<br>
Difference from v7:<br>
1. Nothing<br>
src/qcam/cam_select_dialog.cpp | 52 ++++++++++++++++++++++++++++++++++<br>
src/qcam/cam_select_dialog.h | 10 +++++++<br>
2 files changed, 62 insertions(+)<br>
<br>
diff --git a/src/qcam/cam_select_dialog.cpp b/src/qcam/cam_select_dialog.cpp<br>
index d8982800..f97ad6eb 100644<br>
--- a/src/qcam/cam_select_dialog.cpp<br>
+++ b/src/qcam/cam_select_dialog.cpp<br>
@@ -7,6 +7,7 @@<br>
<br>
#include "cam_select_dialog.h"<br>
<br>
+#include <memory><br>
#include <string><br>
<br>
#include <libcamera/camera.h><br>
@@ -30,6 +31,14 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag<br>
for (const auto &cam : cm_->cameras())<br>
cameraIdComboBox_->addItem(QString::fromStdString(cam->id()));<br>
<br>
+ /* Set camera information labels. */<br>
+ cameraLocation_ = new QLabel;<br>
+ cameraModel_ = new QLabel;<br>
+<br>
+ handleCameraChange();<br>
+ connect(cameraIdComboBox_, &QComboBox::currentTextChanged,<br>
+ this, &CameraSelectorDialog::handleCameraChange);<br>
+<br>
/* Setup the QDialogButton Box */<br>
QDialogButtonBox *buttonBox =<br>
new QDialogButtonBox(QDialogButtonBox::Ok |<br>
@@ -41,7 +50,10 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag<br>
this, &QDialog::reject);<br>
<br>
/* Set the layout. */<br>
+<br>
layout->addRow("Camera:", cameraIdComboBox_);<br>
+ layout->addRow("Location:", cameraLocation_);<br>
+ layout->addRow("Model:", cameraModel_);<br>
layout->addWidget(buttonBox);<br>
}<br>
<br>
@@ -63,3 +75,43 @@ void CameraSelectorDialog::cameraRemoved(libcamera::Camera *camera)<br>
<br>
cameraIdComboBox_->removeItem(cameraIndex);<br>
}<br>
+<br>
+/* Camera Information */<br>
+void CameraSelectorDialog::handleCameraChange()<br>
+{<br>
+ updateCamInfo(cm_->get(getCameraId()));<br>
+}<br></blockquote><div><br></div><div>This function can be removed and we can shift the cm_->get(getCameraId()) in the updateCamInfo</div><div>itself.<br></div><div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+void CameraSelectorDialog::updateCamInfo(const std::shared_ptr<libcamera::Camera> &camera)<br>
+{<br>
+ if (!camera)<br>
+ return;<br>
+<br>
+ const libcamera::ControlList &cameraProperties = camera->properties();<br>
+<br>
+ const auto &location =<br>
+ cameraProperties.get(libcamera::properties::Location);<br>
+ if (location) {<br>
+ switch (*location) {<br>
+ case libcamera::properties::CameraLocationFront:<br>
+ cameraLocation_->setText("Internal front camera");<br>
+ break;<br>
+ case libcamera::properties::CameraLocationBack:<br>
+ cameraLocation_->setText("Internal back camera");<br>
+ break;<br>
+ case libcamera::properties::CameraLocationExternal:<br>
+ cameraLocation_->setText("External camera");<br>
+ break;<br>
+ default:<br>
+ cameraLocation_->setText("Unknown");<br>
+ }<br>
+ } else {<br>
+ cameraLocation_->setText("Unknown");<br>
+ }<br>
+<br>
+ const auto &model = cameraProperties<br>
+ .get(libcamera::properties::Model)<br>
+ .value_or("Unknown");<br>
+<br>
+ cameraModel_->setText(QString::fromStdString(model));<br>
+}<br>
diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h<br>
index 04c71fd8..16475af6 100644<br>
--- a/src/qcam/cam_select_dialog.h<br>
+++ b/src/qcam/cam_select_dialog.h<br>
@@ -11,9 +11,12 @@<br>
<br>
#include <libcamera/camera.h><br>
#include <libcamera/camera_manager.h><br>
+#include <libcamera/controls.h><br>
+#include <libcamera/property_ids.h><br>
<br>
#include <QComboBox><br>
#include <QDialog><br>
+#include <QLabel><br>
<br>
class CameraSelectorDialog : public QDialog<br>
{<br>
@@ -30,9 +33,16 @@ public:<br>
void cameraAdded(libcamera::Camera *camera);<br>
<br>
void cameraRemoved(libcamera::Camera *camera);<br>
+<br>
+ /* Camera Information */<br>
+ void updateCamInfo(const std::shared_ptr<libcamera::Camera> &camera);<br>
+ void handleCameraChange();<br>
+<br>
private:<br>
libcamera::CameraManager *cm_;<br>
<br>
/* UI elements. */<br>
QComboBox *cameraIdComboBox_;<br>
+ QLabel *cameraLocation_;<br>
+ QLabel *cameraModel_;<br>
};<br>
-- <br>
2.25.1<br>
<br>
</blockquote></div></div>