8
8
# from asyncqt import QEventLoop
9
9
from PyQt5 .QtCore import Qt , pyqtSlot
10
10
from PyQt5 .QtGui import QIcon
11
- from PyQt5 .QtWidgets import QAction , QListWidgetItem
11
+ from PyQt5 .QtWidgets import QAction , QListWidgetItem , QStyleFactory
12
12
from PyQt5 .QtWidgets import QSystemTrayIcon , QApplication , QMenu , qApp
13
13
14
14
from FileUtils import WatchFiles
25
25
APP_PATH = os .path .dirname (sys .executable )
26
26
elif __file__ :
27
27
APP_PATH = os .path .dirname (__file__ )
28
- # print(APP_PATH)
29
28
30
29
31
30
def resource_path (relative_path ):
@@ -38,10 +37,18 @@ def resource_path(relative_path):
38
37
39
38
40
39
CONFIGS = {}
41
- if os .path .isfile (APP_PATH + "\\ config.json" ):
42
- with open (APP_PATH + "\\ config.json" ) as config_file :
43
- CONFIGS = json .load (config_file )
44
-
40
+ if not APP_PATH :
41
+ if os .path .isfile ("config.json" ):
42
+ with open ("config.json" ) as config_file :
43
+ CONFIGS = json .load (config_file )
44
+ else :
45
+ print ("File does not exist!\n %s" % APP_PATH + "\\ config.json" )
46
+ else :
47
+ if os .path .isfile (APP_PATH + "\\ config.json" ):
48
+ with open (APP_PATH + "\\ config.json" ) as config_file :
49
+ CONFIGS = json .load (config_file )
50
+ else :
51
+ print ("File does not exist!\n %s" % APP_PATH + "\\ config.json" )
45
52
46
53
@pyqtSlot ("QWidget*" , "QWidget*" )
47
54
def on_focus_out (old , now ):
@@ -98,10 +105,17 @@ def swap_icon():
98
105
task .status_synced ()
99
106
100
107
108
+ # Enable High DPI display with PyQt5
109
+ QApplication .setAttribute (Qt .AA_EnableHighDpiScaling )
110
+
101
111
app = QApplication (sys .argv )
112
+ app .setStyle ("fusion" )
102
113
app .setQuitOnLastWindowClosed (False )
103
114
qApp .focusChanged .connect (on_focus_out )
104
115
116
+ if hasattr (QStyleFactory , 'AA_UseHighDpiPixmaps' ):
117
+ app .setAttribute (Qt .AA_UseHighDpiPixmaps )
118
+
105
119
menu_login = QAction ('Login' )
106
120
menu_login .triggered .connect (lambda : logout () if session .logged_status else Login (session ).exec_ ())
107
121
session = LoginSession ()
0 commit comments