|
9 | 9 |
|
10 | 10 | class AnimationButton(QPushButton): |
11 | 11 | def __init__(self, parent=None): |
| 12 | + """ |
| 13 | + :param parent: QWidget |
| 14 | + AnimationButton的构造函数 |
| 15 | + .""" |
12 | 16 | super().__init__(parent) |
13 | 17 | self.pixmap: QPixmap = None |
14 | 18 | self.clicked.connect(self.animationStart) |
@@ -39,6 +43,11 @@ def paintEvent(self, event): |
39 | 43 | self.setMask(self.pixmap.scaled(size, size).mask()) |
40 | 44 |
|
41 | 45 | def animationStart(self, check): |
| 46 | + """ |
| 47 | + :param check: bool |
| 48 | + 点击按钮时,开始动画。 |
| 49 | + check为True时,从0度到90度,否则从90度到0度,持续时间300ms。 |
| 50 | + """ |
42 | 51 | if check: |
43 | 52 | self.animation.setStartValue(0) |
44 | 53 | self.animation.setEndValue(90) |
@@ -136,6 +145,16 @@ def initConnect(self): |
136 | 145 | self.downloadButton.clicked.connect(self.downLoadButtonClicked) |
137 | 146 |
|
138 | 147 | 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 | + """ |
139 | 158 | self.formWidget.setVisible(True) |
140 | 159 | animation = QPropertyAnimation(self.formWidget, b"size", self) |
141 | 160 | easingCurveType = QEasingCurve.Type.OutBack if checked else QEasingCurve.Type.InBack |
@@ -163,7 +182,7 @@ def showButtonClicked(self, checked: bool): |
163 | 182 | animation2.start(QPropertyAnimation.DeletionPolicy.DeleteWhenStopped) |
164 | 183 | animation.start(QPropertyAnimation.DeletionPolicy.DeleteWhenStopped) |
165 | 184 | animation.finished.connect(lambda: self.formWidget.setVisible(checked)) |
166 | | - animation.finished.connect(lambda: self.resWidth()) |
| 185 | + # animation.finished.connect(lambda: self.resWidth()) |
167 | 186 |
|
168 | 187 | def downLoadButtonClicked(self): |
169 | 188 | self.downLoadFile.emit(self.release) |
@@ -199,7 +218,9 @@ def __setStyleSheet(self, isEnter: bool): |
199 | 218 | else: |
200 | 219 | # label字体微软雅黑Ui,大小13,圆角 8 |
201 | 220 | 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 | + """) |
203 | 224 |
|
204 | 225 | def enterEvent(self, a0: QEnterEvent) -> None: |
205 | 226 | self.__setStyleSheet(True) |
@@ -228,6 +249,9 @@ def __init__(self, github: GitHub, parent=None): |
228 | 249 | self.releaseArea.setHorizontalScrollBarPolicy( |
229 | 250 | Qt.ScrollBarPolicy.ScrollBarAlwaysOff |
230 | 251 | ) |
| 252 | + self.releaseArea.setVerticalScrollBarPolicy( |
| 253 | + Qt.ScrollBarPolicy.ScrollBarAlwaysOn |
| 254 | + ) |
231 | 255 | self.pingThread = None |
232 | 256 | self.sourceSpeedLabel = QLabel() |
233 | 257 | self.sourceCombo = QComboBox() |
|
0 commit comments