精简菜单栏

This commit is contained in:
gfdgd xi 2023-01-16 16:16:26 +08:00
parent 5d2fda8cdd
commit 613c6fa73d

View File

@ -130,79 +130,6 @@ class QT:
e1.setEditText(findExeHistory[-1])
repairList = []
# Flag: 日志推断解决方案功能
class LogChecking():
def ShowWindow():
global logThread
global logWindow
global questionList
global repairButton
logWindow = QtWidgets.QWidget()
logWindowLayout = QtWidgets.QGridLayout()
questionList = QtWidgets.QListView()
repairButton = QtWidgets.QPushButton("一键修复")
repairButton.setDisabled(True)
repairButton.clicked.connect(LogChecking.RepairButton)
nmodel = QtGui.QStandardItemModel(window)
item = QtGui.QStandardItem("正在分析中……")
questionList.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
nmodel.appendRow(item)
questionList.setModel(nmodel)
logWindowLayout.addWidget(questionList, 0, 0, 3, 1)
logWindowLayout.addWidget(repairButton, 0, 2, 1, 1)
logWindow.setWindowTitle("分析日志")
logWindow.setLayout(logWindowLayout)
logThread = LogThreading()
logThread.done.connect(LogChecking.Show)
logThread.start()
logWindow.setWindowIcon(QtGui.QIcon(f"{programPath}/deepin-wine-runner.svg"))
logWindow.resize(int(logWindow.frameGeometry().width() * 1.2), int(logWindow.frameGeometry().height() * 1.2))
logWindow.show()
def RepairButton():
index = questionList.currentIndex().row()
lists = questionMap[index]
print(f"{programPath}/CheckDLL/bash/{lists[1].lower()}.sh")
if lists[0] == 1 and os.path.exists(f"{programPath}/CheckDLL/bash/{lists[1].lower()}.sh"):
OpenTerminal(f"'{programPath}/AutoShell/main.py' '{programPath}/CheckDLL/bash/{lists[1].lower()}.sh'")
return
if lists[0] == 2:
QtWidgets.QMessageBox.information(logWindow, "修复方法", "切换其它 Wine")
return
if lists[0] == 4:
QtWidgets.QMessageBox.information(logWindow, "修复方法", "如是 Deepin Wine 可以尝试切换 WineHQ\n并且取消勾选运行器主页面菜单栏“程序”=>“设置Wine”取消勾选“屏蔽 Wine 默认 Mono 和 Gecko 安装器”\n然后尝试在菜单栏的“Wine”=>“在指定 Wine、容器安装组件”=>“在指定 Wine、容器安装 Gecko”来安装 Gecko")
return
if lists[0] == 5:
InstallMonoGecko("mono")
return
QtWidgets.QMessageBox.critical(logWindow, "错误", "无法修复该问题")
def Show(lists):
global questionMap
nmodel = QtGui.QStandardItemModel(window)
disbledButton = False
print(lists)
if not len(lists):
nmodel.appendRow(QtGui.QStandardItem(f"√ 无法分析到错误"))
disbledButton = True
for i in lists:
if i[0] == 0:
nmodel.appendRow(QtGui.QStandardItem(f"√ 无法分析到错误"))
disbledButton = True
break
if i[0] == 1:
nmodel.appendRow(QtGui.QStandardItem(f"× 无法调用 Dll{i[1]}"))
if i[0] == 2:
nmodel.appendRow(QtGui.QStandardItem(f"× 尝试用 Mono 运行非 .net 应用 {i[1]}"))
if i[0] == 3:
nmodel.appendRow(QtGui.QStandardItem(f" 无法加载 Gecko是被禁用或未安装"))
if i[0] == 4:
nmodel.appendRow(QtGui.QStandardItem(f"× 无法更新 Wine 容器版本,是否还有 Wine 程序运行?"))
if i[0] == 5:
nmodel.appendRow(QtGui.QStandardItem(f"× Mono 禁用/未安装"))
questionMap = lists[:]
repairButton.setDisabled(disbledButton)
questionList.setModel(nmodel)
class LogThreading(QtCore.QThread):
done = QtCore.pyqtSignal(list)
@ -1514,141 +1441,9 @@ class ProgramSetting():
return
QtWidgets.QMessageBox.information(ProgramSetting.message, "提示", "保存完毕!")
class ValueCheck():
def __init__(self):
pass
def BASE64(self, filePath):
src = ""
with open(filePath, "rb") as f:
base64Byte = base64.b64encode(f.read())
src += base64Byte.decode("utf-8")
return src
def SHA1(self, filePath):
sha1 = hashlib.sha1()
file = open(filePath, "rb")
while True:
readByte = file.read(1024 * 1024)
sha1.update(readByte)
if not readByte:
break
file.close()
return sha1.hexdigest()
def MD5(self, filePath):
md5 = hashlib.md5()
file = open(filePath, "rb")
while True:
readByte = file.read(1024 * 1024)
md5.update(readByte)
if not readByte:
break
file.close()
return md5.hexdigest()
def SHA256(self, filePath):
value = hashlib.sha256()
file = open(filePath, "rb")
while True:
readByte = file.read(1024 * 1024)
value.update(readByte)
if not readByte:
break
file.close()
return value.hexdigest()
def SHA384(self, filePath):
value = hashlib.sha384()
file = open(filePath, "rb")
while True:
readByte = file.read(1024 * 1024)
value.update(readByte)
if not readByte:
break
file.close()
return value.hexdigest()
def SHA224(self, filePath):
value = hashlib.sha224()
file = open(filePath, "rb")
while True:
readByte = file.read(1024 * 1024)
value.update(readByte)
if not readByte:
break
file.close()
return value.hexdigest()
def SHA512(self, filePath):
value = hashlib.sha512()
file = open(filePath, "rb")
while True:
readByte = file.read(1024 * 1024)
value.update(readByte)
if not readByte:
break
file.close()
return value.hexdigest()
link = {
"SHA1": SHA1,
"MD5": MD5,
"SHA256": SHA256,
"SHA512": SHA512,
"SHA224": SHA224,
"SHA384": SHA384,
"BASE64": BASE64
}
def Get(self, types):
QtWidgets.QMessageBox.information(window, "提示", "在计算过程中,程序可能会出现无响应的问题,请稍后\n请在接下来的打开对话框中选择要计算的文件")
file = QtWidgets.QFileDialog.getOpenFileName(window, "打开")[0]
if file == "":
return
try:
QtWidgets.QInputDialog.getMultiLineText(window, "", "计算得到的值", self.link[types](self, file))
except:
traceback.print_exc()
QtWidgets.QMessageBox.critical(window, "错误", traceback.format_exc())
def ChangePath():
e1.setCurrentText(f'{setting["DefultBotton"]}/{os.path.splitext(os.path.basename(e2.currentText()))[0]}')
def UploadLog():
if QtWidgets.QMessageBox.question(window, "提示", "您确定要上传吗?上传内容将不会公开,将用于加强日志分析功能") == QtWidgets.QMessageBox.Yes:
text = QtWidgets.QInputDialog.getMultiLineText(window, "输入内容", "输入描述信息")
try:
returnList = requests.post(base64.b64decode("aHR0cDovLzEyMC4yNS4xNTMuMTQ0OjMwMjUwL2xvZw==").decode("utf-8"), {
"Log": returnText.toPlainText(),
"Wine": wine[o1.currentText()],
"Tips": text
}).json()
if returnList["ExitCode"] == 0:
QtWidgets.QMessageBox.information(window, "提示", "上传成功!")
else:
print(returnList)
QtWidgets.QMessageBox.critical(window, "错误", "上传失败!")
except:
traceback.print_exc()
QtWidgets.QMessageBox.critical(window, "错误", "上传失败!")
def SaveLog():
path = QtWidgets.QFileDialog.getSaveFileName(window, "保存日志", get_home(), "txt文件(*.txt);;html 文件(*.html);;所有文件(*.*))")
if not path[1]:
return
print(path)
try:
with open(path[0], "w") as file:
if path[1] == "html 文件(*.html)":
file.write(returnText.toHtml())
else:
file.write(returnText.toPlainText())
except:
traceback.print_exc()
QtWidgets.QMessageBox.critical(window, "错误", traceback.format_exc())
def getFileFolderSize(fileOrFolderPath):
"""get size for file or folder"""
totalSize = 0
@ -1793,41 +1588,6 @@ def FindFile(file, name):
return path
return None
def TransLog():
oldText = returnText.toPlainText()
lineNumber = 0
transText = ""
chooseText = ""
for i in oldText.splitlines():
lineNumber += 1
chooseText += f"{i}\n"
if lineNumber >= 50:
lineNumber = 0
try:
data = { 'doctype': 'json', 'type': 'auto','i': chooseText.replace("\n\n", "\n")}
jsonReturn = requests.post("http://fanyi.youdao.com/translate", data=data).json()["translateResult"]
for i in jsonReturn:
print(i)
transText += f'{i[0]["tgt"]}\n'
chooseText = ""
except:
transText += f"{chooseText}\n"
chooseText = ""
if lineNumber != 0:
lineNumber = 0
try:
data = { 'doctype': 'json', 'type': 'auto','i': chooseText.replace("\n\n", "\n")}
jsonReturn = requests.post("http://fanyi.youdao.com/translate", data=data).json()["translateResult"]
for i in jsonReturn:
print(i[0])
transText += f'{i[0]["tgt"]}\n'
chooseText = ""
except:
transText += f"{chooseText}\n"
chooseText = ""
#return transText
returnText.setText(transText.replace("\n\n", "\n"))
###########################
# 加载配置
###########################
@ -2473,37 +2233,6 @@ v1 = QtWidgets.QAction(QtGui.QIcon.fromTheme("virtualbox"), transla.transe("U",
virtualMachine.addAction(v1)
v1.triggered.connect(RunVM)
checkValue = menu.addMenu(transla.transe("U", "校验值计算(&S)"))
md5Value = QtWidgets.QAction(QtWidgets.QApplication.style().standardIcon(32), transla.transe("U", "MD5(&M)"))
sha1Value = QtWidgets.QAction(QtWidgets.QApplication.style().standardIcon(32), transla.transe("U", "SHA1(&M)"))
base64Value = QtWidgets.QAction(QtWidgets.QApplication.style().standardIcon(32), transla.transe("U", "Base64(建议小文件)(&B)"))
sha256Value = QtWidgets.QAction(QtWidgets.QApplication.style().standardIcon(32), transla.transe("U", "SHA256(&S)"))
sha512Value = QtWidgets.QAction(QtWidgets.QApplication.style().standardIcon(32), transla.transe("U", "SHA512(&S)"))
md5Value.triggered.connect(lambda: ValueCheck().Get("MD5"))
sha1Value.triggered.connect(lambda: ValueCheck().Get("SHA1"))
base64Value.triggered.connect(lambda: ValueCheck().Get("BASE64"))
sha256Value.triggered.connect(lambda: ValueCheck().Get("SHA256"))
sha512Value.triggered.connect(lambda: ValueCheck().Get("SHA512"))
checkValue.addAction(md5Value)
checkValue.addAction(sha1Value)
checkValue.addAction(base64Value)
checkValue.addAction(sha256Value)
checkValue.addAction(sha512Value)
log = menu.addMenu(transla.transe("U", "日志(&L)"))
checkLogText = QtWidgets.QAction(transla.transe("U", "日志分析"))
saveLogText = QtWidgets.QAction(QtWidgets.QApplication.style().standardIcon(16), transla.transe("U", "另存为日志"))
transLogText = QtWidgets.QAction(transla.transe("U", "翻译日志(翻译后日志分析功能会故障)"))
uploadLogText = QtWidgets.QAction(transla.transe("U", "上传日志"))
checkLogText.triggered.connect(LogChecking.ShowWindow)
saveLogText.triggered.connect(SaveLog)
transLogText.triggered.connect(TransLog)
uploadLogText.triggered.connect(UploadLog)
log.addAction(checkLogText)
log.addAction(saveLogText)
log.addAction(transLogText)
log.addAction(uploadLogText)
help = menu.addMenu(transla.transe("U", "帮助(&H)"))
runStatusWebSize = QtWidgets.QAction(QtWidgets.QApplication.style().standardIcon(20), transla.transe("U", "查询程序在 Wine 的运行情况"))
h1 = help.addMenu(QtWidgets.QApplication.style().standardIcon(20), transla.transe("U", "程序官网"))