This commit is contained in:
恍兮惚兮 2024-07-18 16:04:36 +08:00
parent 060acdc7d0
commit 95a7fc9020
3 changed files with 31 additions and 35 deletions

View File

@ -1,5 +1,5 @@
import time, uuid import time, uuid
import os, threading, sys, re, codecs import os, threading, sys, re, codecs, platform
from qtsymbols import * from qtsymbols import *
from traceback import print_exc from traceback import print_exc
from myutils.config import ( from myutils.config import (
@ -36,6 +36,7 @@ from gui.translatorUI import QUnFrameWindow
from gui.languageset import languageset from gui.languageset import languageset
import zhconv, functools import zhconv, functools
from gui.transhist import transhist from gui.transhist import transhist
from gui.usefulwidget import getQMessageBox
from gui.edittext import edittext from gui.edittext import edittext
import importlib, qtawesome import importlib, qtawesome
from functools import partial from functools import partial
@ -1190,6 +1191,31 @@ class MAINUI:
# QFontDatabase.SystemFont.GeneralFont # QFontDatabase.SystemFont.GeneralFont
# ).family() # ).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): def loadui(self):
self.installeventfillter() self.installeventfillter()
self.parsedefaultfont() self.parsedefaultfont()

View File

@ -1,5 +1,5 @@
import sys, windows import sys, windows
import platform, os, time import os
if __name__ == "__main__": if __name__ == "__main__":
_lock = windows.AutoHandle(windows.CreateMutex(False, "LUNA_UPDATER_BLOCK")) _lock = windows.AutoHandle(windows.CreateMutex(False, "LUNA_UPDATER_BLOCK"))
@ -10,8 +10,6 @@ if __name__ == "__main__":
"./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5Core.dll" "./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5Core.dll"
) # win7 no vcredist2015 ) # win7 no vcredist2015
from myutils.config import _TR, static_data, globalconfig
sys.path.append("./") sys.path.append("./")
sys.path.append("./userconfig") sys.path.append("./userconfig")
@ -47,34 +45,10 @@ if __name__ == "__main__":
app = QApplication(sys.argv) app = QApplication(sys.argv)
app.setQuitOnLastWindowClosed(False) 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 from LunaTranslator import MAINUI
gobject.baseobject = MAINUI() gobject.baseobject = MAINUI()
gobject.baseobject.checklang() gobject.baseobject.checklang()
gobject.baseobject.checkintegrity()
gobject.baseobject.loadui() gobject.baseobject.loadui()
app.exit(app.exec()) app.exit(app.exec())

View File

@ -123,13 +123,9 @@ def getQMessageBox(
useok=True, useok=True,
usecancel=False, usecancel=False,
okcallback=None, okcallback=None,
cancelcallback=None, cancelcallback=None
tr=True,
): ):
if tr: msgBox = LMessageBox(parent)
msgBox = LMessageBox(parent)
else:
msgBox = QMessageBox(parent)
msgBox.setWindowTitle((title)) msgBox.setWindowTitle((title))
msgBox.setText((text)) msgBox.setText((text))
btn = 0 btn = 0