This commit is contained in:
2025-05-03 15:44:41 +08:00
parent 6c075c891d
commit b24587bdaa
4 changed files with 45 additions and 32 deletions

View File

@@ -23,7 +23,7 @@ TOOL_MAIN_SCRIPT = os.path.join(TOOL_PATH, "scripts", "Main.py").replace("\\", "
UI_PATH = os.path.join(TOOL_PATH, "scripts", "ui").replace("\\", "/") UI_PATH = os.path.join(TOOL_PATH, "scripts", "ui").replace("\\", "/")
STYLE_FILE = os.path.join(TOOL_PATH, "scripts", "ui", "style.qss").replace("\\", "/") STYLE_FILE = os.path.join(TOOL_PATH, "scripts", "ui", "style.qss").replace("\\", "/")
ICONS_PATH = os.path.join(TOOL_PATH, "icons").replace("\\", "/") ICONS_PATH = os.path.join(TOOL_PATH, "icons").replace("\\", "/")
TOOL_ICON = os.path.join(TOOL_PATH, "icons", "logo.png").replace("\\", "/") TOOL_ICON = os.path.join(TOOL_PATH, "icons", "logo_new.png").replace("\\", "/")
ASSETS_PATH = os.path.join(TOOL_PATH, "assets").replace("\\", "/") ASSETS_PATH = os.path.join(TOOL_PATH, "assets").replace("\\", "/")
DNA_FILE_PATH = os.path.join(TOOL_PATH, "assets", "dna").replace("\\", "/") DNA_FILE_PATH = os.path.join(TOOL_PATH, "assets", "dna").replace("\\", "/")
DNA_IMG_PATH = os.path.join(TOOL_PATH, "assets", "img").replace("\\", "/") DNA_IMG_PATH = os.path.join(TOOL_PATH, "assets", "img").replace("\\", "/")

View File

@@ -28,30 +28,17 @@ from scripts.ui import geometry
from scripts.ui import rigging from scripts.ui import rigging
from scripts.ui import behaviour from scripts.ui import behaviour
from scripts.ui import definition from scripts.ui import definition
#========================================== CONFIG ========================================
import config
TOOL_NAME = config.TOOL_NAME
TOOL_VERSION = config.TOOL_VERSION
TOOL_AUTHOR = config.TOOL_AUTHOR
TOOL_YEAR = config.TOOL_VERSION
TOOL_MOD_FILENAME = config.TOOL_MOD_FILENAME
TOOL_LANG = config.TOOL_LANG
TOOL_WSCL_NAME = config.TOOL_WSCL_NAME
TOOL_HELP_URL = config.TOOL_HELP_URL
TOOL_PATH = config.TOOL_PATH
SCRIPTS_PATH = config.SCRIPTS_PATH
TOOL_MAIN_SCRIPT = config.TOOL_MAIN_SCRIPT
UI_PATH = config.UI_PATH
STYLE_FILE = config.STYLE_FILE
ICONS_PATH = config.ICONS_PATH
TOOL_ICON = config.TOOL_ICON
ASSETS_PATH = config.ASSETS_PATH
DNA_FILE_PATH = config.DNA_FILE_PATH
DNA_IMG_PATH = config.DNA_IMG_PATH
TOOL_COMMAND_ICON = config.TOOL_COMMAND_ICON
#====================================== LOCALIZATION ================================== #====================================== LOCALIZATION ==================================
from scripts.ui import localization from scripts.ui import localization
LANG = localization.LANG LANG = localization.LANG
#========================================== CONFIG ========================================
# 从 scripts 模块导入配置变量
from scripts import (
TOOL_NAME, TOOL_VERSION, TOOL_AUTHOR, TOOL_YEAR, TOOL_MOD_FILENAME,
TOOL_LANG, TOOL_WSCL_NAME, TOOL_HELP_URL, TOOL_PATH, SCRIPTS_PATH,
TOOL_MAIN_SCRIPT, UI_PATH, STYLE_FILE, ICONS_PATH, TOOL_ICON,
ASSETS_PATH, DNA_FILE_PATH, DNA_IMG_PATH, TOOL_COMMAND_ICON
)
#========================================= INIT ======================================= #========================================= INIT =======================================
def get_system_encoding(): def get_system_encoding():
encoding = sys.getdefaultencoding() encoding = sys.getdefaultencoding()
@@ -78,10 +65,8 @@ class MainWindow(QtWidgets.QWidget):
self.create_widgets() self.create_widgets()
self.create_layouts() self.create_layouts()
self.create_connections() self.create_connections()
if os.path.exists(TOOL_ICON):
self.setWindowIcon(QtGui.QIcon(TOOL_ICON)) # 不设置窗口图标
else:
print("WARNING: Icon file not found: {}".format(TOOL_ICON))
def dock_to_maya(self): def dock_to_maya(self):
if cmds.workspaceControl(TOOL_WSCL_NAME, exists=True): if cmds.workspaceControl(TOOL_WSCL_NAME, exists=True):
@@ -89,17 +74,29 @@ class MainWindow(QtWidgets.QWidget):
def create_control(): def create_control():
try: try:
# 直接使用TOOL_ICON__init__.py中已经检查了图标文件是否存在
workspace_control = cmds.workspaceControl( workspace_control = cmds.workspaceControl(
TOOL_WSCL_NAME, TOOL_WSCL_NAME,
label=TOOL_NAME, label=TOOL_NAME,
floating=True, floating=True,
retain=True, retain=True,
resizeWidth=True, resizeWidth=True,
initialWidth=300, initialWidth=600,
minimumWidth=300 minimumWidth=600
) )
cmds.workspaceControl(TOOL_WSCL_NAME, e=True, resizeWidth=True) cmds.workspaceControl(TOOL_WSCL_NAME, e=True, resizeWidth=True)
cmds.control(self.objectName(), e=True, p=workspace_control) cmds.control(self.objectName(), e=True, p=workspace_control)
# 尝试设置工作区控件的尺寸和属性
try:
# 使用Maya命令设置工作区控件属性
cmds.workspaceControl(TOOL_WSCL_NAME, e=True, widthProperty="preferred", heightProperty="preferred")
# 使用原始标题,不添加额外的图标字符
cmds.workspaceControl(TOOL_WSCL_NAME, e=True, label=TOOL_NAME)
except Exception as e:
print(f"设置工作区控件属性失败: {e}")
cmds.evalDeferred(lambda: cmds.workspaceControl(TOOL_WSCL_NAME, e=True, resizeWidth=True)) cmds.evalDeferred(lambda: cmds.workspaceControl(TOOL_WSCL_NAME, e=True, resizeWidth=True))
except Exception as e: except Exception as e:
print("Error creating workspace control: {}".format(e)) print("Error creating workspace control: {}".format(e))
@@ -148,6 +145,8 @@ class MainWindow(QtWidgets.QWidget):
# 创建工具栏 # 创建工具栏
self.toolbar_frame = QtWidgets.QFrame() self.toolbar_frame = QtWidgets.QFrame()
# 不创建Logo图像控件
self.toolbar_frame.setObjectName("toolbar_frame") self.toolbar_frame.setObjectName("toolbar_frame")
self.toolbar_frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.toolbar_frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.toolbar_frame.setFrameShadow(QtWidgets.QFrame.Raised) self.toolbar_frame.setFrameShadow(QtWidgets.QFrame.Raised)
@@ -178,9 +177,11 @@ class MainWindow(QtWidgets.QWidget):
self.scroll_content_layout.setContentsMargins(2, 2, 2, 2) self.scroll_content_layout.setContentsMargins(2, 2, 2, 2)
self.scroll_content_layout.setSpacing(2) self.scroll_content_layout.setSpacing(2)
# 添加工具栏 # 创建工具栏布局
self.toolbar_layout = QtWidgets.QVBoxLayout(self.toolbar_frame) self.toolbar_layout = QtWidgets.QVBoxLayout(self.toolbar_frame)
self.toolbar_layout.setContentsMargins(0, 0, 0, 0) self.toolbar_layout.setContentsMargins(0, 0, 0, 0)
# 使用toolbar模块创建工具栏元素
toolbar.layouts(parent_frame=self.toolbar_frame) toolbar.layouts(parent_frame=self.toolbar_frame)
# 设置各标签页布局 # 设置各标签页布局

View File

@@ -12,16 +12,27 @@ import sys
import config import config
# 将主配置中的变量导入到当前模块的命名空间 # 将主配置中的变量导入到当前模块的命名空间
TOOL_NAME = config.TOOL_NAME TOOL_NAME = config.TOOL_NAME
TOOL_VERSION = config.TOOL_VERSION TOOL_VERSION = config.TOOL_VERSION
TOOL_AUTHOR = config.TOOL_AUTHOR TOOL_AUTHOR = config.TOOL_AUTHOR
TOOL_YEAR = config.TOOL_YEAR
TOOL_MOD_FILENAME = config.TOOL_MOD_FILENAME
TOOL_LANG = config.TOOL_LANG
TOOL_WSCL_NAME = config.TOOL_WSCL_NAME
TOOL_HELP_URL = config.TOOL_HELP_URL
TOOL_PATH = config.TOOL_PATH TOOL_PATH = config.TOOL_PATH
SCRIPTS_PATH = config.SCRIPTS_PATH SCRIPTS_PATH = config.SCRIPTS_PATH
TOOL_MAIN_SCRIPT = config.TOOL_MAIN_SCRIPT
UI_PATH = config.UI_PATH UI_PATH = config.UI_PATH
STYLE_FILE = config.STYLE_FILE STYLE_FILE = config.STYLE_FILE
ICONS_PATH = config.ICONS_PATH ICONS_PATH = config.ICONS_PATH
TOOL_ICON = config.TOOL_ICON
DEFAULT_ICON = os.path.join(ICONS_PATH, "commandButton.png").replace("\\", "/")
ASSETS_PATH = config.ASSETS_PATH ASSETS_PATH = config.ASSETS_PATH
DNA_FILE_PATH = config.DNA_FILE_PATH DNA_FILE_PATH = config.DNA_FILE_PATH
DNA_IMG_PATH = config.DNA_IMG_PATH
TOOL_COMMAND_ICON = config.TOOL_COMMAND_ICON
# 确保项目路径在sys.path中 # 确保项目路径在sys.path中
if TOOL_PATH not in sys.path: if TOOL_PATH not in sys.path:

View File

@@ -304,8 +304,9 @@ QScrollBar::sub-line:horizontal {
/* 状态栏样式 */ /* 状态栏样式 */
QStatusBar { QStatusBar {
background-color: #007ACC; background-color: #333333;
color: white; color: #E0E0E0;
border-top: 1px solid #3F3F46;
} }
QStatusBar::item { QStatusBar::item {