add(系统诊断: 设备检测和系统检测、dals中数据库路径)

This commit is contained in:
2026-01-13 18:31:54 +08:00
parent 29c459e0f2
commit 360cb13b73
5 changed files with 193 additions and 67 deletions

View File

@ -173,13 +173,13 @@ class CustomDropdown(QWidget):
for i in range(self.list_widget.count()):
self.list_widget.item(i).setFont(font)
# 获取当前选中的设备名
def get_selected_device(self):
# 获取当前选中的检测框的名称
def get_selected_name(self):
return self.result_label.text()
# 设置选中的设备名
def set_selected_device(self, device_name:str):
self.result_label.setText(device_name)
# 设置当前选中的检测框的名称
def set_selected_name(self, name:str):
self.result_label.setText(name)
class SystemDiagnosticsDialog(QDialog):
def __init__(self, parent=None):
@ -204,8 +204,9 @@ class SystemDiagnosticsDialog(QDialog):
self.setFixedSize(self.bg_pixmap.size())
# 网格布局8行4列小框
grid_layout = QGridLayout(self)
grid_layout.setContentsMargins(24, 28, 20, 24)
self.grid_layout = QGridLayout(self)
self.grid_layout.setContentsMargins(28, 28, 20, 24)
self.grid_layout.setAlignment(Qt.AlignLeft | Qt.AlignTop)
# 图片路径(替换为实际路径)
box_image_path = ImagePaths.SYSTEM_DIAGNOSTICS_BOX
@ -225,6 +226,7 @@ class SystemDiagnosticsDialog(QDialog):
for col in range(self.max_col):
box_container = QWidget()
box_container.setObjectName(f"box_{row}_{col}")
box_container.setFixedSize(156, 50)
box_container.setStyleSheet(
f"""
background-image: url("{box_image_path}");
@ -247,7 +249,7 @@ class SystemDiagnosticsDialog(QDialog):
# ========== 自定义下拉框(支持获取设备名) ==========
led_dropdown = CustomDropdown(
options=["LED1", "LED2", "LED3"], arrow_img_path=dropdown_arrow_path
options=["----", "LED1", "LED2", "LED3"], arrow_img_path=dropdown_arrow_path
)
# ========== 秒数输入框(获取毫秒值) ==========
@ -290,7 +292,10 @@ class SystemDiagnosticsDialog(QDialog):
# box_layout.addItem(spacer3)
box_layout.addWidget(ms_container)
grid_layout.addWidget(box_container, row, col)
self.grid_layout.addWidget(box_container, row, col)
# 初始状态为隐藏
box_container.hide()
def paintEvent(self, event):
"""重写绘制事件,手动在透明背景上绘制图片"""
@ -318,7 +323,7 @@ class SystemDiagnosticsDialog(QDialog):
"""获取指定行列的选中设备名, 行号和列号都从0开始"""
box = self.findChild(QWidget, f"box_{row}_{col}")
if box and hasattr(box, "dropdown"):
return box.dropdown.get_selected_device()
return box.dropdown.get_selected_name()
return None
# ========== 对外接口:设置选中的设备名 ==========
@ -326,7 +331,14 @@ class SystemDiagnosticsDialog(QDialog):
"""设置指定行列的选中设备名, 行号和列号都从0开始"""
box = self.findChild(QWidget, f"box_{row}_{col}")
if box and hasattr(box, "dropdown"):
return box.dropdown.set_selected_device(device_name)
box.dropdown.set_selected_name(device_name)
# ========== 对外接口:设置选中的服务名 ==========
def set_selected_service(self, row, col, service_name:str):
"""设置指定行列的选中服务名, 行号和列号都从0开始"""
box = self.findChild(QWidget, f"box_{row}_{col}")
if box and hasattr(box, "dropdown"):
box.dropdown.set_selected_name(service_name)
# ========== 对外接口:获取毫秒值 ==========
def get_ms_value(self, row, col):
@ -351,6 +363,20 @@ class SystemDiagnosticsDialog(QDialog):
if box and hasattr(box, "ms_edit"):
box.ms_edit.setText(f"{ms}ms")
# ========== 对外接口:设置显示检测组件 ==========
def set_selected_show(self, row, col):
"""设置指定行列的检测组件显示"""
box = self.findChild(QWidget, f"box_{row}_{col}")
if box and box.isHidden():
box.show()
self.grid_layout.update()
# ========== 对外接口:设置隐藏检测组件 ==========
def set_selected_hide(self, row, col):
"""设置指定行列的检测组件隐藏"""
box = self.findChild(QWidget, f"box_{row}_{col}")
if box and box.isVisible():
box.hide()
if __name__ == "__main__":
app = QApplication(sys.argv)