#include "reservetimepopup.h" #include "ui_reservetimepopup.h" #include #include "reservedtimepopup.h" ReserveTimePopup::ReserveTimePopup(QWidget *parent) : QWidget(parent), ui(new Ui::ReserveTimePopup) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); QDateTime dt = QDateTime::currentDateTime(); ui->month->setValue(dt.date().month()); ui->day->setValue(dt.date().day()); ui->hour->setValue(dt.time().hour()); ui->min->setValue(dt.time().minute()); } ReserveTimePopup::~ReserveTimePopup() { delete ui; } void ReserveTimePopup::on_okButton_clicked() { QDateTime current = QDateTime::currentDateTime(); QDateTime target; target.setDate(QDate(current.date().year(), ui->month->value(), ui->day->value())); target.setTime(QTime(ui->hour->value(), ui->min->value())); if (current >= target) target = target.addYears(1); ReservedTimePopup *p = new ReservedTimePopup(parentWidget(), target); connect(p, SIGNAL(timeout()), SIGNAL(timeout())); connect(p, SIGNAL(canceled()), SIGNAL(canceled())); connect(p, SIGNAL(destroyed(QObject*)), SLOT(deleteLater())); p->showFullScreen(); hide(); } void ReserveTimePopup::on_cancelButton_clicked() { emit canceled(); close(); }