Skip to content

Commit

Permalink
v9.5.0
Browse files Browse the repository at this point in the history
1、修复rename调用bug
2、修复打开网页bug
  • Loading branch information
cgkings committed Dec 15, 2024
1 parent dc6bcc9 commit 7ccaff3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 31 deletions.
34 changes: 8 additions & 26 deletions NFO.Editor.Qt5.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import shutil
import sys
import webbrowser
import xml.etree.ElementTree as ET
import xml.dom.minidom as minidom
from datetime import datetime
Expand Down Expand Up @@ -1277,34 +1278,15 @@ def open_batch_rename_tool(self):
QMessageBox.critical(self, "错误", f"目录不存在: {self.folder_path}")
return

# 获取Python解释器路径
python_executable = sys.executable
# 导入重命名工具
from cg_rename import RenameToolGUI

# 构建重命名工具脚本路径
rename_script = os.path.join(os.path.dirname(__file__), "cg_rename.py")

# 检查脚本文件是否存在
if not os.path.exists(rename_script):
QMessageBox.critical(self, "错误", "找不到重命名工具脚本(cg_rename.py)")
return

# 构建命令
cmd = [python_executable, rename_script, self.folder_path]

# 启动独立进程,并捕获可能的启动错误
try:
process = subprocess.Popen(
cmd,
creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0,
)

# 可选:检查进程是否成功启动
if process.poll() is not None: # 如果进程立即退出
QMessageBox.warning(self, "警告", "重命名工具可能未正常启动")

except subprocess.SubprocessError as se:
raise Exception(f"启动进程失败: {se}")
rename_tool = RenameToolGUI(parent=self) # 设置父窗口
rename_tool.path_entry.setText(self.folder_path) # 设置初始目录
rename_tool.show()

except ImportError:
QMessageBox.critical(self, "错误", "找不到重命名工具模块(cg_rename.py)")
except Exception as e:
QMessageBox.critical(self, "错误", f"启动重命名工具时出错: {str(e)}")

Expand Down
2 changes: 1 addition & 1 deletion NFO_Editor_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self):
self.screen_dpi = self.screen().logicalDotsPerInch()
self.scale_factor = self.screen_dpi / 96.0

self.setWindowTitle("大锤 NFO Editor Qt v9.3.9")
self.setWindowTitle("大锤 NFO Editor Qt v9.5.0")
self.resize(1280, 800)

try:
Expand Down
8 changes: 4 additions & 4 deletions cg_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def replace_folder_name(folder_path, new_name):


class RenameToolGUI(QMainWindow):
def __init__(self):
super().__init__()
def __init__(self, parent=None):
super().__init__(parent)
# 启用高DPI支持
if hasattr(Qt, "AA_EnableHighDpiScaling"):
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
Expand All @@ -210,8 +210,8 @@ def __init__(self):

def init_ui(self):
"""Initialize the UI"""
self.setWindowTitle("大锤批量改名工具 v9.3.9")
self.setMinimumSize(900, 600)
self.setWindowTitle("大锤批量改名工具 v9.5.0")
self.setMinimumSize(900, 800)

# 设置窗口样式
self.setStyleSheet(
Expand Down

0 comments on commit 7ccaff3

Please sign in to comment.