Blame view

app/gui/oven_control/haccpdownloaddlg.cpp 4.57 KB
fa41bb40d   고영탁   HACCP 데이터 파일 다운로드...
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
  #include <QSignalMapper>
  #include <QDate>
  #include <QKeyEvent>
  #include <QDebug>
  #include "haccpdownloaddlg.h"
  #include "ui_haccpdownloaddlg.h"
  #include "soundplayer.h"
  #include "fileprocessdlg.h"
  #include "config.h"
  
  HaccpDownloadDlg::HaccpDownloadDlg(QWidget *parent) :
      QDialog(parent),
      ui(new Ui::HaccpDownloadDlg)
  {
      ui->setupUi(this);
      this->setWindowFlags(Qt::FramelessWindowHint);
      setAttribute(Qt::WA_DeleteOnClose);
      qApp->setActiveWindow(this);
      this->setFocus();
  
      foreach (QPushButton *button, findChildren<QPushButton *>())
          connect(button, &QPushButton::pressed, SoundPlayer::playClick);
  
      ui->ctrSpBxYearStart->setFormatterWidth(4);
      ui->ctrSpBxYearEnd->setFormatterWidth(4);
      QDate date = QDate::currentDate();
      ui->ctrSpBxDayEnd->setValue(date.day());
      ui->ctrSpBxDayStart->setValue(date.day());
      ui->ctrSpBxMonthEnd->setValue(date.month());
      ui->ctrSpBxMonthStart->setValue(date.month());
      ui->ctrSpBxYearStart->setValue(date.year());
      ui->ctrSpBxYearEnd->setValue(date.year());
  
      ui->ctrSpBxYearStart->setFocus();
  
  
  
      connect(ui->keyboardwidget, SIGNAL(onOkKeyClicked()), this, SLOT(keyEnter_clicked()));
      connect(ui->keyboardwidget, SIGNAL(onCancelKeyClicked()), this, SLOT(keyCancel_clicked()));
  
      QSignalMapper* mapper = new QSignalMapper(this);
      mapper->setMapping(ui->ctrSpBxYearStart, ui->ctrSpBxYearStart);
      mapper->setMapping(ui->ctrSpBxYearEnd, ui->ctrSpBxYearEnd);
      mapper->setMapping(ui->ctrSpBxMonthStart, ui->ctrSpBxMonthStart);
      mapper->setMapping(ui->ctrSpBxMonthEnd, ui->ctrSpBxMonthEnd);
      mapper->setMapping(ui->ctrSpBxDayStart, ui->ctrSpBxDayStart);
  
      connect(ui->ctrSpBxDayEnd, SIGNAL(focusInEdit()), mapper,SLOT(map()));
      connect(ui->ctrSpBxDayStart, SIGNAL(focusInEdit()), mapper,SLOT(map()));
      connect(ui->ctrSpBxMonthEnd, SIGNAL(focusInEdit()), mapper,SLOT(map()));
      connect(ui->ctrSpBxMonthStart, SIGNAL(focusInEdit()), mapper,SLOT(map()));
      connect(ui->ctrSpBxYearStart, SIGNAL(focusInEdit()), mapper,SLOT(map()));
      connect(ui->ctrSpBxYearEnd, SIGNAL(focusInEdit()), mapper,SLOT(map()));
  
      connect(mapper, SIGNAL(mapped(QWidget*)), this, SLOT(focusInSpinBox(QWidget*)));
  
  
  }
  
  HaccpDownloadDlg::~HaccpDownloadDlg()
  {
      delete ui;
  }
  
  void HaccpDownloadDlg::on_ctrBtnCancel_clicked()
  {
      deleteLater();
  }
  
  void HaccpDownloadDlg::on_ctrBtnOk_clicked()
  {
      FileProcessDlg* dlg = new FileProcessDlg(QDate(ui->ctrSpBxYearStart->value(), ui->ctrSpBxMonthStart->value(), ui->ctrSpBxDayStart->value()),
                                               QDate(ui->ctrSpBxYearEnd->value(),ui->ctrSpBxMonthEnd->value(), ui->ctrSpBxDayEnd->value()),
                                               this);
      connect(dlg, SIGNAL(destroyed(QObject*)), SLOT(deleteLater()));
      dlg->setWindowModality(Qt::WindowModal);
      dlg->show();
      dlg->exec();
  }
  
  void HaccpDownloadDlg::keyCancel_clicked()
  {
      QSpinBox *spbx = qobject_cast<QSpinBox*>(focusWidget());
      if(spbx != NULL){
          spbx->setValue(m_nFocusValue);
      }
      ui->keyboardwidget->focusOutKeyboard();
  }
  
  void HaccpDownloadDlg::keyEnter_clicked(){
      ui->keyboardwidget->focusOutKeyboard();
  }
  
  
  void HaccpDownloadDlg::focusInSpinBox(QWidget *widget){
      QSpinBox *spbx = qobject_cast<QSpinBox*>(widget);
      if(spbx != NULL){
          m_nFocusValue = spbx->value();
      }
  }
  
  void HaccpDownloadDlg::keyReleaseEvent(QKeyEvent *event)
  {
      switch (event->key())
      {
      case 0x01000032:    // Turn left
          if(focusWidget() == ui->ctrSpBxYearStart) ui->ctrBtnCancel->setFocus();
          else focusPreviousChild();
          break;
      case 0x01000031:    // Push
      {
          QPushButton *btn = qobject_cast<QPushButton*>(focusWidget());
          if(btn != NULL){
              btn->click();
          }
          else{
              QSpinBox *spbx = qobject_cast<QSpinBox*>(focusWidget());
              qDebug() << "grab keyboard";
              if(spbx != NULL) ui->keyboardwidget->focusInKeyboard();
          }
          break;
      }
      case 0x01000030:    // Turn right
          if(focusWidget() == ui->ctrBtnCancel) ui->ctrSpBxYearStart->setFocus();
          else focusNextChild();
          break;
      }
  }
  
  void HaccpDownloadDlg::keyPressEvent(QKeyEvent *event){
      switch (event->key())
      {
      case 0x01000032:    // Turn left
          if(focusWidget() == ui->ctrSpBxYearStart) ui->ctrBtnCancel->setFocus();
          else focusPreviousChild();
          break;
      case 0x01000031:    // Push
          break;
      case 0x01000030:    // Turn right
          if(focusWidget() == ui->ctrBtnCancel) ui->ctrSpBxYearStart->setFocus();
          else focusNextChild();
          break;
      }
  }