Update meshes.py
This commit is contained in:
parent
1b2bc2aeed
commit
951e68abb7
@ -110,8 +110,8 @@ class MeshesTab(QtWidgets.QWidget):
|
||||
# === 顶部工具栏 ===
|
||||
self.toolbar = QtWidgets.QWidget()
|
||||
toolbar_layout = QtWidgets.QHBoxLayout(self.toolbar)
|
||||
toolbar_layout.setContentsMargins(4, 4, 4, 4)
|
||||
toolbar_layout.setSpacing(4)
|
||||
toolbar_layout.setContentsMargins(0, 0, 0, 0)
|
||||
toolbar_layout.setSpacing(0)
|
||||
|
||||
# Meta-Human下拉框
|
||||
self.preset_combo = QtWidgets.QComboBox()
|
||||
@ -119,7 +119,7 @@ class MeshesTab(QtWidgets.QWidget):
|
||||
self.preset_combo.setFixedWidth(120)
|
||||
|
||||
# 删除按钮移到LOD页面的功能按钮区域
|
||||
toolbar_layout.addStretch()
|
||||
toolbar_layout.addStretch(0)
|
||||
|
||||
# === 中间内容区 ===
|
||||
self.content = QtWidgets.QWidget()
|
||||
@ -283,19 +283,24 @@ class MeshesTab(QtWidgets.QWidget):
|
||||
add_btn.setStyleSheet("""
|
||||
QPushButton {
|
||||
background: #232323;
|
||||
border: 2px solid #444444; /* 调整边框颜色 */
|
||||
border-radius: 5px; /* 减小圆角 */
|
||||
border: 2px solid #444444;
|
||||
border-radius: 5px;
|
||||
padding: 2px 4px;
|
||||
color: #CCCCCC;
|
||||
text-align: center; /* 居中对齐 */
|
||||
text-align: center;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background: #454545;
|
||||
border: 1px solid #555555;
|
||||
background: #2A2A2A;
|
||||
border: 2px solid #555555;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background: #2A2A2A;
|
||||
border: 1px solid #666666;
|
||||
background: #1D1D1D;
|
||||
border: 2px solid #666666;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background: #1D1D1D;
|
||||
border: 2px solid #333333;
|
||||
color: #666666;
|
||||
}
|
||||
""")
|
||||
|
||||
@ -309,35 +314,37 @@ class MeshesTab(QtWidgets.QWidget):
|
||||
"""创建工具按钮"""
|
||||
btn = QtWidgets.QPushButton(text)
|
||||
|
||||
# 尝试使用自定义图标,如果失败则使用Maya内置图标
|
||||
# 设置图标
|
||||
icon_path = f"{config.ICONS_PATH}/{icon_name}"
|
||||
print(f"尝试加载图标: {icon_path}") # 添加调试输出
|
||||
|
||||
if os.path.exists(icon_path):
|
||||
btn.setIcon(QtGui.QIcon(icon_path))
|
||||
print(f"成功加载自定义图标: {icon_path}")
|
||||
elif fallback_icon:
|
||||
btn.setIcon(QtGui.QIcon(f":{fallback_icon}"))
|
||||
print(f"使用Maya内置图标: {fallback_icon}")
|
||||
else:
|
||||
print(f"未能找到图标: {icon_path}")
|
||||
|
||||
# 统一按钮样式
|
||||
btn.setFixedHeight(24) # 统一按钮高度为24px
|
||||
btn.setStyleSheet("""
|
||||
QPushButton {
|
||||
background: #3D3D3D;
|
||||
border: 1px solid #555555;
|
||||
border-radius: 2px;
|
||||
padding: 4px 8px;
|
||||
background: #232323;
|
||||
border: 2px solid #444444;
|
||||
border-radius: 5px;
|
||||
padding: 2px 4px;
|
||||
color: #CCCCCC;
|
||||
text-align: left;
|
||||
text-align: center;
|
||||
icon-size: 16px;
|
||||
min-height: 32px; # 统一按钮高度
|
||||
}
|
||||
QPushButton:hover {
|
||||
background: #454545;
|
||||
background: #2A2A2A;
|
||||
border: 2px solid #555555;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background: #2A2A2A;
|
||||
background: #1D1D1D;
|
||||
border: 2px solid #666666;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background: #1D1D1D;
|
||||
border: 2px solid #333333;
|
||||
color: #666666;
|
||||
}
|
||||
""")
|
||||
return btn
|
||||
@ -346,38 +353,61 @@ class MeshesTab(QtWidgets.QWidget):
|
||||
"""创建底部工具栏"""
|
||||
# === Widget ===
|
||||
widget = QtWidgets.QWidget()
|
||||
widget.setFixedHeight(180) # 增加高度
|
||||
widget.setFixedHeight(160) # 减小总高度
|
||||
|
||||
# === Main Layout ===
|
||||
layout = QtWidgets.QVBoxLayout(widget)
|
||||
layout.setContentsMargins(8, 8, 8, 8) # 增加边距
|
||||
layout.setSpacing(8)
|
||||
layout.setContentsMargins(8, 4, 8, 8) # 上边距小一些
|
||||
layout.setSpacing(8) # 主布局间距
|
||||
|
||||
# === 第一行工具栏 - 预设和LOD ===
|
||||
first_row = QtWidgets.QWidget()
|
||||
first_layout = QtWidgets.QHBoxLayout(first_row)
|
||||
first_layout.setContentsMargins(4, 0, 4, 0)
|
||||
first_layout.setSpacing(4)
|
||||
first_layout.setSpacing(8)
|
||||
|
||||
# 预设名称
|
||||
self.preset_label = QtWidgets.QLabel("预设名称:")
|
||||
self.preset_name_combo = QtWidgets.QComboBox()
|
||||
self.preset_name_combo.addItem("Meta-Human")
|
||||
self.preset_name_combo.setFixedWidth(150)
|
||||
self.preset_name_combo.setFixedHeight(32) # 设置为与模型分离按钮相同的高度
|
||||
self.preset_name_combo.setFixedHeight(24) # 设置为与模型分离按钮相同的高度
|
||||
|
||||
# 选择LOD
|
||||
self.lod_label = QtWidgets.QLabel("选择LOD:")
|
||||
self.lod_combo = QtWidgets.QComboBox()
|
||||
self.lod_combo.addItems(["全部"] + [f"LOD{i}" for i in range(8)])
|
||||
self.lod_combo.setFixedWidth(100)
|
||||
self.lod_combo.setFixedHeight(32) # 设置为与模型分离按钮相同的高度
|
||||
self.lod_combo.setFixedHeight(24) # 设置为与模型分离按钮相同的高度
|
||||
|
||||
# 创建LOD按钮
|
||||
self.create_lod_btn = QtWidgets.QPushButton()
|
||||
self.create_lod_btn.setIcon(QtGui.QIcon(f"{config.ICONS_PATH}/create_lod.png"))
|
||||
self.create_lod_btn.setText("创建LOD")
|
||||
self.create_lod_btn.setFixedHeight(32) # 设置为与模型分离按钮相同的高度
|
||||
self.create_lod_btn.setFixedHeight(24)
|
||||
self.create_lod_btn.setStyleSheet("""
|
||||
QPushButton {
|
||||
background: #232323;
|
||||
border: 2px solid #444444;
|
||||
border-radius: 5px;
|
||||
padding: 4px 8px;
|
||||
color: #CCCCCC;
|
||||
text-align: center;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background: #2A2A2A;
|
||||
border: 2px solid #555555;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background: #1D1D1D;
|
||||
border: 2px solid #666666;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background: #1D1D1D;
|
||||
border: 2px solid #333333;
|
||||
color: #666666;
|
||||
}
|
||||
""")
|
||||
|
||||
first_layout.addWidget(self.preset_label)
|
||||
first_layout.addWidget(self.preset_name_combo)
|
||||
@ -390,78 +420,42 @@ class MeshesTab(QtWidgets.QWidget):
|
||||
buttons_widget = QtWidgets.QWidget()
|
||||
buttons_layout = QtWidgets.QVBoxLayout(buttons_widget)
|
||||
buttons_layout.setContentsMargins(4, 4, 4, 4)
|
||||
buttons_layout.setSpacing(8)
|
||||
buttons_layout.setSpacing(4) # 统一行间距
|
||||
|
||||
# 创建按钮行
|
||||
row1 = QtWidgets.QWidget()
|
||||
row1_layout = QtWidgets.QHBoxLayout(row1)
|
||||
row1_layout.setContentsMargins(0, 0, 0, 0)
|
||||
row1_layout.setSpacing(8)
|
||||
|
||||
row2 = QtWidgets.QWidget()
|
||||
row2_layout = QtWidgets.QHBoxLayout(row2)
|
||||
row2_layout.setContentsMargins(0, 0, 0, 0)
|
||||
row2_layout.setSpacing(8)
|
||||
|
||||
row3 = QtWidgets.QWidget()
|
||||
row3_layout = QtWidgets.QHBoxLayout(row3)
|
||||
row3_layout.setContentsMargins(0, 0, 0, 0)
|
||||
row3_layout.setSpacing(8)
|
||||
|
||||
# 创建按钮
|
||||
self.separate_btn = self._create_tool_button("模型分离", "separate.png", "polySplitVertex.png")
|
||||
self.face_accessory_btn = self._create_tool_button("生成面部配件", "supplement_meshes.png", "polyCreateFacet.png")
|
||||
self.fix_normal_btn = self._create_tool_button("修复法线", "repair_normals.png", "polyNormal.png")
|
||||
self.fix_vertex_order_btn = self._create_tool_button("修复点序", "repair_vertex_order.png", "polyNormalPerVertex.png")
|
||||
self.fix_seam_btn = self._create_tool_button("修复接缝", "fix_seam.png", "polyChipOff.png")
|
||||
for row_buttons in [
|
||||
[self.separate_btn, self.face_accessory_btn],
|
||||
[self.fix_normal_btn, self.fix_vertex_order_btn],
|
||||
[self.fix_seam_btn]
|
||||
]:
|
||||
row = QtWidgets.QWidget()
|
||||
row_layout = QtWidgets.QHBoxLayout(row)
|
||||
row_layout.setContentsMargins(0, 0, 0, 0)
|
||||
row_layout.setSpacing(4) # 统一按钮间距
|
||||
|
||||
# 添加按钮到行
|
||||
row_layout.addStretch(1)
|
||||
for btn in row_buttons:
|
||||
row_layout.addWidget(btn)
|
||||
if btn != row_buttons[-1]: # 最后一个按钮后不添加间距
|
||||
row_layout.addSpacing(4)
|
||||
row_layout.addStretch(1)
|
||||
|
||||
buttons_layout.addWidget(row)
|
||||
|
||||
# 设置按钮固定宽度
|
||||
button_width = (widget.width() - 24) // 2 # 24是左右边距和按钮间距(8)的总和
|
||||
for btn in [self.separate_btn, self.face_accessory_btn,
|
||||
self.fix_normal_btn, self.fix_vertex_order_btn,
|
||||
self.fix_seam_btn]:
|
||||
button_width = (widget.width() - 24) // 2 # 24是左右边距和按钮间距的总和
|
||||
for btn in [self.separate_btn, self.face_accessory_btn,
|
||||
self.fix_normal_btn, self.fix_vertex_order_btn,
|
||||
self.fix_seam_btn]:
|
||||
btn.setFixedWidth(button_width)
|
||||
|
||||
# 添加按钮到行
|
||||
row1_layout.addStretch()
|
||||
row1_layout.addWidget(self.separate_btn)
|
||||
row1_layout.addWidget(self.face_accessory_btn)
|
||||
row1_layout.addStretch()
|
||||
|
||||
row2_layout.addStretch()
|
||||
row2_layout.addWidget(self.fix_normal_btn)
|
||||
row2_layout.addWidget(self.fix_vertex_order_btn)
|
||||
row2_layout.addStretch()
|
||||
|
||||
# 修复接缝按钮不居中
|
||||
row3_layout.addWidget(self.fix_seam_btn)
|
||||
row3_layout.addStretch()
|
||||
|
||||
# 添加行到布局
|
||||
buttons_layout.addWidget(row1)
|
||||
buttons_layout.addWidget(row2)
|
||||
buttons_layout.addWidget(row3)
|
||||
|
||||
# === 添加到主布局 ===
|
||||
layout.addWidget(first_row)
|
||||
layout.addWidget(buttons_widget)
|
||||
|
||||
# 添加窗口大小变化事件处理
|
||||
widget.resizeEvent = lambda event: self._adjust_button_widths(event, [
|
||||
self.separate_btn, self.face_accessory_btn,
|
||||
self.fix_normal_btn, self.fix_vertex_order_btn,
|
||||
self.fix_seam_btn
|
||||
])
|
||||
|
||||
return widget
|
||||
|
||||
def _adjust_button_widths(self, event, buttons):
|
||||
"""调整按钮宽度以适应窗口大小"""
|
||||
width = event.size().width()
|
||||
button_width = (width - 24) // 2 # 24是左右边距和按钮间距(8)的总和
|
||||
for btn in buttons:
|
||||
btn.setFixedWidth(button_width)
|
||||
|
||||
def _setup_style(self):
|
||||
"""设置样式"""
|
||||
# 工具栏样式
|
||||
|
Loading…
Reference in New Issue
Block a user