feat: hide operation panels in watch-only mode
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user