Blame view

app/gui/oven_control/multicookselectionwindow.cpp 6.17 KB
2f6b55128   김태훈   다중 요리 구현
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
  #include "multicookselectionwindow.h"
  #include "ui_multicookselectionwindow.h"
  
  #include <QKeyEvent>
  
  #include "mainwindow.h"
  #include "configwindow.h"
  #include "multicookmanualwindow.h"
  #include "multicookautowindow.h"
  #include "soundplayer.h"
  
  MultiCookSelectionWindow::MultiCookSelectionWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MultiCookSelectionWindow)
  {
      ui->setupUi(this);
  
      ui->clockContainer->setParent(ui->upperStack);
      setAttribute(Qt::WA_DeleteOnClose);
  
      mode = Define::InvalidMode;
  
      updateView();
  
      setFocus();
  
      foreach (QPushButton *button, findChildren<QPushButton *>())
          connect(button, &QPushButton::pressed, SoundPlayer::playClick);
  }
  
  MultiCookSelectionWindow::~MultiCookSelectionWindow()
  {
      delete ui;
  }
  
  void MultiCookSelectionWindow::setMode(Define::Mode mode)
  {
      this->mode = mode;
      book.setMode(mode);
      updateView();
  }
  
  void MultiCookSelectionWindow::keyPressEvent(QKeyEvent *event)
  {
      switch (event->key())
      {
      case 0x01000032:    // Turn left
          onEncoderLeft();
          break;
      case 0x01000031:    // Push
          pushed = focusWidget();
          break;
      case 0x01000030:    // Turn right
          onEncoderRight();
          break;
      }
  }
  
  void MultiCookSelectionWindow::keyReleaseEvent(QKeyEvent *event)
  {
      switch (event->key())
      {
      case 0x01000032:    // Turn left
          onEncoderLeft();
          break;
      case 0x01000031:    // Push
          if (focusWidget() == pushed)
              onEncoderClicked(pushed);
  
          pushed = NULL;
          break;
      case 0x01000030:    // Turn right
          onEncoderRight();
          break;
      }
  }
  
  void MultiCookSelectionWindow::updateView()
  {
      if (mode == Define::InvalidMode)
      {
703beed2b   김태훈   디자인 안 반영
82
83
          ui->description->setText(tr("1. 다중 요리에서 사용할 요리 카테고리를 선택해주세요
  2. 스팀, 콤비, 건열 중에서 선택하시면 자동으로 다음 단계로 진행됩니다"));
2f6b55128   김태훈   다중 요리 구현
84
85
86
87
88
89
90
91
92
93
94
95
96
97
          ui->steamButton->setEnabled(true);
          ui->combiButton->setEnabled(true);
          ui->dryheatButton->setEnabled(true);
  
          ui->poultryButton->setEnabled(false);
          ui->meatButton->setEnabled(false);
          ui->fishButton->setEnabled(false);
          ui->dessertButton->setEnabled(false);
          ui->grainButton->setEnabled(false);
          ui->breadButton->setEnabled(false);
          ui->etcButton->setEnabled(false);
      }
      else
      {
703beed2b   김태훈   디자인 안 반영
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
          QString modeString;
          switch (mode)
          {
          case Define::SteamMode:
              modeString = tr("스팀을");
              break;
          case Define::CombiMode:
              modeString = tr("콤비를");
              break;
          case Define::DryMode:
              modeString = tr("건열을");
              break;
          }
  
          ui->description->setText(tr("1. %1 선택하였습니다
  2. 수동 메뉴 혹은 원하시는 자동 메뉴 상세 목록을 선택하세요").arg(modeString));
2f6b55128   김태훈   다중 요리 구현
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
          ui->steamButton->setEnabled(mode == Define::SteamMode);
          ui->combiButton->setEnabled(mode == Define::CombiMode);
          ui->dryheatButton->setEnabled(mode == Define::DryMode);
  
          ui->poultryButton->setEnabled(book.checkType(Define::Poultry));
          ui->meatButton->setEnabled(book.checkType(Define::Meat));
          ui->fishButton->setEnabled(book.checkType(Define::Fish));
          ui->dessertButton->setEnabled(book.checkType(Define::Desert));
          ui->grainButton->setEnabled(book.checkType(Define::Vegetable));
          ui->breadButton->setEnabled(book.checkType(Define::Bread));
          ui->etcButton->setEnabled(book.checkType(Define::Etc));
      }
  
      ui->primeButton->setEnabled(false);
  
      ui->multiButton->setEnabled(false);
      ui->programmingButton->setEnabled(false);
      ui->washButton->setEnabled(false);
  }
  
  void MultiCookSelectionWindow::handleModeClick(Define::Mode mode)
  {
      setFocus();
  
      if (this->mode == Define::InvalidMode)
      {
          setMode(mode);
      }
      else
      {
          MultiCookManualWindow *w = new MultiCookManualWindow(this);
          w->setMode(mode);
          w->setWindowModality(Qt::WindowModal);
          w->showFullScreen();
          w->raise();
  
          connect(w, SIGNAL(selected(MultiCook*)), SIGNAL(selected(MultiCook*)));
          connect(w, SIGNAL(selected(MultiCook*)), SLOT(hide()));
          connect(w, SIGNAL(selected(MultiCook*)), SLOT(close()));
      }
  }
  
  void MultiCookSelectionWindow::handleTypeClick(Define::CookType type)
  {
      setFocus();
  
      book.setType(type);
  
      MultiCookAutoWindow *w = new MultiCookAutoWindow(this);
      w->setType(type);
      w->setBook(&book);
      w->setWindowModality(Qt::WindowModal);
      w->showFullScreen();
      w->raise();
  
      connect(w, SIGNAL(selected(MultiCook*)), SIGNAL(selected(MultiCook*)));
      connect(w, SIGNAL(selected(MultiCook*)), SLOT(hide()));
      connect(w, SIGNAL(selected(MultiCook*)), SLOT(close()));
  }
  
  void MultiCookSelectionWindow::on_steamButton_clicked()
  {
      handleModeClick(Define::SteamMode);
  }
  
  void MultiCookSelectionWindow::on_combiButton_clicked()
  {
      handleModeClick(Define::CombiMode);
  }
  
  void MultiCookSelectionWindow::on_dryheatButton_clicked()
  {
      handleModeClick(Define::DryMode);
  }
  
  void MultiCookSelectionWindow::on_poultryButton_clicked()
  {
      handleTypeClick(Define::Poultry);
  }
  
  void MultiCookSelectionWindow::on_meatButton_clicked()
  {
      handleTypeClick(Define::Meat);
  }
  
  void MultiCookSelectionWindow::on_fishButton_clicked()
  {
      handleTypeClick(Define::Fish);
  }
  
  void MultiCookSelectionWindow::on_dessertButton_clicked()
  {
      handleTypeClick(Define::Desert);
  }
  
  void MultiCookSelectionWindow::on_grainButton_clicked()
  {
      handleTypeClick(Define::Vegetable);
  }
  
  void MultiCookSelectionWindow::on_breadButton_clicked()
  {
      handleTypeClick(Define::Bread);
  }
  
  void MultiCookSelectionWindow::on_etcButton_clicked()
  {
      handleTypeClick(Define::Etc);
  }
  
  void MultiCookSelectionWindow::on_backButton_clicked()
  {
      close();
  }
  
  void MultiCookSelectionWindow::on_helpButton_clicked()
  {
  
  }
2f6b55128   김태훈   다중 요리 구현
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
  void MultiCookSelectionWindow::onEncoderLeft()
  {
      focusPreviousChild();
  }
  
  void MultiCookSelectionWindow::onEncoderRight()
  {
      focusNextChild();
  }
  
  void MultiCookSelectionWindow::onEncoderClicked(QWidget *clicked)
  {
      QPushButton *b = qobject_cast<QPushButton *>(clicked);
      if (b)
          b->click();
  }