MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / fade

Function fade

lib/macro/macro-edit.cpp:598–629  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

596}
597
598static void fade(QWidget *widget, bool fadeOut)
599{
600 const double fadeOutOpacity = 0.3;
601 // Don't use exactly 1.0 as for some reason this causes buttons in
602 // macroSplitter handle layout to not be redrawn unless mousing over
603 // them
604 const double fadeInOpacity = 0.99;
605 auto curEffect = widget->graphicsEffect();
606 if (curEffect) {
607 auto curOpacity =
608 dynamic_cast<QGraphicsOpacityEffect *>(curEffect);
609 if (curOpacity &&
610 ((fadeOut && DoubleEquals(curOpacity->opacity(),
611 fadeOutOpacity, 0.0001)) ||
612 (!fadeOut && DoubleEquals(curOpacity->opacity(),
613 fadeInOpacity, 0.0001)))) {
614 return;
615 }
616 } else if (!fadeOut) {
617 return;
618 }
619 delete curEffect;
620 QGraphicsOpacityEffect *opacityEffect = new QGraphicsOpacityEffect();
621 widget->setGraphicsEffect(opacityEffect);
622 QPropertyAnimation *animation =
623 new QPropertyAnimation(opacityEffect, "opacity");
624 animation->setDuration(350);
625 animation->setStartValue(fadeOut ? fadeInOpacity : fadeOutOpacity);
626 animation->setEndValue(fadeOut ? fadeOutOpacity : fadeInOpacity);
627 animation->setEasingCurve(QEasingCurve::OutQuint);
628 animation->start(QPropertyAnimation::DeleteWhenStopped);
629}
630
631static void fadeWidgets(const std::vector<QWidget *> &widgets, bool fadeOut)
632{

Callers 1

fadeWidgetsFunction · 0.85

Calls 2

DoubleEqualsFunction · 0.85
startMethod · 0.45

Tested by

no test coverage detected