| 92 | } |
| 93 | |
| 94 | void SwitchButton::ExecAnimation(bool selected) { |
| 95 | if (selected) { |
| 96 | // left => right |
| 97 | auto anim = new QPropertyAnimation(); |
| 98 | anim->setStartValue(left_point_); |
| 99 | anim->setEndValue(right_point_); |
| 100 | connect(anim, &QPropertyAnimation::valueChanged, this, [=, this](const QVariant &value) { |
| 101 | thumb_point_ = value.toInt(); |
| 102 | update(); |
| 103 | }); |
| 104 | connect(anim, &QPropertyAnimation::finished, this, [=]() { |
| 105 | anim->deleteLater(); |
| 106 | }); |
| 107 | anim->setEasingCurve(QEasingCurve::OutCubic); |
| 108 | anim->setDuration(300); |
| 109 | anim->start(); |
| 110 | } else { |
| 111 | // right => left |
| 112 | auto anim = new QPropertyAnimation(); |
| 113 | anim->setStartValue(right_point_); |
| 114 | anim->setEndValue(left_point_); |
| 115 | connect(anim, &QPropertyAnimation::valueChanged, this, [=, this](const QVariant &value) { |
| 116 | thumb_point_ = value.toInt(); |
| 117 | update(); |
| 118 | }); |
| 119 | connect(anim, &QPropertyAnimation::finished, this, [=]() { |
| 120 | anim->deleteLater(); |
| 121 | }); |
| 122 | anim->setEasingCurve(QEasingCurve::OutCubic); |
| 123 | anim->setDuration(300); |
| 124 | anim->start(); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | } |
nothing calls this directly
no outgoing calls
no test coverage detected