Stacked widget with erase animation
| 46 | |
| 47 | |
| 48 | class EraseStackedWidget(QStackedWidget): |
| 49 | """Stacked widget with erase animation""" |
| 50 | |
| 51 | aniFinished = pyqtSignal() |
| 52 | aniStart = pyqtSignal() |
| 53 | |
| 54 | def __init__(self, parent=None): |
| 55 | super().__init__(parent) |
| 56 | self.aniInfos = [] # type: List[EraseAniInfo] |
| 57 | self._nextIndex = None |
| 58 | self._ani = None |
| 59 | |
| 60 | def addWidget(self, widget, deltaX=180, deltaY=0): |
| 61 | """add widget to window |
| 62 | |
| 63 | Parameters |
| 64 | ----------- |
| 65 | widget: |
| 66 | widget to be added |
| 67 | |
| 68 | deltaX: int |
| 69 | the x-axis offset from the beginning to the end of animation |
| 70 | |
| 71 | deltaY: int |
| 72 | the y-axis offset from the beginning to the end of animation |
| 73 | """ |
| 74 | super().addWidget(widget) |
| 75 | |
| 76 | self.aniInfos.append( |
| 77 | EraseAniInfo( |
| 78 | widget=widget, |
| 79 | deltaX=deltaX, |
| 80 | deltaY=deltaY, |
| 81 | ani=QPropertyAnimation(widget, b"pos"), |
| 82 | ) |
| 83 | ) |
| 84 | |
| 85 | def setCurrentIndex( |
| 86 | self, |
| 87 | index: int, |
| 88 | needPopOut: bool = False, |
| 89 | showNextWidgetDirectly: bool = True, |
| 90 | duration: int = 220, |
| 91 | easingCurve=QEasingCurve.BezierSpline, |
| 92 | ): |
| 93 | """set current window to display |
| 94 | |
| 95 | Parameters |
| 96 | ---------- |
| 97 | index: int |
| 98 | the index of widget to display |
| 99 | |
| 100 | isNeedPopOut: bool |
| 101 | need pop up animation or not |
| 102 | |
| 103 | showNextWidgetDirectly: bool |
| 104 | whether to show next widget directly when animation started |
| 105 |
no outgoing calls
no test coverage detected