From d70cac45bf910d644601102170345ba130d47c89 Mon Sep 17 00:00:00 2001 From: Dawn Date: Thu, 17 Sep 2026 12:52:11 +0200 Subject: [PATCH] fix(gui): keep the file-name preview in the plain theme color Dawn: the red "file exists" tint on the path label reads as an error across the whole panel. The Run guard's popup already reports a clash, so the label stays in the standard text color. The popup now also asks the user to run the data collection again after the run number bump. Co-Authored-By: Claude Fable 5.1 --- src/aare/gui/panels/file_path_panel.py | 11 ++++------- tests/unit/gui/test_data_collection_settings.py | 9 +++------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/aare/gui/panels/file_path_panel.py b/src/aare/gui/panels/file_path_panel.py index f897c9b7..f6ede787 100644 --- a/src/aare/gui/panels/file_path_panel.py +++ b/src/aare/gui/panels/file_path_panel.py @@ -7,7 +7,6 @@ from aarecommon.models.models import DAQStatusModel, SampleShortInfo from PySide6.QtCore import Qt, Signal, Slot from PySide6.QtWidgets import QGridLayout, QLabel, QLineEdit, QMessageBox, QSpinBox, QWidget -from aare.gui.styles import PATH_WARN_TEXT from aare.gui.widgets.title_label import TitleLabel ## Logic for filenames: @@ -165,13 +164,11 @@ class FilePathPanel(QWidget): # Store the GUI’s base (without applying scan-kind transforms) for wiring into requests later self._filename = self._expand_macros(base, run_number) - # Preview label shows the effective path (what will be written) + # Preview label shows the effective path (what will be written), in the + # plain theme color: a clash is reported by the Run guard's popup, not + # by a red label. effective = self._effective_dataset_base(self._filename) - exists = self._exists_for_run(self._filename) self.file_name_label.setText(effective + "_master.h5") - # Empty stylesheet = reset to the THEME text color (a hardcoded - # "default" black would be invisible on the dark theme). - self.file_name_label.setStyleSheet(f"color: {PATH_WARN_TEXT};" if exists else "") self.path_updated.emit(self._filename) @Slot() @@ -257,6 +254,6 @@ class FilePathPanel(QWidget): self, "File exists", f"File already exists:\n{path}\n\n" - f"Run number increased to {self.run_number_edit.value()}.", + f"Run number increased to {self.run_number_edit.value()}. Please run data collection again.", ) return False diff --git a/tests/unit/gui/test_data_collection_settings.py b/tests/unit/gui/test_data_collection_settings.py index 1308b9a9..252566c5 100644 --- a/tests/unit/gui/test_data_collection_settings.py +++ b/tests/unit/gui/test_data_collection_settings.py @@ -518,11 +518,9 @@ def test_run_is_blocked_with_a_popup_when_the_file_exists(file_panel, monkeypatc boxes = [] monkeypatch.setattr(QMessageBox, "warning", lambda *a, **k: boxes.append(a)) - # Editing never skips a taken run silently: the name stays literal and - # the label only turns red. + # Editing never skips a taken run silently: the name stays literal. file_panel.set_scan_kind("rotation") assert file_panel.run_number_edit.value() == 1 - assert file_panel.file_name_label.styleSheet() != "" assert file_panel.file_path_error_box(scan_kind="rotation") is False assert len(boxes) == 1 @@ -555,11 +553,10 @@ def test_a_derived_dataset_counts_as_taken(file_panel, monkeypatch): def test_a_directory_or_a_sibling_run_is_not_taken(file_panel, monkeypatch): - # Only the exact master files count; anything else would paint runs red - # that nothing will write. + # Only the exact master files count; anything else would block runs that + # nothing will write. _taken(monkeypatch, "raster/d/x_001", "raster/d/x_0011_master.h5", "raster/d/x_001_data.h5") file_panel.set_scan_kind("raster") - assert file_panel.file_name_label.styleSheet() == "" assert file_panel.file_path_error_box(scan_kind="raster") is True