2025-02-09 23:22:48 +08:00
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
2025-02-11 00:04:32 +08:00
|
|
|
|
from .. import config
|
|
|
|
|
|
|
|
|
|
QtCore, QtGui, QtWidgets, wrapInstance = config.Qt()
|
|
|
|
|
|
|
|
|
|
if QtCore is None or QtGui is None or QtWidgets is None or wrapInstance is None:
|
|
|
|
|
print(f"Qt加载失败: {QtCore}, {QtGui}, {QtWidgets}, {wrapInstance}")
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
|
|
|
|
class ToolShelf(QtWidgets.QWidget):
|
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
|
super(ToolShelf, self).__init__(parent)
|
|
|
|
|
self._setup_ui()
|
|
|
|
|
self._create_connections()
|
|
|
|
|
|
|
|
|
|
def _setup_ui(self):
|
|
|
|
|
"""设置UI布局"""
|
|
|
|
|
# === Main Layout ===
|
|
|
|
|
self.main_layout = QtWidgets.QHBoxLayout(self)
|
|
|
|
|
self.main_layout.setContentsMargins(2, 2, 2, 2)
|
|
|
|
|
self.main_layout.setSpacing(4)
|
|
|
|
|
|
|
|
|
|
# 创建工具按钮
|
|
|
|
|
self.tool_buttons = {}
|
|
|
|
|
self._create_tool_buttons()
|
|
|
|
|
|
|
|
|
|
def _create_tool_buttons(self):
|
|
|
|
|
"""创建工具按钮"""
|
|
|
|
|
# === 工具按钮配置 ===
|
|
|
|
|
tools = [
|
|
|
|
|
("save_dna", "保存 DNA", "save.png"),
|
|
|
|
|
("load_dna", "加载当前项目 DNA", "open.png"),
|
|
|
|
|
None, # 分隔符
|
|
|
|
|
("create_rl4", "创建RL4节点", "connect.png"),
|
|
|
|
|
("delete_rl4", "删除RL4节点", "disconnect.png"),
|
|
|
|
|
None,
|
|
|
|
|
("export_skin", "导出蒙皮", "export_skin.png"),
|
|
|
|
|
("import_skin", "导入蒙皮", "import_skin.png"),
|
|
|
|
|
("copy_skin", "复制蒙皮", "copy_skin.png"),
|
|
|
|
|
None,
|
|
|
|
|
("help", "帮助文档", "help.png"),
|
|
|
|
|
("about", "关于", "about.png")
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# === 创建按钮 ===
|
|
|
|
|
for tool in tools:
|
|
|
|
|
if tool is None:
|
|
|
|
|
# 添加分隔符
|
|
|
|
|
separator = QtWidgets.QFrame()
|
|
|
|
|
separator.setFrameShape(QtWidgets.QFrame.VLine)
|
|
|
|
|
separator.setFrameShadow(QtWidgets.QFrame.Sunken)
|
|
|
|
|
self.main_layout.addWidget(separator)
|
|
|
|
|
else:
|
|
|
|
|
tool_id, name, icon = tool
|
|
|
|
|
button = self._create_tool_button(name, icon)
|
|
|
|
|
self.tool_buttons[tool_id] = button
|
|
|
|
|
self.main_layout.addWidget(button)
|
|
|
|
|
|
|
|
|
|
# 添加弹性空间
|
|
|
|
|
self.main_layout.addStretch()
|
|
|
|
|
|
|
|
|
|
def _create_tool_button(self, name, icon):
|
|
|
|
|
"""创建单个工具按钮"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
button = QtWidgets.QToolButton()
|
|
|
|
|
|
|
|
|
|
# === 设置按钮属性 ===
|
|
|
|
|
button.setIcon(QtGui.QIcon(f"{config.ICONS_PATH}/{icon}"))
|
|
|
|
|
button.setIconSize(QtCore.QSize(24, 24))
|
|
|
|
|
button.setToolTip(name)
|
|
|
|
|
button.setStatusTip(name)
|
|
|
|
|
|
|
|
|
|
# 设置按钮样式
|
|
|
|
|
button.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
|
|
|
|
|
button.setAutoRaise(True) # 鼠标悬停时才显示边框
|
|
|
|
|
|
|
|
|
|
return button
|
|
|
|
|
|
|
|
|
|
def _create_connections(self):
|
|
|
|
|
"""创建信号连接"""
|
|
|
|
|
# 保存/加载DNA
|
|
|
|
|
self.tool_buttons["save_dna"].clicked.connect(self._on_save_dna)
|
|
|
|
|
self.tool_buttons["load_dna"].clicked.connect(self._on_load_dna)
|
|
|
|
|
|
|
|
|
|
# RL4节点
|
|
|
|
|
self.tool_buttons["create_rl4"].clicked.connect(self._on_create_rl4)
|
|
|
|
|
self.tool_buttons["delete_rl4"].clicked.connect(self._on_delete_rl4)
|
|
|
|
|
|
|
|
|
|
# 蒙皮操作
|
|
|
|
|
self.tool_buttons["export_skin"].clicked.connect(self._on_export_skin)
|
|
|
|
|
self.tool_buttons["import_skin"].clicked.connect(self._on_import_skin)
|
|
|
|
|
self.tool_buttons["copy_skin"].clicked.connect(self._on_copy_skin)
|
|
|
|
|
|
|
|
|
|
# 帮助/关于
|
|
|
|
|
self.tool_buttons["help"].clicked.connect(self._on_help)
|
|
|
|
|
self.tool_buttons["about"].clicked.connect(self._on_about)
|
|
|
|
|
|
|
|
|
|
# ================================ 事件函数 ================================
|
|
|
|
|
def _on_save_dna(self):
|
|
|
|
|
"""保存DNA"""
|
|
|
|
|
# TODO: 实现保存DNA逻辑
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_load_dna(self):
|
|
|
|
|
"""加载DNA"""
|
|
|
|
|
# TODO: 实现加载DNA逻辑
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_create_rl4(self):
|
|
|
|
|
"""创建RL4节点"""
|
|
|
|
|
# TODO: 实现创建RL4节点逻辑
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_delete_rl4(self):
|
|
|
|
|
"""删除RL4节点"""
|
|
|
|
|
# TODO: 实现删除RL4节点逻辑
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_export_skin(self):
|
|
|
|
|
"""导出蒙皮"""
|
|
|
|
|
# TODO: 实现导出蒙皮逻辑
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_import_skin(self):
|
|
|
|
|
"""导入蒙皮"""
|
|
|
|
|
# TODO: 实现导入蒙皮逻辑
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_copy_skin(self):
|
|
|
|
|
"""复制蒙皮"""
|
|
|
|
|
# TODO: 实现复制蒙皮逻辑
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_help(self):
|
|
|
|
|
"""显示帮助文档"""
|
|
|
|
|
# TODO: 实现显示帮助逻辑
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_about(self):
|
|
|
|
|
"""显示关于对话框"""
|
|
|
|
|
# TODO: 实现显示关于对话框逻辑
|
|
|
|
|
pass
|