(self, _)
| 41 | self.clicked.connect(self._onClick) |
| 42 | |
| 43 | def paintEvent(self, _): |
| 44 | option = QStyleOptionButton() |
| 45 | self.initStyleOption(option) |
| 46 | painter = QStylePainter(self) |
| 47 | if self._rotateAnimationStarted: |
| 48 | option.text = "" |
| 49 | painter.drawControl(QStyle.CE_PushButton, option) |
| 50 | if not self._rotateAnimationStarted: |
| 51 | return |
| 52 | painter.save() |
| 53 | font = self.font() |
| 54 | font.setPointSize(self.fontSize) |
| 55 | font.setFamily("FontAwesome") |
| 56 | painter.setFont(font) |
| 57 | # 变换坐标为正中间 |
| 58 | painter.translate(self.rect().center()) |
| 59 | # 旋转90度 |
| 60 | painter.rotate(self._rotateAnimation.currentValue() * 30) |
| 61 | fm = self.fontMetrics() |
| 62 | # 在变换坐标后的正中间画文字 |
| 63 | w = fm.width(self.LoadingText) |
| 64 | h = fm.height() |
| 65 | painter.drawText( |
| 66 | QRectF(0 - w * 2, 0 - h, w * 2 * 2, h * 2), Qt.AlignCenter, |
| 67 | self.LoadingText) |
| 68 | painter.restore() |
| 69 | |
| 70 | def _onClick(self): |
| 71 | if self._rotateAnimationStarted: |
nothing calls this directly
no test coverage detected