| 337 | } |
| 338 | |
| 339 | void fadeTo(qreal value) |
| 340 | { |
| 341 | if (mFadeAnimation.data()) { |
| 342 | qreal endValue = mFadeAnimation.data()->endValue().toReal(); |
| 343 | if (qFuzzyCompare(value, endValue)) { |
| 344 | // Same end value, don't change the actual animation |
| 345 | return; |
| 346 | } |
| 347 | } |
| 348 | // Create a new fade animation |
| 349 | auto anim = new QPropertyAnimation(mOpacityEffect, "opacity"); |
| 350 | anim->setStartValue(mOpacityEffect->opacity()); |
| 351 | anim->setEndValue(value); |
| 352 | if (qFuzzyCompare(value, 1)) { |
| 353 | QObject::connect(anim, &QAbstractAnimation::finished, q, &DocumentView::slotFadeInFinished); |
| 354 | } |
| 355 | QObject::connect(anim, &QAbstractAnimation::finished, q, &DocumentView::isAnimatedChanged); |
| 356 | anim->setDuration(DocumentView::AnimDuration); |
| 357 | mFadeAnimation = anim; |
| 358 | Q_EMIT q->isAnimatedChanged(); |
| 359 | anim->start(QAbstractAnimation::DeleteWhenStopped); |
| 360 | } |
| 361 | |
| 362 | bool canPan() const |
| 363 | { |