fix(sample_storage widget): rename "Change name..." context-menu action to "Change sample..."
CI for csaxs_bec / test (push) Successful in 1m58s

The action replaces both name and owner and resets the slot's measured
status/account back to "none" -- "change name" undersold what it
actually does. Renamed action_change_name() -> action_change_sample()
to match, and documented the status-reset behavior in its docstring.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Mupip8x7Hean6E3FFvpbj
This commit is contained in:
x01dcandClaude Sonnet 5 committed 2026-09-04 16:55:00 +02:00
1 parent 2086c9e4e6
commit 7dc8de741c
1 file changed
+15 -11
@@ -420,11 +420,11 @@ class _SlotCell(QFrame):
def _show_menu(self, pos) -> None:
menu = QMenu(self)
if self._occupied:
act_rename = menu.addAction("Change name…")
act_rename = menu.addAction("Change sample…")
act_clear = menu.addAction("Clear (set empty)")
chosen = menu.exec_(self.mapToGlobal(pos))
if chosen == act_rename:
self._owner.action_change_name(self._slot, self._name, self._sample_owner)
self._owner.action_change_sample(self._slot, self._name, self._sample_owner)
elif chosen == act_clear:
self._owner.action_clear(self._slot)
else:
@@ -1002,7 +1002,7 @@ class OMNY_SampleStorage(BECWidget, QWidget):
def _write_sample(self, slot, used: int, name: str, owner: str = "") -> bool:
"""Shared write dispatcher used by the sample-cell mutation actions
(action_change_name/action_new_sample/action_clear) for both
(action_change_sample/action_new_sample/action_clear) for both
setups: OMNY keys are tuples (see _SlotCell), FlOMNI keys are
plain ints.
"""
@@ -1210,7 +1210,7 @@ class OMNY_SampleStorage(BECWidget, QWidget):
def _find_duplicate_name(self, slot, name: str):
"""Return the slot key that already holds `name`, if any OTHER
occupied slot of the active setup currently has this exact name, or
None. Used by action_change_name()/action_new_sample() to enforce
None. Used by action_change_sample()/action_new_sample() to enforce
that sample names are unique -- otherwise the measured-sample log
(FlOMNI, keyed by name+owner) and operators reading the storage
overview could no longer tell two same-named samples apart.
@@ -1230,11 +1230,15 @@ class OMNY_SampleStorage(BECWidget, QWidget):
return key
return None
def action_change_name(self, slot, current_name: str, current_owner: str = "") -> None:
"""Rename an occupied slot (stays occupied). Shared by both setups
(see ``_SlotCell``) -- both require a name and an owner (see module
docstring), and both require the name to be unique across the
active setup's slots (see ``_find_duplicate_name``).
def action_change_sample(self, slot, current_name: str, current_owner: str = "") -> None:
"""Replace an occupied slot's sample identity (name + owner), stays
occupied. Named "change sample" rather than "rename" because
_write_sample() resets the slot's measured status/account back to
"none" -- appropriate since a new name+owner means a different
physical sample, not a correction to the existing one's record.
Shared by both setups (see ``_SlotCell``) -- both require a name and
an owner (see module docstring), and both require the name to be
unique across the active setup's slots (see ``_find_duplicate_name``).
"""
name, ok = QInputDialog.getText(
self,
@@ -1279,7 +1283,7 @@ class OMNY_SampleStorage(BECWidget, QWidget):
def action_new_sample(self, slot) -> None:
"""Mark an empty slot occupied and give it a name. Shared by both
setups (see ``action_change_name``), including the uniqueness check.
setups (see ``action_change_sample``), including the uniqueness check.
"""
name, ok = QInputDialog.getText(
self, "New sample", f"Sample name for slot {self._slot_title(slot)}:"
@@ -1313,7 +1317,7 @@ class OMNY_SampleStorage(BECWidget, QWidget):
def action_clear(self, slot) -> None:
"""Mark a slot empty (destructive; confirmed). Shared by both
setups (see ``action_change_name``).
setups (see ``action_change_sample``).
"""
reply = QMessageBox.question(
self,