#include "waitanimationwidget.h"
#include "ui_waitanimationwidget.h"

WaitAnimationWidget::WaitAnimationWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::WaitAnimationWidget),
    loadingMovie(nullptr)
{
    ui->setupUi(this);
}

void WaitAnimationWidget::initialize(ResourceManager *resourceManager)
{
    loadingMovie = resourceManager->getMovie();
    ui->MovieLabel->setMovie(loadingMovie);
}

void WaitAnimationWidget::slotActivateLoadingAnimation(bool flag)
{
    if (flag)showWithPlay();
    else hideWithStop();
}

void WaitAnimationWidget::showWithPlay()
{
    show();
    loadingMovie->start();
}

void WaitAnimationWidget::hideWithStop()
{
    hide();
    loadingMovie->stop();
}

WaitAnimationWidget::~WaitAnimationWidget()
{
    delete ui;
}


