在单位回退时就近提示缺少可用标定
让实时和回放的原始单位回退原因出现在力曲线单位按钮旁。相关定向测试与 lint gate 通过。
This commit is contained in:
@@ -152,6 +152,7 @@ class AcquirePresenter(QObject):
|
||||
if not self._host.session.raw_fallback_notified:
|
||||
self._host.session.raw_fallback_notified = True
|
||||
self._host.notify(t("status.units_raw_fallback"))
|
||||
self._charts.show_unit_fallback()
|
||||
else:
|
||||
self._host.session.raw_fallback_notified = False
|
||||
self._host.session.last_sample_valid = True
|
||||
|
||||
@@ -1411,6 +1411,7 @@ class ReplayController(QObject):
|
||||
self._host.set_display_unit(unit)
|
||||
if unit != wanted:
|
||||
self._host.notify(t("status.units_raw_fallback"))
|
||||
self._charts.show_unit_fallback()
|
||||
self._charts.show_all()
|
||||
self._image_panel.set_source_kind("replay")
|
||||
return
|
||||
@@ -1483,6 +1484,7 @@ class ReplayController(QObject):
|
||||
wanted = "N" if self._charts.unit() == "N" else "raw"
|
||||
if wanted == "N" and not source.unit_available("N"):
|
||||
self._host.notify(t("status.units_raw_fallback"))
|
||||
self._charts.show_unit_fallback()
|
||||
return "raw"
|
||||
return wanted
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ from orisys_app_shared.force.source import StoreCurveSource
|
||||
from orisys_app_shared.i18n import t
|
||||
from orisys_app_shared.record.sample import plottable_axis_mask
|
||||
from orisys_app_shared.theme import color
|
||||
from PySide6.QtCore import QSize, Qt, Signal
|
||||
from PySide6.QtCore import QSize, Qt, QTimer, Signal
|
||||
from PySide6.QtGui import QColor, QFont, QFontDatabase, QFontMetrics
|
||||
from PySide6.QtWidgets import (
|
||||
QFrame,
|
||||
@@ -252,6 +252,13 @@ class ForcePlotsPanel(QFrame):
|
||||
self.btn_settings = self._header_button("settings")
|
||||
self.btn_settings.clicked.connect(self.plot_settings_requested.emit)
|
||||
header.addWidget(self.btn_settings)
|
||||
self.unit_notice = QLabel()
|
||||
self.unit_notice.setObjectName("hintText")
|
||||
self.unit_notice.hide()
|
||||
header.addWidget(self.unit_notice)
|
||||
self._unit_notice_timer = QTimer(self)
|
||||
self._unit_notice_timer.setSingleShot(True)
|
||||
self._unit_notice_timer.timeout.connect(self.unit_notice.hide)
|
||||
# The unit chip is a button: switching between newton and raw is a chart
|
||||
# concern, so it lives on the chart.
|
||||
self.unit_badge = QPushButton()
|
||||
@@ -733,6 +740,12 @@ class ForcePlotsPanel(QFrame):
|
||||
self._last_overview_at = now
|
||||
self._sync_overview()
|
||||
|
||||
def show_unit_fallback(self) -> None:
|
||||
"""Explain a failed Newton switch beside the unit control."""
|
||||
self.unit_notice.setText(t("status.units_raw_fallback"))
|
||||
self.unit_notice.show()
|
||||
self._unit_notice_timer.start(6000)
|
||||
|
||||
def set_units(self, unit: str) -> None:
|
||||
"""Switch display units without mixing units in the curve buffer.
|
||||
|
||||
@@ -742,6 +755,9 @@ class ForcePlotsPanel(QFrame):
|
||||
cleared rather than reinterpreted.
|
||||
"""
|
||||
unit = "N" if str(unit).upper().startswith("N") else "raw"
|
||||
if unit == "N":
|
||||
self._unit_notice_timer.stop()
|
||||
self.unit_notice.hide()
|
||||
if unit == self._unit:
|
||||
return
|
||||
self._unit = unit
|
||||
@@ -1450,6 +1466,7 @@ class ForcePlotsPanel(QFrame):
|
||||
self.btn_settings.setAccessibleName(t("chart.settings"))
|
||||
self.unit_badge.setToolTip(t("chart.unit_toggle_tip"))
|
||||
self.unit_badge.setAccessibleName(t("chart.unit_toggle"))
|
||||
self.unit_notice.setText(t("status.units_raw_fallback"))
|
||||
self.window_caption.setText(t("chart.overview"))
|
||||
self.window_caption.setToolTip(t("chart.window_tip"))
|
||||
self._refresh_mode_label()
|
||||
|
||||
Reference in New Issue
Block a user