Commit 7c415d2f715f2268cdb5ec668830751818121122

Authored by 김태훈
1 parent 8765fbc775
Exists in master and in 2 other branches fhd, fhd-demo

현재 습도/온도 값을 볼 때 슬라이더도 같이 움직이도록 수정

app/gui/oven_control/manualcookwindow.cpp
... ... @@ -34,20 +34,32 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) :
34 34 ui->closeDoorWidget->setParent(ui->upperStack);
35 35 setAttribute(Qt::WA_DeleteOnClose);
36 36  
  37 +
37 38 oven = Oven::getInstance();
  39 +
  40 + lastViewHumidity = -1;
  41 + lastViewTemp = -1;
  42 + lastViewTime = -1;
  43 + lastViewInterTemp = -1;
  44 + lastViewInterTempEnabled = !oven->interTempEnabled();
  45 + lastViewCooking = false;
  46 + lastViewDamper = false;
  47 + lastViewHumidification = false;
  48 + lastViewFan = -1;
  49 +
38 50 connect(oven, SIGNAL(changed(Oven*)), this, SLOT(onOvenUpdated(Oven*)));
39 51  
40 52 connect(ui->humiditySlider, SIGNAL(valueChanged(int)), oven, SLOT(setHumidity(int)));
41 53 connect(ui->tempSlider, SIGNAL(valueChanged(int)), oven, SLOT(setTemp(int)));
42 54 connect(ui->timeSlider, SIGNAL(valueChanged(int)), oven, SLOT(setTime(int)));
43 55 connect(ui->timeSlider, SIGNAL(valueChanged(int)), &startCookingTimer, SLOT(start()));
44   - connect(ui->timeSlider, SIGNAL(valueChanged(int)), this, SLOT(updateLabels()));
  56 + connect(ui->timeSlider, SIGNAL(valueChanged(int)), this, SLOT(updateView()));
45 57 connect(ui->interTempSlider, SIGNAL(valueChanged(int)), oven, SLOT(setInterTemp(int)));
46 58  
47   - connect(ui->humiditySlider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabels()));
48   - connect(ui->tempSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabels()));
49   - connect(ui->timeSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabels()));
50   - connect(ui->interTempSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabels()));
  59 + connect(ui->humiditySlider, SIGNAL(sliderMoved(int)), this, SLOT(updateView()));
  60 + connect(ui->tempSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateView()));
  61 + connect(ui->timeSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateView()));
  62 + connect(ui->interTempSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateView()));
51 63  
52 64 startCookingTimer.setSingleShot(true);
53 65 startCookingTimer.setInterval(2000);
... ... @@ -63,9 +75,8 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) :
63 75  
64 76 oven->setDefault(mode);
65 77  
66   - checkTimeTimer.setInterval(100);
67   - connect(&checkTimeTimer, SIGNAL(timeout()), SLOT(checkTime()));
68   - checkTimeTimer.start();
  78 + connect(&updateViewTimer, SIGNAL(timeout()), SLOT(updateView()));
  79 + updateViewTimer.start(100);
69 80  
70 81 foreach (QPushButton *button, findChildren<QPushButton *>())
71 82 connect(button, &QPushButton::pressed, SoundPlayer::playClick);
... ... @@ -107,66 +118,25 @@ void ManualCookWindow::setupAnimation()
107 118 ui->openDoorAnimation->start(300);
108 119 }
109 120  
110   -void ManualCookWindow::checkTime()
  121 +void ManualCookWindow::updateView()
