fix(gui): step8_panel QBrush崩溃修复 + step9_panel step5→step8_panel 回填链路对齐
This commit is contained in:
@ -42,10 +42,11 @@ class Step8Panel(QWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.index_checkboxes: Dict[str, QCheckBox] = {}
|
||||
self.index_checkboxes: Dict[str, QListWidgetItem] = {}
|
||||
self.work_dir: Optional[str] = None
|
||||
self.builtin_formula_path = get_resource_path("waterindex.csv")
|
||||
self._formula_type_map: Dict[str, str] = {}
|
||||
self._formula_color_map: Dict[str, QColor] = {}
|
||||
|
||||
self.init_ui()
|
||||
self._auto_load_formulas()
|
||||
@ -156,11 +157,12 @@ class Step8Panel(QWidget):
|
||||
|
||||
def _on_item_changed(self, item: QListWidgetItem):
|
||||
if item.checkState() == Qt.Checked:
|
||||
color_data = item.data(Qt.UserRole + 1)
|
||||
if isinstance(color_data, QColor):
|
||||
item.setBackground(QBrush(QColor(color_data)))
|
||||
else:
|
||||
item.setBackground(QBrush(self.COLOR_RATIO))
|
||||
bg_color = self.COLOR_RATIO
|
||||
for name, ref_item in self.index_checkboxes.items():
|
||||
if ref_item is item:
|
||||
bg_color = self._formula_color_map.get(name, self.COLOR_RATIO)
|
||||
break
|
||||
item.setBackground(QBrush(bg_color))
|
||||
else:
|
||||
item.setBackground(QBrush(self.COLOR_RATIO))
|
||||
|
||||
@ -203,16 +205,15 @@ class Step8Panel(QWidget):
|
||||
self.formula_list.clear()
|
||||
self.index_checkboxes.clear()
|
||||
|
||||
self._formula_color_map.clear()
|
||||
for name, ftype in self._formula_type_map.items():
|
||||
item = QListWidgetItem(name, self.formula_list)
|
||||
item.setCheckState(Qt.Checked)
|
||||
if ftype == 'concentration':
|
||||
bg_color = QColor(220, 240, 255)
|
||||
item.setData(Qt.UserRole + 1, bg_color)
|
||||
item.setBackground(QBrush(bg_color))
|
||||
else:
|
||||
bg_color = self.COLOR_RATIO
|
||||
item.setData(Qt.UserRole + 1, bg_color)
|
||||
self._formula_color_map[name] = bg_color
|
||||
item.setBackground(QBrush(bg_color))
|
||||
self.index_checkboxes[name] = item
|
||||
|
||||
|
||||
@ -297,23 +297,20 @@ class Step9Panel(QWidget):
|
||||
else:
|
||||
self.work_dir = None
|
||||
|
||||
# 1. 尝试从 Step5 界面读取训练光谱 CSV 路径
|
||||
# 1. 尝试从 Step8 界面读取训练光谱 CSV 路径
|
||||
main_window = self.window()
|
||||
if main_window and hasattr(main_window, 'step5_panel'):
|
||||
step5_widget = getattr(main_window.step5_panel, 'output_file', None)
|
||||
step5_output_path = ""
|
||||
if hasattr(step5_widget, 'get_path'):
|
||||
step5_output_path = step5_widget.get_path() or ""
|
||||
elif hasattr(step5_widget, 'text'):
|
||||
step5_output_path = step5_widget.text() or ""
|
||||
if main_window and hasattr(main_window, 'step8_panel'):
|
||||
step8_widget = main_window.step8_panel.training_data_widget
|
||||
step8_output_path = ""
|
||||
if hasattr(step8_widget, 'get_path'):
|
||||
step8_output_path = step8_widget.get_path() or ""
|
||||
|
||||
if step5_output_path:
|
||||
# 若为相对路径,使用 work_dir 合成为绝对路径
|
||||
if not os.path.isabs(step5_output_path):
|
||||
step5_output_path = os.path.join(self.work_dir or '', step5_output_path).replace('\\', '/')
|
||||
if step8_output_path:
|
||||
if not os.path.isabs(step8_output_path):
|
||||
step8_output_path = os.path.join(self.work_dir or '', step8_output_path).replace('\\', '/')
|
||||
existing = self.csv_file.get_path()
|
||||
if not existing or not existing.strip():
|
||||
self.csv_file.set_path(step5_output_path)
|
||||
self.csv_file.set_path(step8_output_path)
|
||||
|
||||
# 1.5 自动探测并回填 Step 8 双轨输出的 Traditional_Indices 目录
|
||||
if self.work_dir:
|
||||
|
||||
Reference in New Issue
Block a user