@@ -49,3 +49,17 @@ std::string CameraSelectorDialog::getCameraId()
{
return cameraIdComboBox_->currentText().toStdString();
}
+
+/* Hotplug / Unplug Support. */
+void CameraSelectorDialog::cameraAdded(libcamera::Camera *camera)
+{
+ cameraIdComboBox_->addItem(QString::fromStdString(camera->id()));
+}
+
+void CameraSelectorDialog::cameraRemoved(libcamera::Camera *camera)
+{
+ int cameraIndex = cameraIdComboBox_->findText(
+ QString::fromStdString(camera->id()));
+
+ cameraIdComboBox_->removeItem(cameraIndex);
+}
@@ -29,6 +29,10 @@ public:
std::string getCameraId();
+ /* Hotplug / Unplug Support. */
+ void cameraAdded(libcamera::Camera *camera);
+
+ void cameraRemoved(libcamera::Camera *camera);
private:
libcamera::CameraManager *cm_;
@@ -593,6 +593,8 @@ void MainWindow::processHotplug(HotplugEvent *e)
if (event == HotplugEvent::HotPlug) {
cameraCombo_->addItem(QString::fromStdString(camera->id()));
+
+ cameraSelectorDialog_->cameraAdded(camera);
} else if (event == HotplugEvent::HotUnplug) {
/* Check if the currently-streaming camera is removed. */
if (camera == camera_.get()) {
@@ -604,6 +606,8 @@ void MainWindow::processHotplug(HotplugEvent *e)
int camIndex = cameraCombo_->findText(QString::fromStdString(camera->id()));
cameraCombo_->removeItem(camIndex);
+
+ cameraSelectorDialog_->cameraRemoved(camera);
}
}