111 122 {
112   - if (!ui->timeSlider->isSliderDown())
113   - {
114   - bool old = ui->timeSlider->blockSignals(true);
115   - ui->timeSlider->setSliderPosition(oven->time());
116   - ui->timeSlider->blockSignals(old);
117   -
118   - updateLabels();
119   - }
120   -
121   - if (oven->interTempEnabled() && oven->currentInterTemp() >= oven->interTemp())
122   - {
123   - oven->stopCooking();
124   - }
125   -
126   - if (repeat && !oven->cooking())
  123 + switch (oven->mode())
127 124 {
128   - repeat = false;
129   -
130   - ui->repeatButton->setStyleSheet("\
131   -QPushButton { background-image: url(:/images/manual_button/repeat.png); }\
132   -QPushButton:pressed { background-image: url(:/images/manual_button/repeat_ov.png); }");
133   -
134   - oven->setMode(repeatSetting.mode);
135   - oven->setHumidity(repeatSetting.humidity);
136   - oven->setTemp(repeatSetting.temp);
137   - oven->setTime(repeatSetting.time);
138   - oven->setInterTempEnabled(repeatSetting.coreTempEnabled);
139   - oven->setInterTemp(repeatSetting.coreTemp);
  125 + case Define::DryMode:
  126 + if (!ui->dryheatButton->isChecked())
  127 + ui->dryheatButton->setChecked(true);
  128 + break;
  129 + case Define::SteamMode:
  130 + if (!ui->steamButton->isChecked())
  131 + ui->steamButton->setChecked(true);
  132 + break;
  133 + case Define::CombiMode:
  134 + if (!ui->combiButton->isChecked())
  135 + ui->combiButton->setChecked(true);
  136 + break;
  137 + default:
  138 + break;
140 139 }
141   -}
142   -
143   -void ManualCookWindow::showCurrentHumidity()
144   -{
145   - showCurrentHumidity_ = true;
146   - updateLabels();
147   -}
148   -
149   -void ManualCookWindow::hideCurrentHumidity()
150   -{
151   - showCurrentHumidity_ = false;
152   - updateLabels();
153   -}
154   -
155   -void ManualCookWindow::showCurrentTemp()
156   -{
157   - showCurrentTemp_ = true;
158   - updateLabels();
159   -}
160   -
161   -void ManualCookWindow::hideCurrentTemp()
162   -{
163   - showCurrentTemp_ = false;
164   - updateLabels();
165   -}
166   -
167   -void ManualCookWindow::updateLabels()
168   -{
169   - QString buf;
170 140  
171 141 int humidity;
172 142 if (showCurrentHumidity_)
... ... @@ -176,7 +146,18 @@ void ManualCookWindow::updateLabels()
176 146 else
177 147 humidity = oven->humidity();
178 148  
179   - ui->humidityLabel->setText(buf.sprintf("%d%%", humidity));
  149 + if (humidity != lastViewHumidity)
  150 + {
  151 + lastViewHumidity = humidity;
  152 +
  153 + bool old = ui->humiditySlider->blockSignals(true);
  154 + if (ui->humiditySlider->sliderPosition() != humidity)
  155 + ui->humiditySlider->setValue(humidity);
  156 + ui->humiditySlider->setEnabled(oven->mode() == Define::CombiMode);
  157 + ui->humiditySlider->blockSignals(old);
  158 +
  159 + ui->humidityLabel->setText(QString("%1%").arg(humidity));
  160 + }
180 161  
181 162 int temp;
182 163 if (showCurrentTemp_)
... ... @@ -186,7 +167,18 @@ void ManualCookWindow::updateLabels()
186 167 else
187 168 temp = oven->temp();
188 169  
189   - ui->tempLabel->setText(Stringer::temperature(temp, Stringer::fontSize14));
  170 + if (temp != lastViewTemp)
  171 + {
  172 + lastViewTemp = temp;
  173 +
  174 + bool old = ui->tempSlider->blockSignals(true);
  175 + ui->tempSlider->setRange(oven->minTemp(), oven->maxTemp());
  176 + if (ui->tempSlider->sliderPosition() != temp)
  177 + ui->tempSlider->setValue(temp);
  178 + ui->tempSlider->blockSignals(old);
  179 +
  180 + ui->tempLabel->setText(Stringer::temperature(temp, Stringer::fontSize14));
  181 + }
190 182  
191 183 int msecs;
192 184 if (ui->timeSlider->isSliderDown())
... ... @@ -194,128 +186,133 @@ void ManualCookWindow::updateLabels()
194 186 else
195 187 msecs = oven->msecs();
196 188  
197   - ui->timeLabel->setText(Stringer::remainingTime(msecs, Stringer::fontSize14));
198   -
199   - if (oven->interTempEnabled())
  189 + if (msecs != lastViewTime)
200 190 {
201   - int interTemp;
202   - if (ui->interTempSlider->isSliderDown())
203   - interTemp = ui->interTempSlider->sliderPosition();
204   - else
205   - interTemp = oven->interTemp();
  191 + lastViewTime = msecs;
206 192  
207   - ui->interTempLabel->setText(Stringer::temperature(interTemp, Stringer::fontSize14));
208   - }
209   - else
210   - ui->interTempLabel->setText(Stringer::unusedTemperature(Stringer::fontSize14));
211   -}
  193 + bool old = ui->timeSlider->blockSignals(true);
  194 + ui->timeSlider->setSliderPosition(msecs / 1000);
  195 + ui->timeSlider->blockSignals(old);
