summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qcam/cam_select_dialog.cpp12
-rw-r--r--src/qcam/cam_select_dialog.h5
-rw-r--r--src/qcam/main_window.cpp7
3 files changed, 22 insertions, 2 deletions
diff --git a/src/qcam/cam_select_dialog.cpp b/src/qcam/cam_select_dialog.cpp
index a49d822b..07f53f40 100644
--- a/src/qcam/cam_select_dialog.cpp
+++ b/src/qcam/cam_select_dialog.cpp
@@ -48,3 +48,15 @@ std::string CameraSelectorDialog::getCameraId()
{
return cameraIdComboBox_->currentText().toStdString();
}
+
+/* Hotplug / Unplug Support. */
+void CameraSelectorDialog::addCamera(QString cameraId)
+{
+ cameraIdComboBox_->addItem(cameraId);
+}
+
+void CameraSelectorDialog::removeCamera(QString cameraId)
+{
+ int cameraIndex = cameraIdComboBox_->findText(cameraId);
+ cameraIdComboBox_->removeItem(cameraIndex);
+}
diff --git a/src/qcam/cam_select_dialog.h b/src/qcam/cam_select_dialog.h
index bce258b2..44b081a5 100644
--- a/src/qcam/cam_select_dialog.h
+++ b/src/qcam/cam_select_dialog.h
@@ -13,6 +13,7 @@
#include <libcamera/camera_manager.h>
#include <QDialog>
+#include <QString>
class QComboBox;
@@ -26,6 +27,10 @@ public:
std::string getCameraId();
+ /* Hotplug / Unplug Support. */
+ void addCamera(QString cameraId);
+ void removeCamera(QString cameraId);
+
private:
libcamera::CameraManager *cm_;
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index 3bddb1f1..385b0059 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -594,10 +594,12 @@ void MainWindow::stopCapture()
void MainWindow::processHotplug(HotplugEvent *e)
{
Camera *camera = e->camera();
+ QString cameraId = QString::fromStdString(camera->id());
HotplugEvent::PlugEvent event = e->hotplugEvent();
if (event == HotplugEvent::HotPlug) {
- cameraCombo_->addItem(QString::fromStdString(camera->id()));
+ cameraCombo_->addItem(cameraId);
+ cameraSelectorDialog_->addCamera(cameraId);
} else if (event == HotplugEvent::HotUnplug) {
/* Check if the currently-streaming camera is removed. */
if (camera == camera_.get()) {
@@ -607,8 +609,9 @@ void MainWindow::processHotplug(HotplugEvent *e)
cameraCombo_->setCurrentIndex(0);
}
- int camIndex = cameraCombo_->findText(QString::fromStdString(camera->id()));
+ int camIndex = cameraCombo_->findText(cameraId);
cameraCombo_->removeItem(camIndex);
+ cameraSelectorDialog_->removeCamera(cameraId);
}
}