From c697049ce6adf1adc718ea6b608220f612ae3e36 Mon Sep 17 00:00:00 2001 From: Dawn Date: Sat, 8 Aug 2026 15:10:27 +0200 Subject: [PATCH] feat: hide operation panels in watch-only mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without the baton the GUI now shows only the camera stream and status bar; every operating surface (panels, docks, pop-out mirrors) is hidden outright. Regaining the baton restores dock layout via saveState/ restoreState — per-dock visibility snapshots lose docks tabbed behind others — so LogDock gains the objectName restoreState requires. Co-Authored-By: Claude Fable 5 --- src/aare/gui/main_window.py | 36 ++++++++++++++++++++++++++++++++ src/aare/gui/panels/log_panel.py | 2 ++ 2 files changed, 38 insertions(+) diff --git a/src/aare/gui/main_window.py b/src/aare/gui/main_window.py index 781f1b49..c1314086 100644 --- a/src/aare/gui/main_window.py +++ b/src/aare/gui/main_window.py @@ -2417,6 +2417,42 @@ class MainWindow(QMainWindow): for banner in banners: banner.set_collapsed(True, persist=False) + # Watch-only shows ONLY the camera stream: every other operating + # surface is hidden outright (not just greyed), and regaining the + # baton restores exactly the visibility each one had before. The + # status bar and its SESSION VACANT badge stay — they are the way + # back in. To later hide the camera streams as well, add + # self.video_tab to this list. + # findChildren instead of a hand list: hand-listing missed docks + # (Console Log, Fluorescence, ...) and would again for future ones. + # Covers the pop-out mirrors too — they are operating surfaces. + hide_in_watch_mode = [ + self.left_column_tabs, + self.beamline, + self.beamline_state_panel, + *self.findChildren(PopoutWindow), + ] + if owned: + for widget, was_visible in getattr(self, "_pre_watch_visibility", []): + widget.setVisible(was_visible) + # Docks restore via restoreState, not per-dock setVisible: a dock + # TABBED BEHIND another is isHidden() at snapshot time, so a + # visibility snapshot mistakes it for user-closed and loses it + # (the vanished Sample List). restoreState also brings back + # tab order, the active tab and dock sizes. Needs objectNames + # on every dock. + state = getattr(self, "_pre_watch_dock_state", None) + if state is not None: + self.restoreState(state) + else: + # not isHidden(), NOT isVisible(): the vacant gate first runs + # before the window is shown, where isVisible() is False for + # everything and the restore would then "restore" all-hidden. + self._pre_watch_dock_state = self.saveState() + self._pre_watch_visibility = [(w, not w.isHidden()) for w in hide_in_watch_mode] + for widget in hide_in_watch_mode + self.findChildren(QDockWidget): + widget.hide() + @Slot(DAQStatusModel) def update_daq_status(self, s: DAQStatusModel): self._latest_daq_status = s diff --git a/src/aare/gui/panels/log_panel.py b/src/aare/gui/panels/log_panel.py index 9d1033ea..12289ea4 100644 --- a/src/aare/gui/panels/log_panel.py +++ b/src/aare/gui/panels/log_panel.py @@ -197,6 +197,8 @@ class RuntimeNotificationWidget(QFrame): class LogDock(QDockWidget): def __init__(self, title="Log", parent=None): super().__init__(title, parent) + # saveState/restoreState (watch-mode hide/restore) skips unnamed docks. + self.setObjectName("log_dock") self.setAllowedAreas( Qt.DockWidgetArea.BottomDockWidgetArea | Qt.DockWidgetArea.RightDockWidgetArea