1- from PyQt5 .QtWidgets import QWidget , QDialog , QScrollArea , QLabel , QVBoxLayout , QHBoxLayout , QSpacerItem , \
2- QSizePolicy , QPushButton , QFrame , QMessageBox , QFormLayout , QProgressDialog , QTextEdit , QComboBox
3- from githubApi import GitHub , Release , PingThread
41from PyQt5 .QtCore import QObject , pyqtSlot , Qt , pyqtSignal , QUrl , QPropertyAnimation , \
52 QSize , QVariantAnimation , QDateTime , QEvent , QEasingCurve
63from PyQt5 .QtGui import QDesktopServices , QFont , QMouseEvent , QPainter , QPixmap , QEnterEvent
4+ from PyQt5 .QtWidgets import QWidget , QDialog , QScrollArea , QLabel , QVBoxLayout , QHBoxLayout , QSpacerItem , \
5+ QSizePolicy , QPushButton , QFrame , QMessageBox , QFormLayout , QProgressDialog , QTextEdit , QComboBox
6+
7+ from githubApi import GitHub , ReleaseInfo , PingThread
78
89
910class AnimationButton (QPushButton ):
@@ -22,6 +23,7 @@ def rotate(self):
2223 def setRotate (self , rotate ):
2324 self .__rotate = rotate
2425 self .update ()
26+
2527 # rotate = property(int,rotate, setRotate)
2628
2729 def paintEvent (self , event ):
@@ -48,11 +50,11 @@ def animationStart(self, check):
4850
4951
5052class ReleaseFrame (QFrame ):
51- downLoadFile = pyqtSignal (Release )
53+ downLoadFile = pyqtSignal (ReleaseInfo )
5254
53- def __init__ (self , release : Release , mode = ">" , parent = None , r_path = "" ):
55+ def __init__ (self , release : ReleaseInfo , mode = ">" , parent = None , r_path = "" ):
5456 super ().__init__ (parent )
55- self .release : Release = release
57+ self .release : ReleaseInfo = release
5658 self .showButton = AnimationButton ()
5759 self .showButton .setToolTip (self .tr ("unfold" ))
5860 self .showButton .setCheckable (True )
@@ -104,7 +106,8 @@ def initUi(self):
104106 formLayout .addRow (QObject .tr (self , "download_count" ),
105107 QLabel (str (self .release .assets_download_count )))
106108 formLayout .addRow (QObject .tr (self , "created_at" ),
107- QLabel (QDateTime .fromString (self .release .assets_created_at , "yyyy-MM-ddThh:mm:ssZ" ).toString ("yyyy-MM-dd hh:mm:ss" )))
109+ QLabel (QDateTime .fromString (self .release .assets_created_at , "yyyy-MM-ddThh:mm:ssZ" ).toString (
110+ "yyyy-MM-dd hh:mm:ss" )))
108111 downloadUrlLabel = QLabel ()
109112 downloadUrlLabel .setText ("<a href='" + self .release .assets_browser_download_url +
110113 "'>" + QObject .tr (self , "open download links" ) + "</a>" )
@@ -126,19 +129,7 @@ def initUi(self):
126129 layout .addWidget (self .titleWidget )
127130 layout .addWidget (self .formWidget )
128131 self .setLayout (layout )
129- rgbStr = ""
130- if self .mode == ">" :
131- # 样式表绿色
132- rgbStr = "rgb(200,255,250)"
133- elif self .mode == "=" :
134- # 样式表蓝色
135- rgbStr = "rgb(200,216,230)"
136- else :
137- # 样式表红色背景
138- rgbStr = "rgb(249, 179, 163)"
139- # label字体微软雅黑Ui,大小13,圆角 8
140- self .setStyleSheet (
141- f"QFrame{{background-color:{ rgbStr } ; font-family:Microsoft YaHei UI; font-size:14px; border-radius: 5px;}}" )
132+ self .__setStyleSheet (False )
142133
143134 def initConnect (self ):
144135 self .showButton .clicked .connect (self .showButtonClicked )
@@ -153,10 +144,6 @@ def showButtonClicked(self, checked: bool):
153144 animation2 .setEasingCurve (easingCurveType )
154145 animation .setDuration (300 )
155146 animation2 .setDuration (300 )
156- start : QSize = None
157- end : QSize = None
158- start1 : QSize = None
159- end1 : QSize = None
160147 if checked :
161148 self .showButton .setToolTip (QObject .tr (self , "fold" ))
162149 start = QSize (self .width (), 0 )
@@ -193,7 +180,6 @@ def mousePressEvent(self, a0: QMouseEvent) -> None:
193180 self .showButton .click ()
194181
195182 def __setStyleSheet (self , isEnter : bool ):
196- rgbStr = ""
197183 if self .mode == ">" :
198184 # 样式表绿色
199185 rgbStr = "rgb(200,255,250)"
@@ -230,7 +216,7 @@ def __init__(self, github: GitHub, parent=None):
230216 self .setWindowTitle (QObject .tr (self , "CheckUpdate" ))
231217 # 去掉问号
232218 self .setWindowFlags (self .windowFlags () & ~
233- Qt .WindowContextHelpButtonHint )
219+ Qt .WindowContextHelpButtonHint )
234220 self .r_path = parent .r_path
235221 self .github : GitHub = github
236222 self .github .setParent (self )
@@ -308,7 +294,7 @@ def changeSource(self, source: str):
308294 self .checkUpdateButton .click ()
309295
310296 @pyqtSlot (list )
311- def checkUpdate (self , releases : list [Release ]):
297+ def checkUpdate (self , releases : list [ReleaseInfo ]):
312298 widget = self .releaseArea .widget ()
313299 if widget is not None :
314300 widget .deleteLater ()
@@ -338,7 +324,7 @@ def showError(self, msg: str):
338324 widget .deleteLater ()
339325 QMessageBox .critical (self , QObject .tr (self , "Error" ), msg )
340326
341- def showDownloadDialog (self , release : Release ):
327+ def showDownloadDialog (self , release : ReleaseInfo ):
342328 if self .processDialog is not None :
343329 self .processDialog .close ()
344330 self .processDialog = QProgressDialog (self )
@@ -354,7 +340,7 @@ def updateDownloadDialog(self, a: int, b: int):
354340 self .processDialog .setValue (a )
355341 self .processDialog .setMaximum (b )
356342 self .processDialog .setLabelText (
357- f'{ a / 1000000 : .2f} /{ b / 1000000 : .2f} MB' )
343+ f'{ a / 1000000 : .2f} /{ b / 1000000 : .2f} MB' )
358344
359345 def hideDownloadDialog (self , path : str ):
360346 if self .processDialog is not None :
0 commit comments