Blame view

app/gui/oven_control/manualcookwindow.cpp 30.5 KB
8c2952457   김태훈   응용 프로그램 추가
1
2
3
4
5
6
  #include "manualcookwindow.h"
  #include "ui_manualcookwindow.h"
  
  #include <QSignalMapper>
  #include <QTimer>
  #include <QtDebug>
ac60b5cec   김태훈   음향 효과 일부 적용 및 소스 ...
7
  #include "soundplayer.h"
05f2a7552   김태훈   image 관리 구조 변경
8
  #include "preheatpopup.h"
cfc2fcc35   김태훈   쿨다운 팝업 추가
9
  #include "cooldownpopup.h"
f588aa273   김태훈   부가 기능 로직 추가
10
11
12
  #include "cookhistory.h"
  #include "favoritenamepopup.h"
  #include "confirmpopup.h"
2bfd3a050   김태훈   환경 설정 대응
13
14
  #include "stringer.h"
  #include "config.h"
d35b8bcdf   김태훈   수동 요리의 중심 요리 설정 화...
15
  #include "coretempsettingpopup.h"
0e279295f   김태훈   수동 요리 구현
16
17
  #include "reservetimepopup.h"
  #include "reservedtimepopup.h"
e00c6a2a9   김태훈   기능 추가 구현
18
19
20
21
  #include "mainwindow.h"
  #include "configwindow.h"
  #include "primewindow.h"
  #include "washwindow.h"
ea536cd1d   김태훈   적재 / 조리 중 문 열림 시간...
22
  #include "errorpopupdlg.h"
05f2a7552   김태훈   image 관리 구조 변경
23
bb26a0523   김태훈   소스 코드 정리
24
  #include <QTime>
d0cfbd177   김태훈   GUI V0.1.10 (이 버전...
25
  ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) :
8c2952457   김태훈   응용 프로그램 추가
26
      QMainWindow(parent),
213c24135   김태훈   수동 요리 반복 추가
27
28
      ui(new Ui::ManualCookWindow),
      repeat(false)
8c2952457   김태훈   응용 프로그램 추가
29
30
  {
      ui->setupUi(this);
6f96c947a   김태훈   GUI 0.1.4
31
      ui->clockContainer->setParent(ui->upperStack);
cfc2fcc35   김태훈   쿨다운 팝업 추가
32
      ui->closeDoorWidget->setParent(ui->upperStack);
6f96c947a   김태훈   GUI 0.1.4
33
      setAttribute(Qt::WA_DeleteOnClose);
3f52600cc   김태훈   소스 코드 구조 개선
34
      oven = Oven::getInstance();
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
35
a2de3cbfc   김태훈   수동 요리에 새 슬라이더 적용
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
      ui->humiditySlider->setSubPixmap(":/images/slider/humidity.png");
      ui->humiditySlider->setRange(0, 100);
      ui->humiditySlider->bigTickInterval = 50;
      ui->humiditySlider->tickInterval = 10;
  
      ui->tempSlider->setSubPixmap(":/images/slider/temp.png");
      ui->tempSlider->bigTickInterval = 50;
      ui->tempSlider->tickInterval = 10;
  
      ui->timeSlider->setSubPixmap(":/images/slider/time.png");
      ui->timeSlider->setRange(0, 342);
      ui->timeSlider->bigTicks.append(0);
      ui->timeSlider->bigTicks.append(180);
      ui->timeSlider->bigTicks.append(270);
      ui->timeSlider->bigTicks.append(342);
      ui->timeSlider->ticks.append(60);
      ui->timeSlider->ticks.append(120);
      ui->timeSlider->ticks.append(180 + 30);
      ui->timeSlider->ticks.append(180 + 60);
      ui->timeSlider->ticks.append(270 + 4 * 6);
      ui->timeSlider->ticks.append(270 + 4 * 12);
  
      ui->interTempSlider->setSubPixmap(":/images/slider/core.png");
  
      QList<int> &bigTicks = ui->interTempSlider->bigTicks;
      bigTicks.append(oven->minInterTemp());
      bigTicks.append(oven->minInterTemp() + (oven->maxInterTemp() - oven->minInterTemp()) / 2);
      bigTicks.append(oven->maxInterTemp());
  
      QList<int> &ticks = ui->interTempSlider->ticks;
      for (int i = 1; i < 3; i++)
          ticks.append(bigTicks.at(0) + i * (bigTicks.at(1) - bigTicks.at(0)) / 3);
      for (int i = 1; i < 3; i++)
          ticks.append(bigTicks.at(1) + i * (bigTicks.at(2) - bigTicks.at(1)) / 3);
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
70
71
72
73
74
75
76
77
78
      lastViewHumidity = -1;
      lastViewTemp = -1;
      lastViewTime = -1;
      lastViewInterTemp = -1;
      lastViewInterTempEnabled = !oven->interTempEnabled();
      lastViewCooking = false;
      lastViewDamper = false;
      lastViewHumidification = false;
      lastViewFan = -1;
097e5e14a   김태훈   프로그래밍 모드 세부 사항 구현
79
      lastCheckedCooking = false;
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
80
ea536cd1d   김태훈   적재 / 조리 중 문 열림 시간...
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
      Config *config = Config::getInstance();
      config_item item = config->getConfigValue(Define::config_cooking_door_monitoring);
  
      monitorLevel = item.d8.d8_0;
      if (monitorLevel > 0 && monitorLevel < 4)
      {
          monitor1.setSingleShot(true);
          monitor2.setSingleShot(true);
          monitor3.setSingleShot(true);
          monitor1.setInterval(item.d8.d8_1 * 1000);
          monitor2.setInterval(item.d8.d8_2 * 1000);
          monitor3.setInterval(item.d8.d8_3 * 1000);
          connect(&monitor1, SIGNAL(timeout()), SLOT(onMonitor1Timeout()));
          connect(&monitor2, SIGNAL(timeout()), SLOT(onMonitor2Timeout()));
          connect(&monitor3, SIGNAL(timeout()), SLOT(onMonitor3Timeout()));
      }
      else
          monitorLevel = 0;
8c2952457   김태훈   응용 프로그램 추가
99
100
      connect(ui->humiditySlider, SIGNAL(valueChanged(int)), oven, SLOT(setHumidity(int)));
      connect(ui->tempSlider, SIGNAL(valueChanged(int)), oven, SLOT(setTemp(int)));
bb26a0523   김태훈   소스 코드 정리
101
      connect(ui->timeSlider, SIGNAL(valueChanged(int)), &startCookingTimer, SLOT(start()));
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
102
      connect(ui->timeSlider, SIGNAL(valueChanged(int)), this, SLOT(updateView()));
8c2952457   김태훈   응용 프로그램 추가
103
      connect(ui->interTempSlider, SIGNAL(valueChanged(int)), oven, SLOT(setInterTemp(int)));
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
104
105
106
107
      connect(ui->humiditySlider, SIGNAL(sliderMoved(int)), this, SLOT(updateView()));
      connect(ui->tempSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateView()));
      connect(ui->timeSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateView()));
      connect(ui->interTempSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateView()));
