2021-10-16 16:19:51 +01:00
|
|
|
#pragma once
|
|
|
|
|
2020-06-01 17:11:56 +01:00
|
|
|
#include "../mischelpers_global.h"
|
|
|
|
|
2021-10-16 16:19:51 +01:00
|
|
|
class MISCHELPERS_EXPORT CExitDialog : public QDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CExitDialog(const QString& Prompt, QWidget* parent = 0)
|
|
|
|
: QDialog(parent)
|
|
|
|
{
|
|
|
|
m_pMainLayout = new QGridLayout(this);
|
|
|
|
|
|
|
|
QLabel* pLabel = new QLabel(Prompt);
|
|
|
|
m_pMainLayout->addWidget(pLabel, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
m_pButtonBox = new QDialogButtonBox();
|
|
|
|
m_pButtonBox->setOrientation(Qt::Horizontal);
|
|
|
|
m_pButtonBox->setStandardButtons(QDialogButtonBox::Yes|QDialogButtonBox::No);
|
|
|
|
m_pMainLayout->addWidget(m_pButtonBox, 2, 0, 1, 1);
|
|
|
|
|
|
|
|
connect(m_pButtonBox,SIGNAL(accepted()),this,SLOT(accept()));
|
|
|
|
connect(m_pButtonBox,SIGNAL(rejected()),this,SLOT(reject()));
|
|
|
|
|
|
|
|
m_TimerId = startTimer(1000);
|
|
|
|
m_CountDown = 15;
|
|
|
|
}
|
|
|
|
~CExitDialog()
|
|
|
|
{
|
|
|
|
killTimer(m_TimerId);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void timerEvent(QTimerEvent *e)
|
|
|
|
{
|
|
|
|
if (e->timerId() != m_TimerId)
|
|
|
|
{
|
|
|
|
QDialog::timerEvent(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_CountDown != 0)
|
|
|
|
{
|
|
|
|
m_CountDown--;
|
|
|
|
m_pButtonBox->button(QDialogButtonBox::Yes)->setText(tr("Yes (%1)").arg(m_CountDown));
|
|
|
|
if(m_CountDown == 0)
|
|
|
|
accept();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void reject()
|
|
|
|
{
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void closeEvent(QCloseEvent *e)
|
|
|
|
{
|
|
|
|
hide();
|
|
|
|
e->ignore();
|
|
|
|
}
|
|
|
|
|
|
|
|
int m_TimerId;
|
|
|
|
int m_CountDown;
|
|
|
|
|
|
|
|
QGridLayout* m_pMainLayout;
|
|
|
|
QDialogButtonBox * m_pButtonBox;
|
|
|
|
};
|