2025-01-13 23:36:50 +08:00
|
|
|
|
#!/usr/bin/env python
|
2025-01-11 16:53:48 +08:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
#===================================== IMPORTS =====================================
|
|
|
|
|
# Standard library imports
|
|
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
import webbrowser
|
|
|
|
|
import locale
|
|
|
|
|
|
|
|
|
|
# Qt imports
|
|
|
|
|
from PySide2 import QtWidgets, QtCore, QtGui
|
|
|
|
|
from shiboken2 import wrapInstance
|
|
|
|
|
|
|
|
|
|
# Maya imports
|
|
|
|
|
from maya import OpenMayaUI as omui
|
|
|
|
|
import maya.cmds as cmds
|
|
|
|
|
import maya.mel as mel
|
|
|
|
|
|
|
|
|
|
#===================================== IMPORT MODULES =====================================
|
|
|
|
|
import BodyPrep
|
|
|
|
|
import BatchImport
|
2025-01-13 20:41:08 +08:00
|
|
|
|
import DNA_Viewer
|
2025-01-13 23:36:50 +08:00
|
|
|
|
<<<<<<< Updated upstream
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
|
|
>>>>>>> Stashed changes
|
2025-01-11 16:53:48 +08:00
|
|
|
|
#===================================== CONSTANTS =====================================
|
|
|
|
|
# Tool info
|
|
|
|
|
TOOL_NAME = "MetaFusion"
|
|
|
|
|
TOOL_VERSION = "Beta v1.0.0"
|
2025-01-13 23:36:50 +08:00
|
|
|
|
TOOL_AUTHOR = "CGNICO"
|
|
|
|
|
TOOL_LANG = 'en_US'
|
2025-01-11 16:53:48 +08:00
|
|
|
|
# UI Constants
|
|
|
|
|
TOOL_WSCL_NAME = "MetaFusionWorkSpaceControl"
|
2025-01-13 23:36:50 +08:00
|
|
|
|
<<<<<<< Updated upstream
|
2025-01-11 16:53:48 +08:00
|
|
|
|
TOOL_HELP_URL = f"http://10.72.61.59:3000/ArtGroup/{TOOL_NAME}/wiki"
|
2025-01-13 23:36:50 +08:00
|
|
|
|
=======
|
|
|
|
|
TOOL_HELP_URL = f"https://gitea.cgnico.com/CGNICO/MetaFusion/wiki"
|
|
|
|
|
>>>>>>> Stashed changes
|
2025-01-13 20:41:08 +08:00
|
|
|
|
DEFAULT_WINDOW_SIZE = (500, 800)
|
2025-01-11 16:53:48 +08:00
|
|
|
|
|
|
|
|
|
# Paths
|
|
|
|
|
TOOL_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))).replace("\\", "/")
|
|
|
|
|
SCRIPTS_PATH = os.path.join(TOOL_PATH, "scripts").replace("\\", "/")
|
|
|
|
|
ICONS_PATH = os.path.join(TOOL_PATH, "icons").replace("\\", "/")
|
|
|
|
|
TOOL_ICON = os.path.join(ICONS_PATH, "logo.png").replace("\\", "/")
|
|
|
|
|
|
|
|
|
|
# Metahuman paths
|
|
|
|
|
DATA_PATH = os.path.join(TOOL_PATH, "data").replace("\\", "/")
|
|
|
|
|
DNA_PATH = os.path.join(DATA_PATH, "dna").replace("\\", "/")
|
|
|
|
|
BODY_PATH = os.path.join(DATA_PATH, "body").replace("\\", "/")
|
|
|
|
|
IMG_PATH = os.path.join(DATA_PATH, "img").replace("\\", "/")
|
|
|
|
|
MAP_PATH = os.path.join(DATA_PATH, "map").replace("\\", "/")
|
|
|
|
|
MASKS_PATH = os.path.join(DATA_PATH, "masks").replace("\\", "/")
|
|
|
|
|
SHADERS_PATH = os.path.join(DATA_PATH, "shaders").replace("\\", "/")
|
|
|
|
|
MH4_PATH = os.path.join(DATA_PATH, "mh4").replace("\\", "/")
|
|
|
|
|
MH4_DNA_PATH = os.path.join(MH4_PATH, "dna").replace("\\", "/")
|
|
|
|
|
OUT_PATH = os.path.join(DATA_PATH, "out").replace("\\", "/")
|
|
|
|
|
SAVE_PATH = os.path.join(DATA_PATH, "save").replace("\\", "/")
|
|
|
|
|
MAYA_VERSION = cmds.about(version=True)
|
|
|
|
|
PLUGIN_PATH = os.path.join(TOOL_PATH, "plugins", f"{MAYA_VERSION}").replace("\\", "/")
|
|
|
|
|
if not os.path.exists(PLUGIN_PATH):
|
|
|
|
|
cmds.warning(f"Plugin path not found: {PLUGIN_PATH}")
|
|
|
|
|
|
|
|
|
|
print(f"TOOL_PATH: {TOOL_PATH}")
|
|
|
|
|
print(f"SCRIPTS_PATH: {SCRIPTS_PATH}")
|
|
|
|
|
print(f"ICONS_PATH: {ICONS_PATH}")
|
|
|
|
|
print(f"TOOL_ICON: {TOOL_ICON}")
|
|
|
|
|
print(f"DATA_PATH: {DATA_PATH}")
|
|
|
|
|
print(f"DNA_PATH: {DNA_PATH}")
|
|
|
|
|
print(f"BODY_PATH: {BODY_PATH}")
|
|
|
|
|
print(f"IMG_PATH: {IMG_PATH}")
|
|
|
|
|
print(f"MAP_PATH: {MAP_PATH}")
|
|
|
|
|
print(f"MASKS_PATH: {MASKS_PATH}")
|
|
|
|
|
print(f"SHADERS_PATH: {SHADERS_PATH}")
|
|
|
|
|
|
2025-01-13 20:41:08 +08:00
|
|
|
|
|
2025-01-11 16:53:48 +08:00
|
|
|
|
#===================================== LANGUAGE SETTINGS =====================================
|
|
|
|
|
TOOL_LANG = 'en_US'
|
|
|
|
|
SUPPORTED_LANGUAGES = ['en_US', 'zh_CN']
|
|
|
|
|
|
|
|
|
|
LANG = {
|
|
|
|
|
"en_US": {
|
|
|
|
|
"MetaFusion": "MetaFusion",
|
2025-01-13 23:36:50 +08:00
|
|
|
|
"Prepare": "Prepare",
|
|
|
|
|
"Body Prepare": "Body Prepare",
|
|
|
|
|
"DNA Edit": "DNA Edit",
|
|
|
|
|
"Open DNA Viewer": "Open DNA Viewer",
|
|
|
|
|
"Import": "Import",
|
|
|
|
|
"Batch Import": "Batch Import",
|
2025-01-11 16:53:48 +08:00
|
|
|
|
"Help": "Help",
|
|
|
|
|
"Switch Language": "Switch Language",
|
2025-01-13 23:36:50 +08:00
|
|
|
|
"Language switched": "Language switched",
|
2025-01-11 16:53:48 +08:00
|
|
|
|
"EN": "EN",
|
|
|
|
|
"ZH": "ZH",
|
|
|
|
|
"English": "English",
|
2025-01-13 23:36:50 +08:00
|
|
|
|
"Chinese": "Chinese"
|
2025-01-11 16:53:48 +08:00
|
|
|
|
},
|
|
|
|
|
"zh_CN": {
|
|
|
|
|
"MetaFusion": "MetaFusion",
|
2025-01-13 23:36:50 +08:00
|
|
|
|
"Prepare": "准备",
|
|
|
|
|
"Body Prepare": "身体准备",
|
|
|
|
|
"DNA Edit": "DNA 编辑",
|
|
|
|
|
"Open DNA Viewer": "打开 DNA 查看器",
|
|
|
|
|
"Import": "导入",
|
|
|
|
|
"Batch Import": "批量导入",
|
2025-01-11 16:53:48 +08:00
|
|
|
|
"Help": "帮助",
|
|
|
|
|
"Switch Language": "切换语言",
|
2025-01-13 23:36:50 +08:00
|
|
|
|
"Language switched": "语言已切换",
|
2025-01-11 16:53:48 +08:00
|
|
|
|
"EN": "英文",
|
|
|
|
|
"ZH": "中文",
|
|
|
|
|
"English": "英语",
|
2025-01-13 23:36:50 +08:00
|
|
|
|
"Chinese": "中文"
|
2025-01-11 16:53:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#===================================== UTILITY FUNCTIONS =====================================
|
|
|
|
|
def get_system_encoding():
|
|
|
|
|
encoding = sys.getdefaultencoding()
|
|
|
|
|
if encoding.lower() == 'ascii':
|
|
|
|
|
encoding = locale.getpreferredencoding()
|
|
|
|
|
return encoding
|
|
|
|
|
|
|
|
|
|
def maya_main_window():
|
|
|
|
|
main_window_ptr = omui.MQtUtil.mainWindow()
|
|
|
|
|
return wrapInstance(int(main_window_ptr), QtWidgets.QWidget)
|
|
|
|
|
|
|
|
|
|
#===================================== UI COMPONENTS =====================================
|
|
|
|
|
class MainButton(QtWidgets.QPushButton):
|
2025-01-13 23:36:50 +08:00
|
|
|
|
DEFAULT_COLORS = {"normal": "#D0D0D0", "hover": "#E0E0E0", "pressed": "#C0C0C0"}
|
2025-01-11 16:53:48 +08:00
|
|
|
|
|
|
|
|
|
def __init__(self, text="", icon=None, color=None, hover_color=None, pressed_color=None):
|
|
|
|
|
super().__init__(text)
|
|
|
|
|
if icon:
|
|
|
|
|
self.setIcon(icon)
|
|
|
|
|
self.setIconSize(QtCore.QSize(24, 24))
|
|
|
|
|
self.setMinimumHeight(30)
|
2025-01-13 20:41:08 +08:00
|
|
|
|
colors = {
|
|
|
|
|
"normal": color or self.DEFAULT_COLORS["normal"],
|
|
|
|
|
"hover": hover_color or self.DEFAULT_COLORS["hover"],
|
|
|
|
|
"pressed": pressed_color or self.DEFAULT_COLORS["pressed"]
|
|
|
|
|
}
|
|
|
|
|
self.setStyleSheet(self._generate_style_sheet(**colors))
|
2025-01-11 16:53:48 +08:00
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def _generate_style_sheet(normal, hover, pressed):
|
|
|
|
|
return f"""
|
|
|
|
|
QPushButton {{
|
|
|
|
|
background-color: {normal};
|
|
|
|
|
color: #303030;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
padding: 5px;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}}
|
|
|
|
|
QPushButton:hover {{
|
|
|
|
|
background-color: {hover};
|
|
|
|
|
}}
|
|
|
|
|
QPushButton:pressed {{
|
|
|
|
|
background-color: {pressed};
|
|
|
|
|
}}
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
class BottomButton(QtWidgets.QPushButton):
|
|
|
|
|
def __init__(self, text="", icon=None):
|
|
|
|
|
super().__init__(text)
|
|
|
|
|
self.setMinimumHeight(20)
|
|
|
|
|
self.setStyleSheet(self._generate_style_sheet())
|
|
|
|
|
self.setFont(QtGui.QFont("Microsoft YaHei", 10))
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def _generate_style_sheet():
|
|
|
|
|
return """
|
|
|
|
|
QPushButton {
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
border: none;
|
|
|
|
|
color: gray;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
QPushButton:hover {
|
|
|
|
|
color: black;
|
|
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
#===================================== MAIN WINDOW =====================================
|
|
|
|
|
class MainWindow(QtWidgets.QWidget):
|
|
|
|
|
|
|
|
|
|
instance = None
|
|
|
|
|
|
|
|
|
|
def __init__(self, parent=maya_main_window()):
|
2025-01-13 20:41:08 +08:00
|
|
|
|
self.load_required_plugins()
|
|
|
|
|
|
2025-01-11 16:53:48 +08:00
|
|
|
|
super(MainWindow, self).__init__(parent)
|
|
|
|
|
self.setWindowTitle(f"{TOOL_NAME} - {TOOL_VERSION}")
|
|
|
|
|
self.setObjectName(TOOL_PATH)
|
|
|
|
|
self.setWindowFlags(QtCore.Qt.Window)
|
|
|
|
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
|
|
|
|
self.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred)
|
|
|
|
|
self.setMinimumSize(300, 800)
|
|
|
|
|
|
|
|
|
|
self.create_widgets()
|
|
|
|
|
self.create_layouts()
|
|
|
|
|
self.create_connections()
|
|
|
|
|
|
|
|
|
|
if os.path.exists(TOOL_ICON):
|
|
|
|
|
self.setWindowIcon(QtGui.QIcon(TOOL_ICON))
|
|
|
|
|
else:
|
|
|
|
|
print(f"WARNING: Icon file not found: {TOOL_ICON}")
|
|
|
|
|
|
2025-01-13 20:41:08 +08:00
|
|
|
|
def load_required_plugins(self):
|
|
|
|
|
try:
|
|
|
|
|
if PLUGIN_PATH not in os.environ.get('MAYA_PLUG_IN_PATH', ''):
|
|
|
|
|
if 'MAYA_PLUG_IN_PATH' in os.environ:
|
|
|
|
|
os.environ['MAYA_PLUG_IN_PATH'] = f"{PLUGIN_PATH};{os.environ['MAYA_PLUG_IN_PATH']}"
|
|
|
|
|
else:
|
|
|
|
|
os.environ['MAYA_PLUG_IN_PATH'] = PLUGIN_PATH
|
|
|
|
|
|
|
|
|
|
required_plugins = ['embeddedRL4.mll']
|
|
|
|
|
for plugin in required_plugins:
|
|
|
|
|
plugin_path = os.path.join(PLUGIN_PATH, plugin)
|
|
|
|
|
if os.path.exists(plugin_path):
|
|
|
|
|
try:
|
|
|
|
|
if not cmds.pluginInfo(plugin, query=True, loaded=True):
|
|
|
|
|
cmds.loadPlugin(plugin_path)
|
|
|
|
|
print(f"Successfully loaded plugin: {plugin}")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
cmds.warning(f"Failed to load plugin {plugin}: {str(e)}")
|
|
|
|
|
else:
|
|
|
|
|
cmds.warning(f"Plugin not found: {plugin_path}")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
cmds.warning(f"Error loading plugins: {str(e)}")
|
|
|
|
|
|
2025-01-11 16:53:48 +08:00
|
|
|
|
@classmethod
|
|
|
|
|
def show_window(cls):
|
|
|
|
|
try:
|
|
|
|
|
if cmds.workspaceControl(TOOL_WSCL_NAME, exists=True):
|
|
|
|
|
cmds.deleteUI(TOOL_WSCL_NAME, control=True)
|
|
|
|
|
|
|
|
|
|
if cls.instance is not None:
|
|
|
|
|
try:
|
|
|
|
|
cls.instance.close()
|
|
|
|
|
cls.instance.deleteLater()
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
cls.instance = cls()
|
|
|
|
|
cls.instance.dock_to_maya()
|
|
|
|
|
return cls.instance
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"Error showing {TOOL_NAME} window: {e}")
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def dock_to_maya(self):
|
|
|
|
|
if cmds.workspaceControl(TOOL_WSCL_NAME, exists=True):
|
|
|
|
|
cmds.deleteUI(TOOL_WSCL_NAME)
|
|
|
|
|
try:
|
|
|
|
|
workspace_control = cmds.workspaceControl(
|
|
|
|
|
TOOL_WSCL_NAME,
|
|
|
|
|
label=TOOL_NAME,
|
|
|
|
|
floating=True,
|
|
|
|
|
retain=True,
|
|
|
|
|
resizeWidth=True,
|
2025-01-13 20:41:08 +08:00
|
|
|
|
initialWidth=500,
|
|
|
|
|
minimumWidth=500
|
2025-01-11 16:53:48 +08:00
|
|
|
|
)
|
|
|
|
|
cmds.workspaceControl(TOOL_WSCL_NAME, e=True, resizeWidth=True)
|
|
|
|
|
cmds.control(self.objectName(), e=True, p=workspace_control)
|
|
|
|
|
cmds.evalDeferred(lambda: cmds.workspaceControl(TOOL_WSCL_NAME, e=True, resizeWidth=True))
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"Error creating workspace control: {e}")
|
|
|
|
|
|
|
|
|
|
#===================================== UI COMPONENTS =====================================
|
|
|
|
|
def create_widgets(self):
|
2025-01-13 23:36:50 +08:00
|
|
|
|
<<<<<<< Updated upstream
|
2025-01-13 20:41:08 +08:00
|
|
|
|
# DNA Edit group
|
|
|
|
|
self.dna_edit_btn = MainButton(LANG[TOOL_LANG]["DNA Edit"])
|
|
|
|
|
self.dna_viewer_btn = MainButton(LANG[TOOL_LANG]["Open DNA Viewer"], color="#B8E6B3", hover_color="#C4F2BF", pressed_color="#A3D99E")
|
|
|
|
|
|
2025-01-13 23:36:50 +08:00
|
|
|
|
=======
|
|
|
|
|
|
|
|
|
|
>>>>>>> Stashed changes
|
2025-01-11 16:53:48 +08:00
|
|
|
|
# Prepare group
|
|
|
|
|
self.prepare_btn = MainButton(LANG[TOOL_LANG]["Prepare"])
|
|
|
|
|
self.body_prepare_btn = MainButton(LANG[TOOL_LANG]["Body Prepare"], color="#FFEBA1", hover_color="#FFF5B3", pressed_color="#FFE68A")
|
2025-01-13 23:36:50 +08:00
|
|
|
|
|
|
|
|
|
<<<<<<< Updated upstream
|
|
|
|
|
=======
|
|
|
|
|
# DNA Edit group
|
|
|
|
|
self.dna_edit_btn = MainButton(LANG[TOOL_LANG]["DNA Edit"])
|
|
|
|
|
self.dna_viewer_btn = MainButton(LANG[TOOL_LANG]["Open DNA Viewer"], color="#B8E6B3", hover_color="#C4F2BF", pressed_color="#A3D99E")
|
|
|
|
|
|
2025-01-11 16:53:48 +08:00
|
|
|
|
# Import group
|
|
|
|
|
self.import_btn = MainButton(LANG[TOOL_LANG]["Import"])
|
|
|
|
|
self.batch_import_btn = MainButton(LANG[TOOL_LANG]["Batch Import"], color="#A7C6ED", hover_color="#B2D3F0", pressed_color="#8BB8E0")
|
|
|
|
|
|
2025-01-13 23:36:50 +08:00
|
|
|
|
>>>>>>> Stashed changes
|
2025-01-13 20:41:08 +08:00
|
|
|
|
# Bottom buttons (existing code)
|
2025-01-11 16:53:48 +08:00
|
|
|
|
self.help_btn = BottomButton(LANG[TOOL_LANG]["Help"])
|
|
|
|
|
self.help_btn.setToolTip(LANG[TOOL_LANG]["Help"])
|
|
|
|
|
self.help_btn.setFixedSize(100, 20)
|
|
|
|
|
|
|
|
|
|
self.lang_btn = BottomButton(LANG[TOOL_LANG]["ZH" if TOOL_LANG == 'en_US' else "EN"])
|
|
|
|
|
self.lang_btn.setToolTip(LANG[TOOL_LANG]["Switch Language"])
|
|
|
|
|
self.lang_btn.setFixedSize(30, 20)
|
|
|
|
|
|
2025-01-13 20:41:08 +08:00
|
|
|
|
for button in [self.help_btn, self.lang_btn]:
|
|
|
|
|
button.setFont(QtGui.QFont("Microsoft YaHei", 10))
|
|
|
|
|
|
2025-01-11 16:53:48 +08:00
|
|
|
|
def create_layouts(self):
|
|
|
|
|
main_layout = QtWidgets.QVBoxLayout(self)
|
|
|
|
|
main_layout.setContentsMargins(2, 2, 2, 2)
|
|
|
|
|
content_layout = QtWidgets.QVBoxLayout()
|
|
|
|
|
content_layout.setContentsMargins(5, 5, 5, 5)
|
2025-01-13 23:36:50 +08:00
|
|
|
|
bottom_layout = QtWidgets.QHBoxLayout()
|
|
|
|
|
bottom_layout.setContentsMargins(5, 0, 5, 5)
|
2025-01-11 16:53:48 +08:00
|
|
|
|
|
2025-01-13 23:36:50 +08:00
|
|
|
|
prepare_group = QtWidgets.QGroupBox("Prepare")
|
2025-01-11 16:53:48 +08:00
|
|
|
|
prepare_layout = QtWidgets.QVBoxLayout(prepare_group)
|
|
|
|
|
prepare_layout.addWidget(self.body_prepare_btn)
|
|
|
|
|
content_layout.addWidget(prepare_group)
|
|
|
|
|
|
2025-01-13 23:36:50 +08:00
|
|
|
|
import_group = QtWidgets.QGroupBox("Import")
|
2025-01-11 16:53:48 +08:00
|
|
|
|
import_layout = QtWidgets.QVBoxLayout(import_group)
|
|
|
|
|
import_layout.addWidget(self.batch_import_btn)
|
|
|
|
|
content_layout.addWidget(import_group)
|
|
|
|
|
|
2025-01-13 23:36:50 +08:00
|
|
|
|
<<<<<<< Updated upstream
|
2025-01-11 16:53:48 +08:00
|
|
|
|
main_layout.addLayout(content_layout)
|
|
|
|
|
main_layout.addStretch()
|
|
|
|
|
|
2025-01-13 20:41:08 +08:00
|
|
|
|
# Bottom layout (existing code)
|
2025-01-11 16:53:48 +08:00
|
|
|
|
bottom_layout = QtWidgets.QHBoxLayout()
|
|
|
|
|
bottom_layout.setContentsMargins(5, 0, 5, 5)
|
|
|
|
|
|
2025-01-13 23:36:50 +08:00
|
|
|
|
=======
|
|
|
|
|
dna_edit_group = QtWidgets.QGroupBox("DNA Edit")
|
|
|
|
|
dna_edit_layout = QtWidgets.QVBoxLayout(dna_edit_group)
|
|
|
|
|
dna_edit_layout.addWidget(self.dna_viewer_btn)
|
|
|
|
|
content_layout.addWidget(dna_edit_group)
|
|
|
|
|
|
|
|
|
|
>>>>>>> Stashed changes
|
2025-01-11 16:53:48 +08:00
|
|
|
|
icon_label = QtWidgets.QLabel()
|
|
|
|
|
if os.path.exists(TOOL_ICON):
|
|
|
|
|
icon = QtGui.QPixmap(TOOL_ICON).scaled(24, 24, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
|
|
|
|
|
icon_label.setPixmap(icon)
|
2025-01-13 23:36:50 +08:00
|
|
|
|
|
2025-01-11 16:53:48 +08:00
|
|
|
|
version_label = QtWidgets.QLabel(f"{TOOL_VERSION}")
|
|
|
|
|
version_label.setStyleSheet("color: gray; font-size: 12px;")
|
2025-01-13 23:36:50 +08:00
|
|
|
|
|
2025-01-11 16:53:48 +08:00
|
|
|
|
bottom_layout.addWidget(icon_label)
|
|
|
|
|
bottom_layout.addWidget(version_label)
|
|
|
|
|
bottom_layout.addWidget(self.help_btn)
|
|
|
|
|
bottom_layout.addWidget(self.lang_btn)
|
2025-01-13 23:36:50 +08:00
|
|
|
|
|
|
|
|
|
main_layout.addLayout(content_layout)
|
2025-01-11 16:53:48 +08:00
|
|
|
|
main_layout.addLayout(bottom_layout)
|
2025-01-13 23:36:50 +08:00
|
|
|
|
main_layout.addStretch()
|
2025-01-11 16:53:48 +08:00
|
|
|
|
|
|
|
|
|
def create_connections(self):
|
|
|
|
|
self.body_prepare_btn.clicked.connect(self.run_body_prepare)
|
|
|
|
|
self.dna_viewer_btn.clicked.connect(self.run_dna_viewer)
|
2025-01-13 23:36:50 +08:00
|
|
|
|
<<<<<<< Updated upstream
|
2025-01-11 16:53:48 +08:00
|
|
|
|
|
2025-01-13 20:41:08 +08:00
|
|
|
|
# Existing connections
|
2025-01-13 23:36:50 +08:00
|
|
|
|
=======
|
|
|
|
|
self.batch_import_btn.clicked.connect(self.run_batch_import)
|
|
|
|
|
>>>>>>> Stashed changes
|
2025-01-11 16:53:48 +08:00
|
|
|
|
self.help_btn.clicked.connect(self.help)
|
|
|
|
|
self.lang_btn.clicked.connect(self.switch_language)
|
|
|
|
|
|
|
|
|
|
#===================================== FUNCTIONS =====================================
|
|
|
|
|
#===================================== MAIN FUNCTIONS =====================================
|
|
|
|
|
def run_body_prepare(self):
|
|
|
|
|
BodyPrep.run()
|
|
|
|
|
|
|
|
|
|
def run_batch_import(self):
|
|
|
|
|
BatchImport.run()
|
|
|
|
|
|
|
|
|
|
def run_dna_viewer(self):
|
2025-01-13 23:36:50 +08:00
|
|
|
|
<<<<<<< Updated upstream
|
2025-01-13 20:41:08 +08:00
|
|
|
|
import DNA_Viewer
|
|
|
|
|
DNA_Viewer.show()
|
|
|
|
|
|
2025-01-13 23:36:50 +08:00
|
|
|
|
=======
|
|
|
|
|
DNA_Viewer.show()
|
|
|
|
|
>>>>>>> Stashed changes
|
2025-01-11 16:53:48 +08:00
|
|
|
|
|
|
|
|
|
#===================================== BOTTOM LAYOUT =====================================
|
|
|
|
|
def help(self):
|
|
|
|
|
webbrowser.open(TOOL_HELP_URL)
|
|
|
|
|
|
|
|
|
|
def switch_language(self):
|
|
|
|
|
global TOOL_LANG
|
|
|
|
|
TOOL_LANG = 'en_US' if TOOL_LANG == 'zh_CN' else 'zh_CN'
|
|
|
|
|
self.lang_btn.setText("ZH" if TOOL_LANG == 'en_US' else "EN")
|
|
|
|
|
self.retranslate_ui()
|
|
|
|
|
QtWidgets.QToolTip.showText(
|
|
|
|
|
self.lang_btn.mapToGlobal(QtCore.QPoint(0, -30)),
|
|
|
|
|
"Language switched" if TOOL_LANG == 'en_US' else "语言已切换",
|
|
|
|
|
self.lang_btn
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def retranslate_ui(self):
|
2025-01-13 23:36:50 +08:00
|
|
|
|
<<<<<<< Updated upstream
|
2025-01-11 16:53:48 +08:00
|
|
|
|
|
|
|
|
|
# Update function button translations
|
2025-01-13 23:36:50 +08:00
|
|
|
|
=======
|
|
|
|
|
>>>>>>> Stashed changes
|
2025-01-13 20:41:08 +08:00
|
|
|
|
self.load_dna_btn.setText(LANG[TOOL_LANG]["Load DNA"])
|
2025-01-11 16:53:48 +08:00
|
|
|
|
self.body_prepare_btn.setText(LANG[TOOL_LANG]["Body Prepare"])
|
|
|
|
|
self.dna_viewer_btn.setText(LANG[TOOL_LANG]["Open DNA Viewer"])
|
2025-01-13 23:36:50 +08:00
|
|
|
|
self.batch_import_btn.setText(LANG[TOOL_LANG]["Batch Import"])
|
2025-01-11 16:53:48 +08:00
|
|
|
|
|
|
|
|
|
self.help_btn.setText(LANG[TOOL_LANG]["Help"])
|
|
|
|
|
self.lang_btn.setText("ZH" if TOOL_LANG == 'en_US' else "EN")
|
2025-01-13 23:36:50 +08:00
|
|
|
|
|
|
|
|
|
for button in [self.body_prepare_btn, self.dna_viewer_btn, self.batch_import_btn]:
|
|
|
|
|
button.setFont(QtGui.QFont("Microsoft YaHei", 10))
|
|
|
|
|
|
|
|
|
|
for button in [self.help_btn, self.lang_btn]:
|
2025-01-11 16:53:48 +08:00
|
|
|
|
button.setFont(QtGui.QFont("Microsoft YaHei", 10))
|
|
|
|
|
|
2025-01-13 20:41:08 +08:00
|
|
|
|
self.dna_file_label.setText(LANG[TOOL_LANG]["DNA File:"])
|
|
|
|
|
|
|
|
|
|
def on_dna_selected(self, dna_path):
|
|
|
|
|
"""当DNA被选中时"""
|
|
|
|
|
global DNA_File
|
|
|
|
|
DNA_File = dna_path
|
|
|
|
|
self.dna_file_input.setText(DNA_File)
|
|
|
|
|
print(f"Selected DNA file: {DNA_File}")
|
|
|
|
|
|
|
|
|
|
def on_dna_file_changed(self):
|
|
|
|
|
"""当DNA文件输入框内容改变时"""
|
|
|
|
|
global DNA_File
|
|
|
|
|
DNA_File = self.dna_file_input.text()
|
|
|
|
|
print(f"DNA file path updated: {DNA_File}")
|
|
|
|
|
|
2025-01-11 16:53:48 +08:00
|
|
|
|
#===================================== LAUNCH FUNCTIONS =====================================
|
|
|
|
|
def show():
|
2025-01-13 23:36:50 +08:00
|
|
|
|
return MainWindow.show_window()
|