8c2952457   김태훈   응용 프로그램 추가
108
bb26a0523   김태훈   소스 코드 정리
109
      startCookingTimer.setSingleShot(true);
5228da630   김태훈   딜레이 변경
110
      startCookingTimer.setInterval(3000);
bb26a0523   김태훈   소스 코드 정리
111
112
113
      connect(&startCookingTimer, SIGNAL(timeout()), SLOT(start()));
  
      showCurrentHumidityTimer.setSingleShot(true);
5228da630   김태훈   딜레이 변경
114
      showCurrentHumidityTimer.setInterval(1000);
bb26a0523   김태훈   소스 코드 정리
115
116
117
      connect(&showCurrentHumidityTimer, SIGNAL(timeout()), SLOT(showCurrentHumidity()));
  
      showCurrentTempTimer.setSingleShot(true);
5228da630   김태훈   딜레이 변경
118
      showCurrentTempTimer.setInterval(1000);
bb26a0523   김태훈   소스 코드 정리
119
      connect(&showCurrentTempTimer, SIGNAL(timeout()), SLOT(showCurrentTemp()));
8c2952457   김태훈   응용 프로그램 추가
120
271dda4ae   김태훈   엔코더 구현
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
      focusHumidityButtonTimer.setSingleShot(true);
      focusHumidityButtonTimer.setInterval(3000);
      connect(&focusHumidityButtonTimer, SIGNAL(timeout()), SLOT(focusHumidityButton()));
  
      focusTempButtonTimer.setSingleShot(true);
      focusTempButtonTimer.setInterval(3000);
      connect(&focusTempButtonTimer, SIGNAL(timeout()), SLOT(focusTempButton()));
  
      focusTimeButtonTimer.setSingleShot(true);
      focusTimeButtonTimer.setInterval(3000);
      connect(&focusTimeButtonTimer, SIGNAL(timeout()), SLOT(focusTimeButton()));
  
      focusInterTempButtonTimer.setSingleShot(true);
      focusInterTempButtonTimer.setInterval(3000);
      connect(&focusInterTempButtonTimer, SIGNAL(timeout()), SLOT(focusInterTempButton()));
  
      connect(ui->humiditySlider, SIGNAL(sliderMoved(int)), &focusHumidityButtonTimer, SLOT(start()));
      connect(ui->tempSlider, SIGNAL(sliderMoved(int)), &focusTempButtonTimer, SLOT(start()));
      connect(ui->timeSlider, SIGNAL(sliderMoved(int)), &focusTimeButtonTimer, SLOT(start()));
      connect(ui->interTempSlider, SIGNAL(sliderMoved(int)), &focusInterTempButtonTimer, SLOT(start()));
a2de3cbfc   김태훈   수동 요리에 새 슬라이더 적용
141
      connect(oven, SIGNAL(changed(Oven*)), this, SLOT(onOvenUpdated(Oven*)));
bb26a0523   김태훈   소스 코드 정리
142
      oven->setDefault(mode);
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
143
144
      connect(&updateViewTimer, SIGNAL(timeout()), SLOT(updateView()));
      updateViewTimer.start(100);
2bfd3a050   김태훈   환경 설정 대응
145
bbd7d8f29   김태훈   버튼 음향 추가
146
      foreach (QPushButton *button, findChildren<QPushButton *>())
bbd7d8f29   김태훈   버튼 음향 추가
147
          connect(button, &QPushButton::pressed, SoundPlayer::playClick);
d35b8bcdf   김태훈   수동 요리의 중심 요리 설정 화...
148
149
  
      QTimer::singleShot(0, this, SLOT(setupAnimation()));
271dda4ae   김태훈   엔코더 구현
150
151
  
      setFocus();
bb26a0523   김태훈   소스 코드 정리
152
  }
f588aa273   김태훈   부가 기능 로직 추가
153
154
155
156
157
158
159
160
161
162
163
164
165
166
  ManualCookWindow::ManualCookWindow(QWidget *parent, ManualCookSetting setting)
      : ManualCookWindow(parent, setting.mode)
  {
      oven->setHumidity(setting.humidity);
      oven->setTemp(setting.temp);
      oven->setTime(setting.time);
      oven->setFan(setting.fan);
      oven->setInterTempEnabled(setting.coreTempEnabled);
      oven->setInterTemp(setting.coreTemp);
  
      startCookingTimer.start();
  
      onOvenUpdated(oven);
  }
bb26a0523   김태훈   소스 코드 정리
167
168
  ManualCookWindow::~ManualCookWindow()
  {
ea536cd1d   김태훈   적재 / 조리 중 문 열림 시간...
169
      stop();
bb26a0523   김태훈   소스 코드 정리
170
171
      delete ui;
  }
271dda4ae   김태훈   엔코더 구현
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
  void ManualCookWindow::keyPressEvent(QKeyEvent *event)
  {
      switch (event->key())
      {
      case 0x01000030:    // Turn left
          onEncoderLeft();
          break;
      case 0x01000031:    // Push
          if (focusWidget() != this)
          {
              pushed = focusWidget();
  
              if (pushed == ui->humidityButton)
                  on_humidityButton_pressed();
              else if (pushed == ui->tempButton)
                  on_tempButton_pressed();
  
          }
          break;
      case 0x01000032:    // Turn right
          onEncoderRight();
          break;
      }
  }
  
  void ManualCookWindow::keyReleaseEvent(QKeyEvent *event)
  {
      switch (event->key())
      {
      case 0x01000030:    // Turn left
          onEncoderLeft();
          break;
      case 0x01000031:    // Push
ec8811c60   김태훈   엔코더 동작 개선
205
          if (pushed == ui->humidityButton)
271dda4ae   김태훈   엔코더 구현
206
              on_humidityButton_released();
ec8811c60   김태훈   엔코더 동작 개선
207
          else if (pushed == ui->tempButton)
271dda4ae   김태훈   엔코더 구현
208
209
210
211
212
213
214
215
216
217
218
219
              on_tempButton_released();
  
          if (focusWidget() == pushed)
              onEncoderClicked(pushed);
  
          pushed = NULL;
          break;
      case 0x01000032:    // Turn right
          onEncoderRight();
          break;
      }
  }
