AIDeveloper-PC/gui_ai_developer/dialogs/module_detail_dialog.py

168 lines
5.0 KiB
Python
Raw Permalink Normal View History

2026-01-31 09:32:00 +00:00
"""
模块详情对话框
"""
from PyQt5.QtWidgets import (
QDialog, QVBoxLayout, QHBoxLayout, QLabel,
QPushButton, QProgressBar, QGroupBox
)
from PyQt5.QtCore import Qt
class ModuleDetailDialog(QDialog):
"""模块详情对话框"""
def __init__(self, module, parent=None):
"""
初始化对话框
Args:
module: 模块对象
parent: 父窗口
"""
super().__init__(parent)
self.module = module
self._setup_ui()
def _setup_ui(self):
"""设置UI"""
self.setWindowTitle(f"模块详情 - {self.module.name}")
self.resize(600, 500)
layout = QVBoxLayout(self)
layout.setSpacing(20)
# 模块标题
title_label = QLabel(f"<h2>{self.module.icon} {self.module.name}</h2>")
layout.addWidget(title_label)
# 基本信息组
basic_group = self._create_basic_info_group()
layout.addWidget(basic_group)
# 关联需求组
req_group = self._create_requirements_group()
layout.addWidget(req_group)
# 技术栈组
tech_group = self._create_tech_stack_group()
layout.addWidget(tech_group)
# 开发进度组
progress_group = self._create_progress_group()
layout.addWidget(progress_group)
layout.addStretch()
# 关闭按钮
button_layout = QHBoxLayout()
button_layout.addStretch()
close_btn = QPushButton("关闭")
close_btn.setMinimumWidth(100)
close_btn.clicked.connect(self.accept)
button_layout.addWidget(close_btn)
layout.addLayout(button_layout)
def _create_basic_info_group(self) -> QGroupBox:
"""创建基本信息组"""
group = QGroupBox("基本信息")
layout = QVBoxLayout(group)
# 描述
desc_label = QLabel(f"<b>描述:</b><br>{self.module.description}")
desc_label.setWordWrap(True)
desc_label.setStyleSheet("color: #e0e6ed; padding: 5px;")
layout.addWidget(desc_label)
return group
def _create_requirements_group(self) -> QGroupBox:
"""创建关联需求组"""
group = QGroupBox("关联需求")
layout = QVBoxLayout(group)
if self.module.requirements:
req_layout = QHBoxLayout()
req_layout.setSpacing(8)
for req_id in self.module.requirements:
req_label = QLabel(req_id)
req_label.setStyleSheet("""
background: #3b82f633;
color: #3b82f6;
border: 1px solid #3b82f6;
border-radius: 4px;
padding: 4px 10px;
font-size: 12px;
""")
req_layout.addWidget(req_label)
req_layout.addStretch()
layout.addLayout(req_layout)
else:
no_req_label = QLabel("暂无关联需求")
no_req_label.setStyleSheet("color: #94a3b8;")
layout.addWidget(no_req_label)
return group
def _create_tech_stack_group(self) -> QGroupBox:
"""创建技术栈组"""
group = QGroupBox("技术栈")
layout = QVBoxLayout(group)
if self.module.tech_stack:
tech_layout = QHBoxLayout()
tech_layout.setSpacing(8)
for tech in self.module.tech_stack:
tech_label = QLabel(tech)
tech_label.setStyleSheet("""
background: rgba(100, 116, 139, 0.3);
color: #94a3b8;
border: 1px solid rgba(100, 116, 139, 0.5);
border-radius: 4px;
padding: 4px 10px;
font-size: 12px;
""")
tech_layout.addWidget(tech_label)
tech_layout.addStretch()
layout.addLayout(tech_layout)
else:
no_tech_label = QLabel("暂无技术栈信息")
no_tech_label.setStyleSheet("color: #94a3b8;")
layout.addWidget(no_tech_label)
return group
def _create_progress_group(self) -> QGroupBox:
"""创建开发进度组"""
group = QGroupBox("开发进度")
layout = QVBoxLayout(group)
# 进度条
progress = QProgressBar()
progress.setValue(self.module.progress)
progress.setTextVisible(True)
progress.setFormat(f"{self.module.progress}%")
layout.addWidget(progress)
# 状态说明
if self.module.progress == 0:
status_text = "尚未开始"
status_color = "#94a3b8"
elif self.module.progress < 100:
status_text = "开发中"
status_color = "#3b82f6"
else:
status_text = "已完成"
status_color = "#10b981"
status_label = QLabel(f"状态: {status_text}")
status_label.setStyleSheet(f"color: {status_color}; font-weight: bold;")
layout.addWidget(status_label)
return group