From 22228c0868d7276a0e8aa1da8cba2a93024b76de Mon Sep 17 00:00:00 2001 From: Dawn Date: Wed, 9 Sep 2026 15:28:30 +0200 Subject: [PATCH] feat: highlight whole mounted row in sample list The mounted sample used to tint only the frozen "#" cell. Paint the full row in the same blue so it is findable at a glance, and keep the theme's own text color on it (the mid-tone blue reads fine without the dark ink that the pastel status tints need). Repaint the whole row span on mount/unmount, not just column 0. Co-Authored-By: Claude Fable 5.1 --- src/aare/gui/models/user_sample_model.py | 23 ++++++++++++++++------- tests/unit/gui/test_models.py | 15 +++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/aare/gui/models/user_sample_model.py b/src/aare/gui/models/user_sample_model.py index 78699887..4fbd7b30 100644 --- a/src/aare/gui/models/user_sample_model.py +++ b/src/aare/gui/models/user_sample_model.py @@ -139,17 +139,25 @@ class UserSampleSpreadsheet(QAbstractTableModel): elif role == Qt.ItemDataRole.BackgroundRole: # Status lives in the "#" column, as a full cell fill under the # row number — rows themselves alternate grey/white (view-level) - # and selection stays the pale blue tint. + # and selection stays the pale blue tint. Exception: the mounted + # sample paints the WHOLE row blue so it is findable at a glance. + sample = self._sorted_samples[index.row()] + if sample.db_id == self.current_sample: + return QBrush(qcolor(SAMPLE_ROW_QUEUED_BG)) if index.column() == COL_STATUS: - color = self._status_color(self._sorted_samples[index.row()]) + color = self._status_color(sample) if color is not None: return QBrush(qcolor(color)) elif role == Qt.ItemDataRole.ForegroundRole: - # Tinted cells get fixed dark ink: the tints stay light pastel in - # BOTH themes, so Sunset's white theme text would vanish on them. + # Pastel-tinted "#" cells get fixed dark ink: the tints stay light + # in BOTH themes, so Sunset's white theme text would vanish on + # them. The mounted-row blue is mid-tone and readable with the + # theme's own text color, so it keeps the default ink. + sample = self._sorted_samples[index.row()] if ( index.column() == COL_STATUS - and self._status_color(self._sorted_samples[index.row()]) is not None + and sample.db_id != self.current_sample + and self._status_color(sample) is not None ): return QBrush(qcolor(SAMPLE_STATUS_TEXT)) elif role == Qt.ItemDataRole.TextAlignmentRole: # Align text to center @@ -220,10 +228,11 @@ class UserSampleSpreadsheet(QAbstractTableModel): def _emit_tints_changed(self) -> None: if self.rowCount() > 0: + # Whole span: the mounted row tints every column, not just "#". self.dataChanged.emit( self.index(0, COL_STATUS), - self.index(self.rowCount() - 1, COL_STATUS), - [Qt.ItemDataRole.BackgroundRole], + self.index(self.rowCount() - 1, self.columnCount() - 1), + [Qt.ItemDataRole.BackgroundRole, Qt.ItemDataRole.ForegroundRole], ) def headerData(self, section, orientation, role=None): diff --git a/tests/unit/gui/test_models.py b/tests/unit/gui/test_models.py index e36b10df..58868d6a 100644 --- a/tests/unit/gui/test_models.py +++ b/tests/unit/gui/test_models.py @@ -265,6 +265,21 @@ def test_mime_data_round_trips_for_chip_drops(status_model): assert samples.s[0].db_id == model.get_id(0).db_id +def test_mounted_row_is_blue_across_all_columns(status_model): + # Whole-row blue (not just "#") so the mounted sample is findable at a + # glance; the blue keeps the theme's own ink (no dark override). + model = status_model + model.updateCurrentSample(current_puck="P1", current_sample=1) + row = _row_of(model, 1) + for col in range(model.columnCount()): + brush = model.data(model.index(row, col), Qt.ItemDataRole.BackgroundRole) + assert brush.color().name().lower() == "#729fcf" + assert model.data(model.index(row, col), Qt.ItemDataRole.ForegroundRole) is None + # Other rows: still "#"-only tint, other columns untouched. + other = _row_of(model, 2) + assert model.data(model.index(other, 1), Qt.ItemDataRole.BackgroundRole) is None + + def test_spreadsheet_param_columns(status_model): from aarecommon.models.models import DataCollectionParameters