bb26a0523   김태훈   소스 코드 정리
220
221
  void ManualCookWindow::setupAnimation()
  {
cfc2fcc35   김태훈   쿨다운 팝업 추가
222
223
224
225
226
227
228
229
230
231
      ui->openDoorAnimation->load(":/images/animation/door_big_09.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_08.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_07.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_06.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_05.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_04.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_03.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_02.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_01.png");
      ui->openDoorAnimation->start(300);
8c2952457   김태훈   응용 프로그램 추가
232
  }
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
233
  void ManualCookWindow::updateView()
8c2952457   김태훈   응용 프로그램 추가
234
  {
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
235
      switch (oven->mode())
213c24135   김태훈   수동 요리 반복 추가
236
      {
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
237
      case Define::DryMode:
271dda4ae   김태훈   엔코더 구현
238
239
240
241
          if (ui->steamButton->isChecked())
              ui->steamButton->setChecked(false);
          if (ui->combiButton->isChecked())
              ui->combiButton->setChecked(false);
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
242
243
244
245
246
247
          if (!ui->dryheatButton->isChecked())
              ui->dryheatButton->setChecked(true);
          break;
      case Define::SteamMode:
          if (!ui->steamButton->isChecked())
              ui->steamButton->setChecked(true);
271dda4ae   김태훈   엔코더 구현
248
249
250
251
          if (ui->combiButton->isChecked())
              ui->combiButton->setChecked(false);
          if (ui->dryheatButton->isChecked())
              ui->dryheatButton->setChecked(false);
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
252
253
          break;
      case Define::CombiMode:
271dda4ae   김태훈   엔코더 구현
254
255
          if (ui->steamButton->isChecked())
              ui->steamButton->setChecked(false);
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
256
257
          if (!ui->combiButton->isChecked())
              ui->combiButton->setChecked(true);
271dda4ae   김태훈   엔코더 구현
258
259
          if (ui->dryheatButton->isChecked())
              ui->dryheatButton->setChecked(false);
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
260
261
262
          break;
      default:
          break;
213c24135   김태훈   수동 요리 반복 추가
263
      }
8c2952457   김태훈   응용 프로그램 추가
264
9c1ea4a13   김태훈   포커스 디자인 변경 일부 적용
265
266
267
268
      QWidget *focused = focusWidget();
      ui->humidityButton->setChecked(focused == ui->humiditySlider);
      ui->tempButton->setChecked(focused == ui->tempSlider);
      ui->timeButton->setChecked(focused == ui->timeSlider);
8c2952457   김태훈   응용 프로그램 추가
269
270
271
      int humidity;
      if (showCurrentHumidity_)
          humidity = oven->currentHumidity();
271dda4ae   김태훈   엔코더 구현
272
      else if (ui->humiditySlider->isSliderDown() || focusWidget() == ui->humiditySlider)
8c2952457   김태훈   응용 프로그램 추가
273
274
275
          humidity = ui->humiditySlider->sliderPosition();
      else
          humidity = oven->humidity();
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
276
277
278
279
280
281
282
283
284
285
286
287
      if (humidity != lastViewHumidity)
      {
          lastViewHumidity = humidity;
  
          bool old = ui->humiditySlider->blockSignals(true);
          if (ui->humiditySlider->sliderPosition() != humidity)
              ui->humiditySlider->setValue(humidity);
          ui->humiditySlider->setEnabled(oven->mode() == Define::CombiMode);
          ui->humiditySlider->blockSignals(old);
  
          ui->humidityLabel->setText(QString("%1%").arg(humidity));
      }
8c2952457   김태훈   응용 프로그램 추가
288
289
290
291
  
      int temp;
      if (showCurrentTemp_)
          temp = oven->currentTemp();
271dda4ae   김태훈   엔코더 구현
292
      else if (ui->tempSlider->isSliderDown() || focusWidget() == ui->tempSlider)
8c2952457   김태훈   응용 프로그램 추가
293
294
295
          temp = ui->tempSlider->sliderPosition();
      else
          temp = oven->temp();
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
296
297
298
      if (temp != lastViewTemp)
      {
          lastViewTemp = temp;
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
299
300
          ui->tempLabel->setText(Stringer::temperature(temp, Stringer::fontSize14));
      }
8c2952457   김태훈   응용 프로그램 추가
301
a2de3cbfc   김태훈   수동 요리에 새 슬라이더 적용
302
303
304
305
306
      bool old = ui->tempSlider->blockSignals(true);
      ui->tempSlider->setRange(oven->minTemp(), oven->maxTemp());
      if (ui->tempSlider->sliderPosition() != temp)
          ui->tempSlider->setValue(temp);
      ui->tempSlider->blockSignals(old);
271dda4ae   김태훈   엔코더 구현
307
308
309
      int msecs = oven->msecs();
      if (ui->timeSlider->isSliderMoved())
          ui->timeLabel->setText(Stringer::remainingTime(sliderToTime(ui->timeSlider->sliderPosition()) * 1000, Stringer::fontSize14));
8c2952457   김태훈   응용 프로그램 추가
310
      else
271dda4ae   김태훈   엔코더 구현
311
          ui->timeLabel->setText(Stringer::remainingTime(msecs, Stringer::fontSize14));
8c2952457   김태훈   응용 프로그램 추가
312
271dda4ae   김태훈   엔코더 구현
313
      if (focusWidget() != ui->timeSlider)
8c2952457   김태훈   응용 프로그램 추가
314
      {
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
315
          bool old = ui->timeSlider->blockSignals(true);
a2de3cbfc   김태훈   수동 요리에 새 슬라이더 적용
316
          ui->timeSlider->setSliderPosition(timeToSlider(msecs / 1000));
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
317
          ui->timeSlider->blockSignals(old);
8c2952457   김태훈   응용 프로그램 추가
318
      }
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
319
      int interTemp;
271dda4ae   김태훈   엔코더 구현
320
      if (ui->interTempSlider->isSliderDown() || focusWidget() == ui->interTempSlider)
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
321
322
323
          interTemp = ui->interTempSlider->sliderPosition();
      else
          interTemp = oven->interTemp();
8c2952457   김태훈   응용 프로그램 추가
324
e75b6df28   김태훈   수동 요리 화면 동작 개선
325
      ui->interTempButton->setChecked(oven->interTempEnabled());
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
326
327
      bool interTempEnabled = oven->interTempEnabled();
      if (interTempEnabled != lastViewInterTempEnabled || interTemp != lastViewInterTemp)
8c2952457   김태훈   응용 프로그램 추가
328
      {
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
329
          if (interTempEnabled != lastViewInterTempEnabled)
e75b6df28   김태훈   수동 요리 화면 동작 개선
330
  //        {
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
331
              lastViewInterTempEnabled = oven->interTempEnabled();
e75b6df28   김태훈   수동 요리 화면 동작 개선
332
333
  //            ui->interTempButton->setChecked(interTempEnabled);
  //        }
8c2952457   김태훈   응용 프로그램 추가
334
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
335
          lastViewInterTemp = interTemp;
8c2952457   김태훈   응용 프로그램 추가
336
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
337
338
          bool old = ui->interTempSlider->blockSignals(true);
          ui->interTempSlider->setEnabled(interTempEnabled);
a2de3cbfc   김태훈   수동 요리에 새 슬라이더 적용
339
          ui->interTempSlider->setSubVisible(interTempEnabled);
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
340
          ui->interTempSlider->setRange(oven->minInterTemp(), oven->maxInterTemp());
a2de3cbfc   김태훈   수동 요리에 새 슬라이더 적용
341
342
          if (ui->interTempSlider->sliderPosition() != interTemp)
              ui->interTempSlider->setValue(interTemp);
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
343
          ui->interTempSlider->blockSignals(old);
c598b01b2   김태훈   GUI 업데이트
344
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
345
346
347
348
349
          if (interTempEnabled)
              ui->interTempLabel->setText(Stringer::temperature(interTemp, Stringer::fontSize14));
          else
              ui->interTempLabel->setText(Stringer::unusedTemperature(Stringer::fontSize14));
      }
c598b01b2   김태훈   GUI 업데이트
350
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
351
352
353
354
      bool cooking = oven->cooking();
      if (cooking != lastViewCooking)
      {
          lastViewCooking = cooking;
07441dbd3   김태훈   엔코더 관련 디자인 변경 대비
355
          ui->runStopButton->setChecked(cooking);
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
356
      }
271dda4ae   김태훈   엔코더 구현
357
      if (showFrontButtons)
8c2952457   김태훈   응용 프로그램 추가
358
      {
271dda4ae   김태훈   엔코더 구현
359
360
361
362
363
          ui->preheatButton->show();
          ui->damperButton->show();
          ui->humidificationButton->show();
          if (oven->cooking())
              ui->repeatButton->show();
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
364
          else
271dda4ae   김태훈   엔코더 구현
365
              ui->repeatButton->hide();
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
366
271dda4ae   김태훈   엔코더 구현
367
368
369
370
371
372
          ui->cooldownButton->hide();
          ui->fanButton->hide();
          ui->reserveButton->hide();
          ui->favoriteButton->hide();
      }
      else
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
373
      {
271dda4ae   김태훈   엔코더 구현
374
375
376
377
          ui->preheatButton->hide();
          ui->damperButton->hide();
          ui->humidificationButton->hide();
          ui->repeatButton->hide();
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
378
271dda4ae   김태훈   엔코더 구현
379
380
381
382
383
384
385
          ui->cooldownButton->show();
          ui->fanButton->show();
          if (oven->cooking())
          {
              ui->reserveButton->hide();
              ui->favoriteButton->hide();
          }
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
386
          else
271dda4ae   김태훈   엔코더 구현
387
388
389
390
          {
              ui->reserveButton->show();
              ui->favoriteButton->show();
          }
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
391
      }
271dda4ae   김태훈   엔코더 구현
392
393
      bool damper = oven->damper();
      ui->damperButton->setChecked(damper);
271dda4ae   김태훈   엔코더 구현
394
395
396
  
      bool humidification = oven->humidification();
      ui->humidificationButton->setChecked(humidification);
271dda4ae   김태훈   엔코더 구현
397
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
      int fan = oven->fan();
      if (fan != lastViewFan)
      {
          lastViewFan = fan;
  
          switch (fan)
          {
          case 1:
              ui->fanButton->setStyleSheet(
                          "background-image: url(:/images/manual_button/fan_1.png)");
              break;
          case 2:
              ui->fanButton->setStyleSheet(
                          "background-image: url(:/images/manual_button/fan_2.png)");
              break;
          case 3:
              ui->fanButton->setStyleSheet(
                          "background-image: url(:/images/manual_button/fan_3.png)");
              break;
          case 4:
              ui->fanButton->setStyleSheet(
                          "background-image: url(:/images/manual_button/fan_4.png)");
              break;
          case 5:
              ui->fanButton->setStyleSheet(
                          "background-image: url(:/images/manual_button/fan_5.png)");
              break;
          default:
              ui->fanButton->setStyleSheet(
                          "background-image: url(:/images/manual_button/fan_1.png)");
              break;
          }
8c2952457   김태훈   응용 프로그램 추가
430
      }
07441dbd3   김태훈   엔코더 관련 디자인 변경 대비
431
      ui->repeatButton->setChecked(repeat);
cfc2fcc35   김태훈   쿨다운 팝업 추가
432
433
434
435
      if (oven->paused() && !oven->cooldown() && oven->door())
          ui->upperStack->setCurrentIndex(1);
      else
          ui->upperStack->setCurrentIndex(0);
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
  }
  
  void ManualCookWindow::showCurrentHumidity()
  {
      showCurrentHumidity_ = true;
      updateView();
  }
  
  void ManualCookWindow::hideCurrentHumidity()
  {
      showCurrentHumidity_ = false;
      updateView();
  }
  
  void ManualCookWindow::showCurrentTemp()
  {
      showCurrentTemp_ = true;
      updateView();
  }
  
  void ManualCookWindow::hideCurrentTemp()
  {
      showCurrentTemp_ = false;
      updateView();
  }
  
  void ManualCookWindow::onOvenUpdated(Oven *oven)
  {
      updateView();
  
      if (oven->interTempEnabled() && oven->currentInterTemp() >= oven->interTemp())
ea536cd1d   김태훈   적재 / 조리 중 문 열림 시간...
467
          stop();
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
468
469
470
471
  
      if (repeat && !oven->cooking())
      {
          repeat = false;
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
472
473
474
475
476
477
          oven->setMode(repeatSetting.mode);
          oven->setHumidity(repeatSetting.humidity);
          oven->setTemp(repeatSetting.temp);
          oven->setTime(repeatSetting.time);
          oven->setInterTempEnabled(repeatSetting.coreTempEnabled);
          oven->setInterTemp(repeatSetting.coreTemp);
07441dbd3   김태훈   엔코더 관련 디자인 변경 대비
478
479
  
          updateView();
7c415d2f7   김태훈   현재 습도/온도 값을 볼 때 슬...
480
      }
097e5e14a   김태훈   프로그래밍 모드 세부 사항 구현
481
482
483
484
485
486
487
488
489
490
      else if (lastCheckedCooking && !oven->cooking()){
          if ((oven->interTempEnabled() && oven->currentInterTemp() >= oven->interTemp())
                  || oven->time() == 0)
          {
              lastCheckedCooking = oven->cooking();
              emit done();
          }
      }
  
      lastCheckedCooking = oven->cooking();
ea536cd1d   김태훈   적재 / 조리 중 문 열림 시간...
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
  
      if (oven->paused() && oven->door())
      {
          if (monitorLevel > 0 && !monitorTriggered)
          {
              monitorTriggered = true;
              monitor1.start();
          }
      }
  
      if (monitorTriggered && !oven->door())
      {
          monitorTriggered = false;
          monitor1.stop();
          monitor2.stop();
          monitor3.stop();
      }
8c2952457   김태훈   응용 프로그램 추가
508
  }
