Blame view

app/gui/oven_control/reservetimepopup.cpp 1.26 KB
0e279295f   김태훈   수동 요리 구현
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  #include "reservetimepopup.h"
  #include "ui_reservetimepopup.h"
  
  #include <QDateTime>
  
  #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();
  }