#include "loemptydialog.h" #include "ui_loemptydialog.h" #include "QThread" LoEmptyDialog::LoEmptyDialog(QWidget *parent) : LoQDialog(parent), ui(new Ui::LoEmptyDialog) { ui->setupUi(this); setStyleSheet("background-color: rgba(216,216,216,0.8);"); ui->label->setStyleSheet("font-size: 24px;font-weight: 650;color: rgba(0,147,221,1); background-color: transparent;"); m_pIndicator = new CustomProgressIndicator(this); m_pIndicator->setDisplayStringInfo(tr(""),tr("")); m_pIndicator->setDisplayModel(1); ui->horizontalLayout_2->addWidget(m_pIndicator,Qt::AlignCenter); m_pIndicator->show(); m_pIndicator->setColor(QColor(0,147,221)); m_pIndicator->setDisplayedWhenStopped(true);//动画停止后任就显示,直到关闭窗口 m_pIndicator->startAnimation(); } LoEmptyDialog::~LoEmptyDialog() { delete ui; } void LoEmptyDialog::SetTipTextContent(QString strTip) { ui->label->setText(strTip); } void LoEmptyDialog::lock(QString strTip,QString strUnLockTip,QString strTimerOutUnLockTip) { iLockFlag=true; ui->label->setText(strTip); m_strUnLockTip=strUnLockTip; m_strTimerOutUnLockTip=strTimerOutUnLockTip; } void LoEmptyDialog::unlock() { if(iClosedFlag==1) return; ui->label->setText(m_strUnLockTip); if(m_pIndicator != nullptr) { m_pIndicator->setBackground(":/res/success.png"); m_pIndicator->stopAnimation(); // QThread::sleep(1); CloseWndByDelaySec(600); } iClosedFlag=1; iLockFlag=false; } bool LoEmptyDialog::getLockStatus() { return iLockFlag; } void LoEmptyDialog::TimerOutUnlock() { if(iClosedFlag==1) return; ui->label->setText(m_strTimerOutUnLockTip); if(m_pIndicator != nullptr) { m_pIndicator->setBackground(":/res/tip.png"); m_pIndicator->stopAnimation(); // QThread::sleep(1); CloseWndByDelaySec(600); } iClosedFlag=1; } void LoEmptyDialog::SetFailedTipString(QString strTip) { m_strTimerOutUnLockTip=strTip; } void LoEmptyDialog::CloseWndByDelaySec(int iCloseWndDelaySec) { m_pTimer = new QTimer(this); m_pTimer->setSingleShot(true); //connect(m_pTimer, &QTimer::timeout, this, [=](){this->close();}); //connect(m_pTimer, &QTimer::timeout, this, SLOT(CloseDlg())); connect(m_pTimer,SIGNAL(timeout()),this,SLOT(CloseDlg())); m_pTimer->start(iCloseWndDelaySec); } void LoEmptyDialog::CloseDlg() { m_pTimer->stop(); this->close(); emit sigClose(); } void LoEmptyDialog::DeleteSelf(const LoEmptyDialog *p) { //m_pSelf=p; }