79 lines
2.2 KiB
C++
79 lines
2.2 KiB
C++
#include "loemptydialog.h"
|
|
#include <QVBoxLayout>
|
|
|
|
LoEmptyDialog::LoEmptyDialog(QWidget *parent) : BaseDlg(parent) {
|
|
setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
auto pal = palette();
|
|
pal.setBrush(QPalette::Window, QColor(0xdd, 0xdd, 0xdd, 0xdd));
|
|
setPalette(pal);
|
|
|
|
auto vBox = new QVBoxLayout(this);
|
|
vBox->addStretch();
|
|
|
|
mIndicator = new CustomProgressIndicator(this);
|
|
mIndicator->setDisplayModel(1);
|
|
mIndicator->setColor(QColor(0x0088dd));
|
|
mIndicator->setDisplayedWhenStopped(true);//动画停止后任就显示,直到关闭窗口
|
|
mIndicator->startAnimation();
|
|
vBox->addWidget(mIndicator, 0, Qt::AlignCenter);
|
|
|
|
vBox->addStretch();
|
|
|
|
label = new QLabel();
|
|
label->setAlignment(Qt::AlignCenter);
|
|
label->setStyleSheet("font-size: 24px; font-weight: bold; color: #08d;");
|
|
vBox->addWidget(label);
|
|
|
|
vBox->addStretch();
|
|
}
|
|
|
|
void LoEmptyDialog::SetTipTextContent(QString strTip) {
|
|
label->setText(strTip);
|
|
}
|
|
void LoEmptyDialog::SetFailedTipString(QString strTip) {
|
|
mTimeroutTip = strTip;
|
|
}
|
|
bool LoEmptyDialog::getLockStatus() {
|
|
return iLockFlag;
|
|
}
|
|
|
|
void LoEmptyDialog::lock(QString strTip, QString finishTip, QString timeroutTip) {
|
|
iLockFlag = true;
|
|
label->setText(strTip);
|
|
mFinishTip = finishTip;
|
|
mTimeroutTip = timeroutTip;
|
|
}
|
|
|
|
void LoEmptyDialog::unlock() {
|
|
if(iClosedFlag==1) return;
|
|
label->setText(mFinishTip);
|
|
if(mIndicator != nullptr) {
|
|
mIndicator->setBackground(":/res/success.png");
|
|
mIndicator->stopAnimation();
|
|
CloseWndByDelaySec(600);
|
|
}
|
|
iClosedFlag=1;
|
|
iLockFlag = false;
|
|
}
|
|
void LoEmptyDialog::TimerOutUnlock() {
|
|
if(iClosedFlag==1) return;
|
|
label->setText(mTimeroutTip);
|
|
if(mIndicator != nullptr) {
|
|
mIndicator->setBackground(":/res/tip.png");
|
|
mIndicator->stopAnimation();
|
|
CloseWndByDelaySec(600);
|
|
}
|
|
iClosedFlag = 1;
|
|
}
|
|
void LoEmptyDialog::CloseWndByDelaySec(int iCloseWndDelaySec) {
|
|
auto timer = new QTimer(this);
|
|
timer->setSingleShot(true);
|
|
connect(timer, &QTimer::timeout, this, [this, timer] {
|
|
timer->stop();
|
|
close();
|
|
emit sigClose();
|
|
});
|
|
timer->start(iCloseWndDelaySec);
|
|
}
|