初步迁移QT
This commit is contained in:
parent
eb44817201
commit
b34877538a
|
@ -4,7 +4,7 @@
|
|||
"https://gitee.com/gfdgd-xi/uengine-runner",
|
||||
"https://github.com/gfdgd-xi/uengine-runner"
|
||||
],
|
||||
"Version": "1.7.0",
|
||||
"Version": "1.8.0",
|
||||
"System": "Linux(deepin/UOS)",
|
||||
"Tips": [
|
||||
"更多可见:https://gitee.com/gfdgd-xi/uengine-runner/wikis",
|
||||
|
|
154
main.py
154
main.py
|
@ -2,8 +2,8 @@
|
|||
# 使用系统默认的 python3 运行
|
||||
###########################################################################################
|
||||
# 作者:gfdgd xi<3025613752@qq.com>
|
||||
# 版本:1.7.0
|
||||
# 更新时间:2022年07月08日(暑假了)
|
||||
# 版本:1.8.0
|
||||
# 更新时间:2022年07月23日
|
||||
# 感谢:anbox、deepin 和 UOS
|
||||
# 基于 Python3 的 tkinter 构建
|
||||
# 更新:gfdgd xi<3025613752@qq.com>、actionchen<917981399@qq.com>、为什么您不喜欢熊出没和阿布呢
|
||||
|
@ -32,6 +32,9 @@ import matplotlib.pylab
|
|||
import matplotlib.font_manager
|
||||
import PIL.Image as Image
|
||||
import PIL.ImageTk as ImageTk
|
||||
import PyQt5.QtGui as QtGui
|
||||
import PyQt5.QtCore as QtCore
|
||||
import PyQt5.QtWidgets as QtWidgets
|
||||
import tkinter as tk
|
||||
import tkinter.ttk as ttk
|
||||
import tkinter.messagebox as messagebox
|
||||
|
@ -1396,7 +1399,154 @@ if not os.path.exists("/usr/bin/uengine"):
|
|||
###########################
|
||||
# 窗口创建
|
||||
###########################
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
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)
|
||||
# 布局控件
|
||||
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)
|
||||
|
||||
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])
|
||||
|
||||
adbServer.addAction(adbStartServer)
|
||||
adbServer.addAction(adbStopServer)
|
||||
adbServer.addAction(adbKillAdbProgress)
|
||||
|
||||
uengineUseAdbm.addAction(uengineConnectAdb)
|
||||
uengineUseAdbm.addAction(uengineUseAdb)
|
||||
uengineUseAdbm.addSeparator()
|
||||
uengineUseAdbm.addAction(uengineDoNotUseAdb)
|
||||
|
||||
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])
|
||||
uengine.addAction(uengineAllowOrDisallowUpdateAndroidApp)
|
||||
uengine.addAction(uengineSetHttpProxy)
|
||||
uengine.addAction(uengineOpenDebBuilder)
|
||||
uengine.addAction(uengineKeyboardToMouse)
|
||||
uengine.addAction(uengineCheckCpu)
|
||||
uengine.addAction(uengineUbuntuInstall)
|
||||
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)
|
||||
uengine.addAction(uengineUbuntuInstall)
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
#uengineData
|
||||
#uengineRoot
|
||||
# 设置窗口
|
||||
widget.setLayout(widgetLayout)
|
||||
window.setCentralWidget(widget)
|
||||
window.setWindowTitle(title)
|
||||
window.show()
|
||||
window.setFixedSize(window.frameSize().width() * 1.5, window.frameSize().height())
|
||||
sys.exit(app.exec_())
|
||||
|
||||
# 设置窗口
|
||||
#style = ttkthemes.ThemedStyle(win)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
###########################################################################################
|
||||
# 作者:gfdgd xi
|
||||
# 版本:1.7.0
|
||||
# 更新时间:2022年07月08日(暑假了)
|
||||
# 更新时间:2022年07月23日
|
||||
# 感谢:anbox、deepin 和 统信
|
||||
# 基于 Python3 的 tkinter 构建
|
||||
###########################################################################################
|
||||
|
@ -19,78 +19,88 @@ import zipfile
|
|||
import traceback
|
||||
import threading
|
||||
import subprocess
|
||||
import ttkthemes
|
||||
import tkinter as tk
|
||||
import tkinter.ttk as ttk
|
||||
import tkinter.messagebox as messagebox
|
||||
import tkinter.filedialog as filedialog
|
||||
import PyQt5.QtGui as QtGui
|
||||
import PyQt5.QtCore as QtCore
|
||||
import PyQt5.QtWidgets as QtWidgets
|
||||
from getxmlimg import getsavexml
|
||||
|
||||
def FindApk():
|
||||
path = filedialog.askopenfilename(title="选择 Apk", filetypes=[("APK 文件", "*.apk"), ("所有文件", "*.*")], initialdir=json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkBuild.json"))["path"])
|
||||
path = QtWidgets.QFileDialog.getOpenFileName(widget, "选择 APK", json.loads(readtxt(get_home() + "/.config/uengine-runner/FindApkBuild.json"))["path"], "APK 可执行文件(*.apk);;所有文件(*.*)")
|
||||
if path != "" and path != "()":
|
||||
try:
|
||||
combobox1.set(path)
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApkBuild.json", json.dumps({"path": os.path.dirname(path)})) # 写入配置文件
|
||||
combobox1.setEditText(path[0])
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApkBuild.json", json.dumps({"path": os.path.dirname(path[0])})) # 写入配置文件
|
||||
except:
|
||||
pass
|
||||
traceback.print_exc()
|
||||
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
||||
|
||||
class QT:
|
||||
run = None
|
||||
|
||||
def BuildDeb():
|
||||
if combobox1.get() == "":
|
||||
messagebox.showerror(title="提示", message="信息没有填写完整,无法继续打包 APK")
|
||||
if combobox1.currentText() == "":
|
||||
QtWidgets.QMessageBox.critical(None, "提示", "信息没有填写完整,无法继续打包 APK")
|
||||
return
|
||||
if not os.path.exists(combobox1.get()):
|
||||
messagebox.showerror(title="提示", message="信息填写错误,无法继续打包 APK")
|
||||
if not os.path.exists(combobox1.currentText()):
|
||||
QtWidgets.QMessageBox.critical(None, "提示", "信息填写错误,无法继续打包 APK")
|
||||
return
|
||||
DisabledAndEnbled(True)
|
||||
threading.Thread(target=GetBuildApkDebError, args=(combobox1.get(),)).start()
|
||||
QT.run = BuildApkDeb(combobox1.currentText())
|
||||
QT.run.signal.connect(TextboxAddText1)
|
||||
QT.run.labelChange.connect(ChangeItems)
|
||||
QT.run.tips.connect(TipsMessagebox)
|
||||
QT.run.start()
|
||||
|
||||
def RunCommandShow(command):
|
||||
TextboxAddText1("$> {}".format(command) + "\n")
|
||||
res = subprocess.Popen([command], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
# 实时读取程序返回
|
||||
while res.poll() is None:
|
||||
try:
|
||||
texts = res.stdout.readline().decode("utf8")
|
||||
except:
|
||||
texts = ""
|
||||
print(texts, end="")
|
||||
TextboxAddText1(texts)
|
||||
class BuildApkDeb(QtCore.QThread):
|
||||
signal = QtCore.pyqtSignal(str)
|
||||
labelChange = QtCore.pyqtSignal(str)
|
||||
tips = QtCore.pyqtSignal(str)
|
||||
|
||||
def __init__(self, apkPath) -> None:
|
||||
self.apkPath = apkPath
|
||||
super().__init__()
|
||||
|
||||
def RunCommandShow(self, command):
|
||||
if command.replace(" ", "").replace("\n", "") == "":
|
||||
return
|
||||
self.signal.emit("$> {}".format(command))
|
||||
res = subprocess.Popen([command], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
# 实时读取程序返回
|
||||
while res.poll() is None:
|
||||
try:
|
||||
texts = res.stdout.readline().decode("utf8")
|
||||
except:
|
||||
texts = ""
|
||||
print(texts, end="")
|
||||
self.signal.emit(texts)
|
||||
# 已废弃
|
||||
# TextboxAddText1(GetCommandReturn(command))
|
||||
|
||||
def GetBuildApkDebError(apkPath):
|
||||
try:
|
||||
BuildApkDeb(apkPath)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
||||
DisabledAndEnbled(False)
|
||||
|
||||
def BuildApkDeb(apkPath):
|
||||
textbox1.delete("1.0","end")
|
||||
tempPath = "/tmp/uengine-apk-builder-{}".format(int(random.randint(0, 1024)))
|
||||
RunCommandShow("echo '======================================New===================================='")
|
||||
RunCommandShow("echo '创建目录'")
|
||||
RunCommandShow("mkdir -pv '{}/DEBIAN'".format(tempPath))
|
||||
RunCommandShow("mkdir -pv '{}/usr/share/applications'".format(tempPath))
|
||||
RunCommandShow("mkdir -pv '{}/usr/share/uengine/apk'".format(tempPath))
|
||||
RunCommandShow("mkdir -pv '{}/usr/share/uengine/icons'".format(tempPath))
|
||||
RunCommandShow("echo '写入文件,因为写入过程过于复杂,不显示写入命令……'")
|
||||
apkPackageName = GetApkPackageName(apkPath, False)
|
||||
if qianZhui.get():
|
||||
apkPackageNameNew = GetApkPackageName(apkPath, True).lower()
|
||||
else:
|
||||
apkPackageNameNew = GetApkPackageName(apkPath, False).lower()
|
||||
apkPackageVersion = GetApkVersion(apkPath)
|
||||
if apkPackageVersion[0].upper() == "V":
|
||||
package = list(apkPackageVersion)
|
||||
package.pop(0)
|
||||
apkPackageVersion = "".join(package)
|
||||
apkChineseLabel = GetApkChineseLabel(apkPath)
|
||||
apkActivityName = GetApkActivityName(apkPath)
|
||||
iconSavePath = "{}/usr/share/uengine/icons/{}.png".format(tempPath, apkPackageNameNew)
|
||||
debControl = '''Package: {}
|
||||
def run(self):
|
||||
try:
|
||||
apkPath = self.apkPath
|
||||
tempPath = "/tmp/uengine-apk-builder-{}".format(int(random.randint(0, 1024)))
|
||||
self.RunCommandShow("echo '======================================New===================================='")
|
||||
self.RunCommandShow("echo '创建目录'")
|
||||
self.RunCommandShow("mkdir -pv '{}/DEBIAN'".format(tempPath))
|
||||
self.RunCommandShow("mkdir -pv '{}/usr/share/applications'".format(tempPath))
|
||||
self.RunCommandShow("mkdir -pv '{}/usr/share/uengine/apk'".format(tempPath))
|
||||
self.RunCommandShow("mkdir -pv '{}/usr/share/uengine/icons'".format(tempPath))
|
||||
self.RunCommandShow("echo '写入文件,因为写入过程过于复杂,不显示写入命令……'")
|
||||
apkPackageName = GetApkPackageName(apkPath, False)
|
||||
if check.isChecked():
|
||||
apkPackageNameNew = GetApkPackageName(apkPath, True).lower()
|
||||
else:
|
||||
apkPackageNameNew = GetApkPackageName(apkPath, False).lower()
|
||||
apkPackageVersion = GetApkVersion(apkPath)
|
||||
if apkPackageVersion[0].upper() == "V":
|
||||
package = list(apkPackageVersion)
|
||||
package.pop(0)
|
||||
apkPackageVersion = "".join(package)
|
||||
apkChineseLabel = GetApkChineseLabel(apkPath)
|
||||
apkActivityName = GetApkActivityName(apkPath)
|
||||
iconSavePath = "{}/usr/share/uengine/icons/{}.png".format(tempPath, apkPackageNameNew)
|
||||
debControl = '''Package: {}
|
||||
Version: {}
|
||||
Architecture: all
|
||||
Maintainer: {}
|
||||
|
@ -98,7 +108,7 @@ Depends: deepin-elf-verify (>= 0.0.16.7-1), uengine (>= 1.0.1)
|
|||
Section: utils
|
||||
Priority: optional
|
||||
Description: {}\n'''.format(apkPackageNameNew, apkPackageVersion, apkChineseLabel, apkChineseLabel)
|
||||
debPostinst = '''#!/bin/sh
|
||||
debPostinst = '''#!/bin/sh
|
||||
|
||||
APK_DIR="/usr/share/uengine/apk"
|
||||
APK_NAME="{}"
|
||||
|
@ -135,7 +145,7 @@ fi
|
|||
/usr/bin/uengine-session-launch-helper -- uengine install --apk="$APK_PATH"
|
||||
|
||||
exit 0'''.format(apkPackageNameNew + ".apk", "/usr/share/applications/{}.desktop".format(apkPackageNameNew))
|
||||
debPrerm = '''#!/bin/sh
|
||||
debPrerm = '''#!/bin/sh
|
||||
|
||||
APP_NAME="{}"
|
||||
DESKTOP_FILE="{}"
|
||||
|
@ -157,7 +167,7 @@ echo "Uninstalling $APP_NAME"
|
|||
/usr/bin/uengine-session-launch-helper -- uengine uninstall --pkg="$APP_NAME"
|
||||
|
||||
exit 0'''.format(apkPackageName, "/usr/share/applications/{}.desktop".format(apkPackageNameNew))
|
||||
desktopFile = '''[Desktop Entry]
|
||||
desktopFile = '''[Desktop Entry]
|
||||
Categories=Other;
|
||||
Exec=uengine launch --action=android.intent.action.MAIN --package={} --component={}
|
||||
Icon=/usr/share/uengine/icons/{}.png
|
||||
|
@ -166,54 +176,63 @@ Type=Application
|
|||
GenericName={}
|
||||
Name={}
|
||||
'''
|
||||
#RunCommandShow("echo '{}' > '{}/DEBIAN/control'".format(debControl, tempPath))
|
||||
RunCommandShow("echo 正在写入文件:'{}/DEBIAN/control'".format(tempPath))
|
||||
write_txt("{}/DEBIAN/control".format(tempPath), debControl)
|
||||
RunCommandShow("echo 正在写入文件:'{}/DEBIAN/postinst'".format(tempPath))
|
||||
write_txt("{}/DEBIAN/postinst".format(tempPath), debPostinst)
|
||||
RunCommandShow("echo 正在写入文件:'{}/DEBIAN/prerm'".format(tempPath))
|
||||
write_txt("{}/DEBIAN/prerm".format(tempPath), debPrerm)
|
||||
RunCommandShow("echo 正在写入文件:'/usr/share/applications/{}.desktop'".format(apkPackageNameNew))
|
||||
#write_txt("{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageNameNew), desktopFile)
|
||||
BuildUengineDesktop(apkPackageName, apkActivityName, apkChineseLabel, "/usr/share/uengine/icons/{}.png".format(apkPackageNameNew),
|
||||
#self.RunCommandShow("echo '{}' > '{}/DEBIAN/control'".format(debControl, tempPath))
|
||||
self.RunCommandShow("echo 正在写入文件:'{}/DEBIAN/control'".format(tempPath))
|
||||
write_txt("{}/DEBIAN/control".format(tempPath), debControl)
|
||||
self.RunCommandShow("echo 正在写入文件:'{}/DEBIAN/postinst'".format(tempPath))
|
||||
write_txt("{}/DEBIAN/postinst".format(tempPath), debPostinst)
|
||||
self.RunCommandShow("echo 正在写入文件:'{}/DEBIAN/prerm'".format(tempPath))
|
||||
write_txt("{}/DEBIAN/prerm".format(tempPath), debPrerm)
|
||||
self.RunCommandShow("echo 正在写入文件:'/usr/share/applications/{}.desktop'".format(apkPackageNameNew))
|
||||
#write_txt("{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageNameNew), desktopFile)
|
||||
BuildUengineDesktop(apkPackageName, apkActivityName, apkChineseLabel, "/usr/share/uengine/icons/{}.png".format(apkPackageNameNew),
|
||||
"{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageNameNew))
|
||||
RunCommandShow("echo '复制文件'")
|
||||
RunCommandShow("echo '写入 APK 软件图标'")
|
||||
SaveApkIcon(apkPath, iconSavePath)
|
||||
RunCommandShow("echo '复制 APK 文件'")
|
||||
RunCommandShow("cp -rv '{}' '{}/usr/share/uengine/apk/{}.apk'".format(apkPath, tempPath, apkPackageNameNew))
|
||||
RunCommandShow("echo '正在设置文件权限……'")
|
||||
RunCommandShow("chmod 0775 -vR '{}/DEBIAN/postinst'".format(tempPath))
|
||||
RunCommandShow("chmod 0775 -vR '{}/DEBIAN/prerm'".format(tempPath))
|
||||
RunCommandShow("echo '打包 deb 到桌面……'")
|
||||
RunCommandShow("dpkg -b '{}' '{}/{}_{}.deb'".format(tempPath, get_desktop_path(),apkPackageNameNew, apkPackageVersion))
|
||||
RunCommandShow("echo '正在删除临时目录……'")
|
||||
RunCommandShow("rm -rfv '{}'".format(tempPath))
|
||||
RunCommandShow("echo '完成!'")
|
||||
findApkHistory.append(apkPath)
|
||||
combobox1['value'] = findApkHistory
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApkBuildHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
|
||||
messagebox.showinfo(title="提示", message="打包完成")
|
||||
DisabledAndEnbled(False)
|
||||
self.RunCommandShow("echo '复制文件'")
|
||||
self.RunCommandShow("echo '写入 APK 软件图标'")
|
||||
SaveApkIcon(apkPath, iconSavePath)
|
||||
self.RunCommandShow("echo '复制 APK 文件'")
|
||||
self.RunCommandShow("cp -rv '{}' '{}/usr/share/uengine/apk/{}.apk'".format(apkPath, tempPath, apkPackageNameNew))
|
||||
self.RunCommandShow("echo '正在设置文件权限……'")
|
||||
self.RunCommandShow("chmod 0775 -vR '{}/DEBIAN/postinst'".format(tempPath))
|
||||
self.RunCommandShow("chmod 0775 -vR '{}/DEBIAN/prerm'".format(tempPath))
|
||||
self.RunCommandShow("echo '打包 deb 到桌面……'")
|
||||
self.RunCommandShow("dpkg -b '{}' '{}/{}_{}.deb'".format(tempPath, get_desktop_path(),apkPackageNameNew, apkPackageVersion))
|
||||
self.RunCommandShow("echo '正在删除临时目录……'")
|
||||
self.RunCommandShow("rm -rfv '{}'".format(tempPath))
|
||||
self.RunCommandShow("echo '完成!'")
|
||||
findApkHistory.append(apkPath)
|
||||
self.labelChange.emit("")
|
||||
write_txt(get_home() + "/.config/uengine-runner/FindApkBuildHistory.json", str(json.dumps(ListToDictionary(findApkHistory)))) # 将历史记录的数组转换为字典并写入
|
||||
DisabledAndEnbled(False)
|
||||
self.tips.emit("打包完成")
|
||||
|
||||
except:
|
||||
DisabledAndEnbled(False)
|
||||
traceback.print_exc()
|
||||
QtWidgets.QMessageBox.critical(widget, "错误", traceback.format_exc())
|
||||
|
||||
def TipsMessagebox(tips):
|
||||
QtWidgets.QMessageBox.information(widget, "提示", tips)
|
||||
|
||||
def ChangeItems(self):
|
||||
combobox1.clear()
|
||||
combobox1.addItems(findApkHistory)
|
||||
#combobox1.setEditText("")
|
||||
|
||||
def DisabledAndEnbled(choose):
|
||||
userChoose = {True: tk.DISABLED, False: tk.NORMAL}
|
||||
a = userChoose[choose]
|
||||
combobox1.configure(state=a)
|
||||
check.configure(state=a)
|
||||
button2.configure(state=a)
|
||||
button3.configure(state=a)
|
||||
|
||||
# 需引入 subprocess
|
||||
def GetCommandReturn(cmd):
|
||||
# cmd 是要获取输出的命令
|
||||
return subprocess.getoutput(cmd)
|
||||
combobox1.setDisabled(choose)
|
||||
check.setDisabled(choose)
|
||||
button2.setDisabled(choose)
|
||||
button3.setDisabled(choose)
|
||||
|
||||
# 重启本应用程序
|
||||
def ReStartProgram():
|
||||
python = sys.executable
|
||||
os.execl(python, python, * sys.argv)
|
||||
|
||||
def GetCommandReturn(command):
|
||||
return subprocess.getoutput(command)
|
||||
|
||||
# 获取用户主目录
|
||||
def get_home():
|
||||
return os.path.expanduser('~')
|
||||
|
@ -354,9 +373,7 @@ def SaveApkIcon(apkFilePath, iconSavePath)->"获取 apk 文件的图标":
|
|||
|
||||
def TextboxAddText1(message):
|
||||
global textbox1
|
||||
textbox1.configure(state=tk.NORMAL)
|
||||
textbox1.insert(tk.END,message)
|
||||
textbox1.configure(state=tk.DISABLED)
|
||||
textbox1.append(message)
|
||||
|
||||
# 获取用户桌面目录
|
||||
def get_desktop_path():
|
||||
|
@ -388,7 +405,7 @@ if not lang in langFile.keys():
|
|||
information = json.loads(readtxt(programPath + "/information.json"))
|
||||
version = information["Version"]
|
||||
title = "{} {}".format(langFile[lang]["Uengine Apk Builder"]["Title"], version)
|
||||
iconPath = "{}/builer.png".format(os.path.split(os.path.realpath(__file__))[0])
|
||||
iconPath = "{}/builer.svg".format(os.path.split(os.path.realpath(__file__))[0])
|
||||
|
||||
###########################
|
||||
# 加载配置
|
||||
|
@ -408,6 +425,53 @@ findApkHistory = list(json.loads(readtxt(get_home() + "/.config/uengine-runner/F
|
|||
###########################
|
||||
# 窗口创建
|
||||
###########################
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
# 权重
|
||||
size = QtWidgets.QSizePolicy()
|
||||
size.setHorizontalPolicy(0)
|
||||
widgetSize = QtWidgets.QSizePolicy()
|
||||
widgetSize.setVerticalPolicy(0)
|
||||
#
|
||||
window = QtWidgets.QMainWindow()
|
||||
widget = QtWidgets.QWidget()
|
||||
widgetLayout = QtWidgets.QGridLayout()
|
||||
combobox1 = QtWidgets.QComboBox()
|
||||
label1 = QtWidgets.QLabel(langFile[lang]["Uengine Apk Builder"]["label1"])
|
||||
button2 = QtWidgets.QPushButton(langFile[lang]["Uengine Apk Builder"]["button2"])
|
||||
button3 = QtWidgets.QPushButton(langFile[lang]["Uengine Apk Builder"]["button3"])
|
||||
textbox1 = QtWidgets.QTextBrowser()
|
||||
frame2 = QtWidgets.QHBoxLayout()
|
||||
check = QtWidgets.QCheckBox(langFile[lang]["Uengine Apk Builder"]["check"])
|
||||
label1.setSizePolicy(size)
|
||||
button2.setSizePolicy(size)
|
||||
check.setSizePolicy(size)
|
||||
button3.setSizePolicy(size)
|
||||
combobox1.setEditable(True)
|
||||
combobox1.addItems(findApkHistory)
|
||||
combobox1.setEditText("")
|
||||
button2.clicked.connect(FindApk)
|
||||
button3.clicked.connect(BuildDeb)
|
||||
widgetLayout.addWidget(label1, 0, 0, 1, 1)
|
||||
widgetLayout.addWidget(combobox1, 0, 1, 1, 1)
|
||||
widgetLayout.addWidget(button2, 0, 2, 1, 1)
|
||||
widgetLayout.addLayout(frame2, 1, 0, 1, 3)
|
||||
widgetLayout.addWidget(textbox1, 2, 0, 1, 3)
|
||||
# 菜单栏
|
||||
menu = window.menuBar()
|
||||
programmenu = menu.addMenu(langFile[lang]["Uengine Apk Builder"]["Menu"][0]["Name"])
|
||||
exitProgram = QtWidgets.QAction(langFile[lang]["Uengine Apk Builder"]["Menu"][0]["Menu"][0])
|
||||
exitProgram.triggered.connect(window.close)
|
||||
programmenu.addAction(exitProgram)
|
||||
#
|
||||
frame2.addWidget(check)
|
||||
frame2.addWidget(button3)
|
||||
widget.setLayout(widgetLayout)
|
||||
window.setWindowTitle(title)
|
||||
window.setCentralWidget(widget)
|
||||
window.setWindowIcon(QtGui.QIcon(iconPath))
|
||||
window.resize(window.frameSize().width() * 1.3, window.frameSize().height() * 1.1)
|
||||
window.show()
|
||||
sys.exit(app.exec_())
|
||||
# 读取主题
|
||||
try:
|
||||
theme = not ("dark" in readtxt(get_home() + "/.gtkrc-2.0") and "gtk-theme-name=" in readtxt(get_home() + "/.gtkrc-2.0"))
|
||||
|
|
Loading…
Reference in New Issue