Skip to content

Commit 437d1d1

Browse files
committed
修改pingThread内nam不设置父类自动管理析构,防止出现子类和父类不在同一线程的问题,修改版本列表始终显示滚动条,使得不用管理宽度。,给RleaseFrame非选中状态增加1px透明的边框,使得选中后的大小不再发生变化
1 parent 88781da commit 437d1d1

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

src/CheckUpdateGui.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
class AnimationButton(QPushButton):
1111
def __init__(self, parent=None):
12+
"""
13+
:param parent: QWidget
14+
AnimationButton的构造函数
15+
."""
1216
super().__init__(parent)
1317
self.pixmap: QPixmap = None
1418
self.clicked.connect(self.animationStart)
@@ -39,6 +43,11 @@ def paintEvent(self, event):
3943
self.setMask(self.pixmap.scaled(size, size).mask())
4044

4145
def animationStart(self, check):
46+
"""
47+
:param check: bool
48+
点击按钮时,开始动画。
49+
check为True时,从0度到90度,否则从90度到0度,持续时间300ms。
50+
"""
4251
if check:
4352
self.animation.setStartValue(0)
4453
self.animation.setEndValue(90)
@@ -136,6 +145,16 @@ def initConnect(self):
136145
self.downloadButton.clicked.connect(self.downLoadButtonClicked)
137146

138147
def showButtonClicked(self, checked: bool):
148+
"""
149+
切换显示和隐藏的按钮点击事件处理函数。
150+
151+
根据参数checked的值,切换formWidget的可见性,并执行相应的展开或折叠动画。
152+
当checked为True时,展开formWidget并设置按钮提示为"fold",
153+
否则折叠formWidget并设置按钮提示为"unfold"。
154+
155+
Args:
156+
checked (bool): 指示按钮是否被选中的布尔值。
157+
"""
139158
self.formWidget.setVisible(True)
140159
animation = QPropertyAnimation(self.formWidget, b"size", self)
141160
easingCurveType = QEasingCurve.Type.OutBack if checked else QEasingCurve.Type.InBack
@@ -163,7 +182,7 @@ def showButtonClicked(self, checked: bool):
163182
animation2.start(QPropertyAnimation.DeletionPolicy.DeleteWhenStopped)
164183
animation.start(QPropertyAnimation.DeletionPolicy.DeleteWhenStopped)
165184
animation.finished.connect(lambda: self.formWidget.setVisible(checked))
166-
animation.finished.connect(lambda: self.resWidth())
185+
# animation.finished.connect(lambda: self.resWidth())
167186

168187
def downLoadButtonClicked(self):
169188
self.downLoadFile.emit(self.release)
@@ -199,7 +218,9 @@ def __setStyleSheet(self, isEnter: bool):
199218
else:
200219
# label字体微软雅黑Ui,大小13,圆角 8
201220
self.setStyleSheet(
202-
f"QFrame{{background-color:{rgbStr}; font-family:Microsoft YaHei UI; font-size:14px; border-radius: 5px;}}")
221+
f"""QFrame{{background-color:{rgbStr}; font-family:Microsoft YaHei UI; font-size:14px; border-radius: 5px;}}
222+
ReleaseFrame{{border: 1px solid transparent;}}
223+
""")
203224

204225
def enterEvent(self, a0: QEnterEvent) -> None:
205226
self.__setStyleSheet(True)
@@ -228,6 +249,9 @@ def __init__(self, github: GitHub, parent=None):
228249
self.releaseArea.setHorizontalScrollBarPolicy(
229250
Qt.ScrollBarPolicy.ScrollBarAlwaysOff
230251
)
252+
self.releaseArea.setVerticalScrollBarPolicy(
253+
Qt.ScrollBarPolicy.ScrollBarAlwaysOn
254+
)
231255
self.pingThread = None
232256
self.sourceSpeedLabel = QLabel()
233257
self.sourceCombo = QComboBox()

src/githubApi.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ def ping(self) -> float:
2727
timer = QElapsedTimer()
2828
timer.start()
2929
try:
30-
nam = QNetworkAccessManager(self)
30+
nam = QNetworkAccessManager()
3131
request = QNetworkRequest(QUrl(self.url))
3232

3333
reply = nam.get(request)
3434
loop = QEventLoop()
3535
reply.finished.connect(loop.quit)
3636
loop.exec_()
37-
3837
except Exception:
3938
return float('inf')
4039
time = timer.elapsed()

0 commit comments

Comments
 (0)