| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #include "NavigationAnimator.h" |
| | #include "NavigationAnimation.h" |
| | #include <QEventLoop> |
| |
|
| | using namespace Gui; |
| |
|
| | NavigationAnimator::NavigationAnimator() |
| | : activeAnimation(nullptr) |
| | {} |
| |
|
| | NavigationAnimator::~NavigationAnimator() |
| | { |
| | stop(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | void NavigationAnimator::start(const std::shared_ptr<NavigationAnimation>& animation) |
| | { |
| | stop(); |
| | activeAnimation = animation; |
| | activeAnimation->initialize(); |
| |
|
| | connect(activeAnimation.get(), &NavigationAnimation::finished, this, [this]() { |
| | activeAnimation->onStop(true); |
| | activeAnimation.reset(); |
| | }); |
| |
|
| | activeAnimation->start(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | bool NavigationAnimator::startAndWait(const std::shared_ptr<NavigationAnimation>& animation) |
| | { |
| | stop(); |
| | bool finished = true; |
| | QEventLoop loop; |
| | connect(animation.get(), &NavigationAnimation::finished, &loop, &QEventLoop::quit); |
| | connect(animation.get(), &NavigationAnimation::interrupted, &loop, [&finished, &loop]() { |
| | finished = false; |
| | loop.quit(); |
| | }); |
| | start(animation); |
| | loop.exec(); |
| | return finished; |
| | } |
| |
|
| | |
| | |
| | |
| | void NavigationAnimator::stop() |
| | { |
| | if (activeAnimation && activeAnimation->state() != QAbstractAnimation::State::Stopped) { |
| | disconnect(activeAnimation.get(), &NavigationAnimation::finished, 0, 0); |
| | Q_EMIT activeAnimation->interrupted(); |
| | activeAnimation->stop(); |
| | activeAnimation->onStop(false); |
| | activeAnimation.reset(); |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | bool NavigationAnimator::isAnimating() const |
| | { |
| | if (activeAnimation != nullptr) { |
| | return activeAnimation->state() == QAbstractAnimation::State::Running; |
| | } |
| |
|
| | return false; |
| | } |
| |
|