#include "self_destroy_message_box.h"
#include <QEventLoop>
SelfDestroyMessageBox::SelfDestroyMessageBox(QString warningInfo, int msec, QWidget *parentWin)
    :m_parentWin(parentWin)
{
    this->setIcon(QMessageBox::Warning);
    this->setText(warningInfo);
    this->setStandardButtons(QMessageBox::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();
}
