Blame view

app/gui/oven_control/cooldownpopup.cpp 5.22 KB
cfc2fcc35   김태훈   쿨다운 팝업 추가
1
2
  #include "cooldownpopup.h"
  #include "ui_cooldownpopup.h"
2bfd3a050   김태훈   환경 설정 대응
3
  #include "stringer.h"
cfc2fcc35   김태훈   쿨다운 팝업 추가
4
5
6
7
8
9
10
11
12
  CooldownPopup::CooldownPopup(QWidget *parent, Oven *oven) :
      QWidget(parent),
      ui(new Ui::CooldownPopup),
      oven(oven),
      showingCurrentTemp(false)
  {
      ui->setupUi(this);
  
      setAttribute(Qt::WA_DeleteOnClose);
2bfd3a050   김태훈   환경 설정 대응
13
14
      lastDisplayedFanLevel = -1;
      lastDisplayedHumidification = !oven->humidification();
cfc2fcc35   김태훈   쿨다운 팝업 추가
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
      ui->openDoorAnimation->load(":/images/animation/door_big_01.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_02.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_03.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_04.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_05.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_06.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_07.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_08.png");
      ui->openDoorAnimation->load(":/images/animation/door_big_09.png");
      ui->openDoorAnimation->start(300);
  
      cookingFanLevel = oven->fan();
      expectingFanLevel = oven->maxFan();
      started = false;
      opened = false;
  
      connect(oven, SIGNAL(changed(Oven*)), SLOT(updateView()));
  
      cooldownStartTimer.setSingleShot(true);
      cooldownStartTimer.setInterval(2000);
      connect(&cooldownStartTimer, SIGNAL(timeout()), SLOT(start()));
  
      showCurrentTempTimer.setSingleShot(true);
      showCurrentTempTimer.setInterval(2000);
      connect(&showCurrentTempTimer, SIGNAL(timeout()), SLOT(showCurrentTemp()));
  
      checkOvenTimer.setInterval(100);
      connect(&checkOvenTimer, SIGNAL(timeout()), SLOT(checkOven()));
  
      connect(ui->tempSlider, SIGNAL(valueChanged(int)), SLOT(updateView()));
  
      updateView();
  
      cooldownStartTimer.start();
  }
  
  CooldownPopup::~CooldownPopup()
  {
      delete ui;
  }
  
  void CooldownPopup::start()
  {
      started = true;
      opened = false;
  
      checkOvenTimer.start();
  
      updateView();
  }
  
  void CooldownPopup::stop()
  {
      started = false;
  
      oven->stopCooldown();
      oven->setFan(cookingFanLevel);
  
      close();
  }
  
  void CooldownPopup::showCurrentTemp()
  {
      showingCurrentTemp = true;
      updateView();
  }
  
  void CooldownPopup::updateView()
  {
      int temp;
      if (showingCurrentTemp)
          temp = oven->currentTemp();
      else
          temp = ui->tempSlider->value();
2bfd3a050   김태훈   환경 설정 대응
89
      ui->tempCurrentLabel->setText(Stringer::temperature(temp, Stringer::fontSize14));
cfc2fcc35   김태훈   쿨다운 팝업 추가
90
2bfd3a050   김태훈   환경 설정 대응
91
      if (lastDisplayedFanLevel != expectingFanLevel)
cfc2fcc35   김태훈   쿨다운 팝업 추가
92
      {
2bfd3a050   김태훈   환경 설정 대응
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
          lastDisplayedFanLevel = expectingFanLevel;
  
          switch (expectingFanLevel)
          {
          case 1:
              ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan1.png);");
              break;
          case 2:
              ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan2.png);");
              break;
          case 3:
              ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan3.png);");
              break;
          case 4:
              ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan4.png);");
              break;
          case 5:
              ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan5.png);");
              break;
          }
cfc2fcc35   김태훈   쿨다운 팝업 추가
113
      }
2bfd3a050   김태훈   환경 설정 대응
114
115
116
117
118
119
120
121
122
      if (lastDisplayedHumidification != oven->humidification())
      {
          lastDisplayedHumidification = oven->humidification();
  
          if (oven->humidification())
              ui->humidificationButton->setStyleSheet("background-image: url(:/images/cooldown/side_nozzle_ov.png);");
          else
              ui->humidificationButton->setStyleSheet("background-image: url(:/images/cooldown/side_nozzle.png);");
      }
cfc2fcc35   김태훈   쿨다운 팝업 추가
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
  
      if (started && !oven->door())
          ui->openDoorWidget->show();
      else
          ui->openDoorWidget->hide();
  }
  
  void CooldownPopup::checkOven()
  {
      updateView();
  
      if (!started)
          return;
  
      if (!opened)
      {
          if (oven->door())
          {
              opened = true;
              oven->setFan(expectingFanLevel);
              oven->startCooldown();
          }
      }
      else
      {
          if (oven->currentTemp() <= ui->tempSlider->value())
          {
              stop();
          }
      }
  }
  
  void CooldownPopup::on_closeButton_clicked()
  {
      stop();
      close();
  }
  
  void CooldownPopup::on_closeButton_2_clicked()
  {
      stop();
      close();
  }
  
  void CooldownPopup::on_tempButton_pressed()
  {
      showCurrentTempTimer.start();
  }
  
  void CooldownPopup::on_tempButton_released()
  {
      if (showCurrentTempTimer.isActive())
          showCurrentTempTimer.stop();
  
      if (showingCurrentTemp)
      {
          showingCurrentTemp = false;
          updateView();
      }
  }
  
  void CooldownPopup::on_runButton_clicked()
  {
      if (cooldownStartTimer.isActive())
      {
          cooldownStartTimer.stop();
          start();
      }
  }
  
  void CooldownPopup::on_fanButton_clicked()
  {
      expectingFanLevel--;
      if (expectingFanLevel < oven->minFan())
          expectingFanLevel = oven->maxFan();
  
      if (oven->cooldown())
          oven->setFan(expectingFanLevel);
      else
          updateView();
  
      if (cooldownStartTimer.isActive())
          cooldownStartTimer.start();
  }
  
  void CooldownPopup::on_humidificationButton_clicked()
  {
      if (oven->humidification())
          oven->stopHumidification();
      else
          oven->startHumidification();
  }