summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUtkarsh Tiwari <utkarsh02t@gmail.com>2022-08-09 16:14:23 +0100
committerUtkarsh Tiwari <utkarsh02t@gmail.com>2022-09-05 12:19:00 +0530
commitd598e77aa5500c60694f1f6aa4f95d67edc202ae (patch)
tree2a0a3b443effa1438d015da0bc99d6d5342db578
parentb63519d201628bd662b4d616b90db88d3fcce163 (diff)
qcam: CamSelectDialog: Display Location and Model propety of camera
The camera selection dialog currently only displays the camera Id. Display the camera location and camera model if available. Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/qcam/cam_select_dialog.cpp49
-rw-r--r--src/qcam/cam_select_dialog.h8
2 files changed, 57 insertions, 0 deletions
diff --git a/src/qcam/cam_select_dialog.cpp b/src/qcam/cam_select_dialog.cpp
index 07f53f40..3c8b12a9 100644
--- a/src/qcam/cam_select_dialog.cpp
+++ b/src/qcam/cam_select_dialog.cpp
@@ -7,12 +7,15 @@
#include "cam_select_dialog.h"
+#include <memory>
+
#include <libcamera/camera.h>
#include <libcamera/camera_manager.h>
#include <QComboBox>
#include <QDialogButtonBox>
#include <QFormLayout>
+#include <QLabel>
#include <QString>
CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManager,
@@ -27,6 +30,14 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag
for (const auto &cam : cm_->cameras())
cameraIdComboBox_->addItem(QString::fromStdString(cam->id()));
+ /* Set camera information labels. */
+ cameraLocation_ = new QLabel;
+ cameraModel_ = new QLabel;
+
+ updateCameraInfo(cameraIdComboBox_->currentText());
+ connect(cameraIdComboBox_, &QComboBox::currentTextChanged,
+ this, &CameraSelectorDialog::updateCameraInfo);
+
/* Setup the QDialogButton Box */
QDialogButtonBox *buttonBox =
new QDialogButtonBox(QDialogButtonBox::Ok |
@@ -39,6 +50,8 @@ CameraSelectorDialog::CameraSelectorDialog(libcamera::CameraManager *cameraManag
/* Set the layout. */
layout->addRow("Camera:", cameraIdComboBox_);
+ layout->addRow("Location:", cameraLocation_);
+ layout->addRow("Model:", cameraModel_);
layout->addWidget(buttonBox);
}
@@ -60,3 +73,39 @@ void CameraSelectorDialog::removeCamera(QString cameraId)
int cameraIndex = cameraIdComboBox_->findText(cameraId);
cameraIdComboBox_->removeItem(cameraIndex);
}
+
+/* Camera Information */
+void CameraSelectorDialog::updateCameraInfo(QString cameraId)
+{
+ const std::shared_ptr<libcamera::Camera> &camera =
+ cm_->get(cameraId.toStdString());
+
+ if (!camera)
+ return;
+
+ const libcamera::ControlList &properties = camera->properties();
+
+ const auto &location = properties.get(libcamera::properties::Location);
+ if (location) {
+ switch (*location) {
+ case libcamera::properties::CameraLocationFront:
+ cameraLocation_->setText("Internal front camera");
+ break;
+ case libcamera::properties::CameraLocationBack:
+ cameraLocation_->setText("Internal back camera");
+ break;
+ case libcamera::properties::CameraLocationExternal:
+ cameraLocation_->setText("External camera");
+ break;
+ default:
+ cameraLocation_->setText("Unknown");
+ }
+ } else {
+ cameraLocation_->setText("Unknown");
+ }
+
+ const auto &model = properties.get(libcamera::properties::Model)
+ .value_or("Unknown");
+
+ cameraModel_->setText(QString::fromStdString(model));
+}
diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h
index 44b081a5..0b7709ed 100644
--- a/src/qcam/cam_select_dialog.h
+++ b/src/qcam/cam_select_dialog.h
@@ -11,11 +11,14 @@
#include <libcamera/camera.h>
#include <libcamera/camera_manager.h>
+#include <libcamera/controls.h>
+#include <libcamera/property_ids.h>
#include <QDialog>
#include <QString>
class QComboBox;
+class QLabel;
class CameraSelectorDialog : public QDialog
{
@@ -31,9 +34,14 @@ public:
void addCamera(QString cameraId);
void removeCamera(QString cameraId);
+ /* Camera Information */
+ void updateCameraInfo(QString cameraId);
+
private:
libcamera::CameraManager *cm_;
/* UI elements. */
QComboBox *cameraIdComboBox_;
+ QLabel *cameraLocation_;
+ QLabel *cameraModel_;
};