Commit 2bfd3a050666e56dcafafeda6c64f8132091612c

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

환경 설정 대응

- 온도 단위 반영
 - 잔여 시간 형식 반영
app/gui/oven_control/autocook.cpp
... ... @@ -521,3 +521,31 @@ int AutoCook::remainingTime()
521 521 return t / 1000;
522 522 }
523 523 }
  524 +
  525 +int AutoCook::msecs()
  526 +{
  527 + if (done_)
  528 + {
  529 + return 0;
  530 + }
  531 + else if (checkingCoreTemp && currentStepIndex + 1 >= cook.steps.size())
  532 + {
  533 + CookStep &step = cook.steps[cook.steps.size() - 1];
  534 + int t = step.time;
  535 + if (!doorOpened)
  536 + t -= lastCoreTempIncreasedTime.elapsed();
  537 +
  538 + return t;
  539 + }
  540 + else
  541 + {
  542 + int t = 0;
  543 + for (int i = currentStepIndex; i < cook.steps.size(); i++)
  544 + t += cook.steps[i].time;
  545 +
  546 + if (!doorOpened && Define::classify(cook.steps[currentStepIndex].type) == Define::CookClass)
  547 + t -= stepStartTime.elapsed();
  548 +
  549 + return t;
  550 + }
  551 +}
... ...
app/gui/oven_control/autocook.h
... ... @@ -19,6 +19,8 @@ public:
19 19 bool isWaitingDoorOpened() { return isWaitingDoorOpened_; }
20 20 bool done() { return done_; }
21 21  
  22 + int msecs();
  23 +
22 24 Cook cook;
23 25 int currentStepIndex;
24 26  
... ...
app/gui/oven_control/autocookconfigwindow.cpp
... ... @@ -3,6 +3,7 @@
3 3  
4 4 #include "autocookwindow.h"
5 5 #include "confirmpopup.h"
  6 +#include "stringer.h"