d0cfbd177   김태훈   GUI V0.1.10 (이 버전...
509
  void ManualCookWindow::setOvenDefault(Define::Mode mode)
8c2952457   김태훈   응용 프로그램 추가
510
  {
bb26a0523   김태훈   소스 코드 정리
511
512
513
      stop();
  
      oven->setDefault(mode);
bb26a0523   김태훈   소스 코드 정리
514
515
516
517
  }
  
  void ManualCookWindow::start()
  {
bbd7d8f29   김태훈   버튼 음향 추가
518
519
      if (oven->cooking())
          return;
f588aa273   김태훈   부가 기능 로직 추가
520
521
      if (oven->time() > 0)
      {
c6dd03260   김태훈   요리 시작/종료 관련 음향 효과...
522
          SoundPlayer::playStart();
f588aa273   김태훈   부가 기능 로직 추가
523
524
525
526
          if (startCookingTimer.isActive())
              startCookingTimer.stop();
  
          oven->startCooking();
f588aa273   김태훈   부가 기능 로직 추가
527
528
529
530
531
532
533
534
535
536
537
  
          ManualCookSetting s;
          s.mode = oven->mode();
          s.humidity = oven->humidity();
          s.temp = oven->temp();
          s.time = oven->time();
          s.fan = oven->fan();
          s.coreTempEnabled = oven->interTempEnabled();
          s.coreTemp = oven->interTemp();
  
          CookHistory::record(s);
ea536cd1d   김태훈   적재 / 조리 중 문 열림 시간...
538
539
540
541
542
543
544
545
  
          if (monitorLevel > 0 && oven->door())
          {
              monitorTriggered = true;
              monitor1.start();
          }
          else
              monitorTriggered = false;
f588aa273   김태훈   부가 기능 로직 추가
546
      }
bb26a0523   김태훈   소스 코드 정리
547
548
549
550
  }
  
  void ManualCookWindow::stop()
  {
ac60b5cec   김태훈   음향 효과 일부 적용 및 소스 ...
551
552
      if (oven->cooking())
          SoundPlayer::playStop();
bb26a0523   김태훈   소스 코드 정리
553
554
      oven->stop();
      startCookingTimer.stop();
bb26a0523   김태훈   소스 코드 정리
555
  }
e00c6a2a9   김태훈   기능 추가 구현
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
  void ManualCookWindow::addFavorite()
  {
      ManualCookSetting s;
      s.mode = oven->mode();
      s.humidity = oven->humidity();
      s.temp = oven->temp();
      s.time = oven->time();
      s.fan = oven->fan();
      s.coreTempEnabled = oven->interTempEnabled();
      s.coreTemp = oven->interTemp();
  
      FavoriteNamePopup *p = new FavoriteNamePopup(this, s);
      p->showFullScreen();
  }
  
  void ManualCookWindow::jumpConfig()
  {
      stop();
  
      ConfigWindow *w = new ConfigWindow(MainWindow::getInstance());
      w->setWindowModality(Qt::WindowModal);
      w->showFullScreen();
      w->raise();
  
      MainWindow::jump(w);
  }
  
  void ManualCookWindow::jumpFavorites()
  {
      stop();
  
      PrimeWindow *w = new PrimeWindow(MainWindow::getInstance());
      w->setWindowModality(Qt::WindowModal);
      w->listFavorites();
      w->showFullScreen();
      w->raise();
  
      MainWindow::jump(w);
  }
  
  void ManualCookWindow::jumpWash()
  {
      stop();
  
      WashWindow *w = new WashWindow(MainWindow::getInstance());
      w->setWindowModality(Qt::WindowModal);
      w->showFullScreen();
      w->raise();
  
      MainWindow::jump(w);
  }
ea536cd1d   김태훈   적재 / 조리 중 문 열림 시간...
607
608
609
  void ManualCookWindow::onMonitor1Timeout()
  {
      SoundPlayer::playError1();
8a89c201e   김태훈   tr 추가
610
      ErrorPopupDlg *d = new ErrorPopupDlg(this, tr("문을 닫아주세요"), tr("조리 중 문 열림 시간 모니터링 1단계"));
ea536cd1d   김태훈   적재 / 조리 중 문 열림 시간...
611
612
613
614
615
616
617
618
619
      d->showFullScreen();
  
      if (monitorLevel > 1)
          monitor2.start();
  }
  
  void ManualCookWindow::onMonitor2Timeout()
  {
      SoundPlayer::playError1();
8a89c201e   김태훈   tr 추가
620
      ErrorPopupDlg *d = new ErrorPopupDlg(this, tr("문을 닫아주세요"), tr("조리 중 문 열림 시간 모니터링 2단계"));
ea536cd1d   김태훈   적재 / 조리 중 문 열림 시간...
621
622
623
624
625
626
627
628
629
      d->showFullScreen();
  
      if (monitorLevel > 2)
          monitor3.start();
  }
  
  void ManualCookWindow::onMonitor3Timeout()
  {
      SoundPlayer::playError1();
8a89c201e   김태훈   tr 추가
630
      ErrorPopupDlg *d = new ErrorPopupDlg(MainWindow::getInstance(), tr("문이 오래 열려있어 조리가 취소되었습니다"), tr("조리 중 문 열림 시간 모니터링 3단계"));
ea536cd1d   김태훈   적재 / 조리 중 문 열림 시간...
631
632
633
      d->showFullScreen();
      close();
  }
271dda4ae   김태훈   엔코더 구현
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
  void ManualCookWindow::onEncoderLeft()
  {
      QWidget *focused = focusWidget();
      if (focused == NULL)
          focusPreviousChild();
      else if (focused == this || focused->inherits("QPushButton"))
      {
          focusPreviousChild();
          focused = focusWidget();
  
          if (focused == ui->steamButton)
          {
              if (oven->mode() == Define::SteamMode)
                  focusPreviousChild();
          }
          else if (focused == ui->combiButton)
          {
              if (oven->mode() == Define::CombiMode)
                  focusPreviousChild();
          }
          else if (focused == ui->dryheatButton)
          {
              if (oven->mode() == Define::DryMode)
                  focusPreviousChild();
          }
      }
  }
  
  void ManualCookWindow::onEncoderRight()
  {
      QWidget *focused = focusWidget();
      if (focused == NULL)
          focusNextChild();
      else if (focused == this)
      {
          switch (oven->mode())
          {
          case Define::DryMode:
          case Define::SteamMode:
              ui->tempButton->setFocus();
              break;
          default:
              ui->humidityButton->setFocus();
          }
      }
      else if (focused->inherits("QPushButton"))
      {
          focusNextChild();
          focused = focusWidget();
  
          if (focused == ui->steamButton)
          {
              if (oven->mode() == Define::SteamMode)
                  focusNextChild();
          }
          else if (focused == ui->combiButton)
          {
              if (oven->mode() == Define::CombiMode)
                  focusNextChild();
          }
          else if (focused == ui->dryheatButton)
          {
              if (oven->mode() == Define::DryMode)
                  focusNextChild();
          }
      }
  }
  
  void ManualCookWindow::onEncoderClicked(QWidget *clicked)
  {
      QWidget *focused = clicked;
      if (focused == NULL)
          return;
  
      if (focused->inherits("QPushButton"))
      {
          QPushButton *pb = qobject_cast<QPushButton *>(focused);
          if (pb)
          {
              pb->click();
  
              if (pb == ui->steamButton || pb == ui->dryheatButton)
                  ui->tempButton->setFocus();
              else if (pb == ui->combiButton)
                  ui->humidityButton->setFocus();
          }
      }
      else if (focused->inherits("Slider"))
      {
          Slider *slider = qobject_cast<Slider *>(focused);
          if (slider)
          {
              if (slider->value() != slider->sliderPosition())
                  slider->setValue(slider->sliderPosition());
  
              if (slider == ui->humiditySlider)
                  ui->humidityButton->setFocus();
              else if (slider == ui->tempSlider)
                  ui->tempButton->setFocus();
              else if (slider == ui->timeSlider)
                  ui->timeButton->setFocus();
              else if (slider == ui->interTempSlider)
                  ui->interTempButton->setFocus();
          }
      }
  }
  
  void ManualCookWindow::focusHumidityButton()
  {
      if (focusWidget() == ui->humiditySlider)
      {
          oven->setHumidity(ui->humiditySlider->value());
          ui->humidityButton->setFocus();
      }
  }
  
  void ManualCookWindow::focusTempButton()
  {
      if (focusWidget() == ui->tempSlider)
      {
          oven->setTemp(ui->tempSlider->value());
          ui->tempButton->setFocus();
      }
  }
  
  void ManualCookWindow::focusTimeButton()
  {
      if (focusWidget() == ui->timeSlider)
      {
          if (ui->timeSlider->isSliderMoved())
              oven->setTime(sliderToTime(ui->timeSlider->value()));
          ui->timeButton->setFocus();
      }
  }
  
  void ManualCookWindow::focusInterTempButton()
  {
      if (focusWidget() == ui->interTempSlider)
      {
          oven->setInterTemp(ui->interTempSlider->value());
          ui->interTempButton->setFocus();
      }
  }
  
  void ManualCookWindow::focusAgain()
  {
      if (focused)
      {
          focused->setFocus();
          focused = NULL;
      }
  }
bb26a0523   김태훈   소스 코드 정리
786
787
  void ManualCookWindow::on_steamButton_clicked()
  {
d0cfbd177   김태훈   GUI V0.1.10 (이 버전...
788
      setOvenDefault(Define::SteamMode);
bb26a0523   김태훈   소스 코드 정리
789
790
791
792
  }
  
  void ManualCookWindow::on_combiButton_clicked()
  {
d0cfbd177   김태훈   GUI V0.1.10 (이 버전...
793
      setOvenDefault(Define::CombiMode);
bb26a0523   김태훈   소스 코드 정리
794
795
796
797
  }
  
  void ManualCookWindow::on_dryheatButton_clicked()
  {
d0cfbd177   김태훈   GUI V0.1.10 (이 버전...
798
      setOvenDefault(Define::DryMode);
bb26a0523   김태훈   소스 코드 정리
799
800
801
802
803
804
805
806
807
808
809
  }
  
  void ManualCookWindow::on_humidityButton_pressed()
  {
      showCurrentHumidityTimer.start();
  }
  
  void ManualCookWindow::on_humidityButton_released()
  {
      if (showCurrentHumidityTimer.isActive())
          showCurrentHumidityTimer.stop();
c598b01b2   김태훈   GUI 업데이트
810
      else
bb26a0523   김태훈   소스 코드 정리
811
          hideCurrentHumidity();
8c2952457   김태훈   응용 프로그램 추가
812
  }
bb26a0523   김태훈   소스 코드 정리
813
  void ManualCookWindow::on_tempButton_pressed()
8c2952457   김태훈   응용 프로그램 추가
814
  {
bb26a0523   김태훈   소스 코드 정리
815
816
      showCurrentTempTimer.start();
  }
8c2952457   김태훈   응용 프로그램 추가
817
bb26a0523   김태훈   소스 코드 정리
818
819
820
821
822
823
824
  void ManualCookWindow::on_tempButton_released()
  {
      if (showCurrentTempTimer.isActive())
          showCurrentTempTimer.stop();
      else
          hideCurrentTemp();
  }
271dda4ae   김태훈   엔코더 구현
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
  void ManualCookWindow::on_humidityButton_clicked()
  {
      ui->humiditySlider->setFocus();
  
      focusHumidityButtonTimer.start();
  }
  
  void ManualCookWindow::on_tempButton_clicked()
  {
      ui->tempSlider->setFocus();
  
      focusTempButtonTimer.start();
  }
  
  void ManualCookWindow::on_timeButton_clicked()
  {
      ui->timeSlider->setFocus();
  
      focusTimeButtonTimer.start();
  }
bb26a0523   김태훈   소스 코드 정리
845
846
847
848
849
  void ManualCookWindow::on_interTempButton_clicked()
  {
      if (oven->interTempEnabled())
          oven->setInterTempEnabled(false);
      else
d35b8bcdf   김태훈   수동 요리의 중심 요리 설정 화...
850
851
852
      {
          CoreTempSettingPopup *p = new CoreTempSettingPopup(this);
          p->show();
271dda4ae   김태훈   엔코더 구현
853
854
855
  
          focused = ui->interTempButton;
          connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain()));
d35b8bcdf   김태훈   수동 요리의 중심 요리 설정 화...
856
      }
8c2952457   김태훈   응용 프로그램 추가
857
  }
bb26a0523   김태훈   소스 코드 정리
858
  void ManualCookWindow::on_runStopButton_clicked()
8c2952457   김태훈   응용 프로그램 추가
859
  {
bb26a0523   김태훈   소스 코드 정리
860
      if (oven->cooking())
bb26a0523   김태훈   소스 코드 정리
861
          stop();
8c2952457   김태훈   응용 프로그램 추가
862
      else
f588aa273   김태훈   부가 기능 로직 추가
863
          start();
bb26a0523   김태훈   소스 코드 정리
864
865
866
867
868
869
870
871
872
  }
  
  void ManualCookWindow::on_fanButton_clicked()
  {
      int fan = oven->fan() + 1;
      if (fan > oven->maxFan())
          fan = oven->minFan();
  
      oven->setFan(fan);
8c2952457   김태훈   응용 프로그램 추가
873
874
875
876
  }
  
  void ManualCookWindow::on_preheatButton_clicked()
  {
bb26a0523   김태훈   소스 코드 정리
877
      startCookingTimer.stop();
4fc65fb81   김태훈   GUI V0.1.6(이 버전으로...
878
05f2a7552   김태훈   image 관리 구조 변경
879
880
881
      PreheatPopup *p = new PreheatPopup(this, oven);
      p->setWindowModality(Qt::WindowModal);
      p->showFullScreen();
271dda4ae   김태훈   엔코더 구현
882
883
884
  
      focused = ui->preheatButton;
      connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain()));
8c2952457   김태훈   응용 프로그램 추가
885
886
887
888
  }
  
  void ManualCookWindow::on_damperButton_clicked()
  {
c598b01b2   김태훈   GUI 업데이트
889
890
      if (oven->damper())
          oven->closeDamper();
8c2952457   김태훈   응용 프로그램 추가
891
      else
c598b01b2   김태훈   GUI 업데이트
892
          oven->openDamper();
8c2952457   김태훈   응용 프로그램 추가
893
894
895
896
  }
  
  void ManualCookWindow::on_humidificationButton_clicked()
  {
c598b01b2   김태훈   GUI 업데이트
897
898
      if (oven->humidification())
          oven->stopHumidification();
8c2952457   김태훈   응용 프로그램 추가
899
      else
c598b01b2   김태훈   GUI 업데이트
900
          oven->startHumidification();
8c2952457   김태훈   응용 프로그램 추가
901
902
903
904
  }
  
  void ManualCookWindow::on_repeatButton_clicked()
  {
213c24135   김태훈   수동 요리 반복 추가
905
906
907
      if (repeat)
      {
          repeat = false;
07441dbd3   김태훈   엔코더 관련 디자인 변경 대비
908
          updateView();
213c24135   김태훈   수동 요리 반복 추가
909
910
911
912
      }
      else
      {
          repeat = true;
07441dbd3   김태훈   엔코더 관련 디자인 변경 대비
913
          updateView();
213c24135   김태훈   수동 요리 반복 추가
914
915
916
917
918
919
920
          repeatSetting.mode = oven->mode();
          repeatSetting.humidity = oven->humidity();
          repeatSetting.temp= oven->temp();
          repeatSetting.time = oven->time();
          repeatSetting.coreTempEnabled = oven->interTempEnabled();
          repeatSetting.coreTemp = oven->interTemp();
      }
8c2952457   김태훈   응용 프로그램 추가
921
922
923
924
  }
  
  void ManualCookWindow::on_cooldownButton_clicked()
  {
bb26a0523   김태훈   소스 코드 정리
925
      startCookingTimer.stop();
cfc2fcc35   김태훈   쿨다운 팝업 추가
926
927
928
929
  
      CooldownPopup *p = new CooldownPopup(this, oven);
      p->setWindowModality(Qt::WindowModal);
      p->showFullScreen();
271dda4ae   김태훈   엔코더 구현
930
931
932
  
      focused = ui->cooldownButton;
      connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain()));
