Skip to content

Commit d0601ee

Browse files
committed
Reset working settings on show; allow camera edits
Add showEvent to reset the cleanup guard and rebuild the working settings from the latest accepted settings, then repopulate the dialog. Allow removing/moving active cameras even while a scan is running and adjust preview button enablement logic. Auto-select the first active camera when populating the list and ensure multi_camera_settings is updated from the working copy before emitting settings_changed on apply.
1 parent 5d4d572 commit d0601ee

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

dlclivegui/gui/camera_config/camera_config_dialog.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ def dlc_camera_id(self, value: str | None) -> None:
8585
self._dlc_camera_id = value
8686
self._refresh_camera_labels()
8787

88+
def showEvent(self, event):
89+
super().showEvent(event)
90+
try:
91+
# Reset cleanup guard so close cleanup runs for each session
92+
self._cleanup_done = False
93+
except Exception:
94+
pass
95+
96+
# Rebuild the working copy from the latest “accepted” settings
97+
self._working_settings = self._multi_camera_settings.model_copy(deep=True)
98+
self._current_edit_index = None
99+
self._populate_from_settings()
100+
88101
# Maintain overlay geometry when resizing
89102
def resizeEvent(self, event):
90103
super().resizeEvent(event)
@@ -304,13 +317,14 @@ def _update_button_states(self) -> None:
304317

305318
active_row = self.active_cameras_list.currentRow()
306319
has_active_selection = active_row >= 0
307-
allow_structure_edits = has_active_selection and not scan_running
308320

309-
self.remove_camera_btn.setEnabled(allow_structure_edits)
310-
self.move_up_btn.setEnabled(allow_structure_edits and active_row > 0)
311-
self.move_down_btn.setEnabled(allow_structure_edits and active_row < self.active_cameras_list.count() - 1)
312-
# During loading, preview button becomes "Cancel Loading"
321+
# Allow removing/moving active cameras even during scanning
322+
self.remove_camera_btn.setEnabled(has_active_selection)
323+
self.move_up_btn.setEnabled(has_active_selection and active_row > 0)
324+
self.move_down_btn.setEnabled(has_active_selection and active_row < self.active_cameras_list.count() - 1)
325+
313326
self.preview_btn.setEnabled(has_active_selection or self._preview.state == PreviewState.LOADING)
327+
314328
available_row = self.available_cameras_list.currentRow()
315329
self.add_camera_btn.setEnabled(available_row >= 0 and not scan_running)
316330

@@ -1014,6 +1028,9 @@ def _populate_from_settings(self) -> None:
10141028
item.setForeground(Qt.GlobalColor.gray)
10151029
self.active_cameras_list.addItem(item)
10161030

1031+
if self.active_cameras_list.count() > 0:
1032+
self.active_cameras_list.setCurrentRow(0)
1033+
10171034
self._refresh_available_cameras()
10181035
self._update_button_states()
10191036

@@ -1076,6 +1093,7 @@ def _on_ok_clicked(self) -> None:
10761093
if self._working_settings.cameras and not active:
10771094
QMessageBox.warning(self, "No Active Cameras", "Please enable at least one camera or remove all cameras.")
10781095
return
1096+
self._multi_camera_settings = self._working_settings.model_copy(deep=True)
10791097
self.settings_changed.emit(copy.deepcopy(self._working_settings))
10801098

10811099
self._on_close_cleanup()

0 commit comments

Comments
 (0)