-
Notifications
You must be signed in to change notification settings - Fork 87
/
main.py
61 lines (46 loc) · 1.73 KB
/
main.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
# coding:utf-8
from app.view.main_window import MainWindow
from app.common.config import cfg, VERSION, BETA
import sys
import os
import asyncio
from qasync import QApplication, QEventLoop
from app.common.qfluentwidgets import FluentTranslator
from PyQt5.QtCore import Qt, QTranslator
from PyQt5.QtGui import QFont
os.chdir(os.path.dirname(os.path.abspath(__file__)))
def main():
args = sys.argv
if len(args) == 2 and args[1] in ['--version', '-v']:
print(BETA or VERSION)
return
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)
font = QFont()
font.setStyleStrategy(QFont.PreferAntialias)
font.setHintingPreference(QFont.PreferFullHinting)
QApplication.setFont(font)
app = QApplication(sys.argv)
app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)
eventLoop = QEventLoop(app)
asyncio.set_event_loop(eventLoop)
appCloseEvent = asyncio.Event()
app.aboutToQuit.connect(appCloseEvent.set)
locale = cfg.get(cfg.language).value
fluentTranslator = FluentTranslator(locale)
seraphineTranslator = QTranslator()
seraphineTranslator.load(locale, "Seraphine", ".", "./app/resource/i18n")
app.installTranslator(fluentTranslator)
app.installTranslator(seraphineTranslator)
w = MainWindow()
w.show()
eventLoop.run_until_complete(appCloseEvent.wait())
eventLoop.close()
if __name__ == '__main__':
main()