8c2952457   김태훈   응용 프로그램 추가
933
934
935
936
  }
  
  void ManualCookWindow::on_reserveButton_clicked()
  {
0e279295f   김태훈   수동 요리 구현
937
938
939
940
941
942
943
944
      if (oven->time() > 0)
      {
          startCookingTimer.stop();
  
          ReserveTimePopup *p = new ReserveTimePopup(this);
          connect(p, SIGNAL(timeout()), SLOT(start()));
          connect(p, SIGNAL(canceled()), &startCookingTimer, SLOT(start()));
          p->showFullScreen();
271dda4ae   김태훈   엔코더 구현
945
946
947
  
          focused = ui->reserveButton;
          connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain()));
0e279295f   김태훈   수동 요리 구현
948
      }
8c2952457   김태훈   응용 프로그램 추가
949
  }
213c24135   김태훈   수동 요리 반복 추가
950
  void ManualCookWindow::on_favoriteButton_clicked()
8c2952457   김태훈   응용 프로그램 추가
951
  {
f588aa273   김태훈   부가 기능 로직 추가
952
953
954
955
956
      if (oven->cooking())
          return;
  
      ConfirmPopup *p = new ConfirmPopup(this, tr("즐겨찾기 항목에 추가하시겠습니까?"));
      p->showFullScreen();
8c2952457   김태훈   응용 프로그램 추가
957
271dda4ae   김태훈   엔코더 구현
958
      focused = ui->favoriteButton;
f5634ecc7   김태훈   엔코더 구현
959
      connect(p, SIGNAL(rejected()), SLOT(focusAgain()));
f588aa273   김태훈   부가 기능 로직 추가
960
961
962
963
964
965
966
      connect(p, SIGNAL(accepted()), SLOT(addFavorite()));
  
      if (startCookingTimer.isActive())
      {
          startCookingTimer.stop();
          connect(p, SIGNAL(rejected()), &startCookingTimer, SLOT(start()));
      }
8c2952457   김태훈   응용 프로그램 추가
967
  }
