#include "reservedtimepopup.h" #include "ui_reservedtimepopup.h" #include #include "stringer.h" ReservedTimePopup::ReservedTimePopup(QWidget *parent, QDateTime target) : QWidget(parent), ui(new Ui::ReservedTimePopup), target(target) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); connect(&checkTimeTimer, SIGNAL(timeout()), SLOT(checkTime())); checkTimeTimer.start(100); checkTime(); } ReservedTimePopup::~ReservedTimePopup() { delete ui; } void ReservedTimePopup::checkTime() { qint64 remaining = QDateTime::currentDateTime().msecsTo(target); if (remaining > 0) ui->timeLabel->setText(Stringer::remainingTime(remaining)); else { emit timeout(); close(); } } void ReservedTimePopup::on_cancelButton_clicked() { emit canceled(); close(); }