diff --git a/src/aare/gui/main_window.py b/src/aare/gui/main_window.py index 29838c51..ea663b8a 100644 --- a/src/aare/gui/main_window.py +++ b/src/aare/gui/main_window.py @@ -608,6 +608,23 @@ class MainWindow(QMainWindow): self.job_list_panel.remove_button.clicked.connect(self._remove_selected_from_queue) self.job_list_panel.hide() + # Queue controls act on the queue, whose order only the Queued chip + # view shows — so they are live there and greyed out elsewhere. The + # pop-out clones register themselves in _clone_automation_row. "run" + # kind stays enabled while automation runs: pausing is always allowed. + self._queue_action_buttons: list[tuple[QPushButton, str]] = [ + (self.job_list_panel.play_button, "run"), + (self.job_list_panel.remove_button, "queue"), + (self.job_list_panel.clear_button, "queue"), + ] + self.tell_samples.status_chips.buttonClicked.connect( + lambda _chip: self._update_queue_buttons_enabled() + ) + self.job_list_panel.automation_running_changed.connect( + lambda _running: self._update_queue_buttons_enabled() + ) + self._update_queue_buttons_enabled() + self.sample_lists_tabs = QTabWidget() self.sample_lists_tabs.addTab(dewar_tab, "Dewar samples") self.sample_lists_tabs.addTab(self.ref_tools_panel, "Auxiliary puck") @@ -1297,6 +1314,16 @@ class MainWindow(QMainWindow): sample.db_id for sample in self.job_list_panel.table_model.samples ) + @Slot() + def _update_queue_buttons_enabled(self) -> None: + queued_view = self.tell_samples.table_model.status_filter == "queued" + running = self.job_list_panel.is_running() + tip = "Active in the Queued view — click the Queued chip above the table" + for button, kind in self._queue_action_buttons: + enabled = queued_view or (kind == "run" and running) + button.setEnabled(enabled) + button.setToolTip("" if enabled else tip) + @Slot() def _remove_selected_from_queue(self) -> None: self._unqueue_panel_selection(self.tell_samples) @@ -1341,6 +1368,11 @@ class MainWindow(QMainWindow): dewar_panel.status_chips.buttonClicked.connect( lambda chip: self.tell_samples.set_status_chip(chip.property("status_key")) ) + # Pop-out chips drive the same shared filter — regate the queue + # buttons from here too. + dewar_panel.status_chips.buttonClicked.connect( + lambda _chip: self._update_queue_buttons_enabled() + ) dewar_panel.set_status_chip(self.tell_samples.table_model.status_filter) dewar_tab = QWidget() @@ -1408,6 +1440,14 @@ class MainWindow(QMainWindow): unmount_button = QPushButton("⏏ Unmount") unmount_button.clicked.connect(lambda: self._on_manual_unmount_requested()) + # Same Queued-view gating as the docked trio. + self._queue_action_buttons += [ + (run_button, "run"), + (remove_button, "queue"), + (clear_button, "queue"), + ] + self._update_queue_buttons_enabled() + row = QHBoxLayout() for button in (run_button, remove_button, clear_button, unmount_button): row.addWidget(button)