bb26a0523   김태훈   소스 코드 정리
968
bb26a0523   김태훈   소스 코드 정리
969
970
  void ManualCookWindow::on_goFrontStackButton_clicked()
  {
271dda4ae   김태훈   엔코더 구현
971
972
973
      showFrontButtons = !showFrontButtons;
  
      updateView();
bb26a0523   김태훈   소스 코드 정리
974
975
976
977
978
979
980
  }
  
  void ManualCookWindow::on_backButton_clicked()
  {
      stop();
      close();
  }
f588aa273   김태훈   부가 기능 로직 추가
981
e00c6a2a9   김태훈   기능 추가 구현
982
983
984
985
986
987
988
989
  void ManualCookWindow::on_configButton_clicked()
  {
      if (oven->cooking())
      {
          ConfirmPopup *p = new ConfirmPopup(this, tr("요리가 중단되고 환경 설정 모드로 들어갑니다. 진행할까요?"));
          p->showFullScreen();
  
          connect(p, SIGNAL(accepted()), SLOT(jumpConfig()));
271dda4ae   김태훈   엔코더 구현
990
991
992
  
          focused = ui->configButton;
          connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain()));
e00c6a2a9   김태훈   기능 추가 구현
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
      }
      else
      {
          ConfigWindow *w = new ConfigWindow(MainWindow::getInstance());
          w->setWindowModality(Qt::WindowModal);
          w->showFullScreen();
          w->raise();
  
          MainWindow::jump(w);
      }
  }
  
  void ManualCookWindow::on_favoritesButton_clicked()
  {
      if (oven->cooking())
      {
          ConfirmPopup *p = new ConfirmPopup(this, tr("요리가 중단되고 즐겨찾기 모드로 들어갑니다. 진행할까요?"));
          p->showFullScreen();
  
          connect(p, SIGNAL(accepted()), SLOT(jumpFavorites()));
271dda4ae   김태훈   엔코더 구현
1013
1014
1015
  
          focused = ui->favoritesButton;
          connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain()));
