-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgui.py
66 lines (49 loc) · 1.66 KB
/
gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
Author: Night-stars-1 nujj1042633805@gmail.com
Date: 2024-04-02 18:52:36
LastEditTime: 2024-12-28 00:09:42
LastEditors: Night-stars-1 nujj1042633805@gmail.com
"""
import atexit
import os
import sys
from PyQt5.QtCore import QLocale, Qt, QTranslator
from PyQt5.QtWidgets import QApplication
from qfluentwidgets import FluentTranslator
from app.common.config import cfg
cfg.save() # 生成配置文件
from app.view.main_window import MainWindow
from core.adb.adb import kill
def close_service():
"""界面退出关闭服务"""
kill()
def exception_hook(exctype, value, traceback):
sys.__excepthook__(exctype, value, traceback)
sys.exit(1) # 强制程序退出
sys.excepthook = exception_hook # 设置全局异常钩子
atexit.register(close_service) # 注册退出时的清理函数
# enable dpi scale
if cfg.get(cfg.dpiScale) == "Auto":
QApplication.setHighDpiScaleFactorRoundingPolicy(
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough
)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
else:
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"
os.environ["QT_SCALE_FACTOR"] = str(cfg.get(cfg.dpiScale))
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
# create application
app = QApplication(sys.argv)
app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)
# internationalization
locale = QLocale(QLocale.Chinese, QLocale.China)
translator = FluentTranslator(locale)
galleryTranslator = QTranslator()
galleryTranslator.load(locale, "gallery", ".", "app/resource/i18n")
app.installTranslator(translator)
app.installTranslator(galleryTranslator)
# create main window
w = MainWindow()
from main import run, stop
w.show()
app.exec_()