"""Main-window layout and typed section views, without acquisition state.""" from pathlib import Path from PyQt6.QtWidgets import ( QFileDialog, QFrame, QHBoxLayout, QLabel, QMainWindow, QPushButton, QScrollArea, QVBoxLayout, QWidget, ) from python_app.gui.controllers.history_controller import HistoryController from python_app.gui.controllers.sections.data_actions_section import build_data_actions_group from python_app.gui.controllers.sections.preprocess_summary_section import build_preprocess_summary_group from python_app.gui.controllers.sections.primary_actions_section import build_primary_actions_group from python_app.gui.controllers.sections.processing_section import build_processing_group from python_app.gui.controllers.sections.radar_section import build_radar_group from python_app.gui.controllers.sections.switch_section import build_switch_group from python_app.models.gui_profile_schema import GuiStateModel from python_app.models.run_config_schema import RunConfigModel class WindowView: def __init__(self, parent: QMainWindow, config: RunConfigModel, gui: GuiStateModel, plot_stack: QWidget, log_panel: QWidget, *, project_root: Path) -> None: self._parent = parent self.root = QWidget(parent) parent.setCentralWidget(self.root) parent.setWindowTitle("Radar System Control") layout = QHBoxLayout(self.root) layout.setContentsMargins(12, 12, 12, 12) layout.setSpacing(14) layout.addWidget(plot_stack, stretch=11) self._toggle = QPushButton(">") self._toggle.setObjectName("settingsToggleButton") self._toggle.setFixedWidth(26) self._toggle.setToolTip("Hide settings panel") self._toggle.clicked.connect(self.toggle_settings) layout.addWidget(self._toggle) self.settings_panel = QWidget(self.root) self.settings_panel.setMinimumWidth(610) settings_layout = QVBoxLayout(self.settings_panel) settings_layout.setContentsMargins(0, 0, 0, 0) settings_layout.setSpacing(10) self.primary = build_primary_actions_group() settings_layout.addWidget(self.primary.group) self.data = build_data_actions_group(gui) self.switches = build_switch_group(config, gui) self.preprocess = build_preprocess_summary_group() self.processing = build_processing_group(config, gui) self.radar = build_radar_group(config) self.data.browse.clicked.connect(lambda: self.browse_save_path(project_root)) self.sections = (self.data, self.switches, self.preprocess, self.processing, self.radar) controls = QWidget() controls_layout = QVBoxLayout(controls) controls_layout.setContentsMargins(0, 0, 12, 0) controls_layout.setSpacing(10) for section in self.sections: controls_layout.addWidget(section.group) controls_layout.addStretch(1) scroll = QScrollArea(self.settings_panel) scroll.setWidgetResizable(True) scroll.setFrameShape(QFrame.Shape.NoFrame) scroll.setWidget(controls) settings_layout.addWidget(scroll, stretch=1) self.status = QLabel("Status: idle") self.status.setObjectName("statusLabel") self._history = QLabel("History: raw=0, preprocessed=0, results=0") self._history.setObjectName("hintLabel") settings_layout.addWidget(self.status) settings_layout.addWidget(self._history) settings_layout.addWidget(log_panel) layout.addWidget(self.settings_panel, stretch=7) parent.resize(1650, 940) def toggle_settings(self) -> None: visible = self.settings_panel.isHidden() self.settings_panel.setVisible(visible) self._toggle.setText(">" if visible else "<") self._toggle.setToolTip("Hide settings panel" if visible else "Show settings panel") def update_history(self, history: HistoryController) -> None: self._history.setText(f"History: raw={len(history.raw)}, preprocessed={len(history.preprocessed)}, " f"results={len(history.results)}") def update_preprocess(self, selected: dict[str, str]) -> None: for key, label in self.preprocess.labels.items(): label.setText(selected.get(key, "") or "") def browse_save_path(self, project_root: Path) -> None: field = self.data.save_path selected = QFileDialog.getExistingDirectory(self._parent, "Select Snapshot Directory", field.text().strip() or str(project_root)) if selected: field.setText(selected)