diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index 0ee53921..2274afb0 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -1,5 +1,5 @@ import time, uuid -import os, threading, sys, re, codecs +import os, threading, sys, re, codecs, platform from qtsymbols import * from traceback import print_exc from myutils.config import ( @@ -36,6 +36,7 @@ from gui.translatorUI import QUnFrameWindow from gui.languageset import languageset import zhconv, functools from gui.transhist import transhist +from gui.usefulwidget import getQMessageBox from gui.edittext import edittext import importlib, qtawesome from functools import partial @@ -1190,6 +1191,31 @@ class MAINUI: # QFontDatabase.SystemFont.GeneralFont # ).family() + def checkintegrity(self): + + js = static_data["checkintegrity"] + flist = js["shared"] + if platform.architecture()[0] == "64bit": + flist += js["64"] + else: + flist += js["32"] + collect = [] + for f in flist: + if os.path.exists(f) == False: + collect.append(f) + if len(collect): + + getQMessageBox( + None, + "错误", + _TR("找不到重要组件:") + + "\n" + + "\n".join(collect) + + "\n" + + _TR("请重新下载并关闭杀毒软件后重试"), + ) + os._exit(0) + def loadui(self): self.installeventfillter() self.parsedefaultfont() diff --git a/LunaTranslator/LunaTranslator/LunaTranslator_main.py b/LunaTranslator/LunaTranslator/LunaTranslator_main.py index 9382a2d4..fe5e74db 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator_main.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator_main.py @@ -1,5 +1,5 @@ import sys, windows -import platform, os, time +import os if __name__ == "__main__": _lock = windows.AutoHandle(windows.CreateMutex(False, "LUNA_UPDATER_BLOCK")) @@ -10,8 +10,6 @@ if __name__ == "__main__": "./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5Core.dll" ) # win7 no vcredist2015 - from myutils.config import _TR, static_data, globalconfig - sys.path.append("./") sys.path.append("./userconfig") @@ -47,34 +45,10 @@ if __name__ == "__main__": app = QApplication(sys.argv) app.setQuitOnLastWindowClosed(False) - js = static_data["checkintegrity"] - flist = js["shared"] - if platform.architecture()[0] == "64bit": - flist += js["64"] - else: - flist += js["32"] - collect = [] - for f in flist: - if os.path.exists(f) == False: - collect.append(f) - if len(collect): - from gui.usefulwidget import getQMessageBox - - getQMessageBox( - None, - _TR("错误"), - _TR("找不到重要组件:") - + "\n" - + "\n".join(collect) - + "\n" - + _TR("请重新下载并关闭杀毒软件后重试"), - tr=False, - ) - os._exit(0) - from LunaTranslator import MAINUI gobject.baseobject = MAINUI() gobject.baseobject.checklang() + gobject.baseobject.checkintegrity() gobject.baseobject.loadui() app.exit(app.exec()) diff --git a/LunaTranslator/LunaTranslator/gui/usefulwidget.py b/LunaTranslator/LunaTranslator/gui/usefulwidget.py index 532c117f..92451f0b 100644 --- a/LunaTranslator/LunaTranslator/gui/usefulwidget.py +++ b/LunaTranslator/LunaTranslator/gui/usefulwidget.py @@ -123,13 +123,9 @@ def getQMessageBox( useok=True, usecancel=False, okcallback=None, - cancelcallback=None, - tr=True, + cancelcallback=None ): - if tr: - msgBox = LMessageBox(parent) - else: - msgBox = QMessageBox(parent) + msgBox = LMessageBox(parent) msgBox.setWindowTitle((title)) msgBox.setText((text)) btn = 0