diff --git a/ui/property_panel.py b/ui/property_panel.py index 21cf6e1c..6905826b 100644 --- a/ui/property_panel.py +++ b/ui/property_panel.py @@ -21,19 +21,6 @@ class PropertyPanelManager: self._propertyLayout = None self._actor_cache={} - # 定义紧凑样式 - self.compact_style = """ - QDoubleSpinBox { - min-width: 45px; - } - QPushButton { - min-width: 10px; - } - QComboBox { - min-width: 50px; - } - """ - def setPropertyLayout(self, layout): """设置属性面板布局引用""" print("开始设置属性布局") @@ -71,10 +58,6 @@ class PropertyPanelManager: self.clearPropertyPanel() - # 应用紧凑样式到属性面板容器 - if self._propertyLayout.parent(): - self._propertyLayout.parent().setStyleSheet(self.compact_style) - itemText = item.text(0) # 如果点击的是场景根节点,显示提示信息 @@ -4956,20 +4939,18 @@ except Exception as e: # 如果有多种类型的动画,使用标签页 if len(animations) > 1: tab_widget = QTabWidget() - tab_widget.setMinimumWidth(200) # 设置最小宽度 for anim_type, anim_data in animations.items(): tab = QWidget() - tab_layout = QGridLayout(tab) # 改为QGridLayout保持一致 + tab_layout = QVBoxLayout(tab) self._buildAnimationTypeUI(tab_layout, origin_model, anim_type, anim_data) tab_widget.addTab(tab, self._getAnimTypeDisplayName(anim_type)) - layout.addWidget(QLabel("动画类型:"), 1, 0) - layout.addWidget(tab_widget, 1, 1, 1, 3) + self._propertyLayout.addRow("动画类型:", tab_widget) else: # 只有一种类型,直接显示 anim_type, anim_data = next(iter(animations.items())) - self._buildAnimationTypeUI(layout, origin_model, anim_type, anim_data) + self._buildAnimationTypeUI(self._propertyLayout, origin_model, anim_type, anim_data) # 存储动画信息供控制使用 if not hasattr(self, '_non_skeletal_cache'): @@ -4980,69 +4961,46 @@ except Exception as e: """为特定动画类型构建UI""" from PyQt5.QtWidgets import QLabel, QComboBox, QHBoxLayout, QWidget, QPushButton, QDoubleSpinBox - current_row = layout.rowCount() - if anim_type == 'transform': # 变换动画控制 self.ns_transform_combo = QComboBox() self.ns_transform_combo.addItems(anim_data['names']) - self.ns_transform_combo.setMinimumWidth(80) - layout.addWidget(QLabel("变换动画:"), current_row, 0) - layout.addWidget(self.ns_transform_combo, current_row, 1, 1, 3) - current_row += 1 + layout.addRow("变换动画:", self.ns_transform_combo) elif anim_type == 'texture': # 纹理动画控制 self.ns_texture_combo = QComboBox() self.ns_texture_combo.addItems(anim_data['stages']) - self.ns_texture_combo.setMinimumWidth(80) - layout.addWidget(QLabel("纹理动画:"), current_row, 0) - layout.addWidget(self.ns_texture_combo, current_row, 1, 1, 3) - current_row += 1 + layout.addRow("纹理动画:", self.ns_texture_combo) elif anim_type == 'material': # 材质动画控制 self.ns_material_combo = QComboBox() self.ns_material_combo.addItems(anim_data['properties']) - self.ns_material_combo.setMinimumWidth(80) - layout.addWidget(QLabel("材质动画:"), current_row, 0) - layout.addWidget(self.ns_material_combo, current_row, 1, 1, 3) - current_row += 1 + layout.addRow("材质动画:", self.ns_material_combo) elif anim_type == 'lerp': # Lerp动画控制 self.ns_lerp_combo = QComboBox() self.ns_lerp_combo.addItems(anim_data['intervals']) - self.ns_lerp_combo.setMinimumWidth(80) - layout.addWidget(QLabel("Lerp动画:"), current_row, 0) - layout.addWidget(self.ns_lerp_combo, current_row, 1, 1, 3) - current_row += 1 + layout.addRow("Lerp动画:", self.ns_lerp_combo) # 通用控制按钮 btn_box = QWidget() btn_lay = QHBoxLayout(btn_box) - btn_lay.setContentsMargins(0, 0, 0, 0) for txt, cmd in (("播放", "play"), ("暂停", "pause"), ("停止", "stop"), ("循环", "loop")): btn = QPushButton(txt) - btn.setMinimumWidth(35) # 设置按钮最小宽度 - btn.setMaximumWidth(50) # 限制按钮最大宽度 btn.clicked.connect(lambda _, c=cmd, t=anim_type: self._controlNonSkeletalAnimation(origin_model, t, c)) btn_lay.addWidget(btn) - layout.addWidget(QLabel("控制:"), current_row, 0) - layout.addWidget(btn_box, current_row, 1, 1, 3) - current_row += 1 + layout.addRow("控制:", btn_box) # 播放速度 speed_spinbox = QDoubleSpinBox() speed_spinbox.setRange(0.1, 5.0) speed_spinbox.setSingleStep(0.1) speed_spinbox.setValue(1.0) - speed_spinbox.setMinimumWidth(60) - speed_spinbox.setMaximumWidth(80) - speed_spinbox.valueChanged.connect( - lambda v, t=anim_type: self._setNonSkeletalAnimationSpeed(origin_model, t, v)) - layout.addWidget(QLabel("播放速度:"), current_row, 0) - layout.addWidget(speed_spinbox, current_row, 1, 1, 3) + speed_spinbox.valueChanged.connect(lambda v, t=anim_type: self._setNonSkeletalAnimationSpeed(origin_model, t, v)) + layout.addRow("播放速度:", speed_spinbox) def _getAnimTypeDisplayName(self, anim_type): """获取动画类型的显示名称"""