5
5
# @Author : DebuggerX
6
6
7
7
import configparser
8
+ import os
9
+ import sys
8
10
from urllib import request
9
11
from json import loads
10
12
19
21
check_last_version_thread = None
20
22
21
23
24
+ def get_exe_path ():
25
+ if getattr (sys , 'frozen' , False ):
26
+ return os .path .dirname (sys .executable )
27
+ else :
28
+ return os .path .dirname (__file__ )
29
+
30
+
22
31
def _check_ignore_version ():
23
32
config = configparser .ConfigParser ()
24
33
global ignore_code
25
34
# noinspection PyBroadException
26
35
try :
27
- config .read ('.ignore.cfg' )
36
+ config .read (os . path . join ( get_exe_path (), '.ignore.cfg' ) )
28
37
ignore_code = float (config .get ('version' , 'code' ))
29
38
except Exception :
30
39
pass
@@ -48,16 +57,22 @@ def run(self):
48
57
49
58
50
59
def check_last_version_handler (json_obj ):
51
- res = QMessageBox ().information (msg_box_ui , "有新版本更新!" , "新版本(v%s)更新内容:\n %s\n \n 点击[确定]转跳到下载页,点击[取消]忽略该版本提醒" % (json_obj ['code' ], json_obj ['desc' ]),
52
- QMessageBox .Ok ,
53
- QMessageBox .Cancel )
54
- if res == QMessageBox .Cancel :
60
+ msg_box = QMessageBox ()
61
+ msg_box .addButton ('确定' , QMessageBox .AcceptRole )
62
+ msg_box .addButton ('忽略' , QMessageBox .NoRole )
63
+ msg_box .addButton ('关闭' , QMessageBox .RejectRole )
64
+ msg_box .setParent (msg_box_ui )
65
+ msg_box .setWindowTitle ("有新版本更新!" )
66
+ msg_box .setText ("新版本(v%s)更新内容:\n %s\n \n 点击[确定]转跳到下载页,点击[忽略]忽略该版本提醒,点击[关闭]退出本提示框" % (json_obj ['code' ], json_obj ['desc' ]))
67
+
68
+ res = msg_box .exec ()
69
+ if res == QMessageBox .RejectRole :
55
70
config = configparser .ConfigParser ()
56
71
config .add_section ('version' )
57
72
config .set ('version' , 'code' , str (json_obj ['code' ]))
58
- with open ('.ignore.cfg' , 'w' ) as configfile :
73
+ with open (os . path . join ( get_exe_path (), '.ignore.cfg' ) , 'w' ) as configfile :
59
74
config .write (configfile )
60
- else :
75
+ elif res == QMessageBox . AcceptRole :
61
76
QtGui .QDesktopServices .openUrl (QtCore .QUrl ('https://github.com/debuggerx01/JSONFormat4Flutter/releases' ))
62
77
63
78
0 commit comments