6 7 #include "favoritenamepopup.h"
7 8  
8 9 AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Cook cook) :
... ... @@ -129,10 +130,6 @@ void AutoCookConfigWindow::setupUi()
129 130 break;
130 131 }
131 132  
132   -// cw.slider->style()->unpolish(cw.slider);
133   -// cw.slider->style()->polish(cw.slider);
134   -// cw.slider->update();
135   -
136 133 connect(cw.slider, SIGNAL(valueChanged(int)), SLOT(updateConfig()));
137 134 }
138 135 }
... ... @@ -153,36 +150,10 @@ void AutoCookConfigWindow::updateView()
153 150 switch (config.type)
154 151 {
155 152 case Define::Time:
156   - {
157   - int time = cook.time();
158   - if (time >= 3600)
159   - cw.current->setText(QString().sprintf(
160   - "%d"
161   - "<span style=\"font-size:11pt;\">시간</span>"
162   - " %02d"
163   - "<span style=\"font-size:11pt;\">분</span>",
164   - time / 3600,
165   - (time % 3600) / 60));
166   - else if (time >= 60)
167   - cw.current->setText(QString().sprintf(
168   - "%d"
169   - "<span style=\"font-size:11pt;\">분</span>"
170   - " %02d"
171   - "<span style=\"font-size:11pt;\">초</span>",
172   - time / 60,
173   - time % 60));
174   - else
175   - cw.current->setText(QString().sprintf(
176   - "%d"
177   - "<span style=\"font-size:11pt;\">초</span>",
178   - time));
  153 + cw.current->setText(Stringer::remainingTime(cook.time() * 1000, Stringer::fontSize14));
179 154 break;
180   - }
181 155 case Define::BurnDegree:
182   - cw.current->setText(QString().sprintf(
183   - "%d"
184   - "<span style=\"font-size:11pt;\">℃</span>",
185   - cook.coreTemp()));
  156 + cw.current->setText(Stringer::temperature(cook.coreTemp(), Stringer::fontSize14));
186 157 break;
187 158 default:
188 159 cw.current->setText(QString().sprintf(
... ...
app/gui/oven_control/autocooksettingwidget.cpp
1 1 #include "autocooksettingwidget.h"
2 2 #include "ui_autocooksettingwidget.h"
3 3  
  4 +#include "stringer.h"
4 5  
5 6 AutoCookSettingWidget::AutoCookSettingWidget(AutoCookSetting setting, QWidget *parent) :
6 7 QWidget(parent),
... ... @@ -116,36 +117,10 @@ void AutoCookSettingWidget::setupUi(Cook cook)
116 117 switch (config.type)
117 118 {
118 119 case Define::Time:
119   - {
120   - int time = cook.time();
121   - if (time >= 3600)
122   - cw.current->setText(QString().sprintf(
123   - "%d"
124   - "<span style=\"font-size:11pt;\">시간</span>"
125   - " %02d"
126   - "<span style=\"font-size:11pt;\">분</span>",
127   - time / 3600,
128   - (time % 3600) / 60));
129   - else if (time >= 60)
130   - cw.current->setText(QString().sprintf(
131   - "%d"
132   - "<span style=\"font-size:11pt;\">분</span>"
133   - " %02d"
134   - "<span style=\"font-size:11pt;\">초</span>",
135   - time / 60,
136   - time % 60));
137   - else
138   - cw.current->setText(QString().sprintf(
139   - "%d"
140   - "<span style=\"font-size:11pt;\">초</span>",
141   - time));
  120 + cw.current->setText(Stringer::remainingTime(cook.time() * 1000, Stringer::fontSize14));
142 121 break;
143   - }
144 122 case Define::BurnDegree:
145   - cw.current->setText(QString().sprintf(
146   - "%d"
147   - "<span style=\"font-size:11pt;\">℃</span>",
148   - cook.coreTemp()));
  123 + cw.current->setText(Stringer::temperature(cook.coreTemp(), Stringer::fontSize14));
149 124 break;
150 125 default:
151 126 cw.current->setText(QString().sprintf(
... ...
app/gui/oven_control/autocookwindow.cpp
... ... @@ -5,6 +5,7 @@
5 5 #include "cookhistory.h"
6 6 #include "confirmpopup.h"
7 7 #include "favoritenamepopup.h"
  8 +#include "stringer.h"
8 9  
9 10 AutoCookWindow::AutoCookWindow(QWidget *parent, Cook cook) :
10 11 QMainWindow(parent),
... ... @@ -53,6 +54,9 @@ AutoCookWindow::AutoCookWindow(QWidget *parent, Cook cook) :
53 54 setting.configs[i] = cook.configs[i].current;
54 55  
55 56 CookHistory::record(setting);
  57 +
  58 + connect(&updateViewTimer, SIGNAL(timeout()), SLOT(updateView()));
  59 + updateViewTimer.start(100);
56 60 }
57 61  
58 62 AutoCookWindow::~AutoCookWindow()
... ... @@ -189,48 +193,20 @@ void AutoCookWindow::updateView()
189 193 {
190 194 Oven *oven = Oven::getInstance();
191 195  
192   - QString spanFontSize11("<span style=\"font-size:11pt\">%1</span>");
193   - QString spanFontSize9("<span style=\"font-size:9pt\">%1</span>");
194   -
195   - int remainingTime = qMax(0, autocook.remainingTime());
196   - if (remainingTime != lastViewTime)
  196 + if (!autocook.done())
197 197 {
198   - lastViewTime = remainingTime;
199   -
200   - QString hour = spanFontSize11.arg("시간");
201   - QString min = spanFontSize11.arg("분");
202   - QString sec = spanFontSize11.arg("초");
203   -
204   - if (remainingTime >= 3600)
205   - ui->timeLabel->setText(QString("%1%2 %3%4")
206   - .arg(remainingTime / 3600)
207   - .arg(hour)
208   - .arg((remainingTime % 3600) / 60, 2, 10, QLatin1Char('0'))
209   - .arg(min));
210   - else if (remainingTime >= 60)
211   - ui->timeLabel->setText(QString("%1%2 %3%4")
212   - .arg(remainingTime / 60)
213   - .arg(min)
214   - .arg(remainingTime % 60, 2, 10, QLatin1Char('0'))
215   - .arg(sec));
216   - else
217   - ui->timeLabel->setText(QString("%1%2")
218   - .arg(remainingTime)
219   - .arg(sec));
  198 + int remainingTime = qMax(0, autocook.msecs());
  199 + ui->timeLabel->setText(Stringer::remainingTime(remainingTime));
220 200 }
221 201  
222 202 int coreTemp = oven->currentInterTemp();
223 203 if (coreTemp != lastViewCoreTemp)
224 204 {
225 205 lastViewCoreTemp = coreTemp;
226   -
227   - QString coreTempLabel = QString::number(coreTemp);
228 206 if (cook.isCoreTempValid())
229   - coreTempLabel += spanFontSize11.arg("℃ / " + QString::number(cook.coreTemp())) + spanFontSize9.arg("℃");
  207 + ui->interTempLabel->setText(Stringer::temperature(coreTemp, cook.coreTemp(), Stringer::fontSize14));
230 208 else
231   - coreTempLabel += spanFontSize11.arg("℃");
232   -
233   - ui->interTempLabel->setText(coreTempLabel);
  209 + ui->interTempLabel->setText(Stringer::temperature(coreTemp, Stringer::fontSize14));
234 210 }
235 211  
236 212 if (autocook.done())
... ... @@ -523,7 +499,7 @@ void AutoCookWindow::updateView()
523 499 if (temp != lastViewTemp)
524 500 {
525 501 lastViewTemp = temp;
526   - ui->heatLabel->setText(QString("%1℃").arg(temp));
  502 + ui->heatLabel->setText(Stringer::temperature(temp));
527 503 ui->heatGauge->setValue(temp);
528 504 }
529 505 }
... ...
app/gui/oven_control/autocookwindow.h
... ... @@ -53,6 +53,7 @@ private:
53 53 Define::Process selectedProcess;
54 54 QTimer checkProcessTimer;
55 55  
  56 + QTimer updateViewTimer;
56 57  
57 58 void setupUi();
58 59  
... ...
app/gui/oven_control/cooldownpopup.cpp
1 1 #include "cooldownpopup.h"
2 2 #include "ui_cooldownpopup.h"
3 3  
  4 +#include "stringer.h"
  5 +
4 6 CooldownPopup::CooldownPopup(QWidget *parent, Oven *oven) :
5 7 QWidget(parent),
6 8 ui(new Ui::CooldownPopup),
... ... @@ -11,6 +13,9 @@ CooldownPopup::CooldownPopup(QWidget *parent, Oven *oven) :
11 13  
12 14 setAttribute(Qt::WA_DeleteOnClose);
13 15  
  16 + lastDisplayedFanLevel = -1;
  17 + lastDisplayedHumidification = !oven->humidification();
  18 +
14 19 ui->openDoorAnimation->load(":/images/animation/door_big_01.png");
15 20 ui->openDoorAnimation->load(":/images/animation/door_big_02.png");
16 21 ui->openDoorAnimation->load(":/images/animation/door_big_03.png");
... ... @@ -86,31 +91,41 @@ void CooldownPopup::updateView()
86 91 else
87 92 temp = ui->tempSlider->value();
88 93  
89   - ui->tempCurrentLabel->setText(QString("%1<span style=\"font-size:11pt;\">℃</span>").arg(temp));
  94 + ui->tempCurrentLabel->setText(Stringer::temperature(temp, Stringer::fontSize14));
90 95  
91   - switch (expectingFanLevel)
  96 + if (lastDisplayedFanLevel != expectingFanLevel)
92 97 {
93   - case 1:
94   - ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan1.png);");
95   - break;
96   - case 2:
97   - ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan2.png);");
98   - break;
99   - case 3:
100   - ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan3.png);");
101   - break;
102   - case 4:
103   - ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan4.png);");
104   - break;
105   - case 5:
106   - ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan5.png);");
107   - break;
  98 + lastDisplayedFanLevel = expectingFanLevel;
  99 +
  100 + switch (expectingFanLevel)
  101 + {
  102 + case 1:
  103 + ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan1.png);");
  104 + break;
  105 + case 2:
  106 + ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan2.png);");
  107 + break;
  108 + case 3:
  109 + ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan3.png);");
  110 + break;
  111 + case 4:
  112 + ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan4.png);");
  113 + break;
  114 + case 5:
  115 + ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan5.png);");
  116 + break;
  117 + }
