现代化按钮组件 - 替代CursorProButton
| 15 | |
| 16 | |
| 17 | class ModernButton(QPushButton): |
| 18 | """现代化按钮组件 - 替代CursorProButton""" |
| 19 | |
| 20 | def __init__(self, text: str, button_type: str = "primary", parent=None): |
| 21 | super().__init__(text, parent) |
| 22 | self.button_type = button_type |
| 23 | self._setup_button() |
| 24 | |
| 25 | def _setup_button(self): |
| 26 | """设置按钮样式""" |
| 27 | self.setFont(get_button_font()) |
| 28 | self.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) |
| 29 | |
| 30 | # 设置CSS类名用于样式表 |
| 31 | if self.button_type == "secondary": |
| 32 | self.setProperty("class", "secondary") |
| 33 | elif self.button_type == "warning": |
| 34 | self.setProperty("class", "warning") |
| 35 | elif self.button_type == "success": |
| 36 | self.setProperty("class", "success") |
| 37 | |
| 38 | # 设置最小尺寸 |
| 39 | self.setMinimumHeight(45) |
| 40 | |
| 41 | def set_enabled_state(self, enabled: bool): |
| 42 | """设置按钮启用状态""" |
| 43 | self.setEnabled(enabled) |
| 44 | if enabled: |
| 45 | self.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) |
| 46 | else: |
| 47 | self.setCursor(QCursor(Qt.CursorShape.ForbiddenCursor)) |
| 48 | |
| 49 | |
| 50 | class TitleLabel(QLabel): |
no outgoing calls
no test coverage detected