#include "AnimationUtils.h" #include #include #include namespace AnimationUtils { void fadeIn(QWidget* widget, int durationMs) { if (!widget) { return; } widget->setGraphicsEffect(nullptr); auto* effect = new QGraphicsOpacityEffect(widget); effect->setOpacity(0.0); widget->setGraphicsEffect(effect); auto* animation = new QPropertyAnimation(effect, "opacity", widget); animation->setDuration(durationMs); animation->setStartValue(0.0); animation->setEndValue(1.0); animation->setEasingCurve(QEasingCurve::OutCubic); QObject::connect(animation, &QPropertyAnimation::finished, widget, [widget, animation]() { widget->setGraphicsEffect(nullptr); animation->deleteLater(); }); animation->start(); } void fadeWindow(QWidget* window, int durationMs) { if (!window) { return; } auto* animation = new QPropertyAnimation(window, "windowOpacity", window); animation->setDuration(durationMs); animation->setStartValue(0.0); animation->setEndValue(1.0); animation->setEasingCurve(QEasingCurve::OutCubic); QObject::connect(animation, &QPropertyAnimation::finished, animation, &QPropertyAnimation::deleteLater); window->setWindowOpacity(0.0); animation->start(); } } // namespace AnimationUtils