Spaces:
Running
Running
| from PySide6.QtCore import QPropertyAnimation, QEasingCurve, QParallelAnimationGroup, QAbstractAnimation | |
| from PySide6.QtWidgets import QWidget | |
| from typing import Optional | |
| class AnimationManager: | |
| def fade_in(widget: QWidget, duration: int = 300): | |
| animation = QPropertyAnimation(widget, b"windowOpacity") | |
| animation.setDuration(duration) | |
| animation.setStartValue(0) | |
| animation.setEndValue(1) | |
| animation.setEasingCurve(QEasingCurve.OutCubic) | |
| animation.start() | |
| return animation | |
| def slide_up(widget: QWidget, distance: int = 50, duration: int = 400): | |
| animation = QPropertyAnimation(widget, b"pos") | |
| animation.setDuration(duration) | |
| start_pos = widget.pos() | |
| animation.setStartValue(start_pos + QPoint(0, distance)) | |
| animation.setEndValue(start_pos) | |
| animation.setEasingCurve(QEasingCurve.OutExpo) | |
| animation.start() | |
| return animation | |
| def pulse_widget(widget: QWidget, duration: int = 200): | |
| anim = QPropertyAnimation(widget, b"geometry") | |
| anim.setDuration(duration) | |
| geom = widget.geometry() | |
| center = geom.center() | |
| anim.setStartValue(geom) | |
| anim.setEndValue(geom.adjusted(-2, -2, 2, 2)) | |
| anim.setEasingCurve(QEasingCurve.InOutQuad) | |
| anim.start() | |
| return anim | |
| from PySide6.QtCore import QPoint |