212 196  
213   -void ManualCookWindow::onOvenUpdated(Oven *oven)
214   -{
215   - switch (oven->mode())
216   - {
217   - case Define::DryMode:
218   - ui->dryheatButton->setChecked(true);
219   - break;
220   - case Define::SteamMode:
221   - ui->steamButton->setChecked(true);
222   - break;
223   - case Define::CombiMode:
224   - ui->combiButton->setChecked(true);
225   - break;
226   - default:
227   - break;
  197 + ui->timeLabel->setText(Stringer::remainingTime(msecs, Stringer::fontSize14));
228 198 }
229 199  
230   - bool old;
231   - old = ui->humiditySlider->blockSignals(true);
232   - ui->humiditySlider->setValue(oven->humidity());
233   - ui->humiditySlider->setEnabled(oven->mode() == Define::CombiMode);
234   - ui->humiditySlider->blockSignals(old);
235   -
236   - old = ui->tempSlider->blockSignals(true);
237   - ui->tempSlider->setRange(oven->minTemp(), oven->maxTemp());
238   - ui->tempSlider->setValue(oven->temp());
239   - ui->tempSlider->blockSignals(old);
  200 + int interTemp;
  201 + if (ui->interTempSlider->isSliderDown())
  202 + interTemp = ui->interTempSlider->sliderPosition();
  203 + else
  204 + interTemp = oven->interTemp();
240 205  
241   - if (!ui->timeSlider->isSliderDown())
  206 + bool interTempEnabled = oven->interTempEnabled();
  207 + if (interTempEnabled != lastViewInterTempEnabled || interTemp != lastViewInterTemp)
242 208 {
243   - old = ui->timeSlider->blockSignals(true);
244   - ui->timeSlider->setValue(oven->time());
245   - ui->timeSlider->blockSignals(old);
246   - }
  209 + if (interTempEnabled != lastViewInterTempEnabled)
  210 + {
  211 + lastViewInterTempEnabled = oven->interTempEnabled();
247 212  
248   -// ui->interTempButton->setChecked(oven->interTempEnabled());
249   - if (oven->interTempEnabled())
250   - ui->interTempButton->setStyleSheet("\
  213 + if (interTempEnabled)
  214 + ui->interTempButton->setStyleSheet("\
251 215 QPushButton {\
252 216 image: url(:/images/slider_icon/core_temp_enabled.png);\
253 217 }\
254 218 QPushButton:pressed {\
255 219 image: url(:/images/slider_icon/core_temp_ov.png);\
256 220 }");
257   - else
258   - ui->interTempButton->setStyleSheet("\
  221 + else
  222 + ui->interTempButton->setStyleSheet("\
259 223 QPushButton {\
260 224 image: url(:/images/slider_icon/core_temp.png);\
261 225 }\
262 226 QPushButton:pressed {\
263 227 image: url(:/images/slider_icon/core_temp_ov.png);\
264 228 }");
  229 + }
265 230  
266   - old = ui->interTempSlider->blockSignals(true);
267   - ui->interTempSlider->setEnabled(oven->interTempEnabled());
268   - ui->interTempSlider->setRange(oven->minInterTemp(), oven->maxInterTemp());
269   - ui->interTempSlider->setValue(oven->interTemp());
270   - ui->interTempSlider->blockSignals(old);
  231 + lastViewInterTemp = interTemp;
271 232  
272   - if (oven->cooking())
273   - ui->runStopButton->setStyleSheet(
274   - "border-image: url(:/images/manual_button/stop.png)");
275   - else
276   - ui->runStopButton->setStyleSheet(
277   - "border-image: url(:/images/manual_button/run.png)");
  233 + bool old = ui->interTempSlider->blockSignals(true);
  234 + ui->interTempSlider->setEnabled(interTempEnabled);
  235 + ui->interTempSlider->setRange(oven->minInterTemp(), oven->maxInterTemp());
  236 + ui->interTempSlider->setValue(interTemp);
  237 + ui->interTempSlider->blockSignals(old);
278 238  
279   - if (oven->damper())
280   - ui->damperButton->setStyleSheet(
281   - "background-image: url(:/images/manual_button/damper_open.png)");
282   - else
283   - ui->damperButton->setStyleSheet(
284   - "background-image: url(:/images/manual_button/damper_close.png)");
  239 + if (interTempEnabled)
  240 + ui->interTempLabel->setText(Stringer::temperature(interTemp, Stringer::fontSize14));
  241 + else
  242 + ui->interTempLabel->setText(Stringer::unusedTemperature(Stringer::fontSize14));
  243 + }
285 244  
286   - if (oven->humidification())
287   - ui->humidificationButton->setStyleSheet(
288   - "background-image: url(:/images/manual_button/side_nozzle_open.png)");
289   - else
290   - ui->humidificationButton->setStyleSheet(
291   - "background-image: url(:/images/manual_button/side_nozzle_close.png)");
  245 + bool cooking = oven->cooking();
  246 + if (cooking != lastViewCooking)
  247 + {
  248 + lastViewCooking = cooking;
  249 +
  250 + if (cooking)
  251 + ui->runStopButton->setStyleSheet(
  252 + "border-image: url(:/images/manual_button/stop.png)");
  253 + else
  254 + ui->runStopButton->setStyleSheet(
  255 + "border-image: url(:/images/manual_button/run.png)");
  256 + }
292 257  
293   - switch (oven->fan())
  258 + bool damper = oven->damper();
  259 + if (damper != lastViewDamper)
294 260 {
295   - case 1:
296   - ui->fanButton->setStyleSheet(
297   - "background-image: url(:/images/manual_button/fan_1.png)");
298   - break;
299   - case 2:
300   - ui->fanButton->setStyleSheet(
301   - "background-image: url(:/images/manual_button/fan_2.png)");
302   - break;
303   - case 3:
304   - ui->fanButton->setStyleSheet(
305   - "background-image: url(:/images/manual_button/fan_3.png)");
306   - break;
307   - case 4:
308   - ui->fanButton->setStyleSheet(
309   - "background-image: url(:/images/manual_button/fan_4.png)");
310   - break;
311   - case 5:
312   - ui->fanButton->setStyleSheet(
313   - "background-image: url(:/images/manual_button/fan_5.png)");
314   - break;
315   - default:
316   - ui->fanButton->setStyleSheet(
317   - "background-image: url(:/images/manual_button/fan_1.png)");
318   - break;
  261 + lastViewDamper = damper;
  262 +
  263 + if (damper)
  264 + ui->damperButton->setStyleSheet(
  265 + "background-image: url(:/images/manual_button/damper_open.png)");
  266 + else
  267 + ui->damperButton->setStyleSheet(
  268 + "background-image: url(:/images/manual_button/damper_close.png)");
  269 + }
  270 +
  271 + bool humidification = oven->humidification();
  272 + if (humidification != lastViewHumidification)
  273 + {
  274 + lastViewHumidification = humidification;
  275 +
  276 + if (humidification)
  277 + ui->humidificationButton->setStyleSheet(
  278 + "background-image: url(:/images/manual_button/side_nozzle_open.png)");
  279 + else
  280 + ui->humidificationButton->setStyleSheet(
  281 + "background-image: url(:/images/manual_button/side_nozzle_close.png)");
  282 + }
  283 +
  284 + int fan = oven->fan();
  285 + if (fan != lastViewFan)
  286 + {
  287 + lastViewFan = fan;
  288 +
  289 + switch (fan)
  290 + {
  291 + case 1:
  292 + ui->fanButton->setStyleSheet(
  293 + "background-image: url(:/images/manual_button/fan_1.png)");
  294 + break;
  295 + case 2:
  296 + ui->fanButton->setStyleSheet(
  297 + "background-image: url(:/images/manual_button/fan_2.png)");
  298 + break;
  299 + case 3:
  300 + ui->fanButton->setStyleSheet(
  301 + "background-image: url(:/images/manual_button/fan_3.png)");
  302 + break;
  303 + case 4:
  304 + ui->fanButton->setStyleSheet(
  305 + "background-image: url(:/images/manual_button/fan_4.png)");
  306 + break;
  307 + case 5:
  308 + ui->fanButton->setStyleSheet(
  309 + "background-image: url(:/images/manual_button/fan_5.png)");
  310 + break;
  311 + default:
  312 + ui->fanButton->setStyleSheet(
  313 + "background-image: url(:/images/manual_button/fan_1.png)");
  314 + break;
  315 + }
319 316 }
320 317  
321 318 if (oven->paused() && !oven->cooldown() && oven->door())
... ... @@ -323,7 +320,7 @@ QPushButton:pressed {\
323 320 else
324 321 ui->upperStack->setCurrentIndex(0);
325 322  
326   - if (oven->cooking() || oven->cooldown() || oven->preheating())
  323 + if (oven->cooking())
327 324 {
328 325 ui->reserveButton->hide();
329 326 ui->favoriteButton->hide();
... ... @@ -336,7 +333,56 @@ QPushButton:pressed {\
336 333 ui->repeatButton->hide();
337 334 }
338 335  
339   - updateLabels();
  336 +}
  337 +
  338 +void ManualCookWindow::showCurrentHumidity()
  339 +{
  340 + showCurrentHumidity_ = true;
  341 + updateView();
  342 +}
  343 +
  344 +void ManualCookWindow::hideCurrentHumidity()
  345 +{
  346 + showCurrentHumidity_ = false;
  347 + updateView();
  348 +}
  349 +
  350 +void ManualCookWindow::showCurrentTemp()
  351 +{
  352 + showCurrentTemp_ = true;
  353 + updateView();
  354 +}
  355 +
  356 +void ManualCookWindow::hideCurrentTemp()
  357 +{
  358 + showCurrentTemp_ = false;
  359 + updateView();
  360 +}
  361 +
  362 +void ManualCookWindow::onOvenUpdated(Oven *oven)
  363 +{
  364 + updateView();
  365 +
  366 + if (oven->interTempEnabled() && oven->currentInterTemp() >= oven->interTemp())
  367 + {
  368 + oven->stopCooking();
  369 + }
  370 +
  371 + if (repeat && !oven->cooking())
  372 + {
  373 + repeat = false;
  374 +
  375 + ui->repeatButton->setStyleSheet("\
  376 +QPushButton { background-image: url(:/images/manual_button/repeat.png); }\
  377 +QPushButton:pressed { background-image: url(:/images/manual_button/repeat_ov.png); }");
  378 +
  379 + oven->setMode(repeatSetting.mode);
  380 + oven->setHumidity(repeatSetting.humidity);
  381 + oven->setTemp(repeatSetting.temp);
  382 + oven->setTime(repeatSetting.time);
  383 + oven->setInterTempEnabled(repeatSetting.coreTempEnabled);
  384 + oven->setInterTemp(repeatSetting.coreTemp);
  385 + }
340 386 }
341 387  
342 388 void ManualCookWindow::setOvenDefault(Define::Mode mode)
... ...
app/gui/oven_control/manualcookwindow.h
... ... @@ -30,8 +30,7 @@ private slots:
30 30 void setOvenDefault(Define::Mode mode);
31 31 void start();
32 32 void stop();
33   - void checkTime();
34   - void updateLabels();
  33 + void updateView();
35 34 void showCurrentHumidity();
36 35 void hideCurrentHumidity();
37 36 void showCurrentTemp();
... ... @@ -77,7 +76,7 @@ private:
77 76 Oven *oven;
78 77  
79 78 QTimer startCookingTimer;
80   - QTimer checkTimeTimer;
  79 + QTimer updateViewTimer;
81 80  
82 81 QTimer showCurrentHumidityTimer;
83 82 QTimer showCurrentTempTimer;
... ... @@ -90,6 +89,16 @@ private:
90 89 bool showCurrentHumidity_ = false;
91 90 bool showCurrentTemp_ = false;
92 91  
  92 + int lastViewHumidity;
  93 + int lastViewTemp;
  94 + int lastViewTime;
  95 + int lastViewInterTemp;
  96 + bool lastViewInterTempEnabled;
  97 + bool lastViewCooking;
  98 + bool lastViewDamper;
  99 + bool lastViewHumidification;
  100 + int lastViewFan;
  101 +
93 102 ManualCookSetting repeatSetting;
94 103 bool repeat;
95 104 };
... ...