Gui: Add animation interrupted signal
This commit is contained in:
@@ -34,9 +34,14 @@ namespace Gui
|
||||
|
||||
class GuiExport NavigationAnimation : protected QVariantAnimation
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using QVariantAnimation::QObject;
|
||||
explicit NavigationAnimation(NavigationStyle* navigation);
|
||||
|
||||
Q_SIGNALS:
|
||||
void interrupted();
|
||||
|
||||
protected:
|
||||
NavigationStyle* navigation;
|
||||
|
||||
|
||||
@@ -68,6 +68,10 @@ bool NavigationAnimator::startAndWait(const std::shared_ptr<NavigationAnimation>
|
||||
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;
|
||||
@@ -80,6 +84,7 @@ 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();
|
||||
|
||||
Reference in New Issue
Block a user