UpLowLimp/ZBD_IIIDL_S_Project/Src/PopDialog/quitbyspeeddialog.cpp
2024-11-25 17:15:44 +08:00

60 lines
1.2 KiB
C++

#include "quitbyspeeddialog.h"
#include "ui_quitbyspeeddialog.h"
#include <QPainter>
#include <QTimer>
QuitBySpeedDialog::QuitBySpeedDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::QuitBySpeedDialog),
m_downTimer(NULL),
m_downTimeNum(5)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
setAttribute(Qt::WA_TranslucentBackground,true);
m_downTimer = new QTimer();
m_downTimer->setInterval(1000);
connect(m_downTimer,SIGNAL(timeout()),this,SLOT(slotDownTimer()));
}
QuitBySpeedDialog::~QuitBySpeedDialog()
{
delete ui;
}
void QuitBySpeedDialog::startTimer()
{
m_downTimeNum = 5;
m_downTimer->start();
ui->downTime_Label->setText(QString::number(m_downTimeNum));
this->show();
}
void QuitBySpeedDialog::stopTimer()
{
m_downTimer->stop();
this->close();
}
void QuitBySpeedDialog::slotDownTimer()
{
ui->downTime_Label->setText(QString::number(m_downTimeNum));
if(m_downTimeNum == 0)
{
this->close();
emit signalClosed();
}
m_downTimeNum--;
}
void QuitBySpeedDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(),QColor(0,0,0,100));
}