2021-05-29 22:54:59 +08:00
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# 使用系统默认的 python3 运行
|
|
|
|
|
###########################################################################################
|
2021-08-08 22:02:43 +08:00
|
|
|
|
# 作者:gfdgd xi<3025613752@qq.com>
|
2022-07-23 21:51:18 +08:00
|
|
|
|
# 版本:1.8.0
|
2022-07-26 14:57:48 +08:00
|
|
|
|
# 更新时间:2022年07月25日
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 感谢:anbox、deepin 和 UOS
|
2022-07-27 18:15:28 +08:00
|
|
|
|
# 基于 Python3 的 PyQt5 构建
|
2022-05-21 12:06:17 +08:00
|
|
|
|
# 更新:gfdgd xi<3025613752@qq.com>、actionchen<917981399@qq.com>、为什么您不喜欢熊出没和阿布呢
|
2021-05-29 22:54:59 +08:00
|
|
|
|
###########################################################################################
|
|
|
|
|
#################
|
|
|
|
|
# 引入所需的库
|
|
|
|
|
#################
|
|
|
|
|
import os
|
2022-06-19 14:03:40 +08:00
|
|
|
|
import api
|
2021-05-29 22:54:59 +08:00
|
|
|
|
import sys
|
|
|
|
|
import time
|
|
|
|
|
import json
|
2022-07-27 18:15:28 +08:00
|
|
|
|
import numpy
|
2022-07-28 20:04:59 +08:00
|
|
|
|
import base64
|
2021-05-29 22:54:59 +08:00
|
|
|
|
import shutil
|
2021-06-06 11:54:38 +08:00
|
|
|
|
import zipfile
|
2022-07-27 18:15:28 +08:00
|
|
|
|
import requests
|
2021-05-29 22:54:59 +08:00
|
|
|
|
import traceback
|
|
|
|
|
import threading
|
|
|
|
|
import webbrowser
|
|
|
|
|
import subprocess
|
2022-08-03 22:59:13 +08:00
|
|
|
|
map = True
|
|
|
|
|
try:
|
|
|
|
|
import matplotlib
|
|
|
|
|
import matplotlib.figure
|
|
|
|
|
import matplotlib.pylab
|
|
|
|
|
import matplotlib.font_manager
|
|
|
|
|
except:
|
|
|
|
|
map = False
|
2022-07-28 20:04:59 +08:00
|
|
|
|
import urllib.parse as parse
|
2022-07-23 21:51:18 +08:00
|
|
|
|
import PyQt5.QtGui as QtGui
|
|
|
|
|
import PyQt5.QtCore as QtCore
|
|
|
|
|
import PyQt5.QtWidgets as QtWidgets
|
2021-08-08 17:14:48 +08:00
|
|
|
|
from getxmlimg import getsavexml
|
2021-08-30 17:49:12 +08:00
|
|
|
|
|
2022-07-24 23:06:50 +08:00
|
|
|
|
class UninstallProgram(QtCore.QThread):
|
|
|
|
|
info = QtCore.pyqtSignal(str)
|
|
|
|
|
error = QtCore.pyqtSignal(str)
|
|
|
|
|
combo = QtCore.pyqtSignal(int)
|
2021-05-29 22:54:59 +08:00
|
|
|
|
|
2022-07-24 23:06:50 +08:00
|
|
|
|
def __init__(self, package) -> None:
|
|
|
|
|
self.package = package
|
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
package = self.package
|
|
|
|
|
try:
|
|
|
|
|
global fineUninstallApkHistory
|
2022-07-27 18:15:28 +08:00
|
|
|
|
Return = os.system("uengine uninstall --pkg='{}'".format(package))
|
2022-07-24 23:06:50 +08:00
|
|
|
|
print(Return)
|
|
|
|
|
if Return != 0:
|
|
|
|
|
self.error.emit("疑似卸载失败,请检查 UEngine 是否正常安装、运行以及 APK 文件或包名是否正确、完整")
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
return
|
|
|
|
|
if os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), package)):
|
|
|
|
|
os.remove("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), package))
|
|
|
|
|
if os.path.exists("{}/{}.desktop".format(get_desktop_path(), package)):
|
|
|
|
|
os.remove("{}/{}.desktop".format(get_desktop_path(), package))
|
|
|
|
|
findApkHistory.append(ComboInstallPath.currentText())
|
|
|
|
|
self.combo.emit(0)
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindApkHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
|
|
|
|
|
self.info.emit("操作执行完毕!")
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-27 18:15:28 +08:00
|
|
|
|
self.error.emit(traceback.format_exc())
|
2022-07-24 23:06:50 +08:00
|
|
|
|
DisabledAndEnbled(False)
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 卸载程序
|
2022-07-24 23:06:50 +08:00
|
|
|
|
#def UninstallProgram(package: "apk 包名")->"卸载程序":
|
|
|
|
|
# pass
|
2021-05-29 22:54:59 +08:00
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 卸载按钮事件
|
2021-07-02 20:05:01 +08:00
|
|
|
|
def ButtonClick8():
|
2022-07-24 23:06:50 +08:00
|
|
|
|
if ComboInstallPath.currentText() is "":
|
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", langFile[lang]["Main"]["MainWindow"]["Error"]["UninstallError"])
|
2021-07-02 20:38:34 +08:00
|
|
|
|
return
|
2021-07-02 20:05:01 +08:00
|
|
|
|
DisabledAndEnbled(True)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
if os.path.exists(ComboInstallPath.currentText()):
|
|
|
|
|
path = GetApkPackageName(ComboInstallPath.currentText())
|
2021-07-02 20:05:01 +08:00
|
|
|
|
else:
|
2022-07-24 23:06:50 +08:00
|
|
|
|
path = ComboInstallPath.currentText()
|
2022-02-11 16:38:03 +08:00
|
|
|
|
print(path)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
QT.installRun = UninstallProgram(path)
|
|
|
|
|
QT.installRun.error.connect(ErrorBox)
|
|
|
|
|
QT.installRun.info.connect(InformationBox)
|
|
|
|
|
QT.installRun.combo.connect(UpdateCombobox)
|
|
|
|
|
QT.installRun.start()
|
|
|
|
|
#threading.Thread(target=UninstallProgram, args=[path]).start()
|
2021-05-29 22:54:59 +08:00
|
|
|
|
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 浏览窗口
|
2021-08-08 17:14:48 +08:00
|
|
|
|
temppath=""
|
2021-07-11 14:45:11 +08:00
|
|
|
|
def FindApk()->"浏览窗口":
|
2022-07-24 23:06:50 +08:00
|
|
|
|
path = QtWidgets.QFileDialog.getOpenFileName(widget, "选择 Apk", json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApk.json"))["path"], "APK 文件(*.apk);;所有文件(*.*)")[0]
|
2021-08-08 17:14:48 +08:00
|
|
|
|
global temppath
|
|
|
|
|
temppath = path
|
|
|
|
|
print("apk path is find:" + path)
|
2021-05-29 22:54:59 +08:00
|
|
|
|
if path != "" and path != "()":
|
|
|
|
|
try:
|
2022-07-24 23:06:50 +08:00
|
|
|
|
ComboInstallPath.setEditText(path)
|
2021-05-29 22:54:59 +08:00
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindApk.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
2022-07-24 23:06:50 +08:00
|
|
|
|
class QT:
|
|
|
|
|
installRun = None
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 安装按钮事件
|
2021-05-29 22:54:59 +08:00
|
|
|
|
def Button3Install():
|
2022-07-24 23:06:50 +08:00
|
|
|
|
if ComboInstallPath.currentText() is "" or not os.path.exists(ComboInstallPath.currentText()):
|
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", langFile[lang]["Main"]["MainWindow"]["Error"]["InstallError"])
|
2021-05-29 22:54:59 +08:00
|
|
|
|
return
|
|
|
|
|
DisabledAndEnbled(True)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
#threading.Thread(target=InstallApk, args=(ComboInstallPath.get(),)).start()
|
|
|
|
|
QT.installRun = InstallApk(ComboInstallPath.currentText())
|
|
|
|
|
QT.installRun.infor.connect(InformationBox)
|
|
|
|
|
QT.installRun.error.connect(ErrorBox)
|
|
|
|
|
QT.installRun.combo.connect(UpdateCombobox)
|
2022-07-27 18:15:28 +08:00
|
|
|
|
QT.installRun.make.connect(InstallBuildDesktop)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
QT.installRun.start()
|
2021-05-29 22:54:59 +08:00
|
|
|
|
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 安装应用
|
2022-07-24 23:06:50 +08:00
|
|
|
|
class InstallApk(QtCore.QThread):
|
|
|
|
|
infor = QtCore.pyqtSignal(str)
|
|
|
|
|
error = QtCore.pyqtSignal(str)
|
|
|
|
|
combo = QtCore.pyqtSignal(int)
|
2022-07-27 18:15:28 +08:00
|
|
|
|
make = QtCore.pyqtSignal(str)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
|
|
|
|
|
def __init__(self, path, quit = False) -> None:
|
|
|
|
|
self.path = path
|
|
|
|
|
self.quit = quit
|
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
path = self.path
|
|
|
|
|
quit = self.quit
|
2022-02-11 16:38:03 +08:00
|
|
|
|
try:
|
2022-07-24 23:06:50 +08:00
|
|
|
|
if not os.path.exists("/tmp/uengine-runner"):
|
|
|
|
|
os.makedirs("/tmp/uengine-runner")
|
|
|
|
|
if not os.path.exists("{}/.local/share/applications/uengine/".format(get_home())):
|
|
|
|
|
print("Mkdir")
|
|
|
|
|
os.makedirs("{}/.local/share/applications/uengine/".format(get_home()))
|
|
|
|
|
# 读取设置
|
|
|
|
|
setting = json.loads(readtxt(get_home() + "/.config/uengine-runner/setting.json"))
|
|
|
|
|
# 安装应用
|
|
|
|
|
print("start install apk")
|
|
|
|
|
global findApkHistory
|
|
|
|
|
print("start install apk12")
|
|
|
|
|
iconSavePath = "{}/.local/share/icons/hicolor/256x256/apps/{}.png".format(get_home(), GetApkPackageName(path))
|
|
|
|
|
tempstr1 = iconSavePath
|
|
|
|
|
print("start install apk1")
|
|
|
|
|
iconSaveDir = os.path.dirname(iconSavePath)
|
|
|
|
|
if not os.path.exists(iconSaveDir):
|
|
|
|
|
os.makedirs(iconSaveDir,exist_ok=True)
|
|
|
|
|
SaveApkIcon(path, iconSavePath)
|
|
|
|
|
try:
|
|
|
|
|
if setting["SaveApk"]:
|
|
|
|
|
shutil.copy(path, "/tmp/uengine-runner/bak.apk")
|
|
|
|
|
except:
|
|
|
|
|
if QtWidgets.QMessageBox.critical(widget, "错误", "无法备份安装包,是否不备份安装包继续安装?\n提示:新版UEngine安装后会自动删除安装包") == QtWidgets.QMessageBox.No:
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
return
|
|
|
|
|
setting["SaveApk"] = False
|
2022-08-03 22:59:13 +08:00
|
|
|
|
if " " in path:
|
|
|
|
|
i = 0
|
|
|
|
|
while True:
|
|
|
|
|
if os.path.exists(f"{os.path.dirname(path)}/install{i}.apk"):
|
|
|
|
|
i += 1
|
|
|
|
|
continue
|
|
|
|
|
shutil.move(path, f"{os.path.dirname(path)}/install{i}.apk")
|
|
|
|
|
print(f"uengine install --apk='{os.path.dirname(path)}/install{i}.apk'")
|
|
|
|
|
commandReturn = os.system(f"uengine install --apk='{os.path.dirname(path)}/install{i}.apk'")
|
|
|
|
|
shutil.move(f"{os.path.dirname(path)}/install{i}.apk", path)
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
print("uengine install --apk='{}'".format(path))
|
|
|
|
|
commandReturn = os.system("uengine install --apk='{}'".format(path))
|
2022-07-24 23:06:50 +08:00
|
|
|
|
try:
|
|
|
|
|
if setting["SaveApk"]:
|
|
|
|
|
shutil.copy("/tmp/uengine-runner/bak.apk", path)
|
|
|
|
|
except:
|
|
|
|
|
self.error.emit(langFile[lang]["Main"]["MainWindow"]["Error"]["BackApkError"])
|
|
|
|
|
if commandReturn != 0:
|
|
|
|
|
self.error.emit("疑似 APK 安装失败,请检查 UEngine 是否正常安装、运行以及 APK 文件是否正确、完整")
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
return
|
2022-07-27 18:15:28 +08:00
|
|
|
|
if settingConf["AutoScreenConfig"]:
|
|
|
|
|
# 计算最合适的大小
|
|
|
|
|
# 竖屏
|
|
|
|
|
screen = QtGui.QGuiApplication.primaryScreen()
|
|
|
|
|
mm = screen.availableGeometry()
|
|
|
|
|
verticalHeighe = int(mm.height() * 0.9) # 竖屏高
|
|
|
|
|
verticalWidth = int(verticalHeighe / 16 * 9) # 竖屏宽
|
|
|
|
|
horizontaltWidth = int(mm.width() * 0.8) # 横屏宽
|
|
|
|
|
horizontaltHeighe = int(horizontaltWidth / 16 * 9) # 横屏高
|
|
|
|
|
|
|
|
|
|
#verticalHeighe =
|
|
|
|
|
write_txt(f"/tmp/{GetApkPackageName(path)}.txt", f"""verticalWidth {verticalWidth} //竖屏宽
|
|
|
|
|
verticalHeighe {verticalHeighe} //竖屏高
|
|
|
|
|
horizontaltWidth {horizontaltWidth} //横屏宽,备选为1280
|
|
|
|
|
horizontaltHeighe {horizontaltHeighe} //横屏高 ,备选为720
|
|
|
|
|
verticalScreen 1 //设置默认横屏还是竖屏,1为竖屏,0为横屏
|
|
|
|
|
allowFullScreen 1 //设置是否允许全屏,1为允许,0为不允许
|
|
|
|
|
allowScreenSwitching 1 //设置是否允许横竖屏切换,1为允许,0为不允许
|
|
|
|
|
defaultFullScreen 0 //设置是否默认显示最大化,1为默认最大化,0为不是
|
|
|
|
|
|
|
|
|
|
logicalDensityDpi 160
|
|
|
|
|
physicalDpi 72
|
|
|
|
|
appWidth {verticalWidth}
|
|
|
|
|
appHeight {verticalHeighe}
|
|
|
|
|
logicalWidth {verticalWidth}
|
|
|
|
|
logicalHeight {verticalHeighe}
|
|
|
|
|
""")
|
|
|
|
|
if os.system(f"pkexec '{programPath}/uengine-window-size-setting.py' -a {GetApkPackageName(path)}"):
|
|
|
|
|
self.error.emit("屏幕配置设置失败")
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
return
|
|
|
|
|
if settingConf["ChooseProgramType"]:
|
|
|
|
|
self.make.emit(iconSavePath)
|
|
|
|
|
else:
|
|
|
|
|
BuildUengineDesktop(GetApkPackageName(path), GetApkActivityName(path), GetApkChineseLabel(path), iconSavePath,
|
|
|
|
|
"{}/{}.desktop".format(get_desktop_path(), GetApkPackageName(path)))
|
|
|
|
|
print("start install apk3")
|
|
|
|
|
BuildUengineDesktop(GetApkPackageName(path), GetApkActivityName(path), GetApkChineseLabel(path), iconSavePath,
|
|
|
|
|
"{}/.local/share/applications/uengine/{}.desktop".format(get_home(), GetApkPackageName(path)))
|
|
|
|
|
print("\nprint install complete")
|
2022-07-24 23:06:50 +08:00
|
|
|
|
if quit:
|
|
|
|
|
return
|
|
|
|
|
findApkHistory.append(ComboInstallPath.currentText())
|
|
|
|
|
self.combo.emit(0)
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindApkHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
|
2022-07-27 18:15:28 +08:00
|
|
|
|
self.infor.emit("操作完成!")
|
2022-02-11 16:38:03 +08:00
|
|
|
|
except:
|
2022-07-24 23:06:50 +08:00
|
|
|
|
traceback.print_exc()
|
|
|
|
|
self.error.emit(traceback.format_exc())
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
|
2022-07-27 18:15:28 +08:00
|
|
|
|
def InstallBuildDesktop(iconSavePath):
|
|
|
|
|
choose = QtWidgets.QInputDialog.getItem(widget, "提示", "请选择分类,如果点击取消,将会设置为默认的分类", ["Network", "Chat", "Audio", "Video", "Graphics", "Office", "Translation", "Development", "Utility"])[0]
|
|
|
|
|
path = ComboInstallPath.currentText()
|
|
|
|
|
BuildUengineDesktop(GetApkPackageName(path), GetApkActivityName(path), GetApkChineseLabel(path), iconSavePath,
|
|
|
|
|
"{}/{}.desktop".format(get_desktop_path(), GetApkPackageName(path)), choose)
|
|
|
|
|
print("start install apk3")
|
|
|
|
|
BuildUengineDesktop(GetApkPackageName(path), GetApkActivityName(path), GetApkChineseLabel(path), iconSavePath,
|
|
|
|
|
"{}/.local/share/applications/uengine/{}.desktop".format(get_home(), GetApkPackageName(path)), choose)
|
|
|
|
|
print("\nprint install complete")
|
|
|
|
|
|
2022-07-24 23:06:50 +08:00
|
|
|
|
def UpdateCombobox(tmp):
|
|
|
|
|
ComboInstallPath.clear()
|
|
|
|
|
ComboInstallPath.addItems(findApkHistory)
|
|
|
|
|
ComboInstallPath.setEditText(findApkHistory[-1])
|
|
|
|
|
|
|
|
|
|
def ErrorBox(error):
|
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", error)
|
|
|
|
|
|
|
|
|
|
def InformationBox(info):
|
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", info)
|
2021-05-29 22:54:59 +08:00
|
|
|
|
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 禁用或启动所有控件
|
|
|
|
|
def DisabledAndEnbled(choose: "启动或者禁用")->"禁用或启动所有控件":
|
2022-07-24 23:06:50 +08:00
|
|
|
|
ComboInstallPath.setDisabled(choose)
|
2021-09-26 20:16:29 +08:00
|
|
|
|
#ComboUninstallPath.configure(state=a)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
BtnFindApk.setDisabled(choose)
|
|
|
|
|
BtnInstall.setDisabled(choose)
|
|
|
|
|
BtnShowUengineApp.setDisabled(choose)
|
2021-09-26 20:16:29 +08:00
|
|
|
|
#BtnUninstallApkBrowser.configure(state=a)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
BtnUninstall.setDisabled(choose)
|
|
|
|
|
Btngeticon.setDisabled(choose)
|
|
|
|
|
BtnSaveApk.setDisabled(choose)
|
|
|
|
|
BtnApkInformation.setDisabled(choose)
|
|
|
|
|
LabApkPath.setDisabled(choose)
|
2021-05-29 22:54:59 +08:00
|
|
|
|
|
|
|
|
|
# 需引入 subprocess
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 运行系统命令并获取返回值
|
|
|
|
|
def GetCommandReturn(cmd: "命令")->"运行系统命令并获取返回值":
|
2021-05-29 22:54:59 +08:00
|
|
|
|
# cmd 是要获取输出的命令
|
|
|
|
|
return subprocess.getoutput(cmd)
|
|
|
|
|
|
2021-10-03 17:42:30 +08:00
|
|
|
|
def GetSystemVersion():
|
|
|
|
|
systemInformation = readtxt("/etc/os-release")
|
|
|
|
|
for systemInformation in systemInformation.split('\n'):
|
|
|
|
|
if "PRETTY_NAME=" in systemInformation:
|
|
|
|
|
return systemInformation.replace("PRETTY_NAME=", "").replace('"', '')
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 打开所有窗口事件
|
2021-05-29 22:54:59 +08:00
|
|
|
|
def Button5Click():
|
|
|
|
|
threading.Thread(target=OpenUengineProgramList).start()
|
|
|
|
|
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 打开“uengine 所有程序列表”
|
|
|
|
|
def OpenUengineProgramList()->"打开“uengine 所有程序列表”":
|
2021-10-03 17:42:30 +08:00
|
|
|
|
os.system("uengine launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity")
|
2021-05-29 22:54:59 +08:00
|
|
|
|
|
|
|
|
|
# 打开程序官网
|
2021-07-11 14:45:11 +08:00
|
|
|
|
def OpenProgramURL()->"打开程序官网":
|
2021-05-29 22:54:59 +08:00
|
|
|
|
webbrowser.open_new_tab(programUrl)
|
|
|
|
|
|
|
|
|
|
# 重启本应用程序
|
2021-07-11 14:45:11 +08:00
|
|
|
|
def ReStartProgram()->"重启本应用程序":
|
2021-05-29 22:54:59 +08:00
|
|
|
|
python = sys.executable
|
|
|
|
|
os.execl(python, python, * sys.argv)
|
|
|
|
|
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 清理历史记录
|
|
|
|
|
def CleanProgramHistory()->"清理历史记录":
|
2021-05-29 22:54:59 +08:00
|
|
|
|
try:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if QtWidgets.QMessageBox.warning(widget, "警告", "删除后将无法恢复,你确定吗?\n删除后软件将会自动重启。", QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Cancel) == QtWidgets.QMessageBox.Ok:
|
2021-05-29 22:54:59 +08:00
|
|
|
|
shutil.rmtree(get_home() + "/.config/uengine-runner")
|
|
|
|
|
ReStartProgram()
|
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
2021-05-29 22:54:59 +08:00
|
|
|
|
|
|
|
|
|
# 获取用户主目录
|
2021-07-11 14:45:11 +08:00
|
|
|
|
def get_home()->"获取用户主目录":
|
2021-05-29 22:54:59 +08:00
|
|
|
|
return os.path.expanduser('~')
|
|
|
|
|
|
2021-09-20 17:10:05 +08:00
|
|
|
|
# 获取当前语言
|
|
|
|
|
def get_now_lang()->"获取当前语言":
|
|
|
|
|
return os.getenv('LANG')
|
|
|
|
|
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 发送“启动 uengine 所有程序”的 .desktop 文件到桌面
|
|
|
|
|
def SendUengineAndroidListForDesktop()->"发送“启动 uengine 所有程序”的 .desktop 文件到桌面":
|
2021-05-29 22:54:59 +08:00
|
|
|
|
global desktop
|
|
|
|
|
global desktopName
|
|
|
|
|
DisabledAndEnbled(True)
|
|
|
|
|
try:
|
|
|
|
|
if os.path.exists("{}/{}".format(get_desktop_path(), desktopName)):
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if QtWidgets.QMessageBox.question(widget, "提示", "桌面已经存在快捷方式,你确定要覆盖吗?") == QtWidgets.QMessageBox.No:
|
2021-05-29 22:54:59 +08:00
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
return
|
|
|
|
|
shutil.copy(desktop, get_desktop_path())
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "提示", "发送成功!")
|
2021-05-29 22:54:59 +08:00
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
2021-05-29 22:54:59 +08:00
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
|
|
|
|
|
# 获取用户桌面目录
|
2021-07-11 14:45:11 +08:00
|
|
|
|
def get_desktop_path()->"获取用户桌面目录":
|
2021-05-29 22:54:59 +08:00
|
|
|
|
for line in open(get_home() + "/.config/user-dirs.dirs"): # 以行来读取配置文件
|
|
|
|
|
desktop_index = line.find("XDG_DESKTOP_DIR=\"") # 寻找是否有对应项,有返回 0,没有返回 -1
|
|
|
|
|
if desktop_index != -1: # 如果有对应项
|
|
|
|
|
break # 结束循环
|
|
|
|
|
if desktop_index == -1: # 如果是提前结束,值一定≠-1,如果是没有提前结束,值一定=-1
|
|
|
|
|
return -1
|
|
|
|
|
else:
|
|
|
|
|
get = line[17:-2] # 截取桌面目录路径
|
|
|
|
|
get_index = get.find("$HOME") # 寻找是否有对应的项,需要替换内容
|
|
|
|
|
if get != -1: # 如果有
|
|
|
|
|
get = get.replace("$HOME", get_home()) # 则把其替换为用户目录(~)
|
|
|
|
|
return get # 返回目录
|
|
|
|
|
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 发送“启动 uengine 所有程序”的 .desktop 文件到启动器
|
|
|
|
|
def SendUengineAndroidListForLauncher()->"发送“启动 uengine 所有程序”的 .desktop 文件到启动器":
|
2021-05-29 22:54:59 +08:00
|
|
|
|
DisabledAndEnbled(True)
|
|
|
|
|
try:
|
|
|
|
|
if os.path.exists("{}/.local/share/applications/{}".format(get_home(), desktopName)):
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if QtWidgets.QMessageBox.question(widget, "提示", "启动器已经存在快捷方式,你确定要覆盖吗?") == QtWidgets.QMessageBox.No:
|
2021-05-29 22:54:59 +08:00
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
return
|
|
|
|
|
if not os.path.exists("{}/.local/share/applications/".format(get_home())):
|
|
|
|
|
os.makedirs("{}/.local/share/applications/".format(get_home()))
|
|
|
|
|
shutil.copy(desktop, "{}/.local/share/applications/{}".format(get_home(), desktopName))
|
|
|
|
|
os.system("chmod 755 {}/.local/share/applications/{}".format(get_home(), desktopName))
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "提示", "发送成功!")
|
2021-05-29 22:54:59 +08:00
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
2021-05-29 22:54:59 +08:00
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
|
|
|
|
|
# 数组转字典
|
2021-07-11 14:45:11 +08:00
|
|
|
|
def ListToDictionary(list: "需要转换的数组")->"数组转字典":
|
2021-05-29 22:54:59 +08:00
|
|
|
|
dictionary = {}
|
|
|
|
|
for i in range(len(list)):
|
|
|
|
|
dictionary[i] = list[i]
|
|
|
|
|
return dictionary
|
|
|
|
|
|
|
|
|
|
# 读取文本文档
|
2021-07-11 14:45:11 +08:00
|
|
|
|
def readtxt(path: "路径")->"读取文本文档":
|
2021-05-29 22:54:59 +08:00
|
|
|
|
f = open(path, "r") # 设置文件对象
|
|
|
|
|
str = f.read() # 获取内容
|
|
|
|
|
f.close() # 关闭文本对象
|
|
|
|
|
return str # 返回结果
|
|
|
|
|
|
|
|
|
|
# 写入文本文档
|
2021-07-11 14:45:11 +08:00
|
|
|
|
def write_txt(path: "路径", things: "内容")->"写入文本文档":
|
2021-08-08 17:14:48 +08:00
|
|
|
|
TxtDir = os.path.dirname(path)
|
|
|
|
|
print(TxtDir)
|
|
|
|
|
if not os.path.exists(TxtDir):
|
|
|
|
|
os.makedirs(TxtDir,exist_ok=True)
|
2021-05-29 22:54:59 +08:00
|
|
|
|
file = open(path, 'w', encoding='UTF-8') # 设置文件对象
|
|
|
|
|
file.write(things) # 写入文本
|
|
|
|
|
file.close() # 关闭文本对象
|
|
|
|
|
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 获取 aapt 的所有信息
|
|
|
|
|
def GetApkInformation(apkFilePath: "apk 所在路径")->"获取 aapt 的所有信息":
|
2021-06-06 11:54:38 +08:00
|
|
|
|
return GetCommandReturn("aapt dump badging '{}'".format(apkFilePath))
|
|
|
|
|
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 获取 apk Activity
|
|
|
|
|
def GetApkActivityName(apkFilePath: "apk 所在路径")->"获取 apk Activity":
|
2021-06-06 11:54:38 +08:00
|
|
|
|
info = GetApkInformation(apkFilePath)
|
|
|
|
|
for line in info.split('\n'):
|
|
|
|
|
if "launchable-activity" in line:
|
|
|
|
|
line = line[0: line.index("label='")]
|
|
|
|
|
line = line.replace("launchable-activity: ", "")
|
|
|
|
|
line = line.replace("'", "")
|
|
|
|
|
line = line.replace(" ", "")
|
|
|
|
|
line = line.replace("name=", "")
|
|
|
|
|
line = line.replace("label=", "")
|
|
|
|
|
line = line.replace("icon=", "")
|
|
|
|
|
return line
|
|
|
|
|
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 获取 apk 包名
|
|
|
|
|
def GetApkPackageName(apkFilePath: "apk 所在路径")->"获取 apk 包名":
|
2021-06-06 11:54:38 +08:00
|
|
|
|
info = GetApkInformation(apkFilePath)
|
|
|
|
|
for line in info.split('\n'):
|
|
|
|
|
if "package:" in line:
|
|
|
|
|
line = line[0: line.index("versionCode='")]
|
|
|
|
|
line = line.replace("package:", "")
|
|
|
|
|
line = line.replace("name=", "")
|
|
|
|
|
line = line.replace("'", "")
|
|
|
|
|
line = line.replace(" ", "")
|
|
|
|
|
return line
|
|
|
|
|
|
2021-11-28 16:11:01 +08:00
|
|
|
|
def InstallRootUengineImage():
|
|
|
|
|
if not os.path.exists:
|
|
|
|
|
os.mkdir("/tmp/uengine-runner")
|
|
|
|
|
write_txt("/tmp/uengine-runner/install.sh", "sudo dpkg -i /tmp/uengine-runner/u*.deb\nsudo apt install -f")
|
2022-07-07 14:35:44 +08:00
|
|
|
|
threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C \"wget -P '/tmp/uengine-runner' 'https://hub.fastgit.xyz/gfdgd-xi/uengine-runner/releases/download/U1.2.15/uengine-android-image_1.2.15_amd64.deb' && pkexec bash '/tmp/uengine-runner/install.sh'\""]).start()
|
2021-11-28 16:11:01 +08:00
|
|
|
|
|
2022-06-12 22:25:02 +08:00
|
|
|
|
def UengineUbuntuInstall():
|
2022-07-07 14:35:44 +08:00
|
|
|
|
threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C \"bash '{programPath + '/uengine-installer'}'\""]).start()
|
2022-06-12 22:25:02 +08:00
|
|
|
|
|
2022-06-19 21:04:16 +08:00
|
|
|
|
def UbuntuInstallUengine():
|
2022-07-07 14:35:44 +08:00
|
|
|
|
threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C \"bash '{programPath + '/uengine-installer'}'\""]).start()
|
2022-06-19 21:04:16 +08:00
|
|
|
|
|
2021-11-28 16:11:01 +08:00
|
|
|
|
def BuildRootUengineImage():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C \"bash '{programPath}/root-uengine.sh'\""]).start()
|
2021-11-28 16:11:01 +08:00
|
|
|
|
|
|
|
|
|
def ReinstallUengineImage():
|
2022-07-07 14:35:44 +08:00
|
|
|
|
threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -e ''pkexec apt reinstall uengine-android-image -y"]).start()
|
2021-11-28 16:11:01 +08:00
|
|
|
|
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 生成 uengine 启动文件到桌面
|
2022-07-27 18:15:28 +08:00
|
|
|
|
def BuildUengineDesktop(packageName: "软件包名", activityName: "activity", showName: "显示名称", iconPath: "程序图标所在目录", savePath:".desktop 文件保存路径", choose="")->"生成 uengine 启动文件到桌面":
|
2022-02-07 22:35:15 +08:00
|
|
|
|
if showName == "" or showName == None:
|
|
|
|
|
showName = "未知应用"
|
2022-07-27 18:15:28 +08:00
|
|
|
|
if choose != "":
|
|
|
|
|
things = f'''[Desktop Entry]
|
|
|
|
|
Encoding=UTF-8
|
|
|
|
|
Exec=uengine launch --action=android.intent.action.MAIN --package={packageName} --component={activityName}
|
|
|
|
|
GenericName={showName}
|
|
|
|
|
Icon={iconPath}
|
|
|
|
|
MimeType=
|
|
|
|
|
Name={showName}
|
|
|
|
|
StartupWMClass={showName}
|
|
|
|
|
Categories={choose};
|
|
|
|
|
Terminal=false
|
|
|
|
|
Type=Application
|
|
|
|
|
'''
|
|
|
|
|
else:
|
|
|
|
|
things = f'''[Desktop Entry]
|
2021-06-06 11:54:38 +08:00
|
|
|
|
Categories=app;
|
|
|
|
|
Encoding=UTF-8
|
2022-07-27 18:15:28 +08:00
|
|
|
|
Exec=uengine launch --action=android.intent.action.MAIN --package={packageName} --component={activityName}
|
|
|
|
|
GenericName={showName}
|
|
|
|
|
Icon={iconPath}
|
2021-06-06 11:54:38 +08:00
|
|
|
|
MimeType=
|
2022-07-27 18:15:28 +08:00
|
|
|
|
Name={showName}
|
|
|
|
|
StartupWMClass={showName}
|
2021-06-06 11:54:38 +08:00
|
|
|
|
Terminal=false
|
|
|
|
|
Type=Application
|
2022-07-27 18:15:28 +08:00
|
|
|
|
'''
|
2021-06-06 11:54:38 +08:00
|
|
|
|
write_txt(savePath, things)
|
|
|
|
|
|
2021-07-11 14:45:11 +08:00
|
|
|
|
# 获取软件的中文名称
|
|
|
|
|
def GetApkChineseLabel(apkFilePath)->"获取软件的中文名称":
|
2021-06-06 11:54:38 +08:00
|
|
|
|
info = GetApkInformation(apkFilePath)
|
|
|
|
|
for line in info.split('\n'):
|
|
|
|
|
if "application-label:" in line:
|
|
|
|
|
line = line.replace("application-label:", "")
|
|
|
|
|
line = line.replace("'", "")
|
|
|
|
|
return line
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 保存apk图标
|
|
|
|
|
def SaveApkIcon(apkFilePath, iconSavePath)->"保存 apk 文件的图标":
|
2021-08-12 15:12:13 +08:00
|
|
|
|
try:
|
2022-02-11 16:38:03 +08:00
|
|
|
|
if os.path.exists(iconSavePath):
|
|
|
|
|
os.remove(iconSavePath)
|
2021-08-12 15:12:13 +08:00
|
|
|
|
info = GetApkInformation(apkFilePath)
|
|
|
|
|
for line in info.split('\n'):
|
|
|
|
|
if "application:" in line:
|
|
|
|
|
xmlpath = line.split(":")[-1].split()[-1].split("=")[-1].replace("'","")
|
|
|
|
|
if xmlpath.endswith('.xml'):
|
|
|
|
|
xmlsave = getsavexml()
|
|
|
|
|
print(xmlpath)
|
|
|
|
|
xmlsave.savexml(apkFilePath,xmlpath,iconSavePath)
|
2022-02-07 22:35:15 +08:00
|
|
|
|
return
|
2021-08-12 15:12:13 +08:00
|
|
|
|
else:
|
|
|
|
|
zip = zipfile.ZipFile(apkFilePath)
|
|
|
|
|
iconData = zip.read(xmlpath)
|
|
|
|
|
with open(iconSavePath, 'w+b') as saveIconFile:
|
|
|
|
|
saveIconFile.write(iconData)
|
2022-02-07 22:35:15 +08:00
|
|
|
|
return
|
|
|
|
|
print("None Icon! Show defult icon")
|
|
|
|
|
shutil.copy(programPath + "/defult.png", iconSavePath)
|
2021-08-12 15:12:13 +08:00
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
|
|
|
|
print("Error, show defult icon")
|
|
|
|
|
shutil.copy(programPath + "/defult.png", iconSavePath)
|
2021-08-08 17:14:48 +08:00
|
|
|
|
|
|
|
|
|
def saveicon():
|
|
|
|
|
global temppath
|
|
|
|
|
global tempstr1
|
|
|
|
|
iconSavePath = "{}/.local/share/icons/hicolor/256x256/apps/{}.png".format(get_home(), GetApkPackageName(temppath))
|
|
|
|
|
print(iconSavePath+"iconpaths")
|
|
|
|
|
SaveApkIcon(temppath, iconSavePath)
|
|
|
|
|
|
2021-08-26 15:24:26 +08:00
|
|
|
|
def KeyboardToMouse():
|
|
|
|
|
threading.Thread(target=os.system, args=["pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY {}/uengine-keyboard".format(programPath)]).start()
|
|
|
|
|
|
2022-07-26 14:57:48 +08:00
|
|
|
|
# 用户自行保存
|
2021-08-08 22:02:43 +08:00
|
|
|
|
def SaveIconToOtherPath():
|
2022-07-24 23:06:50 +08:00
|
|
|
|
apkPath = ComboInstallPath.currentText()
|
2021-08-08 22:02:43 +08:00
|
|
|
|
if apkPath == "":
|
2022-07-24 23:06:50 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", langFile[lang]["Main"]["MainWindow"]["Error"]["ChooseApkError"])
|
2021-08-08 22:02:43 +08:00
|
|
|
|
return
|
2022-07-24 23:12:34 +08:00
|
|
|
|
path = QtWidgets.QFileDialog.getSaveFileName(widget, "保存图标", "icon.png", "PNG 图片(*.png);;所有文件(*.*)", json.loads(readtxt(get_home() + "/.config/uengine-runner/SaveApkIcon.json"))["path"])[0]
|
2021-08-08 22:02:43 +08:00
|
|
|
|
if not path == "":
|
|
|
|
|
try:
|
|
|
|
|
SaveApkIcon(apkPath, path)
|
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-24 23:12:34 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", langFile[lang]["Main"]["MainWindow"]["Error"]["SaveApkIconError"])
|
2021-08-08 22:02:43 +08:00
|
|
|
|
return
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/SaveApkIcon.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
|
2022-07-24 23:12:34 +08:00
|
|
|
|
findApkHistory.append(ComboInstallPath.currentText())
|
|
|
|
|
UpdateCombobox(0)
|
2021-08-08 22:02:43 +08:00
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindApkHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
|
2022-07-24 23:12:34 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "保存成功!")
|
2021-08-08 22:02:43 +08:00
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 清空 uengine 数据
|
2021-08-15 21:46:48 +08:00
|
|
|
|
def BackUengineClean()->"清空 uengine 数据":
|
|
|
|
|
print("Choose")
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if QtWidgets.QMessageBox.warning(widget, "警告", "清空后数据将会完全丢失,确定要继续吗?", QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Cancel) == QtWidgets.QMessageBox.Ok:
|
2021-08-15 21:46:48 +08:00
|
|
|
|
DisabledAndEnbled(True)
|
|
|
|
|
try:
|
|
|
|
|
if os.path.exists("{}/.local/share/applications/uengine/".format(get_home())):
|
|
|
|
|
shutil.rmtree("{}/.local/share/applications/uengine/".format(get_home()))
|
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
|
|
|
|
os.system(f"'{programPath}/launch.sh' deepin-terminal -C \"pkexec rm -rfv /data/uengine\"")
|
2021-08-15 21:46:48 +08:00
|
|
|
|
return
|
|
|
|
|
print("Choose False")
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 启用 uengine 网络桥接
|
2021-08-16 09:35:08 +08:00
|
|
|
|
def UengineBridgeStart()->"启用 uengine 网络桥接":
|
2021-08-15 21:46:48 +08:00
|
|
|
|
DisabledAndEnbled(True)
|
|
|
|
|
os.system("pkexec uengine-bridge.sh start")
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 关闭 uengine 网络桥接
|
2021-08-16 09:35:08 +08:00
|
|
|
|
def UengineBridgeStop()->"关闭 uengine 网络桥接":
|
2021-08-15 21:46:48 +08:00
|
|
|
|
DisabledAndEnbled(True)
|
|
|
|
|
os.system("pkexec uengine-bridge.sh stop")
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 重启 uengine 网络桥接
|
2021-08-16 09:35:08 +08:00
|
|
|
|
def UengineBridgeRestart()->"重启 uengine 网络桥接":
|
2021-08-15 21:46:48 +08:00
|
|
|
|
DisabledAndEnbled(True)
|
|
|
|
|
os.system("pkexec uengine-bridge.sh restart")
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 加载 uengine 网络桥接
|
2021-08-16 09:35:08 +08:00
|
|
|
|
def UengineBridgeReload()->"加载 uengine 网络桥接":
|
2021-08-15 21:46:48 +08:00
|
|
|
|
DisabledAndEnbled(True)
|
|
|
|
|
os.system("pkexec uengine-bridge.sh reload")
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 强制加载 uengine 网络桥接
|
2021-08-16 09:35:08 +08:00
|
|
|
|
def UengineBridgeForceReload()->"强制加载 uengine 网络桥接":
|
2021-08-15 21:46:48 +08:00
|
|
|
|
DisabledAndEnbled(True)
|
|
|
|
|
os.system("pkexec uengine-bridge.sh force-reload")
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 启用 uengine 服务
|
2021-08-16 09:35:08 +08:00
|
|
|
|
def StartUengine()->"启用 uengine 服务":
|
|
|
|
|
DisabledAndEnbled(True)
|
|
|
|
|
os.system("systemctl enable uengine-container uengine-session && systemctl start uengine-container uengine-session")
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 关闭 uengine 服务
|
2021-08-16 09:35:08 +08:00
|
|
|
|
def StopUengine()->"关闭 uengine 服务":
|
|
|
|
|
DisabledAndEnbled(True)
|
|
|
|
|
os.system("systemctl disable uengine-container uengine-session")
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 重启 uengine 服务
|
2021-08-16 09:35:08 +08:00
|
|
|
|
def UengineRestart()->"重启 uengine 服务":
|
|
|
|
|
DisabledAndEnbled(True)
|
|
|
|
|
os.system("systemctl restart uengine*")
|
|
|
|
|
DisabledAndEnbled(False)
|
|
|
|
|
|
2021-09-11 15:51:23 +08:00
|
|
|
|
def ScrcpyConnectUengine():
|
|
|
|
|
if os.path.exists("/snap/bin/scrcpy"):
|
|
|
|
|
threading.Thread(target=os.system, args=["/snap/bin/scrcpy -s '192.168.250.2:5555'"]).start()
|
|
|
|
|
return
|
2022-07-27 18:15:28 +08:00
|
|
|
|
if QtWidgets.QMessageBox.question(widget, "提示", "你没有安装Scrcpy(指使用Snap安装),\n如果你使用了其他方法安装了Scrcpy,可以输入命令“scrcpy -s '192.168.250.2:5555'”,\n是否现在要使用Snap安装Scrcpy?") == QtWidgets.QMessageBox.Yes:
|
2021-09-11 15:51:23 +08:00
|
|
|
|
if not os.path.exists("/tmp/uengine-runner"):
|
|
|
|
|
os.makedirs("/tmp/uengine-runner")
|
|
|
|
|
write_txt("/tmp/uengine-runner/InstallScrcpy.sh", '''#!/bin/bash
|
|
|
|
|
sudo apt install snapd -y
|
|
|
|
|
sudo snap refresh
|
|
|
|
|
sudo snap install scrcpy''')
|
2022-07-26 14:57:48 +08:00
|
|
|
|
threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C \"chmod 777 /tmp/uengine-runner/InstallScrcpy.sh -Rv && pkexec /tmp/uengine-runner/InstallScrcpy.sh\""]).start()
|
2021-09-11 15:51:23 +08:00
|
|
|
|
return
|
2021-06-06 11:54:38 +08:00
|
|
|
|
|
|
|
|
|
# 获取用户桌面目录
|
2021-07-11 14:45:11 +08:00
|
|
|
|
def get_desktop_path()->"获取用户桌面目录":
|
2021-06-06 11:54:38 +08:00
|
|
|
|
for line in open(get_home() + "/.config/user-dirs.dirs"): # 以行来读取配置文件
|
|
|
|
|
desktop_index = line.find("XDG_DESKTOP_DIR=\"") # 寻找是否有对应项,有返回 0,没有返回 -1
|
|
|
|
|
if desktop_index != -1: # 如果有对应项
|
|
|
|
|
break # 结束循环
|
|
|
|
|
if desktop_index == -1: # 如果是提前结束,值一定≠-1,如果是没有提前结束,值一定=-1
|
|
|
|
|
return -1
|
|
|
|
|
else:
|
|
|
|
|
get = line[17:-2] # 截取桌面目录路径
|
|
|
|
|
get_index = get.find("$HOME") # 寻找是否有对应的项,需要替换内容
|
|
|
|
|
if get != -1: # 如果有
|
|
|
|
|
get = get.replace("$HOME", get_home()) # 则把其替换为用户目录(~)
|
|
|
|
|
return get # 返回目录
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 提取已安装程序的apk
|
2021-08-18 21:54:28 +08:00
|
|
|
|
def SaveInstallUengineApp():
|
|
|
|
|
while True:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
result = QtWidgets.QInputDialog.getText(widget, "输入 APK 包名", "请输入要获取的apk包名以便进行下一步操作")
|
|
|
|
|
if result[1] == False:
|
2021-08-18 21:54:28 +08:00
|
|
|
|
return
|
2022-07-26 14:57:48 +08:00
|
|
|
|
result = result[0]
|
2021-08-18 21:54:28 +08:00
|
|
|
|
if os.path.exists("/data/uengine/data/data/app/{}-1".format(result)):
|
|
|
|
|
break
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", langFile[lang]["Main"]["MainWindow"]["Error"]["PathError"])
|
|
|
|
|
path = QtWidgets.QFileDialog.getSaveFileName(widget, "保存apk", "~", "APK 文件(*.apk);;所有文件(*.*)", json.loads(readtxt(get_home() + "/.config/uengine-runner/SaveApk.json"))["path"])[0]
|
2021-08-18 21:54:28 +08:00
|
|
|
|
if path == "" or path == ():
|
|
|
|
|
return
|
|
|
|
|
try:
|
|
|
|
|
shutil.copy("/data/uengine/data/data/app/{}-1/base.apk".format(result), path)
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/SaveApk.json", json.dumps({"path": os.path.dirname(path)}))
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "提取完成!")
|
2021-08-18 21:54:28 +08:00
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
2021-08-18 21:54:28 +08:00
|
|
|
|
|
2021-10-03 20:34:07 +08:00
|
|
|
|
def UengineCheckCpu():
|
|
|
|
|
english = GetCommandReturn("uengine check-features")
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", english)
|
2021-10-03 20:34:07 +08:00
|
|
|
|
|
2021-06-06 11:54:38 +08:00
|
|
|
|
# 获取用户主目录
|
2021-07-11 14:45:11 +08:00
|
|
|
|
def get_home()->"获取用户主目录":
|
2021-06-06 11:54:38 +08:00
|
|
|
|
return os.path.expanduser('~')
|
2021-07-11 14:45:11 +08:00
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 删除所有的 uengine 应用快捷方式
|
2021-08-18 21:54:28 +08:00
|
|
|
|
def CleanAllUengineDesktopLink():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if QtWidgets.QMessageBox.question(widget, "提示", "你是否要删除所有的 UEngine 应用快捷方式?") == QtWidgets.QMessageBox.No:
|
2021-08-18 21:54:28 +08:00
|
|
|
|
try:
|
|
|
|
|
shutil.rmtree("{}/.local/share/applications/uengine".format(get_home()))
|
2021-09-11 15:51:23 +08:00
|
|
|
|
os.makedirs("{}/.local/share/applications/uengine".format(get_home()))
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "删除完毕!")
|
2021-08-18 21:54:28 +08:00
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
2021-08-18 21:54:28 +08:00
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 打开 uengine 应用打包器
|
|
|
|
|
def OpenUengineDebBuilder():
|
|
|
|
|
threading.Thread(target=os.system, args=[programPath + "/uengine-apk-builder"]).start()
|
|
|
|
|
|
|
|
|
|
# 打开 uengine 根目录
|
|
|
|
|
def OpenUengineRootData():
|
|
|
|
|
threading.Thread(target=os.system, args=["xdg-open /data/uengine/data/data"]).start()
|
|
|
|
|
|
|
|
|
|
# 打开 uengine 用户数据目录
|
|
|
|
|
def OpenUengineUserData():
|
|
|
|
|
threading.Thread(target=os.system, args=["xdg-open ~/安卓应用文件"]).start()
|
|
|
|
|
|
2021-08-30 17:49:12 +08:00
|
|
|
|
# 终端显示 adb 命令行
|
|
|
|
|
def AdbShellShowInTer():
|
|
|
|
|
os.system("adb connect 192.168.250.2:5555")
|
2022-07-07 14:35:44 +08:00
|
|
|
|
threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -w ~ -e 'adb -s 192.168.250.2:5555 shell'"]).start()
|
2021-08-30 17:49:12 +08:00
|
|
|
|
|
|
|
|
|
# 终端显示 adb top
|
|
|
|
|
def AdbCPUAndRAWShowInTer():
|
|
|
|
|
os.system("adb connect 192.168.250.2:5555")
|
2022-07-07 14:35:44 +08:00
|
|
|
|
threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -w ~ -e 'adb -s 192.168.250.2:5555 shell top'"]).start()
|
2021-08-30 17:49:12 +08:00
|
|
|
|
|
|
|
|
|
def UengineSettingShow():
|
2021-10-03 17:42:30 +08:00
|
|
|
|
threading.Thread(target=os.system, args=["/usr/bin/uengine launch --action=android.intent.action.MAIN --package=com.android.settings --component=com.android.settings.Settings"]).start()
|
2021-08-30 17:49:12 +08:00
|
|
|
|
|
|
|
|
|
# 杀死 adb 进程
|
|
|
|
|
def AdbKillAdbProgress():
|
|
|
|
|
os.system("killall adb")
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "完成!")
|
2021-08-30 17:49:12 +08:00
|
|
|
|
|
|
|
|
|
# 关闭 adb 服务
|
|
|
|
|
def AdbStopServer():
|
|
|
|
|
os.system("adb kill-server")
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "完成!")
|
2021-08-30 17:49:12 +08:00
|
|
|
|
|
|
|
|
|
# 开启 adb 服务
|
|
|
|
|
def AdbStartServer():
|
|
|
|
|
os.system("adb start-server")
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "完成!")
|
2021-08-30 17:49:12 +08:00
|
|
|
|
|
2021-10-05 18:16:50 +08:00
|
|
|
|
def ReinstallUengine():
|
2022-07-07 14:35:44 +08:00
|
|
|
|
threading.Thread(target=os.system, args=[f"'{programPath}/launch.sh' deepin-terminal -C 'pkexec apt reinstall uengine uengine-android-image uengine-modules-dkms -y && notify-send -i uengine \"安装完毕!\"'"]).start()
|
2021-10-05 18:16:50 +08:00
|
|
|
|
|
|
|
|
|
def DelUengineCheck():
|
|
|
|
|
if not os.path.exists("/usr/share/uengine/uengine-check-runnable.sh"):
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "本功能已经被删除,无法重复删除!")
|
2021-10-05 18:16:50 +08:00
|
|
|
|
return
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if QtWidgets.QMessageBox.warning(widget, "警告", "删除后将无法使用本软件恢复\n如果需要恢复本功能,请重新安装 UEngine!", QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Ok) == QtWidgets.QMessageBox.Ok:
|
|
|
|
|
threading.Thread(target=os.system, args=["'{programPath}/launch.sh' deepin-terminal -C 'pkexec rm -v /usr/share/uengine/uengine-check-runnable.sh'"]).start()
|
2021-10-05 18:16:50 +08:00
|
|
|
|
|
2021-08-30 17:49:12 +08:00
|
|
|
|
# 使用 adb 连接 uengine
|
|
|
|
|
def UengineConnectAdb():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", subprocess.getoutput("adb connect 192.168.250.2:5555"))
|
2021-08-30 17:49:12 +08:00
|
|
|
|
|
|
|
|
|
# 允许用户使用 adb
|
|
|
|
|
def UengineUseAdb():
|
|
|
|
|
# 因为需要 root,所以需要开二号程序
|
|
|
|
|
os.system("adb start-server") # 保证有生成文件
|
|
|
|
|
os.system("pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY {}/uengine-useadb 0 '{}'".format(programPath, "{}/.android/adbkey.pub".format(get_home()))) # 写入配置
|
2022-07-27 18:15:28 +08:00
|
|
|
|
if QtWidgets.QMessageBox.question(widget, "提示", "是否要连接到 UEngine?") == QtWidgets.QMessageBox.Yes:
|
2021-08-30 17:49:12 +08:00
|
|
|
|
UengineConnectAdb()
|
|
|
|
|
|
|
|
|
|
def UengineDoNotUseAdb():
|
|
|
|
|
# 因为需要 root,所以需要开二号程序
|
|
|
|
|
if not os.path.exists("/data/uengine/data/data/misc/adb/adb_keys"):
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "提示", "你的 uengine 在设置前已经禁用 adb 连接,无需重复设置")
|
2021-08-30 17:49:12 +08:00
|
|
|
|
return
|
|
|
|
|
threading.Thread(target=os.system, args=["pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY {}/uengine-useadb 1".format(programPath)]).start()
|
|
|
|
|
|
2021-10-05 18:16:50 +08:00
|
|
|
|
def UengineRunnerBugUpload():
|
|
|
|
|
threading.Thread(target=os.system, args=[programPath + "/uengine-runner-update-bug"]).start()
|
|
|
|
|
|
2021-08-30 17:49:12 +08:00
|
|
|
|
def AdbConnectDeviceShow():
|
|
|
|
|
ShowTextTipsWindow.ShowWindow(subprocess.getoutput("adb devices -l"))
|
|
|
|
|
|
|
|
|
|
def AdbAndroidInstallAppList():
|
|
|
|
|
ShowTextTipsWindow.ShowWindow('''系统应用:
|
|
|
|
|
{}
|
|
|
|
|
第三方应用:
|
|
|
|
|
{}
|
|
|
|
|
全部应用以及apk所在路径:
|
|
|
|
|
{}'''.format(subprocess.getoutput("adb -s 192.168.250.2:5555 shell pm list packages -s"),
|
|
|
|
|
subprocess.getoutput("adb -s 192.168.250.2:5555 shell pm list package -3"),
|
|
|
|
|
subprocess.getoutput("adb -s 192.168.250.2:5555 shell pm list packages -f")))
|
|
|
|
|
|
2021-09-26 20:16:29 +08:00
|
|
|
|
def GetApkVersion(apkFilePath):
|
|
|
|
|
info = GetApkInformation(apkFilePath)
|
|
|
|
|
for line in info.split('\n'):
|
|
|
|
|
if "package:" in line:
|
|
|
|
|
if "compileSdkVersion='" in line:
|
|
|
|
|
line = line.replace(line[line.index("compileSdkVersion='"): -1], "")
|
|
|
|
|
if "platform" in line:
|
|
|
|
|
line = line.replace(line[line.index("platform"): -1], "")
|
|
|
|
|
line = line.replace(line[0: line.index("versionName='")], "")
|
|
|
|
|
line = line.replace("versionName='", "")
|
|
|
|
|
line = line.replace("'", "")
|
|
|
|
|
line = line.replace(" ", "")
|
|
|
|
|
return line
|
|
|
|
|
|
2022-02-09 11:50:23 +08:00
|
|
|
|
def VersionCheck(version1, version2):
|
|
|
|
|
return version1 == version2
|
2022-02-11 16:38:03 +08:00
|
|
|
|
|
|
|
|
|
def ShowHelp():
|
|
|
|
|
webbrowser.open_new_tab(programPath + "/Help/index.html")
|
|
|
|
|
|
2022-06-19 14:03:40 +08:00
|
|
|
|
def AllowOrDisallowUpdateAndroidApp():
|
|
|
|
|
if not os.path.exists("/data/uengine/data/data/misc/adb/adb_keys"):
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if QtWidgets.QMessageBox.question(widget, langFile[lang]["Main"]["MainWindow"]["Answer"]["Title"], langFile[lang]["Main"]["MainWindow"]["Answer"]["UseAdbPackageAnswer"]) == QtWidgets.QMessageBox.No:
|
2022-06-19 14:03:40 +08:00
|
|
|
|
return
|
2022-06-19 21:04:16 +08:00
|
|
|
|
os.system("pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY {}/uengine-useadb 0 '{}'".format(programPath,"{}/.android/adbkey.pub".format(get_home()))) # 写入配
|
2022-06-19 14:03:40 +08:00
|
|
|
|
adb = api.Adb("192.168.250.2:5555")
|
|
|
|
|
adb.Service.Close()
|
|
|
|
|
adb.connect()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if QtWidgets.QMessageBox.question(widget, langFile[lang]["Main"]["MainWindow"]["Answer"]["Title"], message=langFile[lang]["Main"]["MainWindow"]["Answer"]["AllowOrDisallowUpdateAndroidAppAnswer"][int(adb.boolAndroidInstallOtherAppSetting())]) == QtWidgets.QMessageBox.Yes:
|
2022-06-19 14:03:40 +08:00
|
|
|
|
adb.setAndroidInstallOtherAppSetting(not adb.boolAndroidInstallOtherAppSetting())
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, langFile[lang]["Main"]["MainWindow"]["Information"]["Title"], langFile[lang]["Main"]["MainWindow"]["Answer"]["CompleteInformation"])
|
2022-06-19 14:03:40 +08:00
|
|
|
|
|
2022-07-08 04:02:21 +08:00
|
|
|
|
def SetHttpProxy():
|
|
|
|
|
adb = api.Adb("192.168.250.2:5555")
|
|
|
|
|
adb.Service.Close()
|
|
|
|
|
adb.connect()
|
2022-07-27 18:15:28 +08:00
|
|
|
|
if QtWidgets.QMessageBox.question(widget, "提示", "此功能需要安装 adb 补丁,请保证已经安装然后按下“Yes”") == QtWidgets.QMessageBox.No:
|
2022-07-08 04:02:21 +08:00
|
|
|
|
return
|
2022-07-27 18:15:28 +08:00
|
|
|
|
proxy = QtWidgets.QInputDialog.getText(widget, "输入代理", "请输入要设置的代理(为空代表不设置代理)")
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if proxy[1] == False:
|
2022-07-08 04:02:21 +08:00
|
|
|
|
return
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if proxy[0] == "":
|
2022-07-08 04:02:21 +08:00
|
|
|
|
os.system("adb -s 192.168.250.2:5555 shell settings delete global http_proxy")
|
|
|
|
|
os.system("adb -s 192.168.250.2:5555 shell settings delete global global_http_proxy_host")
|
|
|
|
|
os.system("adb -s 192.168.250.2:5555 shell settings delete global global_http_proxy_port")
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "设置成功!")
|
2022-07-08 04:02:21 +08:00
|
|
|
|
else:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
os.system(f"adb -s 192.168.250.2:5555 shell settings put global http_proxy \"{proxy[0]}\"")
|
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "设置成功!")
|
2022-07-08 04:02:21 +08:00
|
|
|
|
|
2022-07-27 18:15:28 +08:00
|
|
|
|
class UengineWindowSizeSetting:
|
|
|
|
|
setting = None
|
|
|
|
|
package = "com.nuts.extremspeedup"
|
|
|
|
|
verticalWidth = None
|
|
|
|
|
verticalHeighe = None
|
|
|
|
|
horizontaltWidth = None
|
|
|
|
|
horizontaltHeighe = None
|
|
|
|
|
verticalScreen = None
|
|
|
|
|
allowFullScreen = None
|
|
|
|
|
allowScreenSwitching = None
|
|
|
|
|
defaultFullScreen = None
|
|
|
|
|
logicalDensityDpi = None
|
|
|
|
|
physicalDpi = None
|
|
|
|
|
appWidth = None
|
|
|
|
|
appHeight = None
|
|
|
|
|
logicalWidth = None
|
|
|
|
|
logicalHeight = None
|
|
|
|
|
lineEdit = {
|
|
|
|
|
"verticalWidth": verticalWidth,
|
|
|
|
|
"verticalHeighe": verticalHeighe,
|
|
|
|
|
"horizontaltWidth": horizontaltWidth,
|
|
|
|
|
"horizontaltHeighe": horizontaltHeighe,
|
|
|
|
|
"logicalDensityDpi": logicalDensityDpi,
|
|
|
|
|
"physicalDpi": physicalDpi,
|
|
|
|
|
"appWidth": appWidth,
|
|
|
|
|
"appHeight": appHeight,
|
|
|
|
|
"logicalWidth": logicalWidth,
|
|
|
|
|
"logicalHeight": logicalHeight
|
|
|
|
|
}
|
|
|
|
|
checkbox = {
|
|
|
|
|
"verticalScreen": verticalScreen,
|
|
|
|
|
"allowFullScreen": allowFullScreen,
|
|
|
|
|
"allowScreenSwitching": allowScreenSwitching,
|
|
|
|
|
"defaultFullScreen": defaultFullScreen
|
|
|
|
|
}
|
|
|
|
|
def ShowWindow():
|
|
|
|
|
unfound = False
|
|
|
|
|
while True:
|
|
|
|
|
if ComboInstallPath.currentText() == "":
|
|
|
|
|
choose = QtWidgets.QInputDialog.getText(widget, "输入", "请输入需要设置的 Android 应用的包名")
|
|
|
|
|
else:
|
|
|
|
|
if GetApkPackageName(ComboInstallPath.currentText()) == None:
|
|
|
|
|
choose = QtWidgets.QInputDialog.getText(widget, "输入", "请输入需要设置的 Android 应用的包名", text=ComboInstallPath.currentText())
|
|
|
|
|
else:
|
|
|
|
|
choose = QtWidgets.QInputDialog.getText(widget, "输入", "请输入需要设置的 Android 应用的包名", text=GetApkPackageName(ComboInstallPath.currentText()))
|
|
|
|
|
if not choose[1]:
|
|
|
|
|
return
|
|
|
|
|
if choose[0] == "":
|
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "包名不能为空")
|
|
|
|
|
continue
|
|
|
|
|
if not os.path.exists(f"/usr/share/uengine/appetc/{choose[0]}.txt"):
|
|
|
|
|
if QtWidgets.QMessageBox.question(widget, "提示", "未找到这个包名对应的配置文件,是否要创建一个?") == QtWidgets.QMessageBox.No:
|
|
|
|
|
continue
|
|
|
|
|
unfound = True
|
|
|
|
|
UengineWindowSizeSetting.package = choose[0]
|
|
|
|
|
break
|
|
|
|
|
UengineWindowSizeSetting.setting = QtWidgets.QMainWindow()
|
|
|
|
|
settingWidget = QtWidgets.QWidget()
|
|
|
|
|
settingLayout = QtWidgets.QGridLayout()
|
|
|
|
|
|
|
|
|
|
UengineWindowSizeSetting.verticalWidth = QtWidgets.QLineEdit()
|
|
|
|
|
UengineWindowSizeSetting.verticalHeighe = QtWidgets.QLineEdit()
|
|
|
|
|
UengineWindowSizeSetting.horizontaltWidth = QtWidgets.QLineEdit()
|
|
|
|
|
UengineWindowSizeSetting.horizontaltHeighe = QtWidgets.QLineEdit()
|
|
|
|
|
UengineWindowSizeSetting.verticalScreen = QtWidgets.QCheckBox("默认为竖屏")
|
|
|
|
|
UengineWindowSizeSetting.allowFullScreen = QtWidgets.QCheckBox("允许全屏")
|
|
|
|
|
UengineWindowSizeSetting.allowScreenSwitching = QtWidgets.QCheckBox("允许横竖屏切换")
|
|
|
|
|
UengineWindowSizeSetting.defaultFullScreen = QtWidgets.QCheckBox("默认显示最大化")
|
|
|
|
|
UengineWindowSizeSetting.logicalDensityDpi = QtWidgets.QLineEdit()
|
|
|
|
|
UengineWindowSizeSetting.physicalDpi = QtWidgets.QLineEdit()
|
|
|
|
|
UengineWindowSizeSetting.appWidth = QtWidgets.QLineEdit()
|
|
|
|
|
UengineWindowSizeSetting.appHeight = QtWidgets.QLineEdit()
|
|
|
|
|
UengineWindowSizeSetting.logicalWidth = QtWidgets.QLineEdit()
|
|
|
|
|
UengineWindowSizeSetting.logicalHeight = QtWidgets.QLineEdit()
|
|
|
|
|
saveButton = QtWidgets.QPushButton("保存设置")
|
|
|
|
|
deleButton = QtWidgets.QPushButton("删除设置")
|
|
|
|
|
saveButton.clicked.connect(UengineWindowSizeSetting.SaveSetting)
|
|
|
|
|
deleButton.clicked.connect(UengineWindowSizeSetting.DeleteSetting)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("竖屏宽:"), 0, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.verticalWidth, 0, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("竖屏高:"), 1, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.verticalHeighe, 1, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("横屏宽,备选为1280:"), 2, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.horizontaltWidth, 2, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("横屏高,备选为720:"), 3, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.horizontaltHeighe, 3, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("设置默认横屏还是竖屏:"), 4, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.verticalScreen, 4, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("设置是否允许全屏:"), 5, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.allowFullScreen, 5, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("设置是否允许横竖屏切换:"), 6, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.allowScreenSwitching, 6, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("设置是否默认显示最大化:"), 7, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.defaultFullScreen, 7, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("<hr>"), 8, 0, 1, 3)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("屏幕缩放,数值大则大:"), 9, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.logicalDensityDpi, 9, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("physicalDpi:"), 10, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.physicalDpi, 10, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("appWidth:"), 11, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.appWidth, 11, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("appHeight:"), 12, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.appHeight, 12, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("logicalWidth:"), 13, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.logicalWidth, 13, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("logicalHeight:"), 14, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(UengineWindowSizeSetting.logicalHeight, 14, 1, 1, 2)
|
|
|
|
|
settingLayout.addWidget(saveButton, 15, 1, 1, 1)
|
|
|
|
|
settingLayout.addWidget(deleButton, 15, 2, 1, 1)
|
|
|
|
|
UengineWindowSizeSetting.lineEdit = {
|
|
|
|
|
"verticalWidth": UengineWindowSizeSetting.verticalWidth,
|
|
|
|
|
"verticalHeighe": UengineWindowSizeSetting.verticalHeighe,
|
|
|
|
|
"horizontaltWidth": UengineWindowSizeSetting.horizontaltWidth,
|
|
|
|
|
"horizontaltHeighe": UengineWindowSizeSetting.horizontaltHeighe,
|
|
|
|
|
"logicalDensityDpi": UengineWindowSizeSetting.logicalDensityDpi,
|
|
|
|
|
"physicalDpi": UengineWindowSizeSetting.physicalDpi,
|
|
|
|
|
"appWidth": UengineWindowSizeSetting.appWidth,
|
|
|
|
|
"appHeight": UengineWindowSizeSetting.appHeight,
|
|
|
|
|
"logicalWidth": UengineWindowSizeSetting.logicalWidth,
|
|
|
|
|
"logicalHeight": UengineWindowSizeSetting.logicalHeight
|
|
|
|
|
}
|
|
|
|
|
UengineWindowSizeSetting.checkbox = {
|
|
|
|
|
"verticalScreen": UengineWindowSizeSetting.verticalScreen,
|
|
|
|
|
"allowFullScreen": UengineWindowSizeSetting.allowFullScreen,
|
|
|
|
|
"allowScreenSwitching": UengineWindowSizeSetting.allowScreenSwitching,
|
|
|
|
|
"defaultFullScreen": UengineWindowSizeSetting.defaultFullScreen
|
|
|
|
|
}
|
|
|
|
|
settingWidget.setLayout(settingLayout)
|
|
|
|
|
UengineWindowSizeSetting.setting.setCentralWidget(settingWidget)
|
|
|
|
|
if not unfound:
|
|
|
|
|
UengineWindowSizeSetting.ReadSetting()
|
|
|
|
|
else:
|
|
|
|
|
for i in UengineWindowSizeSetting.checkbox.values():
|
|
|
|
|
i.setChecked(True)
|
|
|
|
|
UengineWindowSizeSetting.setting.setWindowTitle(f"设置 Android 应用的窗口大小缩放设置")
|
|
|
|
|
UengineWindowSizeSetting.setting.show()
|
|
|
|
|
UengineWindowSizeSetting.setting.resize(UengineWindowSizeSetting.setting.frameSize().width() * 1.3, UengineWindowSizeSetting.setting.frameSize().height())
|
|
|
|
|
|
|
|
|
|
def ReadSetting():
|
|
|
|
|
file = open(f"/usr/share/uengine/appetc/{UengineWindowSizeSetting.package}.txt")
|
|
|
|
|
while True:
|
|
|
|
|
line = file.readline()
|
|
|
|
|
if not line:
|
|
|
|
|
break
|
|
|
|
|
line = line.strip()
|
|
|
|
|
print(line)
|
|
|
|
|
if "//" in line:
|
|
|
|
|
line = line[:line.index("//")]
|
|
|
|
|
try:
|
|
|
|
|
if line[:line.index(" ")].strip() in UengineWindowSizeSetting.lineEdit.keys():
|
|
|
|
|
UengineWindowSizeSetting.lineEdit[line[:line.index(" ")].strip()].setText(line[line.index(" "):].strip())
|
|
|
|
|
if line[:line.index(" ")].strip() in UengineWindowSizeSetting.checkbox.keys():
|
|
|
|
|
UengineWindowSizeSetting.checkbox[line[:line.index(" ")].strip()].setChecked(bool(line[line.index(" "):].strip()))
|
|
|
|
|
except: # 错误行,忽略
|
|
|
|
|
pass
|
|
|
|
|
file.close()
|
|
|
|
|
|
|
|
|
|
def SaveSetting():
|
|
|
|
|
file = open(f"/tmp/{UengineWindowSizeSetting.package}.txt", "w")
|
|
|
|
|
for i in UengineWindowSizeSetting.lineEdit.keys():
|
|
|
|
|
if UengineWindowSizeSetting.lineEdit[i].text() == "": # 空选项,不写入
|
|
|
|
|
continue
|
|
|
|
|
try:
|
|
|
|
|
file.write(f"{i} {int(UengineWindowSizeSetting.lineEdit[i].text())}\n")
|
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", "格式输入错误")
|
|
|
|
|
return
|
|
|
|
|
for i in UengineWindowSizeSetting.checkbox.keys():
|
|
|
|
|
try:
|
|
|
|
|
file.write(f"{i} {int(UengineWindowSizeSetting.checkbox[i].isChecked())}\n")
|
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
|
|
|
|
return
|
|
|
|
|
file.close()
|
|
|
|
|
if os.system(f"pkexec '{programPath}/uengine-window-size-setting.py' -a {UengineWindowSizeSetting.package}"):
|
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", "保存失败")
|
|
|
|
|
return
|
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "保存完成!")
|
|
|
|
|
|
|
|
|
|
def DeleteSetting():
|
|
|
|
|
if os.system(f"pkexec '{programPath}/uengine-window-size-setting.py' -d {UengineWindowSizeSetting.package}"):
|
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", "删除失败")
|
|
|
|
|
return
|
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "删除完成!")
|
|
|
|
|
|
2022-07-08 04:02:21 +08:00
|
|
|
|
|
2022-02-11 16:38:03 +08:00
|
|
|
|
class SettingWindow():
|
2022-07-07 14:35:44 +08:00
|
|
|
|
saveApkOption = None
|
2022-07-26 14:57:48 +08:00
|
|
|
|
settingWindow = None
|
2022-07-27 18:15:28 +08:00
|
|
|
|
autoScreenConfig = None
|
|
|
|
|
chooseProgramType = None
|
|
|
|
|
theme = None
|
2022-02-11 16:38:03 +08:00
|
|
|
|
def ShowWindow():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
SettingWindow.settingWindow = QtWidgets.QMainWindow()
|
|
|
|
|
setting = QtWidgets.QWidget()
|
|
|
|
|
settingLayout = QtWidgets.QGridLayout()
|
|
|
|
|
|
|
|
|
|
SettingWindow.saveApkOption = QtWidgets.QComboBox()
|
2022-07-27 18:15:28 +08:00
|
|
|
|
SettingWindow.autoScreenConfig = QtWidgets.QCheckBox("安装APK时自动根据系统分辨率设置,卸载时自动移除")
|
|
|
|
|
SettingWindow.chooseProgramType = QtWidgets.QCheckBox("安装APK时手动选择程序分类")
|
|
|
|
|
SettingWindow.theme = QtWidgets.QComboBox()
|
|
|
|
|
themeTry = QtWidgets.QPushButton("测试(重启后变回设置的主题)")
|
|
|
|
|
SettingWindow.theme.addItems(QtWidgets.QStyleFactory.keys())
|
2022-07-26 14:57:48 +08:00
|
|
|
|
controlFrame = QtWidgets.QHBoxLayout()
|
|
|
|
|
cancalButton = QtWidgets.QPushButton("取消")
|
|
|
|
|
okButton = QtWidgets.QPushButton("保存")
|
|
|
|
|
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("APK 安装模式:"), 0, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(SettingWindow.saveApkOption, 0, 1, 1, 1)
|
2022-07-27 18:15:28 +08:00
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("窗口大小策略:"), 1, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(SettingWindow.autoScreenConfig, 1, 1, 1, 1)
|
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("程序分类策略:"), 2, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(SettingWindow.chooseProgramType, 2, 1, 1, 1)
|
2022-08-03 22:59:13 +08:00
|
|
|
|
settingLayout.addWidget(QtWidgets.QLabel("程序主题:"), 3, 0, 1, 1)
|
|
|
|
|
settingLayout.addWidget(SettingWindow.theme, 3, 1, 1, 1)
|
|
|
|
|
settingLayout.addWidget(themeTry, 3, 2, 1, 1)
|
2022-07-27 18:15:28 +08:00
|
|
|
|
settingLayout.addLayout(controlFrame, 4, 1, 1, 2)
|
2022-07-26 14:57:48 +08:00
|
|
|
|
controlFrame.addItem(QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum))
|
|
|
|
|
controlFrame.addWidget(cancalButton)
|
|
|
|
|
controlFrame.addWidget(okButton)
|
2022-07-27 18:15:28 +08:00
|
|
|
|
|
2022-07-26 14:57:48 +08:00
|
|
|
|
SettingWindow.saveApkOption.addItems(["不备份Apk包直接安装", "备份Apk包然后在安装后自动拷贝原先目录"])
|
2022-02-11 16:38:03 +08:00
|
|
|
|
try:
|
|
|
|
|
data = json.loads(readtxt(get_home() + "/.config/uengine-runner/setting.json"))
|
|
|
|
|
except:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", langFile[lang]["Main"]["MainWindow"]["Error"]["SettingReadError"])
|
|
|
|
|
SettingWindow.settingWindow.close()
|
|
|
|
|
return
|
2022-07-27 18:15:28 +08:00
|
|
|
|
SettingWindow.autoScreenConfig.setChecked(settingConf["AutoScreenConfig"])
|
2022-07-26 14:57:48 +08:00
|
|
|
|
SettingWindow.saveApkOption.setCurrentIndex(int(data["SaveApk"]))
|
2022-07-27 18:15:28 +08:00
|
|
|
|
SettingWindow.chooseProgramType.setChecked(settingConf["ChooseProgramType"])
|
|
|
|
|
SettingWindow.theme.setCurrentText(settingConf["Theme"])
|
|
|
|
|
themeTry.clicked.connect(SettingWindow.Try)
|
2022-07-26 14:57:48 +08:00
|
|
|
|
cancalButton.clicked.connect(SettingWindow.settingWindow.close)
|
|
|
|
|
okButton.clicked.connect(SettingWindow.SaveSetting)
|
|
|
|
|
|
|
|
|
|
setting.setLayout(settingLayout)
|
|
|
|
|
SettingWindow.settingWindow.setWindowTitle(f"设置 UEngine 运行器 {version}")
|
|
|
|
|
SettingWindow.settingWindow.setWindowIcon(QtGui.QIcon(iconPath))
|
|
|
|
|
SettingWindow.settingWindow.setCentralWidget(setting)
|
|
|
|
|
SettingWindow.settingWindow.show()
|
|
|
|
|
SettingWindow.settingWindow.setFixedSize(SettingWindow.settingWindow.frameSize().width(), SettingWindow.settingWindow.frameSize().height())
|
|
|
|
|
|
2022-07-27 18:15:28 +08:00
|
|
|
|
def Try():
|
|
|
|
|
app.setStyle(QtWidgets.QStyleFactory.create(SettingWindow.theme.currentText()))
|
|
|
|
|
|
2022-02-11 16:38:03 +08:00
|
|
|
|
def SaveSetting():
|
2022-07-27 18:15:28 +08:00
|
|
|
|
global settingConf
|
2022-02-11 16:38:03 +08:00
|
|
|
|
try:
|
2022-07-27 18:15:28 +08:00
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/setting.json", json.dumps({
|
|
|
|
|
"SaveApk": bool(SettingWindow.saveApkOption.currentIndex()),
|
|
|
|
|
"AutoScreenConfig": SettingWindow.autoScreenConfig.isChecked(),
|
|
|
|
|
"ChooseProgramType": SettingWindow.chooseProgramType.isChecked(),
|
|
|
|
|
"Theme": SettingWindow.theme.currentText()
|
|
|
|
|
}))
|
|
|
|
|
settingConf = {
|
|
|
|
|
"SaveApk": bool(SettingWindow.saveApkOption.currentIndex()),
|
|
|
|
|
"AutoScreenConfig": SettingWindow.autoScreenConfig.isChecked(),
|
|
|
|
|
"ChooseProgramType": SettingWindow.chooseProgramType.isChecked(),
|
|
|
|
|
"Theme": SettingWindow.theme.currentText()
|
|
|
|
|
}
|
|
|
|
|
app.setStyle(QtWidgets.QStyleFactory.create(SettingWindow.theme.currentText()))
|
2022-02-11 16:38:03 +08:00
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", langFile[lang]["Main"]["MainWindow"]["Error"]["SettingSaveError"])
|
2022-02-11 16:38:03 +08:00
|
|
|
|
return
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "设置保存完毕!")
|
2022-02-11 16:38:03 +08:00
|
|
|
|
|
2022-02-09 11:50:23 +08:00
|
|
|
|
class UpdateWindow():
|
2022-02-11 16:38:03 +08:00
|
|
|
|
data = {}
|
2022-07-26 14:57:48 +08:00
|
|
|
|
update = None
|
2022-02-09 11:50:23 +08:00
|
|
|
|
def ShowWindow():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
UpdateWindow.update = QtWidgets.QMainWindow()
|
|
|
|
|
updateWidget = QtWidgets.QWidget()
|
|
|
|
|
updateWidgetLayout = QtWidgets.QGridLayout()
|
|
|
|
|
versionLabel = QtWidgets.QLabel(f"当前版本:{version}\n最新版本:未知\n更新内容:")
|
|
|
|
|
updateText = QtWidgets.QTextBrowser()
|
|
|
|
|
ok = QtWidgets.QPushButton("更新(更新过程中会关闭所有Python应用,包括这个应用)")
|
|
|
|
|
ok.clicked.connect(UpdateWindow.Update)
|
|
|
|
|
cancel = QtWidgets.QPushButton("取消")
|
|
|
|
|
cancel.clicked.connect(UpdateWindow.update.close)
|
2022-02-09 11:50:23 +08:00
|
|
|
|
try:
|
2022-02-11 16:38:03 +08:00
|
|
|
|
UpdateWindow.data = json.loads(requests.get("http://120.25.153.144/uengine-runner/update.json").text)
|
2022-07-26 14:57:48 +08:00
|
|
|
|
versionLabel = QtWidgets.QLabel(f"当前版本:{version}\n最新版本:{UpdateWindow.data['Version']}\n更新内容:")
|
2022-02-11 16:38:03 +08:00
|
|
|
|
if UpdateWindow.data["Version"] == version:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
updateText.setText("此为最新版本,无需更新")
|
|
|
|
|
ok.setDisabled(True)
|
2022-02-09 11:50:23 +08:00
|
|
|
|
else:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
updateText.setText(UpdateWindow.data["New"].replace("\\n", "\n"))
|
2022-02-09 11:50:23 +08:00
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(updateWidget, "错误", "无法连接服务器!")
|
|
|
|
|
updateWidgetLayout.addWidget(versionLabel, 0, 0, 1, 1)
|
|
|
|
|
updateWidgetLayout.addWidget(updateText, 1, 0, 1, 3)
|
|
|
|
|
updateWidgetLayout.addWidget(ok, 2, 2, 1, 1)
|
|
|
|
|
updateWidgetLayout.addWidget(cancel, 2, 1, 1, 1)
|
|
|
|
|
updateWidget.setLayout(updateWidgetLayout)
|
|
|
|
|
UpdateWindow.update.setCentralWidget(updateWidget)
|
|
|
|
|
UpdateWindow.update.setWindowTitle("检查更新")
|
2022-07-27 18:15:28 +08:00
|
|
|
|
UpdateWindow.update.setWindowIcon(QtGui.QIcon(iconPath))
|
2022-07-26 14:57:48 +08:00
|
|
|
|
UpdateWindow.update.resize(updateWidget.frameGeometry().width(), int(updateWidget.frameGeometry().height() * 1.5))
|
|
|
|
|
UpdateWindow.update.show()
|
|
|
|
|
|
2022-02-09 11:50:23 +08:00
|
|
|
|
def Update():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if os.path.exists("/tmp/uengine-runner/update"):
|
|
|
|
|
shutil.rmtree("/tmp/uengine-runner/update")
|
|
|
|
|
os.makedirs("/tmp/uengine-runner/update")
|
2022-02-11 16:38:03 +08:00
|
|
|
|
try:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
print(UpdateWindow.data["Url"])
|
|
|
|
|
write_txt("/tmp/uengine-runner/update.sh", f"""#!/bin/bash
|
2022-02-11 16:38:03 +08:00
|
|
|
|
echo 删除多余的安装包
|
|
|
|
|
rm -rfv /tmp/uengine-runner/update/*
|
|
|
|
|
echo 关闭“UEngine 运行器”以及其它“Python 应用”
|
|
|
|
|
killall python3
|
|
|
|
|
echo 下载安装包
|
2022-07-26 14:57:48 +08:00
|
|
|
|
wget -P /tmp/uengine-runner/update {UpdateWindow.data["Url"][0]}
|
2022-02-11 16:38:03 +08:00
|
|
|
|
echo 安装安装包
|
2022-07-26 14:57:48 +08:00
|
|
|
|
dpkg -i /tmp/uengine-runner/update/*
|
2022-02-11 16:38:03 +08:00
|
|
|
|
echo 修复依赖关系
|
|
|
|
|
apt install -f -y
|
2022-07-26 14:57:48 +08:00
|
|
|
|
notify-send -i "{iconPath}" "更新完毕!"
|
2022-02-11 16:38:03 +08:00
|
|
|
|
zenity --info --text=\"更新完毕!\" --ellipsize
|
2022-07-26 14:57:48 +08:00
|
|
|
|
""")
|
2022-02-11 16:38:03 +08:00
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误,无法继续更新", traceback.format_exc())
|
2022-07-07 14:35:44 +08:00
|
|
|
|
os.system(f"'{programPath}/launch.sh' deepin-terminal -e pkexec bash /tmp/uengine-runner/update.sh")
|
2022-02-09 11:50:23 +08:00
|
|
|
|
|
2022-02-11 16:38:03 +08:00
|
|
|
|
image = None
|
2021-09-26 20:16:29 +08:00
|
|
|
|
class ApkInformation():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
message = None
|
2021-09-26 20:16:29 +08:00
|
|
|
|
def ShowWindows():
|
|
|
|
|
global fullInformation
|
|
|
|
|
global path
|
|
|
|
|
global tab1
|
2022-07-26 14:57:48 +08:00
|
|
|
|
path = ComboInstallPath.currentText()
|
2022-02-07 22:35:15 +08:00
|
|
|
|
package = GetApkPackageName(path)
|
|
|
|
|
if package == None or package == "":
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", langFile[lang]["Main"]["MainWindow"]["Error"]["ApkFileError"])
|
2022-02-07 22:35:15 +08:00
|
|
|
|
return
|
2022-07-26 14:57:48 +08:00
|
|
|
|
ApkInformation.message = QtWidgets.QMainWindow()
|
|
|
|
|
messageWidget = QtWidgets.QWidget()
|
|
|
|
|
messageLayout = QtWidgets.QVBoxLayout()
|
|
|
|
|
ApkInformation.message.setWindowTitle("“{}“的Apk信息".format(GetApkChineseLabel(path)))
|
|
|
|
|
tab = QtWidgets.QTabWidget()
|
2021-09-26 20:16:29 +08:00
|
|
|
|
|
2022-07-26 14:57:48 +08:00
|
|
|
|
tab1 = QtWidgets.QWidget()
|
|
|
|
|
tab2 = QtWidgets.QWidget()
|
2021-09-26 20:16:29 +08:00
|
|
|
|
|
2022-07-26 14:57:48 +08:00
|
|
|
|
tab.addTab(tab1, "简化版")
|
|
|
|
|
tab1Layout = QtWidgets.QGridLayout()
|
2021-09-26 20:16:29 +08:00
|
|
|
|
SaveApkIcon(path, "/tmp/uengine-runner-android-app-icon.png")
|
2022-07-26 14:57:48 +08:00
|
|
|
|
simpleInformation = QtWidgets.QLabel(f"""
|
2022-08-03 22:59:13 +08:00
|
|
|
|
<p align='center'><img width='256' src='/tmp/uengine-runner-android-app-icon.png'></p>
|
2022-07-26 14:57:48 +08:00
|
|
|
|
<p>包名:{GetApkPackageName(path)}</p>
|
|
|
|
|
<p>中文名:{GetApkChineseLabel(path)}</p>
|
|
|
|
|
<p>Activity:{GetApkActivityName(path)}</p>
|
|
|
|
|
<p>版本:{GetApkVersion(path)}</p>""")
|
|
|
|
|
|
|
|
|
|
seeFen = QtWidgets.QPushButton("查看程序评分情况")
|
|
|
|
|
updFen = QtWidgets.QPushButton("上传程序评分情况")
|
2022-08-03 22:59:13 +08:00
|
|
|
|
seeFen.setEnabled(map)
|
2022-07-26 14:57:48 +08:00
|
|
|
|
seeFen.clicked.connect(ApkInformation.ShowMap)
|
|
|
|
|
updFen.clicked.connect(ApkInformation.UpdateMark)
|
|
|
|
|
tab1Layout.addWidget(simpleInformation, 0, 0, 1, 3)
|
|
|
|
|
tab1Layout.addWidget(seeFen, 1, 1, 1, 1)
|
|
|
|
|
tab1Layout.addWidget(updFen, 2, 1, 1, 1)
|
|
|
|
|
tab1.setLayout(tab1Layout)
|
|
|
|
|
|
|
|
|
|
tab.addTab(tab2, "完整版")
|
|
|
|
|
tab2Layout = QtWidgets.QVBoxLayout()
|
|
|
|
|
fullInformation = QtWidgets.QTextBrowser()
|
|
|
|
|
fullInformation.setText(GetApkInformation(path))
|
|
|
|
|
tab2Layout.addWidget(fullInformation)
|
|
|
|
|
tab2.setLayout(tab2Layout)
|
|
|
|
|
|
|
|
|
|
messageLayout.addWidget(tab)
|
|
|
|
|
messageWidget.setLayout(messageLayout)
|
|
|
|
|
ApkInformation.message.setCentralWidget(messageWidget)
|
|
|
|
|
ApkInformation.message.setWindowIcon(QtGui.QIcon(iconPath))
|
|
|
|
|
ApkInformation.message.setWindowTitle("APK 信息")
|
|
|
|
|
ApkInformation.message.show()
|
|
|
|
|
return
|
2022-02-07 22:35:15 +08:00
|
|
|
|
|
|
|
|
|
def UpdateMark():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
chooseWindow = QtWidgets.QMessageBox()
|
|
|
|
|
chooseWindow.setWindowTitle("选择评分")
|
|
|
|
|
chooseWindow.setText(f"""选择应用“{GetApkChineseLabel(path)}”的使用评分。建议参考如下规范进行评分:
|
2022-02-09 11:50:23 +08:00
|
|
|
|
含有不良信息(-1分):含有违法违规信息(如果有就不要选择其它选项了)
|
2022-02-07 22:35:15 +08:00
|
|
|
|
0星:完全无法使用,连安装都有问题
|
|
|
|
|
1星:完全无法使用,但是能正常安装
|
|
|
|
|
2星:可以打开,但只能使用一点点功能
|
|
|
|
|
3星:勉强能使用,运行也不大流畅
|
|
|
|
|
4星:大部分功能正常,运行流畅(可能会有点小卡)
|
|
|
|
|
5星:完全正常且非常流畅,没有任何功能和性能问题,就和直接在手机上用一样
|
2022-07-26 14:57:48 +08:00
|
|
|
|
""")
|
|
|
|
|
choices=["含有不良信息", "0分", "1分", "2分", "3分", "4分", "5分", "取消"]
|
|
|
|
|
button0 = chooseWindow.addButton(choices[0], QtWidgets.QMessageBox.ActionRole)
|
|
|
|
|
button1 = chooseWindow.addButton(choices[1], QtWidgets.QMessageBox.ActionRole)
|
|
|
|
|
button2 = chooseWindow.addButton(choices[2], QtWidgets.QMessageBox.ActionRole)
|
|
|
|
|
button3 = chooseWindow.addButton(choices[3], QtWidgets.QMessageBox.ActionRole)
|
|
|
|
|
button4 = chooseWindow.addButton(choices[4], QtWidgets.QMessageBox.ActionRole)
|
|
|
|
|
button5 = chooseWindow.addButton(choices[5], QtWidgets.QMessageBox.ActionRole)
|
|
|
|
|
button6 = chooseWindow.addButton(choices[6], QtWidgets.QMessageBox.ActionRole)
|
|
|
|
|
button7 = chooseWindow.addButton(choices[7], QtWidgets.QMessageBox.ActionRole)
|
|
|
|
|
button0.clicked.connect(lambda: ApkInformation.UpdateMarkInternet(int(0)))
|
|
|
|
|
button1.clicked.connect(lambda: ApkInformation.UpdateMarkInternet(int(1)))
|
|
|
|
|
button2.clicked.connect(lambda: ApkInformation.UpdateMarkInternet(int(2)))
|
|
|
|
|
button3.clicked.connect(lambda: ApkInformation.UpdateMarkInternet(int(3)))
|
|
|
|
|
button4.clicked.connect(lambda: ApkInformation.UpdateMarkInternet(int(4)))
|
|
|
|
|
button5.clicked.connect(lambda: ApkInformation.UpdateMarkInternet(int(5)))
|
|
|
|
|
button6.clicked.connect(lambda: ApkInformation.UpdateMarkInternet(int(6)))
|
|
|
|
|
button7.clicked.connect(lambda: ApkInformation.UpdateMarkInternet(int(7)))
|
|
|
|
|
chooseWindow.exec_()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
def UpdateMarkInternet(choose):
|
2022-02-07 22:35:15 +08:00
|
|
|
|
print(choose)
|
|
|
|
|
if choose == None or choose == 7:
|
|
|
|
|
return
|
|
|
|
|
try:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "提示", requests.post("http://120.25.153.144/uengine-runner/app/check/add.php", {"Package": GetApkPackageName(path), "Type": choose}).text)
|
2022-02-07 22:35:15 +08:00
|
|
|
|
except:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
traceback.print_exc()
|
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", langFile[lang]["Main"]["MainWindow"]["Error"]["ConnectServerStarError"])
|
2022-06-18 23:01:23 +08:00
|
|
|
|
|
2022-02-07 22:35:15 +08:00
|
|
|
|
|
|
|
|
|
def ShowMap():
|
|
|
|
|
package = GetApkPackageName(path)
|
|
|
|
|
if package == None or package == "":
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", langFile[lang]["Main"]["MainWindow"]["Error"]["ApkFileError"])
|
2022-02-07 22:35:15 +08:00
|
|
|
|
return
|
|
|
|
|
try:
|
|
|
|
|
data = json.loads(requests.get("http://120.25.153.144/uengine-runner/app/check/" + package +"/data.json").text)
|
|
|
|
|
print(data)
|
|
|
|
|
except:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "此程序暂时没有评分,欢迎您贡献第一个评分!")
|
2022-02-07 22:35:15 +08:00
|
|
|
|
return
|
|
|
|
|
index = numpy.arange(len(data))
|
|
|
|
|
print(index)
|
2022-02-09 11:50:23 +08:00
|
|
|
|
chinese = GetApkChineseLabel(path)
|
|
|
|
|
fig = matplotlib.pylab.figure()
|
|
|
|
|
fig.canvas.set_window_title("“" + chinese + "”的用户评分(数据只供参考)")
|
2022-02-07 22:35:15 +08:00
|
|
|
|
fonts = matplotlib.font_manager.FontProperties(fname='/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc') # 用于支持中文显示,需要依赖fonts-noto-cjk
|
|
|
|
|
matplotlib.pylab.barh(index, data)
|
|
|
|
|
matplotlib.pylab.yticks(index, ["不良信息", "0分", "1分", "2分", "3分", "4分", "5分"], fontproperties=fonts)
|
|
|
|
|
matplotlib.pylab.xlabel("用户评分数", fontproperties=fonts)
|
|
|
|
|
matplotlib.pylab.ylabel("等级", fontproperties=fonts)
|
2022-02-09 11:50:23 +08:00
|
|
|
|
matplotlib.pylab.title("“" + chinese + "”的用户评分(数据只供参考)", fontproperties=fonts)
|
2022-07-26 14:57:48 +08:00
|
|
|
|
matplotlib.pylab.show(block=True)
|
2021-09-26 20:16:29 +08:00
|
|
|
|
|
2021-09-11 15:51:23 +08:00
|
|
|
|
class AdbChangeUengineDisplaySize():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
messageWindow = None
|
2021-09-11 15:51:23 +08:00
|
|
|
|
def ShowWindows():
|
|
|
|
|
global displayX
|
|
|
|
|
global displayY
|
|
|
|
|
global displaySize
|
2022-07-26 14:57:48 +08:00
|
|
|
|
AdbChangeUengineDisplaySize.messageWindow = QtWidgets.QMainWindow()
|
|
|
|
|
message = QtWidgets.QWidget()
|
|
|
|
|
messageLayout = QtWidgets.QGridLayout()
|
|
|
|
|
|
|
|
|
|
displaySize = QtWidgets.QLabel("当前 UEngine 屏幕分辨率:\n" + subprocess.getoutput("adb -s '192.168.250.2:5555' shell wm size"))
|
|
|
|
|
displayX = QtWidgets.QLineEdit()
|
|
|
|
|
displayY = QtWidgets.QLineEdit()
|
|
|
|
|
setButton = QtWidgets.QPushButton("设置分辨率")
|
|
|
|
|
setButton.setSizePolicy(size)
|
|
|
|
|
setButton.clicked.connect(AdbChangeUengineDisplaySize.SettingDisplaySize)
|
|
|
|
|
messageLayout.addWidget(displaySize, 0, 0, 1, 3)
|
|
|
|
|
messageLayout.addWidget(displayX, 1, 0, 1, 1)
|
|
|
|
|
messageLayout.addWidget(QtWidgets.QLabel("×"))
|
|
|
|
|
messageLayout.addWidget(displayY, 1, 2, 1, 1)
|
|
|
|
|
messageLayout.addWidget(setButton, 2, 0, 1, 3, QtCore.Qt.AlignCenter)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
message.setLayout(messageLayout)
|
|
|
|
|
AdbChangeUengineDisplaySize.messageWindow.setCentralWidget(message)
|
|
|
|
|
AdbChangeUengineDisplaySize.messageWindow.setWindowTitle("修改 UEngine 分辨率")
|
|
|
|
|
AdbChangeUengineDisplaySize.messageWindow.setWindowIcon(QtGui.QIcon(iconPath))
|
|
|
|
|
AdbChangeUengineDisplaySize.messageWindow.show()
|
|
|
|
|
return
|
2021-09-11 15:51:23 +08:00
|
|
|
|
|
|
|
|
|
def GetUengineDisplaySize():
|
|
|
|
|
global displaySize
|
2022-07-26 14:57:48 +08:00
|
|
|
|
displaySize.setText("当前 UEngine 屏幕分辨率:\n" + subprocess.getoutput("adb -s '192.168.250.2:5555' shell wm size"))
|
2021-09-11 15:51:23 +08:00
|
|
|
|
|
|
|
|
|
def SettingDisplaySize():
|
|
|
|
|
global displayX
|
|
|
|
|
global displayY
|
|
|
|
|
try:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
int(displayX.text())
|
|
|
|
|
int(displayY.text())
|
2021-09-11 15:51:23 +08:00
|
|
|
|
except:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", langFile[lang]["Main"]["MainWindow"]["Error"]["InputDataError"])
|
2021-09-11 15:51:23 +08:00
|
|
|
|
return
|
2022-07-26 14:57:48 +08:00
|
|
|
|
os.system("adb -s '192.168.250.2:5555' shell wm size {}x{}".format(displayX.text(), displayY.text()))
|
2021-09-11 15:51:23 +08:00
|
|
|
|
AdbChangeUengineDisplaySize.GetUengineDisplaySize()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "执行完毕!")
|
2021-09-11 15:51:23 +08:00
|
|
|
|
|
2021-08-30 17:49:12 +08:00
|
|
|
|
class ShowTextTipsWindow():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
messageWindow = None
|
2021-08-30 17:49:12 +08:00
|
|
|
|
def ShowWindow(things):
|
2022-07-26 14:57:48 +08:00
|
|
|
|
ShowTextTipsWindow.messageWindow = QtWidgets.QMainWindow()
|
|
|
|
|
message = QtWidgets.QWidget()
|
|
|
|
|
messageLayout = QtWidgets.QVBoxLayout()
|
|
|
|
|
|
|
|
|
|
text = QtWidgets.QTextBrowser()
|
|
|
|
|
text.setText(things)
|
|
|
|
|
ok = QtWidgets.QPushButton("确定")
|
|
|
|
|
ok.clicked.connect(ShowTextTipsWindow.messageWindow.close)
|
|
|
|
|
#ok.setSizePolicy(size)
|
|
|
|
|
|
|
|
|
|
messageLayout.addWidget(text)
|
|
|
|
|
messageLayout.addWidget(ok)
|
|
|
|
|
|
|
|
|
|
message.setLayout(messageLayout)
|
|
|
|
|
ShowTextTipsWindow.messageWindow.setCentralWidget(message)
|
|
|
|
|
ShowTextTipsWindow.messageWindow.setWindowTitle("提示")
|
|
|
|
|
ShowTextTipsWindow.messageWindow.setWindowIcon(QtGui.QIcon(iconPath))
|
|
|
|
|
ShowTextTipsWindow.messageWindow.show()
|
|
|
|
|
ShowTextTipsWindow.messageWindow.resize(ShowTextTipsWindow.messageWindow.frameSize().width() * 2, ShowTextTipsWindow.messageWindow.frameSize().height() * 1.5)
|
|
|
|
|
return
|
2021-08-30 17:49:12 +08:00
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 添加/删除 uengine 应用快捷方式
|
2021-08-18 21:54:28 +08:00
|
|
|
|
class AddNewUengineDesktopLink():
|
|
|
|
|
addTips = '''可以输入app的包名和Activity或通过浏览apk文件来获取包名和Activity
|
|
|
|
|
注意:如果是要删除只要输入包名即可'''
|
2022-07-26 14:57:48 +08:00
|
|
|
|
messageWindow = None
|
2021-08-18 21:54:28 +08:00
|
|
|
|
def ShowWindow():
|
|
|
|
|
global activityName
|
|
|
|
|
global packageName
|
2022-07-26 14:57:48 +08:00
|
|
|
|
AddNewUengineDesktopLink.messageWindow = QtWidgets.QMainWindow()
|
|
|
|
|
message = QtWidgets.QWidget()
|
|
|
|
|
messageLayout = QtWidgets.QGridLayout()
|
|
|
|
|
|
|
|
|
|
activityName = QtWidgets.QLineEdit()
|
|
|
|
|
packageName = QtWidgets.QLineEdit()
|
|
|
|
|
browser = QtWidgets.QPushButton("浏览……")
|
|
|
|
|
controlFrame = QtWidgets.QHBoxLayout()
|
|
|
|
|
open = QtWidgets.QPushButton("打开")
|
|
|
|
|
save = QtWidgets.QPushButton("保存")
|
|
|
|
|
delete = QtWidgets.QPushButton("删除")
|
|
|
|
|
|
|
|
|
|
packageName.setPlaceholderText("APK 包名")
|
|
|
|
|
activityName.setPlaceholderText("APK 的 Activity")
|
2021-08-18 21:54:28 +08:00
|
|
|
|
|
2022-07-26 14:57:48 +08:00
|
|
|
|
browser.clicked.connect(AddNewUengineDesktopLink.FindApk)
|
|
|
|
|
open.clicked.connect(AddNewUengineDesktopLink.TestOpen)
|
|
|
|
|
save.clicked.connect(AddNewUengineDesktopLink.SaveDesktopLink)
|
|
|
|
|
delete.clicked.connect(AddNewUengineDesktopLink.DelDesktopLink)
|
|
|
|
|
|
|
|
|
|
messageLayout.addWidget(QtWidgets.QLabel(AddNewUengineDesktopLink.addTips), 0, 0, 1, 3)
|
|
|
|
|
messageLayout.addWidget(packageName, 1, 0, 1, 1)
|
|
|
|
|
messageLayout.addWidget(activityName, 1, 1, 1, 1)
|
|
|
|
|
messageLayout.addWidget(browser, 1, 2, 1, 1)
|
|
|
|
|
messageLayout.addLayout(controlFrame, 2, 0, 1, 3)
|
|
|
|
|
controlFrame.addItem(QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum))
|
|
|
|
|
controlFrame.addWidget(open)
|
|
|
|
|
controlFrame.addWidget(save)
|
|
|
|
|
controlFrame.addWidget(delete)
|
|
|
|
|
controlFrame.addItem(QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum))
|
|
|
|
|
|
|
|
|
|
message.setLayout(messageLayout)
|
|
|
|
|
AddNewUengineDesktopLink.messageWindow.setCentralWidget(message)
|
|
|
|
|
AddNewUengineDesktopLink.messageWindow.setWindowTitle("添加/删除 UEngine 图标")
|
|
|
|
|
AddNewUengineDesktopLink.messageWindow.setWindowIcon(QtGui.QIcon(iconPath))
|
|
|
|
|
AddNewUengineDesktopLink.messageWindow.show()
|
|
|
|
|
return
|
2021-08-18 21:54:28 +08:00
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 添加快捷方式
|
2021-08-18 21:54:28 +08:00
|
|
|
|
def SaveDesktopLink():
|
2021-12-12 11:28:22 +08:00
|
|
|
|
try:
|
|
|
|
|
if os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())):
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if QtWidgets.QMessageBox.question(widget, "提示", "文件已存在,是否要覆盖?") == QtWidgets.QMessageBox.No:
|
2021-12-12 11:28:22 +08:00
|
|
|
|
return
|
|
|
|
|
if not os.path.exists("{}/.local/share/icons/hicolor/256x256/apps/".format(get_home())):
|
|
|
|
|
os.makedirs("{}/.local/share/icons/hicolor/256x256/apps/".format(get_home()))
|
|
|
|
|
global activityName
|
|
|
|
|
iconSavePath = "{}/.local/share/icons/hicolor/256x256/apps/{}.png".format(get_home(), packageName.get())
|
|
|
|
|
shutil.copy(programPath + "/defult.png", iconSavePath)
|
|
|
|
|
BuildUengineDesktop(packageName.get(), activityName, packageName.get(), iconSavePath,
|
|
|
|
|
"{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get()))
|
|
|
|
|
BuildUengineDesktop(packageName.get(), activityName, packageName.get(), iconSavePath,
|
|
|
|
|
"{}/{}.desktop".format(get_desktop_path(), packageName.get()))
|
|
|
|
|
AddNewUengineDesktopLink.SaveHistory()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "创建完毕!")
|
2021-12-12 11:28:22 +08:00
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "错误", traceback.format_exc())
|
2021-12-12 11:28:22 +08:00
|
|
|
|
|
2021-08-18 21:54:28 +08:00
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 删除快捷方式
|
2021-08-18 21:54:28 +08:00
|
|
|
|
def DelDesktopLink():
|
|
|
|
|
try:
|
2021-12-12 11:28:22 +08:00
|
|
|
|
global packageName
|
|
|
|
|
if not os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())):
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", "此包名对应的 UEngine 桌面快捷方式不存在!")
|
2021-12-12 11:28:22 +08:00
|
|
|
|
return
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if QtWidgets.QMessageBox.warning(widget, "警告", "你确定要删除吗?删除后将无法恢复!", QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Cancel) == QtWidgets.QMessageBox.Cancel:
|
2021-12-12 11:28:22 +08:00
|
|
|
|
return
|
|
|
|
|
try:
|
|
|
|
|
os.remove("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get()))
|
|
|
|
|
AddNewUengineDesktopLink.SaveHistory()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(widget, "提示", "已删除")
|
2021-12-12 11:28:22 +08:00
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
2021-08-18 21:54:28 +08:00
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
2021-08-18 21:54:28 +08:00
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 保存历史记录
|
2021-08-18 21:54:28 +08:00
|
|
|
|
def SaveHistory():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
findApkNameHistory.append(packageName.text())
|
|
|
|
|
findApkActivityHistory.append(activityName.text())
|
2021-08-18 21:54:28 +08:00
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindApkNameHistory.json", str(json.dumps(ListToDictionary(findApkNameHistory)))) # 将历史记录的数组转换为字典并写入
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindApkActivityHistory.json", str(json.dumps(ListToDictionary(findApkActivityHistory)))) # 将历史记录的数组转换为字典并写入
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 打开测试
|
2021-08-19 08:49:50 +08:00
|
|
|
|
def TestOpen():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
threading.Thread(target=os.system, args=["/usr/bin/uengine launch --package={} --component={}".format(packageName.text(), activityName.text())]).start()
|
2021-08-19 08:49:50 +08:00
|
|
|
|
AddNewUengineDesktopLink.SaveHistory()
|
|
|
|
|
|
2021-08-19 14:08:05 +08:00
|
|
|
|
# 浏览文件
|
2021-08-18 21:54:28 +08:00
|
|
|
|
def FindApk():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
path = QtWidgets.QFileDialog.getOpenFileName(widget, "选择apk", "~", "APK 文件(*.apk);;所有文件(*.*)", json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkName.json"))["path"])[0]
|
|
|
|
|
if path == "" or path == () or path == None:
|
2021-08-18 21:54:28 +08:00
|
|
|
|
return
|
2022-07-26 14:57:48 +08:00
|
|
|
|
packageName.setText(GetApkPackageName(path))
|
|
|
|
|
activityName.setText(str(GetApkActivityName(path)))
|
2021-08-18 21:54:28 +08:00
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindApkName.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
|
|
|
|
|
|
2021-09-11 15:51:23 +08:00
|
|
|
|
def UseProgram():
|
|
|
|
|
global useProgram
|
2022-07-27 18:15:28 +08:00
|
|
|
|
useProgram = '''<p>1、UEngine:{}</p>
|
|
|
|
|
<p>2、python3:{}</p>
|
|
|
|
|
<p>3、PyQt:{}</p>
|
|
|
|
|
<p>4、aapt:{}</p>
|
|
|
|
|
<p>5、dpkg:{}</p>
|
|
|
|
|
<p>6、mkdir:{}</p>
|
|
|
|
|
<p>7、echo</p>
|
|
|
|
|
<p>8、chmod:{}</p>
|
|
|
|
|
<p>9、adb:{}</p>
|
|
|
|
|
<p>10、deepin 终端:{}</p>'''.format(subprocess.getoutput("uengine version"),
|
2021-09-11 15:51:23 +08:00
|
|
|
|
subprocess.getoutput("python3 --version"),
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtCore.qVersion,
|
2021-09-11 15:51:23 +08:00
|
|
|
|
subprocess.getoutput("aapt version"),
|
|
|
|
|
subprocess.getoutput("dpkg --version"),
|
|
|
|
|
subprocess.getoutput("mkdir --version"),
|
|
|
|
|
subprocess.getoutput("chmod --version"),
|
|
|
|
|
subprocess.getoutput("adb version"),
|
|
|
|
|
subprocess.getoutput("deepin-terminal -v"))
|
|
|
|
|
|
2022-07-26 14:57:48 +08:00
|
|
|
|
def BackAPK(choice):
|
|
|
|
|
global choose
|
|
|
|
|
choose = choice
|
|
|
|
|
|
2021-05-29 22:54:59 +08:00
|
|
|
|
###########################
|
|
|
|
|
# 程序信息
|
|
|
|
|
###########################
|
2021-09-20 17:10:05 +08:00
|
|
|
|
lang = get_now_lang()
|
2021-08-19 14:08:05 +08:00
|
|
|
|
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
|
|
|
|
information = json.loads(readtxt(programPath + "/information.json"))
|
2021-09-20 17:10:05 +08:00
|
|
|
|
langFile = json.loads(readtxt(programPath + "/Language.json"))
|
|
|
|
|
if not lang in langFile.keys():
|
|
|
|
|
lang = "en_US.UTF-8"
|
2021-08-19 14:08:05 +08:00
|
|
|
|
programUrl = information["Url"][0]
|
|
|
|
|
version = information["Version"]
|
|
|
|
|
goodRunSystem = information["System"]
|
2021-07-11 14:45:11 +08:00
|
|
|
|
aaptVersion = GetCommandReturn("aapt version")
|
2021-10-03 17:42:30 +08:00
|
|
|
|
SystemVersion = GetSystemVersion()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
iconPath = "{}/runner.svg".format(os.path.split(os.path.realpath(__file__))[0])
|
|
|
|
|
about = f'''<p align="center"><img width=256 src="{iconPath}"/></p>
|
|
|
|
|
<p>介绍 :一个基于 Python3 的 PyQt5 制作的 UEngine 运行器,在新版本Deepin/UOS发布后,可以在应用商店安装部分官方已适配的安卓应用,对爱好者来说,不能自己安装APK软件包始终差点意思,本程序可以为Deepin/UOS上的UEngine安卓运行环境安装自定义APK软件包,并能发送安装的APK包启动菜单到桌面或系统菜单。</p>
|
|
|
|
|
<p>版本 :{version}</p>
|
|
|
|
|
<p>适用平台 :{goodRunSystem}</p>
|
|
|
|
|
<p>Qt 版本 :{QtCore.qVersion()}</p>
|
|
|
|
|
<p>程序官网 :{programUrl}</p>
|
|
|
|
|
<p>系统版本 : {SystemVersion}</p>
|
|
|
|
|
<h3>©2021-{time.strftime("%Y")}</h3>'''
|
|
|
|
|
updateThingsString = ""
|
|
|
|
|
tips = ""
|
2022-07-27 18:15:28 +08:00
|
|
|
|
contribute = ""
|
2022-07-26 14:57:48 +08:00
|
|
|
|
for i in information["Tips"]:
|
|
|
|
|
tips += f"<p>{i}</p>"
|
|
|
|
|
for i in information["Update"]:
|
|
|
|
|
updateThingsString += f"<p>{i}</p>"
|
|
|
|
|
for i in information["Contribute"]:
|
2022-07-27 18:15:28 +08:00
|
|
|
|
contribute += f"<p>{i}</p>"
|
2021-09-20 17:10:05 +08:00
|
|
|
|
title = "{} {}".format(langFile[lang]["Main"]["MainWindow"]["Title"], version)
|
2021-08-19 14:08:05 +08:00
|
|
|
|
updateTime = information["Time"]
|
2021-05-29 22:54:59 +08:00
|
|
|
|
updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
|
2021-08-26 15:24:26 +08:00
|
|
|
|
desktop = programPath + "/UengineAndroidProgramList.desktop"
|
2021-05-29 22:54:59 +08:00
|
|
|
|
desktopName = "UengineAndroidProgramList.desktop"
|
2021-09-11 15:51:23 +08:00
|
|
|
|
useProgram = ""
|
|
|
|
|
threading.Thread(target=UseProgram).start()
|
2021-05-29 22:54:59 +08:00
|
|
|
|
|
|
|
|
|
###########################
|
|
|
|
|
# 加载配置
|
|
|
|
|
###########################
|
2022-07-27 18:15:28 +08:00
|
|
|
|
app = QtWidgets.QApplication(sys.argv)
|
2021-08-15 21:46:48 +08:00
|
|
|
|
if not os.path.exists("{}/.local/share/applications/uengine/".format(get_home())):
|
2021-09-11 15:51:23 +08:00
|
|
|
|
os.makedirs("{}/.local/share/applications/uengine/".format(get_home()))
|
2021-05-29 22:54:59 +08:00
|
|
|
|
if not os.path.exists(get_home() + "/.config/uengine-runner"): # 如果没有配置文件夹
|
2021-09-11 15:51:23 +08:00
|
|
|
|
os.makedirs(get_home() + "/.config/uengine-runner") # 创建配置文件夹
|
2021-05-29 22:54:59 +08:00
|
|
|
|
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApkHistory.json"): # 如果没有配置文件
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindApkHistory.json", json.dumps({})) # 创建配置文件
|
2021-08-18 21:54:28 +08:00
|
|
|
|
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApkNameHistory.json"): # 如果没有配置文件
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindApkNameHistory.json", json.dumps({})) # 创建配置文件
|
|
|
|
|
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApkActivityHistory.json"): # 如果没有配置文件
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindApkActivityHistory.json", json.dumps({})) # 创建配置文件
|
2021-06-06 11:54:38 +08:00
|
|
|
|
if not os.path.exists(get_home() + "/.config/uengine-runner/FindUninstallApkHistory.json"): # 如果没有配置文件
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindUninstallApkHistory.json", json.dumps({})) # 创建配置文件
|
2021-08-18 21:54:28 +08:00
|
|
|
|
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApkName.json"): # 如果没有配置文件
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindApkName.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
|
2021-05-29 22:54:59 +08:00
|
|
|
|
if not os.path.exists(get_home() + "/.config/uengine-runner/FindApk.json"): # 如果没有配置文件
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindApk.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
|
2021-06-06 11:54:38 +08:00
|
|
|
|
if not os.path.exists(get_home() + "/.config/uengine-runner/FindUninstallApk.json"): # 如果没有配置文件
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/FindUninstallApk.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
|
2021-08-08 22:02:43 +08:00
|
|
|
|
if not os.path.exists(get_home() + "/.config/uengine-runner/SaveApkIcon.json"): # 如果没有配置文件
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/SaveApkIcon.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
|
2021-08-18 21:54:28 +08:00
|
|
|
|
if not os.path.exists(get_home() + "/.config/uengine-runner/SaveApk.json"): # 如果没有配置文件
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/SaveApk.json", json.dumps({"path": "~"})) # 写入(创建)一个配置文件
|
2022-02-11 16:38:03 +08:00
|
|
|
|
if not os.path.exists(get_home() + "/.config/uengine-runner/setting.json"):
|
2022-07-26 14:57:48 +08:00
|
|
|
|
choosemsg = QtWidgets.QMessageBox()
|
|
|
|
|
choosemsg.setText("""在使用本程序前,请选择安装Apk包的设置以便更好的运行,下列选项的详细介绍:
|
2022-02-11 16:38:03 +08:00
|
|
|
|
|
|
|
|
|
不备份Apk包直接安装:适用于Deepin(旧版UEngine),安装较快,不受/tmp大小所限,但Deepin23和UOS(新版UEngine)不推荐此选项,因为安装后会自动删除Apk安装包;
|
|
|
|
|
备份Apk包然后在安装后自动拷贝原先目录:适用于Deepin23和UOS(新版UEngine),安装较慢,受/tmp大小所限,安装后不会丢失Apk,Deepin(旧版UEngine)不推荐使用该选项;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
后期可以在程序主界面的菜单栏的“程序”=>“设置”里进行修改,
|
|
|
|
|
如果不知道正在使用的系统是什么版本可以打开系统设置查看。
|
2022-07-26 14:57:48 +08:00
|
|
|
|
""")
|
|
|
|
|
choosemsg.setWindowTitle("设置")
|
|
|
|
|
choose = None
|
|
|
|
|
choosemsg.addButton("不备份Apk包直接安装", QtWidgets.QMessageBox.ActionRole).clicked.connect(lambda: BackAPK(0))
|
|
|
|
|
choosemsg.addButton("备份Apk包然后在安装后自动拷贝原先目录", QtWidgets.QMessageBox.ActionRole).clicked.connect(lambda: BackAPK(1))
|
|
|
|
|
choosemsg.exec_()
|
2022-02-11 16:38:03 +08:00
|
|
|
|
if choose == None:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
QtWidgets.QMessageBox.information(None, "提示", "必须选择一个选项!否则无法进入程序!")
|
2022-02-11 16:38:03 +08:00
|
|
|
|
sys.exit()
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-runner/setting.json", json.dumps({"SaveApk": int(choose)}))
|
2022-07-27 18:15:28 +08:00
|
|
|
|
defultProgramList = {
|
|
|
|
|
"SaveApk": 1,
|
|
|
|
|
"AutoScreenConfig": False,
|
|
|
|
|
"ChooseProgramType": False,
|
|
|
|
|
"Theme": ""
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
settingConf = json.loads(readtxt(get_home() + "/.config/uengine-runner/setting.json"))
|
|
|
|
|
change = False
|
|
|
|
|
for i in defultProgramList.keys():
|
|
|
|
|
if not i in settingConf:
|
|
|
|
|
change = True
|
|
|
|
|
settingConf[i] = defultProgramList[i]
|
|
|
|
|
if change:
|
|
|
|
|
write_txt(get_home() + "/.config/uengine-setting.json", json.dumps(settingConf))
|
|
|
|
|
except:
|
|
|
|
|
traceback.print_exc()
|
|
|
|
|
app = QtWidgets.QApplication(sys.argv)
|
|
|
|
|
QtWidgets.QMessageBox.critical(None, "错误", f"无法读取配置,无法继续\n{traceback.format_exc()}")
|
|
|
|
|
sys.exit(1)
|
2021-05-29 22:54:59 +08:00
|
|
|
|
|
|
|
|
|
###########################
|
|
|
|
|
# 设置变量
|
|
|
|
|
###########################
|
|
|
|
|
findApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkHistory.json")).values())
|
2021-06-06 11:54:38 +08:00
|
|
|
|
fineUninstallApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindUninstallApkHistory.json")).values())
|
2021-08-18 21:54:28 +08:00
|
|
|
|
findApkNameHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkNameHistory.json")).values())
|
|
|
|
|
findApkActivityHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkActivityHistory.json")).values())
|
2021-06-06 11:54:38 +08:00
|
|
|
|
|
2022-07-28 20:04:59 +08:00
|
|
|
|
try:
|
|
|
|
|
threading.Thread(target=requests.get, args=[parse.unquote(base64.b64decode("aHR0cDovLzEyMC4yNS4xNTMuMTQ0L3VlbmdpbmUtcnVubmVyL29wZW4vSW5zdGFsbC5waHA=").decode("utf-8")) + "?Version=" + version]).start()
|
|
|
|
|
except:
|
|
|
|
|
pass
|
2021-08-08 17:14:48 +08:00
|
|
|
|
# add sub window
|
|
|
|
|
#添加窗口开启关闭开关,防止重复开启
|
|
|
|
|
windowflag = "close"
|
2022-07-26 14:57:48 +08:00
|
|
|
|
def Egg():
|
|
|
|
|
try:
|
|
|
|
|
lists = json.loads(requests.get("http://120.25.153.144/uengine-runner/VersionList.json").text)
|
|
|
|
|
data = []
|
|
|
|
|
for i in lists:
|
|
|
|
|
data.append(int(requests.get("http://120.25.153.144/uengine-runner/{}/data.txt".format(i)).text))
|
|
|
|
|
except:
|
|
|
|
|
QtWidgets.QMessageBox.critical(widget, "错误", "服务器出错!数据获取失败!")
|
|
|
|
|
return
|
|
|
|
|
fig = matplotlib.pylab.figure()
|
|
|
|
|
fig.canvas.set_window_title("“UEngine 运行器”安装数(数据只供参考)")
|
|
|
|
|
matplotlib.pylab.plot(lists, data)
|
|
|
|
|
index = numpy.arange(len(lists))
|
|
|
|
|
fonts = matplotlib.font_manager.FontProperties(fname='/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc') # 用于支持中文显示,需要依赖fonts-noto-cjk
|
|
|
|
|
matplotlib.pylab.xlabel("版本号", fontproperties=fonts)
|
|
|
|
|
matplotlib.pylab.ylabel("安装数", fontproperties=fonts)
|
|
|
|
|
|
|
|
|
|
matplotlib.pylab.title("“UEngine 运行器”安装数(数据只供参考)", fontproperties=fonts)
|
|
|
|
|
matplotlib.pylab.show()
|
|
|
|
|
helpWindow = None
|
2021-08-08 17:14:48 +08:00
|
|
|
|
def showhelp():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
global helpWindow
|
|
|
|
|
helpWindow = QtWidgets.QMainWindow()
|
|
|
|
|
helpWidget = QtWidgets.QWidget()
|
|
|
|
|
helpLayout = QtWidgets.QGridLayout()
|
|
|
|
|
|
|
|
|
|
def ChgLog():
|
|
|
|
|
HelpStr.setHtml(updateThingsString)
|
|
|
|
|
def ChgAbout(event):
|
|
|
|
|
HelpStr.setHtml(about)
|
|
|
|
|
def ChgDep():
|
|
|
|
|
if useProgram == "":
|
|
|
|
|
BtnZujian.setDisabled(True)
|
|
|
|
|
return
|
|
|
|
|
HelpStr.setHtml(useProgram)
|
|
|
|
|
def ChgCon():
|
|
|
|
|
HelpStr.setHtml(contribute)
|
|
|
|
|
def ChgTips():
|
|
|
|
|
HelpStr.setHtml(tips)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BtnReadme = QtWidgets.QPushButton("使用说明")
|
|
|
|
|
BtnLog = QtWidgets.QPushButton("更新内容")
|
|
|
|
|
BtnZujian = QtWidgets.QPushButton("程序依赖的组件")
|
2022-07-27 18:15:28 +08:00
|
|
|
|
BtnGongxian = QtWidgets.QPushButton("谢明列表")
|
2022-07-26 14:57:48 +08:00
|
|
|
|
BtnAbout = QtWidgets.QPushButton("关于")
|
2022-07-27 18:15:28 +08:00
|
|
|
|
BtnDownN = QtWidgets.QPushButton("程序下载量")
|
2022-07-26 14:57:48 +08:00
|
|
|
|
HelpStr = QtWidgets.QTextBrowser()
|
2022-07-27 18:15:28 +08:00
|
|
|
|
BtnDownN.setEnabled("--彩蛋" in sys.argv)
|
2022-07-26 14:57:48 +08:00
|
|
|
|
BtnReadme.clicked.connect(ChgTips)
|
|
|
|
|
BtnLog.clicked.connect(ChgLog)
|
|
|
|
|
BtnZujian.clicked.connect(ChgDep)
|
|
|
|
|
BtnGongxian.clicked.connect(ChgCon)
|
|
|
|
|
BtnAbout.clicked.connect(ChgAbout)
|
2022-07-27 18:15:28 +08:00
|
|
|
|
BtnDownN.clicked.connect(Egg)
|
2022-07-26 14:57:48 +08:00
|
|
|
|
|
|
|
|
|
ChgTips()
|
|
|
|
|
|
|
|
|
|
helpLayout.addWidget(BtnReadme, 0, 0, 1, 1)
|
|
|
|
|
helpLayout.addWidget(BtnLog, 1, 0, 1, 1)
|
|
|
|
|
helpLayout.addWidget(BtnZujian, 2, 0, 1, 1)
|
|
|
|
|
helpLayout.addWidget(BtnGongxian, 3, 0, 1, 1)
|
2022-07-27 18:15:28 +08:00
|
|
|
|
helpLayout.addWidget(BtnAbout, 5, 0, 1, 1)
|
|
|
|
|
helpLayout.addWidget(BtnDownN, 4, 0, 1, 1)
|
|
|
|
|
helpLayout.addWidget(HelpStr, 0, 1, 7, 1)
|
2022-07-26 14:57:48 +08:00
|
|
|
|
|
|
|
|
|
helpWidget.setLayout(helpLayout)
|
|
|
|
|
helpWindow.setCentralWidget(helpWidget)
|
2022-08-11 12:27:25 +08:00
|
|
|
|
helpWindow.setFixedSize(int(helpWindow.frameSize().width() * 0.9), int(helpWindow.frameSize().height() * 1.5))
|
2022-07-26 14:57:48 +08:00
|
|
|
|
helpWindow.setWindowTitle("帮助")
|
|
|
|
|
helpWindow.setWindowIcon(QtGui.QIcon(iconPath))
|
|
|
|
|
helpWindow.show()
|
|
|
|
|
return
|
2022-06-20 22:29:10 +08:00
|
|
|
|
|
2022-06-19 21:04:16 +08:00
|
|
|
|
###########################
|
|
|
|
|
# 检查 UEngine 是否安装
|
|
|
|
|
###########################
|
|
|
|
|
if not os.path.exists("/usr/bin/uengine"):
|
|
|
|
|
# Deepin/UOS 用户
|
|
|
|
|
if "deepin" in SystemVersion.lower() or "uos" in SystemVersion.lower():
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if QtWidgets.QMessageBox.question(None, "提示", "您的电脑没有安装 UEngine,是否安装 UEngine 以便更好的使用\n安装完后重新启动该程序即可") == QtWidgets.QMessageBox.Yes:
|
2022-07-07 14:35:44 +08:00
|
|
|
|
os.system(f"'{programPath}/launch.sh' deepin-terminal -C \"pkexec apt install uengine -y\"")
|
2022-06-19 21:04:16 +08:00
|
|
|
|
sys.exit(0)
|
|
|
|
|
# 非 Deepin/UOS 用户
|
|
|
|
|
else:
|
2022-07-26 14:57:48 +08:00
|
|
|
|
if QtWidgets.QMessageBox.question(None, "提示", "您的电脑没有安装 UEngine,是否安装 UEngine 以便更好的使用\n这里将会使用 shenmo 提供的脚本进行安装\n安装完后重新启动该程序即可\n提示:无法保证此安装脚本安装的 UEngine 可以使用") == QtWidgets.QMessageBox.Yes:
|
2022-07-07 14:35:44 +08:00
|
|
|
|
os.system(f"'{programPath}/launch.sh' deepin-terminal -C \"bash '{programPath}/uengine-installer'\"")
|
2022-06-19 21:04:16 +08:00
|
|
|
|
sys.exit(0)
|
2021-08-08 17:14:48 +08:00
|
|
|
|
|
2021-05-29 22:54:59 +08:00
|
|
|
|
###########################
|
|
|
|
|
# 窗口创建
|
|
|
|
|
###########################
|
2022-07-23 21:51:18 +08:00
|
|
|
|
window = QtWidgets.QMainWindow()
|
|
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
|
widgetLayout = QtWidgets.QGridLayout()
|
|
|
|
|
# 权重
|
|
|
|
|
size = QtWidgets.QSizePolicy()
|
|
|
|
|
size.setHorizontalPolicy(0)
|
|
|
|
|
widgetSize = QtWidgets.QSizePolicy()
|
|
|
|
|
widgetSize.setVerticalPolicy(0)
|
|
|
|
|
# 创建控件
|
|
|
|
|
LabApkPath = QtWidgets.QLabel(langFile[lang]["Main"]["MainWindow"]["LabApkPath"])
|
|
|
|
|
ComboInstallPath = QtWidgets.QComboBox()
|
|
|
|
|
FrmInstallWidget = QtWidgets.QWidget()
|
|
|
|
|
FrmInstall = QtWidgets.QGridLayout()
|
|
|
|
|
BtnFindApk = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["BtnFindApk"])
|
|
|
|
|
BtnInstall = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["BtnInstall"])
|
|
|
|
|
BtnShowUengineApp = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["BtnShowUengineApp"])
|
|
|
|
|
BtnUninstall = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["BtnUninstall"])
|
|
|
|
|
Btngeticon = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["Btngeticon"])
|
|
|
|
|
BtnSaveApk = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["BtnSaveApk"])
|
|
|
|
|
BtnApkInformation = QtWidgets.QPushButton(langFile[lang]["Main"]["MainWindow"]["BtnApkInformation"])
|
|
|
|
|
# 设置控件
|
|
|
|
|
FrmInstallWidget.setLayout(FrmInstall)
|
|
|
|
|
FrmInstallWidget.setSizePolicy(size)
|
|
|
|
|
BtnShowUengineApp.setSizePolicy(size)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
ComboInstallPath.setEditable(True)
|
|
|
|
|
ComboInstallPath.addItems(findApkHistory)
|
2022-07-26 14:57:48 +08:00
|
|
|
|
ComboInstallPath.setEditText("")
|
2022-07-24 23:06:50 +08:00
|
|
|
|
ComboInstallPath.setFixedSize(ComboInstallPath.frameSize().width() * 5, ComboInstallPath.frameSize().height())
|
2022-07-26 14:57:48 +08:00
|
|
|
|
try:
|
|
|
|
|
if sys.argv[1] == "-i":
|
|
|
|
|
ComboInstallPath.setCurrentText(sys.argv[2])
|
|
|
|
|
print("Install Path: " + sys.argv[2])
|
|
|
|
|
elif sys.argv[1] == "-u":
|
|
|
|
|
ComboInstallPath.setCurrentText(sys.argv[2])
|
|
|
|
|
print("Unstall Path: " + sys.argv[2])
|
|
|
|
|
else:
|
|
|
|
|
print("Command Format Error")
|
|
|
|
|
except:
|
|
|
|
|
print("Not Command Or Command Format Error")
|
2022-07-24 23:06:50 +08:00
|
|
|
|
# 绑定信号
|
|
|
|
|
BtnFindApk.clicked.connect(FindApk)
|
|
|
|
|
BtnInstall.clicked.connect(Button3Install)
|
|
|
|
|
BtnShowUengineApp.clicked.connect(Button5Click)
|
|
|
|
|
BtnUninstall.clicked.connect(ButtonClick8)
|
|
|
|
|
Btngeticon.clicked.connect(SaveIconToOtherPath)
|
|
|
|
|
BtnSaveApk.clicked.connect(SaveInstallUengineApp)
|
|
|
|
|
BtnApkInformation.clicked.connect(ApkInformation.ShowWindows)
|
2022-07-23 21:51:18 +08:00
|
|
|
|
# 布局控件
|
|
|
|
|
widgetLayout.addWidget(LabApkPath, 0, 0, 1, 2)
|
|
|
|
|
widgetLayout.addWidget(ComboInstallPath, 1, 0, 1, 2)
|
|
|
|
|
widgetLayout.addWidget(BtnShowUengineApp, 2, 0, 1, 1)
|
|
|
|
|
widgetLayout.addWidget(FrmInstallWidget, 0, 2, 3, 1)
|
|
|
|
|
FrmInstall.addWidget(BtnFindApk, 0, 0, 1, 1)
|
|
|
|
|
FrmInstall.addWidget(BtnInstall, 0, 1, 1, 1)
|
|
|
|
|
FrmInstall.addWidget(BtnUninstall, 1, 0, 1, 1)
|
|
|
|
|
FrmInstall.addWidget(Btngeticon, 1, 1, 1, 1)
|
|
|
|
|
FrmInstall.addWidget(BtnSaveApk, 2, 0, 1, 1)
|
|
|
|
|
FrmInstall.addWidget(BtnApkInformation, 2, 1, 1, 1)
|
|
|
|
|
# 设置菜单栏
|
|
|
|
|
menu = window.menuBar()
|
|
|
|
|
programmenu = menu.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][0]["Name"])
|
|
|
|
|
adb = menu.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Name"])
|
|
|
|
|
uengine = menu.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Name"])
|
|
|
|
|
help = menu.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][3]["Name"])
|
|
|
|
|
|
|
|
|
|
cleanProgramHistory = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][0]["Menu"][0])
|
|
|
|
|
settingWindow = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][0]["Menu"][2])
|
|
|
|
|
exitProgram = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][0]["Menu"][1])
|
|
|
|
|
programmenu.addAction(cleanProgramHistory)
|
|
|
|
|
programmenu.addAction(settingWindow)
|
|
|
|
|
programmenu.addSeparator()
|
|
|
|
|
programmenu.addAction(exitProgram)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
# 绑定事件
|
2022-07-26 14:57:48 +08:00
|
|
|
|
cleanProgramHistory.triggered.connect(CleanProgramHistory)
|
|
|
|
|
settingWindow.triggered.connect(SettingWindow.ShowWindow)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
exitProgram.triggered.connect(window.close)
|
2022-07-23 21:51:18 +08:00
|
|
|
|
|
|
|
|
|
adbUengineConnect = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][0])
|
|
|
|
|
adbConnectDevice = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][2])
|
|
|
|
|
adbChangeUengineDisplaySize = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][3])
|
|
|
|
|
adbAndroidInstallAppList = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][4])
|
|
|
|
|
adbTop = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][5])
|
|
|
|
|
adbShell = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][6])
|
|
|
|
|
adbScrcpyConnectUengine = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][7])
|
|
|
|
|
adb.addAction(adbUengineConnect)
|
|
|
|
|
adb.addSeparator()
|
|
|
|
|
adbServer = adb.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][1]["Name"])
|
|
|
|
|
adb.addAction(adbConnectDevice)
|
|
|
|
|
adb.addSeparator()
|
|
|
|
|
adb.addAction(adbChangeUengineDisplaySize)
|
|
|
|
|
adb.addAction(adbAndroidInstallAppList)
|
|
|
|
|
adb.addAction(adbTop)
|
|
|
|
|
adb.addAction(adbShell)
|
|
|
|
|
adb.addAction(adbScrcpyConnectUengine)
|
|
|
|
|
adb.addSeparator()
|
|
|
|
|
uengineUseAdbm = adb.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][8]["Name"])
|
|
|
|
|
adbStartServer = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][1]["Menu"][0])
|
|
|
|
|
adbStopServer = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][1]["Menu"][1])
|
|
|
|
|
adbKillAdbProgress = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][1]["Menu"][2])
|
|
|
|
|
uengineConnectAdb = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][8]["Menu"][0])
|
|
|
|
|
uengineUseAdb = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][8]["Menu"][1])
|
|
|
|
|
uengineDoNotUseAdb = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][1]["Menu"][8]["Menu"][2])
|
2022-07-24 23:06:50 +08:00
|
|
|
|
# 绑定信号
|
|
|
|
|
uengineConnectAdb.triggered.connect(UengineConnectAdb)
|
|
|
|
|
adbConnectDevice.triggered.connect(AdbConnectDeviceShow)
|
|
|
|
|
adbChangeUengineDisplaySize.triggered.connect(AdbChangeUengineDisplaySize.ShowWindows)
|
|
|
|
|
adbAndroidInstallAppList.triggered.connect(AdbAndroidInstallAppList)
|
|
|
|
|
adbTop.triggered.connect(AdbCPUAndRAWShowInTer)
|
|
|
|
|
adbShell.triggered.connect(AdbShellShowInTer)
|
|
|
|
|
adbScrcpyConnectUengine.triggered.connect(ScrcpyConnectUengine)
|
2022-07-23 21:51:18 +08:00
|
|
|
|
|
|
|
|
|
adbServer.addAction(adbStartServer)
|
|
|
|
|
adbServer.addAction(adbStopServer)
|
|
|
|
|
adbServer.addAction(adbKillAdbProgress)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
# 绑定信号
|
|
|
|
|
adbStartServer.triggered.connect(AdbStartServer)
|
|
|
|
|
adbStopServer.triggered.connect(AdbStopServer)
|
|
|
|
|
adbKillAdbProgress.triggered.connect(AdbKillAdbProgress)
|
2022-07-23 21:51:18 +08:00
|
|
|
|
|
|
|
|
|
uengineUseAdbm.addAction(uengineConnectAdb)
|
|
|
|
|
uengineUseAdbm.addAction(uengineUseAdb)
|
|
|
|
|
uengineUseAdbm.addSeparator()
|
|
|
|
|
uengineUseAdbm.addAction(uengineDoNotUseAdb)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
# 绑定信号
|
|
|
|
|
uengineConnectAdb.triggered.connect(UengineConnectAdb)
|
|
|
|
|
uengineUseAdb.triggered.connect(UengineUseAdb)
|
|
|
|
|
uengineDoNotUseAdb.triggered.connect(UengineDoNotUseAdb)
|
2022-07-23 21:51:18 +08:00
|
|
|
|
|
|
|
|
|
uengineAllowOrDisallowUpdateAndroidApp = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][13])
|
|
|
|
|
uengineSetHttpProxy = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][15])
|
|
|
|
|
uengineOpenDebBuilder = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][1])
|
|
|
|
|
uengineKeyboardToMouse = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][7])
|
|
|
|
|
uengineCheckCpu = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][8])
|
|
|
|
|
uengineUbuntuInstall = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][12])
|
|
|
|
|
uengineDeleteUengineCheck = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][9])
|
|
|
|
|
uengineReinstall = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][10])
|
|
|
|
|
uengineUbuntuInstall = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][14])
|
2022-07-27 18:15:28 +08:00
|
|
|
|
uengineWindowSizeSetting = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][16])
|
2022-07-23 21:51:18 +08:00
|
|
|
|
uengine.addAction(uengineAllowOrDisallowUpdateAndroidApp)
|
|
|
|
|
uengine.addAction(uengineSetHttpProxy)
|
|
|
|
|
uengine.addAction(uengineOpenDebBuilder)
|
|
|
|
|
uengine.addAction(uengineKeyboardToMouse)
|
|
|
|
|
uengine.addAction(uengineCheckCpu)
|
|
|
|
|
uengine.addAction(uengineUbuntuInstall)
|
2022-07-27 18:15:28 +08:00
|
|
|
|
uengine.addAction(uengineWindowSizeSetting)
|
2022-07-23 21:51:18 +08:00
|
|
|
|
uengineService = uengine.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][2]["Name"])
|
|
|
|
|
uengineInternet = uengine.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][3]["Name"])
|
|
|
|
|
uengineIcon = uengine.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][4]["Name"])
|
|
|
|
|
uengine.addMenu(uengineUseAdbm)
|
|
|
|
|
uengineData = uengine.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][6]["Name"])
|
|
|
|
|
uengine.addAction(uengineDeleteUengineCheck)
|
|
|
|
|
uengine.addAction(uengineReinstall)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
uengineRoot = uengine.addMenu(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][11]["Name"])
|
|
|
|
|
# 绑定信号
|
|
|
|
|
uengineAllowOrDisallowUpdateAndroidApp.triggered.connect(AllowOrDisallowUpdateAndroidApp)
|
|
|
|
|
uengineSetHttpProxy.triggered.connect(SetHttpProxy)
|
|
|
|
|
uengineOpenDebBuilder.triggered.connect(OpenUengineDebBuilder)
|
|
|
|
|
uengineKeyboardToMouse.triggered.connect(KeyboardToMouse)
|
|
|
|
|
uengineCheckCpu.triggered.connect(UengineCheckCpu)
|
|
|
|
|
uengineUbuntuInstall.triggered.connect(UengineUbuntuInstall)
|
|
|
|
|
uengineDeleteUengineCheck.triggered.connect(DelUengineCheck)
|
|
|
|
|
uengineReinstall.triggered.connect(ReinstallUengine)
|
2022-07-27 18:15:28 +08:00
|
|
|
|
uengineWindowSizeSetting.triggered.connect(UengineWindowSizeSetting.ShowWindow)
|
2022-07-23 21:51:18 +08:00
|
|
|
|
|
|
|
|
|
uengineStart = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][2]["Menu"][0])
|
|
|
|
|
uengineStop = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][2]["Menu"][1])
|
|
|
|
|
uengineRestart = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][2]["Menu"][2])
|
|
|
|
|
uengineService.addAction(uengineStart)
|
|
|
|
|
uengineService.addAction(uengineStop)
|
|
|
|
|
uengineService.addAction(uengineRestart)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
# 绑定信号
|
|
|
|
|
uengineStart.triggered.connect(StartUengine)
|
|
|
|
|
uengineStop.triggered.connect(StopUengine)
|
|
|
|
|
uengineRestart.triggered.connect(UengineRestart)
|
2022-07-23 21:51:18 +08:00
|
|
|
|
|
|
|
|
|
uengineBridgeStart = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][3]["Menu"][0])
|
|
|
|
|
uengineBridgeStop = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][3]["Menu"][1])
|
|
|
|
|
uengineBridgeRestart = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][3]["Menu"][2])
|
|
|
|
|
uengineBridgeReload = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][3]["Menu"][3])
|
|
|
|
|
uengineBridgeForceReload = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][3]["Menu"][4])
|
|
|
|
|
uengineInternet.addAction(uengineBridgeStart)
|
|
|
|
|
uengineInternet.addAction(uengineBridgeStop)
|
|
|
|
|
uengineInternet.addAction(uengineReinstall)
|
|
|
|
|
uengineInternet.addAction(uengineBridgeReload)
|
|
|
|
|
uengineInternet.addAction(uengineBridgeForceReload)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
# 绑定信号
|
|
|
|
|
uengineBridgeStart.triggered.connect(UengineBridgeStart)
|
|
|
|
|
uengineBridgeStop.triggered.connect(UengineBridgeStop)
|
|
|
|
|
uengineBridgeRestart.triggered.connect(UengineBridgeRestart)
|
|
|
|
|
uengineBridgeReload.triggered.connect(UengineBridgeReload)
|
|
|
|
|
uengineBridgeForceReload.triggered.connect(UengineBridgeForceReload)
|
2022-07-23 21:51:18 +08:00
|
|
|
|
|
|
|
|
|
uengineSendUengineAndroidListForDesktop = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][4]["Menu"][0])
|
|
|
|
|
uengineSendUengineAndroidListForLauncher = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][4]["Menu"][1])
|
|
|
|
|
uengineAddNewUengineDesktopLink = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][4]["Menu"][2])
|
|
|
|
|
uengineCleanAllUengineDesktopLink = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][4]["Menu"][3])
|
|
|
|
|
uengineIcon.addAction(uengineSendUengineAndroidListForDesktop)
|
|
|
|
|
uengineIcon.addAction(uengineSendUengineAndroidListForLauncher)
|
|
|
|
|
uengineIcon.addSeparator()
|
|
|
|
|
uengineIcon.addAction(uengineAddNewUengineDesktopLink)
|
|
|
|
|
uengineIcon.addSeparator()
|
|
|
|
|
uengineIcon.addAction(uengineCleanAllUengineDesktopLink)
|
2022-07-24 23:06:50 +08:00
|
|
|
|
# 绑定信号
|
|
|
|
|
uengineSendUengineAndroidListForDesktop.triggered.connect(SendUengineAndroidListForDesktop)
|
|
|
|
|
uengineSendUengineAndroidListForLauncher.triggered.connect(SendUengineAndroidListForLauncher)
|
|
|
|
|
uengineAddNewUengineDesktopLink.triggered.connect(AddNewUengineDesktopLink.ShowWindow)
|
|
|
|
|
uengineCleanAllUengineDesktopLink.triggered.connect(CleanAllUengineDesktopLink)
|
2022-07-23 21:51:18 +08:00
|
|
|
|
|
|
|
|
|
#uengineData
|
2022-07-24 23:06:50 +08:00
|
|
|
|
uengineOpenRootData = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][6]["Menu"][0])
|
|
|
|
|
uengineOpenUserData = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][6]["Menu"][1])
|
|
|
|
|
uengineBackClean = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][6]["Menu"][2])
|
|
|
|
|
uengineData.addAction(uengineOpenRootData)
|
|
|
|
|
uengineData.addAction(uengineOpenUserData)
|
|
|
|
|
uengineData.addSeparator()
|
|
|
|
|
uengineData.addAction(uengineBackClean)
|
|
|
|
|
# 绑定信号
|
|
|
|
|
uengineOpenRootData.triggered.connect(OpenUengineRootData)
|
|
|
|
|
uengineOpenUserData.triggered.connect(OpenUengineUserData)
|
|
|
|
|
uengineBackClean.triggered.connect(BackUengineClean)
|
|
|
|
|
|
2022-07-23 21:51:18 +08:00
|
|
|
|
#uengineRoot
|
2022-07-24 23:06:50 +08:00
|
|
|
|
uengineInstallRootUengineImage = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][11]["Menu"][0])
|
|
|
|
|
uengineBuildRootUengineImage = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][11]["Menu"][1])
|
|
|
|
|
uengineReinstallUengineImage = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][2]["Menu"][11]["Menu"][2])
|
|
|
|
|
uengineRoot.addAction(uengineInstallRootUengineImage)
|
|
|
|
|
uengineRoot.addAction(uengineBuildRootUengineImage)
|
|
|
|
|
uengineRoot.addSeparator()
|
|
|
|
|
uengineRoot.addAction(uengineReinstallUengineImage)
|
|
|
|
|
# 绑定信号
|
|
|
|
|
uengineInstallRootUengineImage.triggered.connect(InstallRootUengineImage)
|
|
|
|
|
uengineBuildRootUengineImage.triggered.connect(BuildRootUengineImage)
|
|
|
|
|
uengineReinstallUengineImage.triggered.connect(ReinstallUengineImage)
|
|
|
|
|
|
|
|
|
|
helpOpenProgramUrl = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][3]["Menu"][0])
|
|
|
|
|
helpUengineRunnerBugUpload = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][3]["Menu"][2])
|
|
|
|
|
helpShowHelp = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][3]["Menu"][4])
|
|
|
|
|
helpRunnerUpdate = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][3]["Menu"][3])
|
|
|
|
|
helpAbout = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][3]["Menu"][1])
|
2022-07-27 18:15:28 +08:00
|
|
|
|
helpAboutQt = QtWidgets.QAction(langFile[lang]["Main"]["MainWindow"]["Menu"][3]["Menu"][5])
|
2022-07-24 23:06:50 +08:00
|
|
|
|
help.addAction(helpOpenProgramUrl)
|
|
|
|
|
help.addAction(helpUengineRunnerBugUpload)
|
|
|
|
|
help.addAction(helpShowHelp)
|
|
|
|
|
help.addAction(helpRunnerUpdate)
|
|
|
|
|
help.addAction(helpAbout)
|
2022-07-27 18:15:28 +08:00
|
|
|
|
help.addAction(helpAboutQt)
|
|
|
|
|
hm1 = help.addMenu("更多生态适配应用")
|
|
|
|
|
hm1_1 = QtWidgets.QAction("运行 Windows 应用:Wine 运行器")
|
|
|
|
|
hm1.addAction(hm1_1)
|
|
|
|
|
hm1_1.triggered.connect(lambda: webbrowser.open_new_tab("https://gitee.com/gfdgd-xi/deep-wine-runner"))
|
2022-07-24 23:06:50 +08:00
|
|
|
|
# 绑定信号
|
|
|
|
|
helpOpenProgramUrl.triggered.connect(OpenProgramURL)
|
|
|
|
|
helpUengineRunnerBugUpload.triggered.connect(UengineRunnerBugUpload)
|
|
|
|
|
helpShowHelp.triggered.connect(ShowHelp)
|
|
|
|
|
helpRunnerUpdate.triggered.connect(UpdateWindow.ShowWindow)
|
|
|
|
|
helpAbout.triggered.connect(showhelp)
|
2022-07-27 18:15:28 +08:00
|
|
|
|
helpAboutQt.triggered.connect(lambda: QtWidgets.QMessageBox.aboutQt(widget))
|
2022-07-23 21:51:18 +08:00
|
|
|
|
# 设置窗口
|
2022-07-27 18:15:28 +08:00
|
|
|
|
app.setStyle(QtWidgets.QStyleFactory.create(settingConf["Theme"]))
|
2022-07-23 21:51:18 +08:00
|
|
|
|
widget.setLayout(widgetLayout)
|
|
|
|
|
window.setCentralWidget(widget)
|
|
|
|
|
window.setWindowTitle(title)
|
|
|
|
|
window.show()
|
2022-07-26 14:57:48 +08:00
|
|
|
|
window.setWindowIcon(QtGui.QIcon(iconPath))
|
2022-07-24 23:06:50 +08:00
|
|
|
|
window.setFixedSize(window.frameSize().width(), window.frameSize().height())
|
2022-07-26 14:57:48 +08:00
|
|
|
|
sys.exit(app.exec_())
|