#include "self_destroy_message_box.h"
#include <QEventLoop>
SelfDestroyMessageBox::SelfDestroyMessageBox(QString warningInfo, int msec, QWidget *parentWin)
    :m_parentWin(parentWin)
{
    this->setIcon(CustomMessageBox::Warning);
    this->setText(warningInfo);
    this->setStandardButtons(CustomMessageBox::Yes);
    this->setParent(m_parentWin);
    m_timer.setInterval(msec);
}

SelfDestroyMessageBox::~SelfDestroyMessageBox()
{
    m_timer.stop();
}

void SelfDestroyMessageBox::onShow()
{
    QEventLoop eventloop;
    connect(&m_timer,SIGNAL(timeout()),&eventloop,SLOT(quit()));
    m_timer.start();
    this->show();
    eventloop.exec();
    this->hide();
}