108 118 }
109 119  
110   - if (oven->humidification())
111   - ui->humidificationButton->setStyleSheet("background-image: url(:/images/cooldown/side_nozzle_ov.png);");
112   - else
113   - ui->humidificationButton->setStyleSheet("background-image: url(:/images/cooldown/side_nozzle.png);");
  120 + if (lastDisplayedHumidification != oven->humidification())
  121 + {
  122 + lastDisplayedHumidification = oven->humidification();
  123 +
  124 + if (oven->humidification())
  125 + ui->humidificationButton->setStyleSheet("background-image: url(:/images/cooldown/side_nozzle_ov.png);");
  126 + else
  127 + ui->humidificationButton->setStyleSheet("background-image: url(:/images/cooldown/side_nozzle.png);");
  128 + }
114 129  
115 130 if (started && !oven->door())
116 131 ui->openDoorWidget->show();
... ...
app/gui/oven_control/cooldownpopup.h
... ... @@ -53,6 +53,9 @@ private:
53 53 int expectingFanLevel;
54 54 bool started;
55 55 bool opened;
  56 +
  57 + int lastDisplayedFanLevel;
  58 + bool lastDisplayedHumidification;
56 59 };
57 60  
58 61 #endif // COOLDOWNPOPUP_H
... ...
app/gui/oven_control/manualcooksettingwidget.cpp
1 1 #include "manualcooksettingwidget.h"
2 2 #include "ui_manualcooksettingwidget.h"
3 3  
  4 +#include "stringer.h"
  5 +