e00c6a2a9   김태훈   기능 추가 구현
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
      }
      else
      {
          PrimeWindow *w = new PrimeWindow(MainWindow::getInstance());
          w->setWindowModality(Qt::WindowModal);
          w->listFavorites();
          w->showFullScreen();
          w->raise();
  
          MainWindow::jump(w);
      }
  }
  
  void ManualCookWindow::on_washButton_clicked()
  {
      if (oven->cooking())
      {
          ConfirmPopup *p = new ConfirmPopup(this, tr("요리가 중단되고 자동 세척 모드로 들어갑니다. 진행할까요?"));
          p->showFullScreen();
  
          connect(p, SIGNAL(accepted()), SLOT(jumpWash()));
271dda4ae   김태훈   엔코더 구현
1037
1038
1039
  
          focused = ui->washButton;
          connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain()));
e00c6a2a9   김태훈   기능 추가 구현
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
      }
      else
      {
          WashWindow *w = new WashWindow(MainWindow::getInstance());
          w->setWindowModality(Qt::WindowModal);
          w->showFullScreen();
          w->raise();
  
          MainWindow::jump(w);
      }
  }
  
  void ManualCookWindow::on_helpButton_clicked()
f588aa273   김태훈   부가 기능 로직 추가
1053
  {
f588aa273   김태훈   부가 기능 로직 추가
1054
f588aa273   김태훈   부가 기능 로직 추가
1055
  }
a2de3cbfc   김태훈   수동 요리에 새 슬라이더 적용
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
  
  void ManualCookWindow::on_timeSlider_valueChanged()
  {
      oven->setTime(sliderToTime(ui->timeSlider->value()));
  }
  
  int ManualCookWindow::sliderToTime(int value)
  {
      if (value <= 180)
          return value * 60;
      if (value <= 270)
          return 180 * 60 + (value - 180) * 2 * 60;
      return 360 * 60 + (value - 270) * 15 * 60;
  }
  
  int ManualCookWindow::timeToSlider(int secs)
  {
      if (secs <= 180 * 60)
271dda4ae   김태훈   엔코더 구현
1074
          return qCeil((qreal) secs / 60);
a2de3cbfc   김태훈   수동 요리에 새 슬라이더 적용
1075
      if (secs <= 360 * 60)
271dda4ae   김태훈   엔코더 구현
1076
1077
          return 180 + qCeil((qreal) (secs - 180 * 60) / 2 / 60);
      return 270 + qCeil((qreal) (secs - 360 * 60) / 15 / 60);
a2de3cbfc   김태훈   수동 요리에 새 슬라이더 적용
1078
  }