Refacto en sous fichiers pour la maintenabilité
This commit is contained in:
32
src/controllers/glow_animator.py
Normal file
32
src/controllers/glow_animator.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from PySide6.QtCore import QPropertyAnimation, QEasingCurve
|
||||
from PySide6.QtWidgets import QGraphicsDropShadowEffect
|
||||
|
||||
from src.constants import GLOW_COLOR, GLOW_BLUR_BASE, GLOW_BLUR_PEAK, GLOW_ANIM_DURATION
|
||||
|
||||
|
||||
class GlowAnimator:
|
||||
# Gère l'effet de lueur pulsée sur un widget.
|
||||
|
||||
def __init__(self, widget):
|
||||
self._widget = widget
|
||||
|
||||
self._effect = QGraphicsDropShadowEffect(widget)
|
||||
self._effect.setBlurRadius(GLOW_BLUR_BASE)
|
||||
self._effect.setOffset(0, 0)
|
||||
self._effect.setColor(GLOW_COLOR)
|
||||
|
||||
self._anim = QPropertyAnimation(self._effect, b"blurRadius")
|
||||
self._anim.setDuration(GLOW_ANIM_DURATION)
|
||||
self._anim.setStartValue(GLOW_BLUR_BASE)
|
||||
self._anim.setKeyValueAt(0.5, GLOW_BLUR_PEAK)
|
||||
self._anim.setEndValue(GLOW_BLUR_BASE)
|
||||
self._anim.setEasingCurve(QEasingCurve.InOutQuad)
|
||||
self._anim.setLoopCount(-1)
|
||||
|
||||
def start(self) -> None:
|
||||
self._widget.setGraphicsEffect(self._effect)
|
||||
self._anim.start()
|
||||
|
||||
def stop(self) -> None:
|
||||
self._anim.stop()
|
||||
self._widget.setGraphicsEffect(None)
|
||||
Reference in New Issue
Block a user