4 6 ManualCookSettingWidget::ManualCookSettingWidget(ManualCookSetting setting, QWidget *parent) :
5 7 QWidget(parent),
6 8 ui(new Ui::ManualCookSettingWidget)
... ... @@ -49,25 +51,13 @@ void ManualCookSettingWidget::setHumidity(int percentage)
49 51 void ManualCookSettingWidget::setTemp(int celsius)
50 52 {
51 53 ui->tempSlider->setValue(celsius);
52   - ui->tempLabel->setText(QString("%1<span style=\"font-size:11pt;\">℃</span>").arg(celsius));
  54 + ui->tempLabel->setText(Stringer::temperature(celsius, Stringer::fontSize14));
53 55 }
54 56  
55 57 void ManualCookSettingWidget::setTime(int secs)
56 58 {
57 59 ui->timeSlider->setValue(secs);
58   -
59   - if (secs >= 3600)
60   - ui->timeLabel->setText(
61   - QString("%1<span style=\"font-size:11pt;\">시간</span> %2<span style=\"font-size:11pt;\">분</span>")
62   - .arg(secs / 3600)
63   - .arg((secs % 3600) / 60, 2, 10, QLatin1Char('0')));
64   - else if (secs >= 60)
65   - ui->timeLabel->setText(
66   - QString("%1<span style=\"font-size:11pt;\">분</span> %2<span style=\"font-size:11pt;\">초</span>")
67   - .arg(secs / 60)
68   - .arg(secs % 60, 2, 10, QLatin1Char('0')));
69   - else
70   - ui->timeLabel->setText(QString("%1<span style=\"font-size:11pt;\">초</span>").arg(secs));
  60 + ui->timeLabel->setText(Stringer::remainingTime(secs * 1000, Stringer::fontSize14));
71 61 }
72 62  
73 63 void ManualCookSettingWidget::setCoreTempEnabled(bool enabled)
... ... @@ -76,16 +66,16 @@ void ManualCookSettingWidget::setCoreTempEnabled(bool enabled)
76 66 ui->coreTempSlider->setEnabled(enabled);
77 67  
78 68 if (enabled)
79   - ui->coreTempLabel->setText(QString("%1<span style=\"font-size:11pt;\">℃</span>").arg(ui->coreTempSlider->value()));
  69 + ui->coreTempLabel->setText(Stringer::temperature(ui->coreTempSlider->value(), Stringer::fontSize14));
80 70 else
81   - ui->coreTempLabel->setText("<span style=\"font-size:11pt;\">℃</span>");
  71 + ui->coreTempLabel->setText(Stringer::unusedTemperature(Stringer::fontSize14));
82 72 }
83 73  
84 74 void ManualCookSettingWidget::setCoreTemp(int celsius)
85 75 {
86 76 ui->coreTempSlider->setValue(celsius);
87 77 if (ui->coreTempSlider->isEnabled())
88   - ui->coreTempLabel->setText(QString("%1<span style=\"font-size:11pt;\">℃</span>").arg(celsius));
  78 + ui->coreTempLabel->setText(Stringer::temperature(celsius, Stringer::fontSize14));
89 79 }
90 80  
91 81 void ManualCookSettingWidget::setFan(int level)
... ...
app/gui/oven_control/manualcookwindow.cpp
... ... @@ -10,9 +10,34 @@
10 10 #include "cookhistory.h"
11 11 #include "favoritenamepopup.h"
12 12 #include "confirmpopup.h"
  13 +#include "stringer.h"
  14 +#include "config.h"
13 15  
14 16 #include <QTime>
15 17  
  18 +namespace {
  19 +
  20 +enum TemperatureFormat { Celsius, Fahrenheit };
  21 +TemperatureFormat temperatureFormat()
  22 +{
  23 + Define::config_item item = Config::getInstance()->getConfigValue(Define::config_temptype);
  24 + switch (item.d32)
  25 + {
  26 + case Define::temp_type_f:
  27 + return Fahrenheit;
  28 + case Define::temp_type_c:
  29 + default:
  30 + return Celsius;
  31 + }
  32 +}
  33 +
  34 +int toFahrenheit(int celsius)
  35 +{
  36 + return celsius * 1.8 + 32;
  37 +}
  38 +
  39 +}
  40 +
