系统诊断增加设备检测
This commit is contained in:
@ -172,13 +172,20 @@ class CameraModule(QWidget):
|
||||
video_display_signal = Signal(str, bool)
|
||||
|
||||
def __init__(
|
||||
self, camera_name="摄像头", rtsp_url="", need_rotate_180=True, parent=None
|
||||
self, camera_name="摄像头", rtsp_url="", need_rotate_180=True, show_ai = False, parent=None
|
||||
):
|
||||
super().__init__(parent)
|
||||
self.setObjectName("cameraModule")
|
||||
self.camera_name = camera_name
|
||||
self.rtsp_url = rtsp_url
|
||||
self.need_rotate_180 = need_rotate_180 # 画面是否需要旋转180度后显示
|
||||
self.show_ai = show_ai # 是否需要展示ai(为True会多出AI显示按钮)
|
||||
|
||||
# 初始化AI显示相关变量为None
|
||||
self.ai_display_group = None
|
||||
self.ai_display_label = None
|
||||
self.ai_display_switch = None
|
||||
|
||||
self.setup_ui()
|
||||
|
||||
def setup_ui(self):
|
||||
@ -195,20 +202,23 @@ class CameraModule(QWidget):
|
||||
self.title_label = QLabel()
|
||||
self.title_label.setAlignment(Qt.AlignLeft)
|
||||
self.title_label.setText(f"{self.camera_name}视频")
|
||||
# self.title_label.setFixedWidth(212)
|
||||
self.title_label.setFixedSize(212, 21)
|
||||
self.title_label.setObjectName("cameraTitleLabel")
|
||||
# background-image: url({ImagePaths.VIDEO_TITLE_BACKGROUND});
|
||||
# min-width: 126px;
|
||||
self.title_label.setStyleSheet(
|
||||
f"""
|
||||
#cameraTitleLabel {{
|
||||
font-size: 18px;
|
||||
color: #16ffff;
|
||||
background-image: url({ImagePaths.VIDEO_TITLE_BACKGROUND});
|
||||
min-width: 180px;
|
||||
padding-left: 12px;
|
||||
}}
|
||||
"""
|
||||
)
|
||||
|
||||
# 创建【显示标签+开关】组合容器
|
||||
# 1、创建【显示标签+开关】组合容器
|
||||
self.display_group = QWidget() # 容器:包裹标签和开关
|
||||
display_group_layout = QHBoxLayout(self.display_group)
|
||||
display_group_layout.setContentsMargins(0, 0, 0, 0) # 容器内边距为0
|
||||
@ -239,9 +249,43 @@ class CameraModule(QWidget):
|
||||
display_group_layout.addWidget(self.display_label)
|
||||
display_group_layout.addWidget(self.display_switch, alignment=Qt.AlignLeft)
|
||||
|
||||
if self.show_ai: # 当需要显示AI时才生成
|
||||
# 2、创建【AI算法标签+开关】组合容器
|
||||
self.ai_display_group = QWidget() # 容器:包裹AI显示标签和开关
|
||||
ai_display_group_layout = QHBoxLayout(self.ai_display_group)
|
||||
ai_display_group_layout.setContentsMargins(0, 0, 0, 0) # 容器内边距为0
|
||||
ai_display_group_layout.setSpacing(0)
|
||||
|
||||
# AI算法显示标签
|
||||
self.ai_display_label = QLabel("AI算法")
|
||||
self.ai_display_label.setObjectName("aiDisplayLabel")
|
||||
# font-weight: bold;
|
||||
self.ai_display_label.setStyleSheet("""
|
||||
#aiDisplayLabel {
|
||||
font-size: 18px;
|
||||
color: #16ffff;
|
||||
margin: 0px;
|
||||
padding-left: 2px;
|
||||
}
|
||||
""")
|
||||
# self.ai_display_label.setFixedWidth(40)
|
||||
self.ai_display_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
|
||||
|
||||
# AI开关
|
||||
self.ai_display_switch = SwitchButton()
|
||||
self.ai_display_switch.setChecked(False)
|
||||
# self.ai_display_switch.switched.connect(self.onDisplayButtonSwitched) # 在camera_controller中处理
|
||||
|
||||
# 将AI显示标签和开关添加到组合容器布局
|
||||
ai_display_group_layout.addWidget(self.ai_display_label)
|
||||
ai_display_group_layout.addWidget(self.ai_display_switch, alignment=Qt.AlignLeft)
|
||||
|
||||
# 添加到标题布局
|
||||
title_layout.addWidget(self.title_label, alignment=Qt.AlignLeft)
|
||||
title_layout.addWidget(self.display_group, alignment=Qt.AlignLeft)
|
||||
title_layout.addWidget(self.display_group, alignment=Qt.AlignRight)
|
||||
if self.show_ai: # 需要添加 AI显示控件
|
||||
title_layout.addWidget(self.ai_display_group, alignment=Qt.AlignLeft)
|
||||
self.title_label.setFixedSize(139, 21) # 调整 xxx视频标签的宽度
|
||||
|
||||
# 视频显示容器:使用堆叠布局,让重连按钮和视频标签分层显示
|
||||
self.video_container = QWidget()
|
||||
@ -313,7 +357,7 @@ class CameraModule(QWidget):
|
||||
|
||||
# 显示开关切换槽函数
|
||||
def onDisplayButtonSwitched(self, state:bool):
|
||||
# 显示开关打开,state 为 True,显示开关关闭,state 为 False
|
||||
# 显示开关打开,state 为 True; 显示开关关闭,state 为 False
|
||||
if state:
|
||||
self.stacked_widget.setCurrentWidget(self.raw_label) # 视频显示标签
|
||||
self.stacked_widget.setHidden(False)
|
||||
@ -403,8 +447,8 @@ class VibrationVideoWidget(QWidget):
|
||||
# 需要修改为相应的地址!!!
|
||||
# 注:在camera_controller中设置地址url
|
||||
self.cam1 = CameraModule("上位料斗")
|
||||
self.cam2 = CameraModule("下位料斗")
|
||||
self.cam3 = CameraModule("模具车")
|
||||
self.cam2 = CameraModule("下位料斗", show_ai=False)
|
||||
self.cam3 = CameraModule("模具车", need_rotate_180=False)
|
||||
|
||||
self.setup_ui()
|
||||
self.connect_signals()
|
||||
|
||||
Reference in New Issue
Block a user