diff --git a/src/mvc/AnnimateSlideWidget.cpp b/src/mvc/AnnimateSlideWidget.cpp index 69461b2..5e25412 100644 --- a/src/mvc/AnnimateSlideWidget.cpp +++ b/src/mvc/AnnimateSlideWidget.cpp @@ -12,6 +12,7 @@ AnnimateSlideWidget::AnnimateSlideWidget(QWidget *parent) : QWidget(parent) _anim_widget = nullptr; _anim_enabled = true; _first = true; + _running = false; } //--------------------------------------------------------------------------- @@ -23,9 +24,11 @@ void AnnimateSlideWidget::setAnimWidget(QWidget* w, QWidget* container_widget) _anim_widget = w; _anim_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); _anim_hide = new QPropertyAnimation(_anim_widget, "minimumWidth"); + connect(_anim_hide, &QPropertyAnimation::finished, this, &AnnimateSlideWidget::onFinished); _anim_hide->setDuration(100); _anim_show = new QPropertyAnimation(_anim_widget, "minimumWidth"); + connect(_anim_show, &QPropertyAnimation::finished, this, &AnnimateSlideWidget::onFinished); _anim_show->setDuration(100); } diff --git a/src/mvc/AnnimateSlideWidget.h b/src/mvc/AnnimateSlideWidget.h index de636b8..4195acd 100644 --- a/src/mvc/AnnimateSlideWidget.h +++ b/src/mvc/AnnimateSlideWidget.h @@ -34,16 +34,18 @@ class AnnimateSlideWidget : public QWidget virtual void enterEvent(QEnterEvent *event) override { - if(_anim_enabled) + if(_anim_enabled && false == _running) { + _running = true; animateSlideOut(); } } virtual void leaveEvent(QEvent *event) override { - if(_anim_enabled) + if(_anim_enabled && false == _running) { + _running = true; animateSlideIn(); } } @@ -71,12 +73,18 @@ private slots: _anim_show->start(); } + void onFinished() + { + _running = false; + } + private: QWidget* _anim_widget; QPropertyAnimation *_anim_hide; QPropertyAnimation *_anim_show; bool _anim_enabled; bool _first; + bool _running; int _saved_width; };