16 41 ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) :
17 42 QMainWindow(parent),
18 43 ui(new Ui::ManualCookWindow)
... ... @@ -66,6 +91,23 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) :
66 91 oven->setDefault(mode);
67 92  
68 93 setupAnimationTimer->start(0);
  94 +
  95 + checkTimeTimer.start();
  96 +
  97 + switch (temperatureFormat())
  98 + {
  99 + case Fahrenheit:
  100 + ui->steamLabel_12->setText("℉");
  101 + ui->steamLabel_13->setText("℉");
  102 + break;
  103 + case Celsius:
  104 + ui->steamLabel_12->setText("℃");
  105 + ui->steamLabel_13->setText("℃");
  106 + break;
  107 + default:
  108 + ui->steamLabel_12->hide();
  109 + ui->steamLabel_13->hide();
  110 + }
69 111 }
70 112  
71 113 ManualCookWindow::ManualCookWindow(QWidget *parent, ManualCookSetting setting)
... ... @@ -104,7 +146,7 @@ void ManualCookWindow::setupAnimation()
104 146  
105 147 void ManualCookWindow::checkTime()
106 148 {
107   - if (oven->cooking() && !ui->timeSlider->isSliderDown())
  149 + if (!ui->timeSlider->isSliderDown())
108 150 {
109 151 bool old = ui->timeSlider->blockSignals(true);
110 152 ui->timeSlider->setSliderPosition(oven->time());
... ... @@ -160,20 +202,15 @@ void ManualCookWindow::updateLabels()
160 202 else
161 203 temp = oven->temp();
162 204  
163   - ui->tempLabel->setText(buf.sprintf("%d<span style=\"font-size:11pt;\">℃</span>", temp));
  205 + ui->tempLabel->setText(Stringer::temperature(temp, Stringer::fontSize14));
164 206  
165   - int time;
  207 + int msecs;
166 208 if (ui->timeSlider->isSliderDown())
167   - time = ui->timeSlider->sliderPosition();
  209 + msecs = ui->timeSlider->sliderPosition() * 1000;
168 210 else
169   - time = oven->time();
  211 + msecs = oven->msecs();
170 212  
171   - if (time >= 3600)
172   - ui->timeLabel->setText(buf.sprintf("%d<span style=\"font-size:11pt;\">시간</span> %02d<span style=\"font-size:11pt;\">분</span>", time / 3600, (time % 3600) / 60));
173   - else if (time >= 60)
174   - ui->timeLabel->setText(buf.sprintf("%d<span style=\"font-size:11pt;\">분</span> %02d<span style=\"font-size:11pt;\">초</span>", time / 60, time % 60));
175   - else
176   - ui->timeLabel->setText(buf.sprintf("%d<span style=\"font-size:11pt;\">초</span>", time));
  213 + ui->timeLabel->setText(Stringer::remainingTime(msecs, Stringer::fontSize14));
177 214  
178 215 if (oven->interTempEnabled())
179 216 {
... ... @@ -183,23 +220,29 @@ void ManualCookWindow::updateLabels()
183 220 else
184 221 interTemp = oven->interTemp();
185 222  
186   - ui->interTempLabel->setText(buf.sprintf("%d<span style=\"font-size:11pt;\">℃</span>", interTemp));
  223 + ui->interTempLabel->setText(Stringer::temperature(interTemp, Stringer::fontSize14));
187 224 }
188 225 else
189   - ui->interTempLabel->setText("<span style=\"font-size:11pt;\">℃</span>");
  226 + ui->interTempLabel->setText(Stringer::unusedTemperature(Stringer::fontSize14));
190 227  
191 228 int innerInterTemp = ui->innerInterTempSlider->sliderPosition();
192   -// if (ui->innerInterTempSlider->isSliderDown())
193   -// innerInterTemp = ui->innerInterTempSlider->sliderPosition();
194   -// else
195   -// innerInterTemp = oven->interTemp();
196   -
197   - ui->innerInterTempLabel->setText(buf.sprintf("%d<span style=\"font-size:11pt;\">℃</span>", innerInterTemp));
  229 + ui->innerInterTempLabel->setText(Stringer::temperature(innerInterTemp, Stringer::fontSize14));
198 230  
199 231 ui->curHumidityLabel->setText(buf.sprintf("%d", oven->currentHumidity()));
200 232 ui->targetHumidityLabel->setText(buf.sprintf("%d", oven->humidity()));
201   - ui->curTempLabel->setText(buf.sprintf("%d", oven->currentTemp()));
202   - ui->curInterTempLabel->setText(buf.sprintf("%d", oven->currentInterTemp()));
  233 +
  234 + switch (temperatureFormat())
  235 + {
  236 + case Fahrenheit:
  237 + ui->curTempLabel->setText(QString::number(toFahrenheit(oven->currentTemp())));
  238 + ui->curInterTempLabel->setText(QString::number(toFahrenheit(oven->currentInterTemp())));
  239 + break;
  240 + case Celsius:
  241 + default:
  242 + ui->curTempLabel->setText(QString::number(oven->currentTemp()));
  243 + ui->curInterTempLabel->setText(QString::number(oven->currentInterTemp()));
  244 + break;
  245 + }
203 246 }
204 247  
205 248 void ManualCookWindow::onOvenUpdated(Oven *oven)
... ... @@ -339,7 +382,6 @@ void ManualCookWindow::start()
339 382 startCookingTimer.stop();
340 383  
341 384 oven->startCooking();
342   - checkTimeTimer.start();
343 385  
344 386 ManualCookSetting s;
345 387 s.mode = oven->mode();
... ... @@ -358,7 +400,6 @@ void ManualCookWindow::stop()
358 400 {
359 401 oven->stop();
360 402 startCookingTimer.stop();
361   - checkTimeTimer.stop();
362 403 }
363 404  
364 405 void ManualCookWindow::on_steamButton_clicked()
... ...
app/gui/oven_control/oven.cpp
... ... @@ -268,6 +268,19 @@ bool Oven::isInterTempValid()
268 268 return isInterTempValid_ && interTempValidTime.elapsed() > 3000;
269 269 }
270 270  
  271 +int Oven::msecs()
  272 +{
  273 + int left = cookingTimer.remainingTime();
  274 + int interval = cookingTimer.interval();
  275 + if (left > interval)
  276 + left = interval;
  277 +
  278 + if (cooking())
  279 + return left;
  280 +
  281 + return time_ * 1000;
  282 +}
  283 +
