style: fix lint for the banner/adaptive changes

- ruff format and import ordering (main_window, data_collection_settings,
  beam_center_panel, beamline_state_panel)
- rename unused unpacked variable in test_title_label
- replace the mousePressEvent monkeypatch on the beamline state title
  with a proper eventFilter so basedpyright accepts the diff

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-11 10:35:46 +02:00
co-authored by Claude Fable 5
parent a9137b3221
commit ce0ed20d5a
5 changed files with 19 additions and 16 deletions
+2 -6
View File
@@ -85,9 +85,9 @@ from aare.gui.widgets.baton_request_dialog import BatonPendingDialog, BatonReque
from aare.gui.widgets.busy_overlay import build_busy_overlay_style
from aare.gui.widgets.camera_image import SampleCameraImageLabel
from aare.gui.widgets.message_box import precondition_check
from aare.gui.widgets.title_label import tighten_column
from aare.gui.widgets.no_wheel_scroll_area import NoWheelScrollArea
from aare.gui.widgets.status_bar import StatusBar
from aare.gui.widgets.title_label import tighten_column
from aare.gui.widgets.video_image import VideoGraphicsView
logger = setup_logger(LOGGER_NAME)
@@ -543,11 +543,7 @@ class MainWindow(QMainWindow):
def _only_current_page_counts(index: int) -> None:
for i in range(self.content_stack.count()):
page = self.content_stack.widget(i)
policy = (
QSizePolicy.Policy.Preferred
if i == index
else QSizePolicy.Policy.Ignored
)
policy = QSizePolicy.Policy.Preferred if i == index else QSizePolicy.Policy.Ignored
page.setSizePolicy(policy, policy)
self.content_stack.currentChanged.connect(_only_current_page_counts)
+3 -1
View File
@@ -14,7 +14,9 @@ class BeamCenterWidget(QWidget):
grid_layout = QGridLayout(self)
grid_layout.addWidget(TitleLabel("Beam center (detector)", self, collapsible=True), 0, 0, 1, 5)
grid_layout.addWidget(
TitleLabel("Beam center (detector)", self, collapsible=True), 0, 0, 1, 5
)
self.x = NumberLineEdit(-4000, 4000, 0, parent=self)
self.x.newValue.connect(self.beam_center_edited)
+11 -6
View File
@@ -2,7 +2,7 @@ from collections import deque
from dataclasses import dataclass
from aarecommon.models.models import BeamlineStateEnum, DAQStatusModel
from PySide6.QtCore import QPoint, QRect, Qt, Signal, Slot
from PySide6.QtCore import QEvent, QObject, QPoint, QRect, Qt, Signal, Slot
from PySide6.QtGui import QColor, QPainter, QPen
from PySide6.QtWidgets import QFrame, QLabel, QPushButton
@@ -219,17 +219,16 @@ class BeamlineStatePanel(QFrame):
self.title.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.title.setFixedHeight(self.title_height)
self.title.setGeometry(0, PANEL_VMARGIN, self.set_width, self.title_height)
# Whole banner toggles, like TitleLabel; the +/ glyph is the indicator.
# Whole banner toggles via eventFilter, like TitleLabel; the +/- glyph
# is only the indicator.
self.title.setCursor(Qt.CursorShape.PointingHandCursor)
self.title.mousePressEvent = lambda _event: self.toggle_collapsed()
self.title.installEventFilter(self)
self.toggle_button = QPushButton("", self)
self.toggle_button.setObjectName("beamlineStateToggleButton")
self.toggle_button.setToolTip("Minimise beamline state panel")
self.toggle_button.setFixedSize(21, 21)
self.toggle_button.move(
self.set_width - 29, PANEL_VMARGIN + (self.title_height - 21) // 2
)
self.toggle_button.move(self.set_width - 29, PANEL_VMARGIN + (self.title_height - 21) // 2)
self.toggle_button.clicked.connect(self.toggle_collapsed)
self.current_label = QLabel("Current: —", self)
@@ -355,6 +354,12 @@ class BeamlineStatePanel(QFrame):
self._apply_station_highlight()
def eventFilter(self, watched: QObject, event: QEvent) -> bool:
if watched is self.title and event.type() == QEvent.Type.MouseButtonPress:
self.toggle_collapsed()
return True
return super().eventFilter(watched, event)
def toggle_collapsed(self) -> None:
self._is_collapsed = not self._is_collapsed
self._update_collapsed_state()
@@ -5,13 +5,13 @@ from PySide6.QtCore import Signal, Slot
from PySide6.QtWidgets import QFrame, QPushButton, QTabWidget, QVBoxLayout, QWidget
from aare.gui.panels.file_path_panel import FilePathPanel
from aare.gui.panels.manual_sample_panel import ManualSamplePanel
from aare.gui.widgets.title_label import TitleLabel, tighten_column
from aare.gui.panels.fluorescence_data_collection import FluorescenceDataCollectionPanel
from aare.gui.panels.manual_sample_panel import ManualSamplePanel
from aare.gui.panels.raster_data_collection import RasterDataCollectionPanel
from aare.gui.panels.rotation_data_collection import RotationDataCollectionPanel
from aare.gui.panels.smart_rotation_panel import SimpleRotationSettingsPanel
from aare.gui.scan_logic.raster_grid_manager import RasterGridManager
from aare.gui.widgets.title_label import TitleLabel, tighten_column
class DataCollectionSettings(QFrame):
+1 -1
View File
@@ -53,7 +53,7 @@ def test_toggle_hides_children_and_persists(qtbot):
def test_collapsed_state_restored_on_construction(qtbot):
QSettings("PSI", "AareGUI").setValue(KEY, True)
try:
panel, title, direct_child, nested_child = _build_panel(qtbot)
_panel, title, direct_child, nested_child = _build_panel(qtbot)
# Restore is deferred with a 0 ms timer (siblings don't exist yet at
# TitleLabel construction), so let the event loop run once.
qtbot.waitUntil(lambda: direct_child.isHidden(), timeout=1000)