refactor(kit): promote the summary-strip edit hint to kit.EDIT_HINT
This commit is contained in:
@@ -11,7 +11,7 @@ from .delegate import ALARM_ROW_ROLE, KIND_ROLE, QUIET_ROLE, STATUS_ROLE, CellKi
|
||||
from .icons import icon_pixmap, tinted_icon
|
||||
from .settings_list import SettingsDelegate, SettingsList
|
||||
from .sidebar import Sidebar, SidebarEntry
|
||||
from .summary_strip import SummaryStrip
|
||||
from .summary_strip import EDIT_HINT, SummaryStrip
|
||||
from .tab_widget import InstrumentTabWidget
|
||||
from .toggle_switch import ToggleSwitch, draw_toggle
|
||||
from .units_header import UnitsHeaderView
|
||||
@@ -20,6 +20,7 @@ __all__ = [
|
||||
"ALARM_ROW_ROLE",
|
||||
"ActivityLogCard",
|
||||
"ConnectionChip",
|
||||
"EDIT_HINT",
|
||||
"KIND_ROLE",
|
||||
"QUIET_ROLE",
|
||||
"STATUS_ROLE",
|
||||
|
||||
@@ -12,6 +12,10 @@ from PySide6.QtWidgets import QFrame, QHBoxLayout, QLabel, QWidget
|
||||
from ..theme import type_styles
|
||||
from ..theme.tokens import Metrics, Space
|
||||
|
||||
# §5.4's right-side edit hint, shared by every editable grid in the suite —
|
||||
# pass to TableTab.enable_summary()/SummaryStrip.set_hint(), don't re-type it.
|
||||
EDIT_HINT = "✎ Click a value to edit · Enter saves · Esc cancels"
|
||||
|
||||
|
||||
class SummaryStrip(QFrame):
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
|
||||
@@ -10,7 +10,7 @@ follows §5.6 (mark_pending on edit/toggle; resolved on the next rebuild echo).
|
||||
from __future__ import annotations
|
||||
|
||||
from cim_suite.core.ui.chrome import message_box
|
||||
from cim_suite.core.ui.kit import STATUS_ROLE, CellKind
|
||||
from cim_suite.core.ui.kit import EDIT_HINT, STATUS_ROLE, CellKind
|
||||
from cim_suite.core.ui.table_tab import TableTab
|
||||
|
||||
_BASE_HEADERS = ["#", "Active", "Local", "Server", "Updated"]
|
||||
@@ -35,7 +35,7 @@ class AlarmTab(TableTab):
|
||||
d.set_column_kind(_LOCAL_COL, CellKind.STATUS)
|
||||
d.set_column_kind(_SERVER_COL, CellKind.STATUS)
|
||||
d.set_column_kind(4, CellKind.NUMERIC) # Updated — time, mono right
|
||||
self.enable_summary("✎ Click a value to edit · Enter saves · Esc cancels")
|
||||
self.enable_summary(EDIT_HINT)
|
||||
self._pending_writes: set[tuple[int, int]] = set()
|
||||
controller.alarmsChanged.connect(self.rebuild)
|
||||
controller.devicesChanged.connect(self.rebuild)
|
||||
|
||||
@@ -17,7 +17,7 @@ from PySide6.QtWidgets import QComboBox, QHBoxLayout, QLabel, QPushButton, QVBox
|
||||
from cim_suite.core.export import Cell, Sheet
|
||||
from cim_suite.core.sensor_models import identify, layout
|
||||
from cim_suite.core.ui.group_band_delegate import GroupBandDelegate
|
||||
from cim_suite.core.ui.kit import ALARM_ROW_ROLE, STATUS_ROLE, CellKind
|
||||
from cim_suite.core.ui.kit import ALARM_ROW_ROLE, EDIT_HINT, STATUS_ROLE, CellKind
|
||||
from cim_suite.core.ui.table_tab import TableTab
|
||||
from cim_suite.core.ui.theme import current, qcolor
|
||||
|
||||
@@ -100,7 +100,7 @@ class ChannelsTab(TableTab):
|
||||
d.set_column_kind(_STATUS_COL, CellKind.STATUS) # §1.2 tag
|
||||
|
||||
self.set_column_units({"Scale": "×", "Offset": "+", "Input": "raw", "Refresh": "s"})
|
||||
self.enable_summary("✎ Click a value to edit · Enter saves · Esc cancels")
|
||||
self.enable_summary(EDIT_HINT)
|
||||
self._pending_writes: set[tuple[int, int]] = set()
|
||||
|
||||
from cim_suite.core.ui.copy_menu import set_extra_actions
|
||||
|
||||
@@ -8,7 +8,7 @@ from cim_suite.core.ui.chrome import message_box
|
||||
from cim_suite.core.ui.combo_delegate import ComboBoxDelegate
|
||||
from cim_suite.core.ui.copy_menu import set_extra_actions
|
||||
from cim_suite.core.ui.help import normalize_label
|
||||
from cim_suite.core.ui.kit import KIND_ROLE, QUIET_ROLE, STATUS_ROLE, CellKind
|
||||
from cim_suite.core.ui.kit import EDIT_HINT, KIND_ROLE, QUIET_ROLE, STATUS_ROLE, CellKind
|
||||
from cim_suite.core.ui.table_tab import TableTab
|
||||
from ..protocol import messages as m
|
||||
|
||||
@@ -63,7 +63,7 @@ class DevicesTab(TableTab):
|
||||
for col in _EDIT_MAP: # Addr / Ctrl / Delay
|
||||
d.set_column_kind(col, CellKind.NUMERIC)
|
||||
d.set_column_kind(_SERIAL_COL, CellKind.IDENTIFIER)
|
||||
self.enable_summary("✎ Click a value to edit · Enter saves · Esc cancels")
|
||||
self.enable_summary(EDIT_HINT)
|
||||
self._pending_writes: set[tuple[int, int]] = set()
|
||||
|
||||
self.rebuild()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from cim_suite.core.sensor_models import identify
|
||||
from cim_suite.core.ui.kit import CellKind
|
||||
from cim_suite.core.ui.kit import CellKind, EDIT_HINT
|
||||
from cim_suite.core.ui.table_tab import TableTab
|
||||
|
||||
HEADERS = ["#", "Serial", "Model", "Name", "Enabled", "Delay", "Lo Alarm", "Lo Warn", "Hi Warn", "Hi Alarm"]
|
||||
@@ -32,7 +32,7 @@ class AlarmLimitsTab(TableTab):
|
||||
for col in (5, 6, 7, 8, 9):
|
||||
self.delegate.set_column_kind(col, CellKind.NUMERIC)
|
||||
self.set_column_units({"Delay": "s"})
|
||||
self.enable_summary("✎ Click a value to edit · Enter saves · Esc cancels")
|
||||
self.enable_summary(EDIT_HINT)
|
||||
self._pending_writes: set[tuple[int, int]] = set()
|
||||
|
||||
from cim_suite.core.ui.copy_menu import set_extra_actions
|
||||
|
||||
@@ -19,7 +19,7 @@ from PySide6.QtWidgets import (
|
||||
from cim_suite.core.sensor_models import identify, layout
|
||||
from cim_suite.core.ui.copy_menu import set_extra_actions
|
||||
from cim_suite.core.ui.group_band_delegate import GroupBandDelegate
|
||||
from cim_suite.core.ui.kit import ALARM_ROW_ROLE, STATUS_ROLE, CellKind
|
||||
from cim_suite.core.ui.kit import ALARM_ROW_ROLE, EDIT_HINT, STATUS_ROLE, CellKind
|
||||
from cim_suite.core.ui.table_tab import TableTab
|
||||
from cim_suite.core.ui.theme import current, qcolor
|
||||
from ..sensor_enums import calc_code, calc_label, calc_labels, disp_code, disp_label, disp_labels
|
||||
@@ -123,7 +123,7 @@ class SensorsTab(TableTab):
|
||||
"Scale": "×", "Offset": "+", "Timestamp": "hh:mm:ss",
|
||||
"Input": "raw", "Refresh": "s",
|
||||
})
|
||||
self.enable_summary("✎ Click a value to edit · Enter saves · Esc cancels")
|
||||
self.enable_summary(EDIT_HINT)
|
||||
self._pending_writes: set[tuple[int, int]] = set()
|
||||
|
||||
controller.sensorsChanged.connect(self.rebuild)
|
||||
|
||||
@@ -33,3 +33,13 @@ def test_hint_is_microcaps(qtbot):
|
||||
qtbot.addWidget(strip)
|
||||
strip.set_hint("✎ Click value to edit · Enter saves · Esc cancels")
|
||||
assert strip._hint.text() == "✎ CLICK VALUE TO EDIT · ENTER SAVES · ESC CANCELS"
|
||||
|
||||
|
||||
def test_edit_hint_is_the_shared_kit_constant(qtbot):
|
||||
from cim_suite.core.ui.kit import EDIT_HINT
|
||||
|
||||
strip = SummaryStrip()
|
||||
qtbot.addWidget(strip)
|
||||
strip.set_hint(EDIT_HINT)
|
||||
assert strip._hint.text() == EDIT_HINT.upper()
|
||||
assert "CLICK A VALUE TO EDIT" in strip._hint.text()
|
||||
|
||||
Reference in New Issue
Block a user