4
4
from AutoSplit import AutoSplit
5
5
6
6
import os
7
- from PyQt6 import QtWidgets
8
7
9
- import requests
10
8
from packaging import version
9
+ from PyQt6 import QtWidgets
10
+ from PyQt6 .QtCore import QThread
11
+ from requests .exceptions import RequestException
12
+ from simplejson .errors import JSONDecodeError
13
+ import requests
11
14
12
15
import about
13
16
import design
17
20
import update_checker
18
21
19
22
# AutoSplit Version number
20
- VERSION = "1.5.0 "
23
+ VERSION = "1.6.1 "
21
24
22
25
23
26
# About Window
24
- class AboutWidget (QtWidgets .QWidget , about .Ui_aboutAutoSplitWidget ):
27
+ class __AboutWidget (QtWidgets .QWidget , about .Ui_aboutAutoSplitWidget ):
25
28
def __init__ (self ):
26
29
super ().__init__ ()
27
30
self .setupUi (self )
@@ -31,7 +34,11 @@ def __init__(self):
31
34
self .show ()
32
35
33
36
34
- class UpdateCheckerWidget (QtWidgets .QWidget , update_checker .Ui_UpdateChecker ):
37
+ def about (self : AutoSplit ):
38
+ self .AboutWidget = __AboutWidget ()
39
+
40
+
41
+ class __UpdateCheckerWidget (QtWidgets .QWidget , update_checker .Ui_UpdateChecker ):
35
42
def __init__ (self , latest_version : str , design_window : design .Ui_MainWindow , check_on_open : bool = False ):
36
43
super ().__init__ ()
37
44
self .setupUi (self )
@@ -61,19 +68,30 @@ def doNotAskMeAgainStateChanged(self):
61
68
self .checkBoxDoNotAskMeAgain .isChecked ())
62
69
63
70
71
+ def open_update_checker (autosplit : AutoSplit , latest_version : str , check_on_open : bool ):
72
+ autosplit .UpdateCheckerWidget = __UpdateCheckerWidget (latest_version , autosplit , check_on_open )
73
+
74
+
64
75
def viewHelp ():
65
76
os .system ("start \" \" https://github.com/Toufool/Auto-Split#tutorial" )
66
77
67
78
68
- def about (self : AutoSplit ):
69
- self .AboutWidget = AboutWidget ()
79
+ class __CheckForUpdatesThread (QThread ):
80
+ def __init__ (self , autosplit : AutoSplit , check_on_open : bool ):
81
+ super ().__init__ ()
82
+ self .autosplit = autosplit
83
+ self .check_on_open = check_on_open
84
+
85
+ def run (self ):
86
+ try :
87
+ response = requests .get ("https://api.github.com/repos/Toufool/Auto-Split/releases/latest" )
88
+ latest_version = response .json ()["name" ].split ("v" )[1 ]
89
+ self .autosplit .updateCheckerWidgetSignal .emit (latest_version , self .check_on_open )
90
+ except (RequestException , KeyError , JSONDecodeError ):
91
+ if not self .check_on_open :
92
+ error_messages .checkForUpdatesError ()
70
93
71
94
72
95
def checkForUpdates (autosplit : AutoSplit , check_on_open : bool = False ):
73
- try :
74
- response = requests .get ("https://api.github.com/repos/Toufool/Auto-Split/releases/latest" )
75
- latest_version = response .json ()["name" ].split ("v" )[1 ]
76
- autosplit .UpdateCheckerWidget = UpdateCheckerWidget (latest_version , autosplit , check_on_open )
77
- except :
78
- if not check_on_open :
79
- error_messages .checkForUpdatesError ()
96
+ autosplit .CheckForUpdatesThread = __CheckForUpdatesThread (autosplit , check_on_open )
97
+ autosplit .CheckForUpdatesThread .start ()
0 commit comments