271 284 bool Oven::cookingStartable()
272 285 {
273 286 if (/*door() || */cooking() || time() <= 0)
... ...
app/gui/oven_control/oven.h
... ... @@ -136,6 +136,7 @@ public:
136 136 int currentInterTemp() { return currentInterTemp_; }
137 137  
138 138 bool isInterTempValid();
  139 + int msecs();
139 140  
140 141 bool cookingStartable();
141 142 bool preheatingStartable();
... ...
app/gui/oven_control/oven_control.pro
... ... @@ -85,7 +85,8 @@ SOURCES += main.cpp\
85 85 autocooksettingwidget.cpp \
86 86 favoritenamepopup.cpp \
87 87 confirmpopup.cpp \
88   - usbcheckpopupdlg.cpp
  88 + usbcheckpopupdlg.cpp \
  89 + stringer.cpp
89 90  
90 91 HEADERS += mainwindow.h \
91 92 cook.h \
... ... @@ -160,7 +161,8 @@ HEADERS += mainwindow.h \
160 161 autocooksettingwidget.h \
161 162 favoritenamepopup.h \
162 163 confirmpopup.h \
163   - usbcheckpopupdlg.h
  164 + usbcheckpopupdlg.h \
  165 + stringer.h
164 166  
165 167 FORMS += mainwindow.ui \
166 168 manualcookwindow.ui \
... ...
app/gui/oven_control/preheatpopup.cpp
1 1 #include "preheatpopup.h"
2 2 #include "ui_preheatpopup.h"
3 3  
  4 +#include "stringer.h"
  5 +
4 6 PreheatPopup::PreheatPopup(QWidget *parent, Oven *oven) :
5 7 QWidget(parent),
6 8 ui(new Ui::PreheatPopup),
... ... @@ -36,22 +38,13 @@ PreheatPopup::~PreheatPopup()
36 38  
37 39 void PreheatPopup::updateView()
38 40 {
39   - int time = oven->time();
40   - if (time >= 3600)
41   - ui->timeLabel->setText(QString().sprintf("%d<span style=\"font-size:11pt;\">시간</span> %02d<span style=\"font-size:11pt;\">분</span>", time / 3600, (time % 3600) / 60));
42   - else if (time >= 60)
43   - ui->timeLabel->setText(QString().sprintf("%d<span style=\"font-size:11pt;\">분</span> %02d<span style=\"font-size:11pt;\">초</span>", time / 60, time % 60));
44   - else
45   - ui->timeLabel->setText(QString().sprintf("%d<span style=\"font-size:11pt;\">초</span>", time));
  41 + ui->timeLabel->setText(Stringer::remainingTime(oven->time(), Stringer::fontSize14));
46 42  
47 43 int curInterTemp = oven->currentInterTemp();
48 44 if (oven->interTempEnabled())
49   - {
50   - int interTemp = oven->interTemp();
51   - ui->interTempLabel->setText(QString().sprintf("%d<span style=\"font-size:11pt;\">℃ / %d</span><span style=\"font-size:9pt;\">℃</span>", curInterTemp, interTemp));
52   - }
  45 + ui->interTempLabel->setText(Stringer::temperature(curInterTemp, oven->interTemp(), Stringer::fontSize14));
53 46 else
54   - ui->interTempLabel->setText(QString().sprintf("%d<span style=\"font-size:11pt;\">℃</span>", curInterTemp));
  47 + ui->interTempLabel->setText(Stringer::temperature(curInterTemp, Stringer::fontSize14));
55 48  
56 49 int humidity;
57 50 if (showingCurrentHumidity)
... ... @@ -67,7 +60,7 @@ void PreheatPopup::updateView()
67 60  
68 61 ui->humidityLabel->setText(QString().sprintf("%d%%", humidity));
69 62 ui->humidityGauge->setValue(humidity);
70   - ui->heatLabel->setText(QString().sprintf("%d℃", temp));
  63 + ui->heatLabel->setText(Stringer::temperature(temp));
71 64 ui->heatGauge->setValue(temp);
72 65  
73 66 ui->preheatGauge->setValue(oven->currentTemp());
... ...
app/gui/oven_control/stringer.cpp
... ... @@ -0,0 +1,162 @@
  1 +#include "stringer.h"
  2 +
  3 +#include "config.h"
  4 +
  5 +namespace {
  6 +QString heavySpan("<span class=\"heavy\">%1</span>");
  7 +QString lightSpan("<span class=\"light\">%1</span>");
  8 +QString lightestSpan("<span class=\"lightest\">%1</span>");
  9 +
  10 +enum RemainingTimeFormat { RemainingTime, FinishTime };
  11 +RemainingTimeFormat remainingTime()
  12 +{
  13 + Define::config_item item = Config::getInstance()->getConfigValue(Define::config_resttime_format);
  14 + switch (item.d32)
  15 + {
  16 + case Define::rest_time_target:
  17 + return FinishTime;
  18 + case Define::rest_time_rest:
  19 + default:
  20 + return RemainingTime;
  21 + }
  22 +}
  23 +
  24 +enum TemperatureFormat { Celsius, Fahrenheit };
  25 +TemperatureFormat temperatureFormat()
  26 +{
  27 + Define::config_item item = Config::getInstance()->getConfigValue(Define::config_temptype);
  28 + switch (item.d32)
  29 + {
  30 + case Define::temp_type_f:
  31 + return Fahrenheit;
  32 + case Define::temp_type_c:
  33 + default:
  34 + return Celsius;
  35 + }
  36 +}
  37 +
  38 +int toFahrenheit(int celsius)
  39 +{
  40 + return celsius * 1.8 + 32;
  41 +}
  42 +}
  43 +
  44 +QString Stringer::remainingTime(int msecs)
  45 +{
  46 + switch (::remainingTime())
  47 + {
  48 + case RemainingTime:
  49 + msecs /= 1000;
  50 + if (msecs >= 3600)
  51 + return QString("%1시간 %2분").arg(msecs / 3600).arg((msecs % 3600) / 60, 2, 10, QLatin1Char('0'));
  52 + if (msecs >= 60)
  53 + return QString("%1분 %2초").arg(msecs / 60).arg(msecs % 60, 2, 10, QLatin1Char('0'));
  54 +
  55 + return QString("%1초").arg(msecs);
  56 + case FinishTime:
  57 + return QDateTime::currentDateTime().addMSecs(msecs).toString("HH:mm:ss");
  58 + }
  59 +
  60 + return QString();
  61 +}
  62 +
  63 +QString Stringer::remainingTime(int msecs, QString style)
  64 +{
  65 + switch (::remainingTime())
  66 + {
  67 + case RemainingTime:
  68 + msecs /= 1000;
  69 + if (msecs >= 3600)
  70 + {
  71 + QString hour = heavySpan.arg(msecs / 3600) + lightSpan.arg("시간");
  72 + QString min = heavySpan.arg((msecs % 3600) / 60, 2, 10, QLatin1Char('0')) + lightSpan.arg("분");
  73 +
  74 + return style + QString("%1 %2").arg(hour).arg(min);
  75 + }
  76 + if (msecs >= 60)
  77 + {
  78 + QString min = heavySpan.arg(msecs / 60) + lightSpan.arg("분");
  79 + QString sec = heavySpan.arg(msecs % 60, 2, 10, QLatin1Char('0')) + lightSpan.arg("초");
  80 +
  81 + return style + QString("%1 %2").arg(min).arg(sec);
  82 + }
  83 +
  84 + return style + heavySpan.arg(msecs) + lightSpan.arg("초");
  85 + case FinishTime:
  86 + return heavySpan.arg(QDateTime::currentDateTime().addMSecs(msecs).toString("HH:mm:ss"));
  87 + }
  88 +
  89 + return QString();
  90 +}
  91 +
  92 +QString Stringer::temperature(int celsius)
  93 +{
  94 + switch (temperatureFormat())
  95 + {
  96 + case Fahrenheit:
  97 + return QString("%1℉").arg(toFahrenheit(celsius));
  98 + case Celsius:
  99 + default:
  100 + return QString("%1℃").arg(celsius);
  101 + }
  102 +}
  103 +
  104 +QString Stringer::temperature(int celsius, QString style)
  105 +{
  106 + switch (temperatureFormat())
  107 + {
  108 + case Fahrenheit:
  109 + return style + heavySpan.arg(toFahrenheit(celsius)) + lightSpan.arg("℉");
  110 + case Celsius:
  111 + default:
  112 + return style + heavySpan.arg(celsius) + lightSpan.arg("℃");
  113 + }
  114 +}
  115 +
  116 +QString Stringer::temperature(int current, int target)
  117 +{
  118 + switch (temperatureFormat())
  119 + {
  120 + case Fahrenheit:
  121 + return QString("%1℉ / %2℉").arg(toFahrenheit(current)).arg(toFahrenheit(target));
  122 + case Celsius:
  123 + default:
  124 + return QString("%1℃ / %2℃").arg(current).arg(target);
  125 + }
  126 +}
  127 +
  128 +QString Stringer::temperature(int current, int target, QString style)
  129 +{
  130 + switch (temperatureFormat())
  131 + {
  132 + case Fahrenheit:
  133 + return style + heavySpan.arg(toFahrenheit(current)) + lightSpan.arg(QString("℉ / %1").arg(toFahrenheit(target))) + lightestSpan.arg("℉");
  134 + case Celsius:
  135 + default:
  136 + return style + heavySpan.arg(current) + lightSpan.arg(QString("℃ / %1").arg(target)) + lightestSpan.arg("℃");
  137 + }
  138 +}
  139 +
  140 +QString Stringer::unusedTemperature()
  141 +{
  142 + switch (temperatureFormat())
  143 + {
  144 + case Fahrenheit:
  145 + return QString("℉");
  146 + case Celsius:
  147 + default:
  148 + return QString("℃");
  149 + }
  150 +}
  151 +
  152 +QString Stringer::unusedTemperature(QString style)
  153 +{
  154 + switch (temperatureFormat())
  155 + {
  156 + case Fahrenheit:
  157 + return style + lightSpan.arg("℉");
  158 + case Celsius:
  159 + default:
  160 + return style + lightSpan.arg("℃");
  161 + }
  162 +}
... ...
app/gui/oven_control/stringer.h
... ... @@ -0,0 +1,26 @@
  1 +#ifndef STRINGER_H
  2 +#define STRINGER_H
  3 +
  4 +
  5 +#include <QtCore>
  6 +
  7 +namespace Stringer {
  8 +const QString fontSize14("\
  9 +<style>\
  10 +span { font-size: 14pt; }\
  11 +span.heavy { font-size: 16pt; }\
  12 +span.light { font-size: 11pt; }\
  13 +span.lightest { font-size: 9pt; }\
  14 +</style>");
  15 +
  16 +QString remainingTime(int secs);
  17 +QString remainingTime(int secs, QString style);
  18 +QString temperature(int celsius);
  19 +QString temperature(int celsius, QString style);
  20 +QString temperature(int current, int target);
  21 +QString temperature(int current, int target, QString style);
  22 +QString unusedTemperature();
  23 +QString unusedTemperature(QString style);
  24 +}
  25 +
  26 +#endif // STRINGER_H
... ...