diff --git a/app/gui/oven_control/autocook.cpp b/app/gui/oven_control/autocook.cpp
index 301e039..5e6f044 100644
--- a/app/gui/oven_control/autocook.cpp
+++ b/app/gui/oven_control/autocook.cpp
@@ -521,3 +521,31 @@ int AutoCook::remainingTime()
return t / 1000;
}
}
+
+int AutoCook::msecs()
+{
+ if (done_)
+ {
+ return 0;
+ }
+ else if (checkingCoreTemp && currentStepIndex + 1 >= cook.steps.size())
+ {
+ CookStep &step = cook.steps[cook.steps.size() - 1];
+ int t = step.time;
+ if (!doorOpened)
+ t -= lastCoreTempIncreasedTime.elapsed();
+
+ return t;
+ }
+ else
+ {
+ int t = 0;
+ for (int i = currentStepIndex; i < cook.steps.size(); i++)
+ t += cook.steps[i].time;
+
+ if (!doorOpened && Define::classify(cook.steps[currentStepIndex].type) == Define::CookClass)
+ t -= stepStartTime.elapsed();
+
+ return t;
+ }
+}
diff --git a/app/gui/oven_control/autocook.h b/app/gui/oven_control/autocook.h
index 3788089..5ec435e 100644
--- a/app/gui/oven_control/autocook.h
+++ b/app/gui/oven_control/autocook.h
@@ -19,6 +19,8 @@ public:
bool isWaitingDoorOpened() { return isWaitingDoorOpened_; }
bool done() { return done_; }
+ int msecs();
+
Cook cook;
int currentStepIndex;
diff --git a/app/gui/oven_control/autocookconfigwindow.cpp b/app/gui/oven_control/autocookconfigwindow.cpp
index fa2ead5..0cfce9e 100644
--- a/app/gui/oven_control/autocookconfigwindow.cpp
+++ b/app/gui/oven_control/autocookconfigwindow.cpp
@@ -3,6 +3,7 @@
#include "autocookwindow.h"
#include "confirmpopup.h"
+#include "stringer.h"
#include "favoritenamepopup.h"
AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Cook cook) :
@@ -129,10 +130,6 @@ void AutoCookConfigWindow::setupUi()
break;
}
-// cw.slider->style()->unpolish(cw.slider);
-// cw.slider->style()->polish(cw.slider);
-// cw.slider->update();
-
connect(cw.slider, SIGNAL(valueChanged(int)), SLOT(updateConfig()));
}
}
@@ -153,36 +150,10 @@ void AutoCookConfigWindow::updateView()
switch (config.type)
{
case Define::Time:
- {
- int time = cook.time();
- if (time >= 3600)
- cw.current->setText(QString().sprintf(
- "%d"
- "시간"
- " %02d"
- "분",
- time / 3600,
- (time % 3600) / 60));
- else if (time >= 60)
- cw.current->setText(QString().sprintf(
- "%d"
- "분"
- " %02d"
- "초",
- time / 60,
- time % 60));
- else
- cw.current->setText(QString().sprintf(
- "%d"
- "초",
- time));
+ cw.current->setText(Stringer::remainingTime(cook.time() * 1000, Stringer::fontSize14));
break;
- }
case Define::BurnDegree:
- cw.current->setText(QString().sprintf(
- "%d"
- "℃",
- cook.coreTemp()));
+ cw.current->setText(Stringer::temperature(cook.coreTemp(), Stringer::fontSize14));
break;
default:
cw.current->setText(QString().sprintf(
diff --git a/app/gui/oven_control/autocooksettingwidget.cpp b/app/gui/oven_control/autocooksettingwidget.cpp
index f804925..293f23b 100644
--- a/app/gui/oven_control/autocooksettingwidget.cpp
+++ b/app/gui/oven_control/autocooksettingwidget.cpp
@@ -1,6 +1,7 @@
#include "autocooksettingwidget.h"
#include "ui_autocooksettingwidget.h"
+#include "stringer.h"
AutoCookSettingWidget::AutoCookSettingWidget(AutoCookSetting setting, QWidget *parent) :
QWidget(parent),
@@ -116,36 +117,10 @@ void AutoCookSettingWidget::setupUi(Cook cook)
switch (config.type)
{
case Define::Time:
- {
- int time = cook.time();
- if (time >= 3600)
- cw.current->setText(QString().sprintf(
- "%d"
- "시간"
- " %02d"
- "분",
- time / 3600,
- (time % 3600) / 60));
- else if (time >= 60)
- cw.current->setText(QString().sprintf(
- "%d"
- "분"
- " %02d"
- "초",
- time / 60,
- time % 60));
- else
- cw.current->setText(QString().sprintf(
- "%d"
- "초",
- time));
+ cw.current->setText(Stringer::remainingTime(cook.time() * 1000, Stringer::fontSize14));
break;
- }
case Define::BurnDegree:
- cw.current->setText(QString().sprintf(
- "%d"
- "℃",
- cook.coreTemp()));
+ cw.current->setText(Stringer::temperature(cook.coreTemp(), Stringer::fontSize14));
break;
default:
cw.current->setText(QString().sprintf(
diff --git a/app/gui/oven_control/autocookwindow.cpp b/app/gui/oven_control/autocookwindow.cpp
index f4f0dc5..742271b 100644
--- a/app/gui/oven_control/autocookwindow.cpp
+++ b/app/gui/oven_control/autocookwindow.cpp
@@ -5,6 +5,7 @@
#include "cookhistory.h"
#include "confirmpopup.h"
#include "favoritenamepopup.h"
+#include "stringer.h"
AutoCookWindow::AutoCookWindow(QWidget *parent, Cook cook) :
QMainWindow(parent),
@@ -53,6 +54,9 @@ AutoCookWindow::AutoCookWindow(QWidget *parent, Cook cook) :
setting.configs[i] = cook.configs[i].current;
CookHistory::record(setting);
+
+ connect(&updateViewTimer, SIGNAL(timeout()), SLOT(updateView()));
+ updateViewTimer.start(100);
}
AutoCookWindow::~AutoCookWindow()
@@ -189,48 +193,20 @@ void AutoCookWindow::updateView()
{
Oven *oven = Oven::getInstance();
- QString spanFontSize11("%1");
- QString spanFontSize9("%1");
-
- int remainingTime = qMax(0, autocook.remainingTime());
- if (remainingTime != lastViewTime)
+ if (!autocook.done())
{
- lastViewTime = remainingTime;
-
- QString hour = spanFontSize11.arg("시간");
- QString min = spanFontSize11.arg("분");
- QString sec = spanFontSize11.arg("초");
-
- if (remainingTime >= 3600)
- ui->timeLabel->setText(QString("%1%2 %3%4")
- .arg(remainingTime / 3600)
- .arg(hour)
- .arg((remainingTime % 3600) / 60, 2, 10, QLatin1Char('0'))
- .arg(min));
- else if (remainingTime >= 60)
- ui->timeLabel->setText(QString("%1%2 %3%4")
- .arg(remainingTime / 60)
- .arg(min)
- .arg(remainingTime % 60, 2, 10, QLatin1Char('0'))
- .arg(sec));
- else
- ui->timeLabel->setText(QString("%1%2")
- .arg(remainingTime)
- .arg(sec));
+ int remainingTime = qMax(0, autocook.msecs());
+ ui->timeLabel->setText(Stringer::remainingTime(remainingTime));
}
int coreTemp = oven->currentInterTemp();
if (coreTemp != lastViewCoreTemp)
{
lastViewCoreTemp = coreTemp;
-
- QString coreTempLabel = QString::number(coreTemp);
if (cook.isCoreTempValid())
- coreTempLabel += spanFontSize11.arg("℃ / " + QString::number(cook.coreTemp())) + spanFontSize9.arg("℃");
+ ui->interTempLabel->setText(Stringer::temperature(coreTemp, cook.coreTemp(), Stringer::fontSize14));
else
- coreTempLabel += spanFontSize11.arg("℃");
-
- ui->interTempLabel->setText(coreTempLabel);
+ ui->interTempLabel->setText(Stringer::temperature(coreTemp, Stringer::fontSize14));
}
if (autocook.done())
@@ -523,7 +499,7 @@ void AutoCookWindow::updateView()
if (temp != lastViewTemp)
{
lastViewTemp = temp;
- ui->heatLabel->setText(QString("%1℃").arg(temp));
+ ui->heatLabel->setText(Stringer::temperature(temp));
ui->heatGauge->setValue(temp);
}
}
diff --git a/app/gui/oven_control/autocookwindow.h b/app/gui/oven_control/autocookwindow.h
index e1882d5..6d840ae 100644
--- a/app/gui/oven_control/autocookwindow.h
+++ b/app/gui/oven_control/autocookwindow.h
@@ -53,6 +53,7 @@ private:
Define::Process selectedProcess;
QTimer checkProcessTimer;
+ QTimer updateViewTimer;
void setupUi();
diff --git a/app/gui/oven_control/cooldownpopup.cpp b/app/gui/oven_control/cooldownpopup.cpp
index c0f4349..38fd670 100644
--- a/app/gui/oven_control/cooldownpopup.cpp
+++ b/app/gui/oven_control/cooldownpopup.cpp
@@ -1,6 +1,8 @@
#include "cooldownpopup.h"
#include "ui_cooldownpopup.h"
+#include "stringer.h"
+
CooldownPopup::CooldownPopup(QWidget *parent, Oven *oven) :
QWidget(parent),
ui(new Ui::CooldownPopup),
@@ -11,6 +13,9 @@ CooldownPopup::CooldownPopup(QWidget *parent, Oven *oven) :
setAttribute(Qt::WA_DeleteOnClose);
+ lastDisplayedFanLevel = -1;
+ lastDisplayedHumidification = !oven->humidification();
+
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");
@@ -86,31 +91,41 @@ void CooldownPopup::updateView()
else
temp = ui->tempSlider->value();
- ui->tempCurrentLabel->setText(QString("%1℃").arg(temp));
+ ui->tempCurrentLabel->setText(Stringer::temperature(temp, Stringer::fontSize14));
- switch (expectingFanLevel)
+ if (lastDisplayedFanLevel != 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;
+ 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;
+ }
}
- 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);");
+ 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);");
+ }
if (started && !oven->door())
ui->openDoorWidget->show();
diff --git a/app/gui/oven_control/cooldownpopup.h b/app/gui/oven_control/cooldownpopup.h
index 3a56cec..75eddcc 100644
--- a/app/gui/oven_control/cooldownpopup.h
+++ b/app/gui/oven_control/cooldownpopup.h
@@ -53,6 +53,9 @@ private:
int expectingFanLevel;
bool started;
bool opened;
+
+ int lastDisplayedFanLevel;
+ bool lastDisplayedHumidification;
};
#endif // COOLDOWNPOPUP_H
diff --git a/app/gui/oven_control/manualcooksettingwidget.cpp b/app/gui/oven_control/manualcooksettingwidget.cpp
index 5e6d506..34cf80a 100644
--- a/app/gui/oven_control/manualcooksettingwidget.cpp
+++ b/app/gui/oven_control/manualcooksettingwidget.cpp
@@ -1,6 +1,8 @@
#include "manualcooksettingwidget.h"
#include "ui_manualcooksettingwidget.h"
+#include "stringer.h"
+
ManualCookSettingWidget::ManualCookSettingWidget(ManualCookSetting setting, QWidget *parent) :
QWidget(parent),
ui(new Ui::ManualCookSettingWidget)
@@ -49,25 +51,13 @@ void ManualCookSettingWidget::setHumidity(int percentage)
void ManualCookSettingWidget::setTemp(int celsius)
{
ui->tempSlider->setValue(celsius);
- ui->tempLabel->setText(QString("%1℃").arg(celsius));
+ ui->tempLabel->setText(Stringer::temperature(celsius, Stringer::fontSize14));
}
void ManualCookSettingWidget::setTime(int secs)
{
ui->timeSlider->setValue(secs);
-
- if (secs >= 3600)
- ui->timeLabel->setText(
- QString("%1시간 %2분")
- .arg(secs / 3600)
- .arg((secs % 3600) / 60, 2, 10, QLatin1Char('0')));
- else if (secs >= 60)
- ui->timeLabel->setText(
- QString("%1분 %2초")
- .arg(secs / 60)
- .arg(secs % 60, 2, 10, QLatin1Char('0')));
- else
- ui->timeLabel->setText(QString("%1초").arg(secs));
+ ui->timeLabel->setText(Stringer::remainingTime(secs * 1000, Stringer::fontSize14));
}
void ManualCookSettingWidget::setCoreTempEnabled(bool enabled)
@@ -76,16 +66,16 @@ void ManualCookSettingWidget::setCoreTempEnabled(bool enabled)
ui->coreTempSlider->setEnabled(enabled);
if (enabled)
- ui->coreTempLabel->setText(QString("%1℃").arg(ui->coreTempSlider->value()));
+ ui->coreTempLabel->setText(Stringer::temperature(ui->coreTempSlider->value(), Stringer::fontSize14));
else
- ui->coreTempLabel->setText("℃");
+ ui->coreTempLabel->setText(Stringer::unusedTemperature(Stringer::fontSize14));
}
void ManualCookSettingWidget::setCoreTemp(int celsius)
{
ui->coreTempSlider->setValue(celsius);
if (ui->coreTempSlider->isEnabled())
- ui->coreTempLabel->setText(QString("%1℃").arg(celsius));
+ ui->coreTempLabel->setText(Stringer::temperature(celsius, Stringer::fontSize14));
}
void ManualCookSettingWidget::setFan(int level)
diff --git a/app/gui/oven_control/manualcookwindow.cpp b/app/gui/oven_control/manualcookwindow.cpp
index d689c9f..00d367c 100644
--- a/app/gui/oven_control/manualcookwindow.cpp
+++ b/app/gui/oven_control/manualcookwindow.cpp
@@ -10,9 +10,34 @@
#include "cookhistory.h"
#include "favoritenamepopup.h"
#include "confirmpopup.h"
+#include "stringer.h"
+#include "config.h"
#include
+namespace {
+
+enum TemperatureFormat { Celsius, Fahrenheit };
+TemperatureFormat temperatureFormat()
+{
+ Define::config_item item = Config::getInstance()->getConfigValue(Define::config_temptype);
+ switch (item.d32)
+ {
+ case Define::temp_type_f:
+ return Fahrenheit;
+ case Define::temp_type_c:
+ default:
+ return Celsius;
+ }
+}
+
+int toFahrenheit(int celsius)
+{
+ return celsius * 1.8 + 32;
+}
+
+}
+
ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) :
QMainWindow(parent),
ui(new Ui::ManualCookWindow)
@@ -66,6 +91,23 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) :
oven->setDefault(mode);
setupAnimationTimer->start(0);
+
+ checkTimeTimer.start();
+
+ switch (temperatureFormat())
+ {
+ case Fahrenheit:
+ ui->steamLabel_12->setText("℉");
+ ui->steamLabel_13->setText("℉");
+ break;
+ case Celsius:
+ ui->steamLabel_12->setText("℃");
+ ui->steamLabel_13->setText("℃");
+ break;
+ default:
+ ui->steamLabel_12->hide();
+ ui->steamLabel_13->hide();
+ }
}
ManualCookWindow::ManualCookWindow(QWidget *parent, ManualCookSetting setting)
@@ -104,7 +146,7 @@ void ManualCookWindow::setupAnimation()
void ManualCookWindow::checkTime()
{
- if (oven->cooking() && !ui->timeSlider->isSliderDown())
+ if (!ui->timeSlider->isSliderDown())
{
bool old = ui->timeSlider->blockSignals(true);
ui->timeSlider->setSliderPosition(oven->time());
@@ -160,20 +202,15 @@ void ManualCookWindow::updateLabels()
else
temp = oven->temp();
- ui->tempLabel->setText(buf.sprintf("%d℃", temp));
+ ui->tempLabel->setText(Stringer::temperature(temp, Stringer::fontSize14));
- int time;
+ int msecs;
if (ui->timeSlider->isSliderDown())
- time = ui->timeSlider->sliderPosition();
+ msecs = ui->timeSlider->sliderPosition() * 1000;
else
- time = oven->time();
+ msecs = oven->msecs();
- if (time >= 3600)
- ui->timeLabel->setText(buf.sprintf("%d시간 %02d분", time / 3600, (time % 3600) / 60));
- else if (time >= 60)
- ui->timeLabel->setText(buf.sprintf("%d분 %02d초", time / 60, time % 60));
- else
- ui->timeLabel->setText(buf.sprintf("%d초", time));
+ ui->timeLabel->setText(Stringer::remainingTime(msecs, Stringer::fontSize14));
if (oven->interTempEnabled())
{
@@ -183,23 +220,29 @@ void ManualCookWindow::updateLabels()
else
interTemp = oven->interTemp();
- ui->interTempLabel->setText(buf.sprintf("%d℃", interTemp));
+ ui->interTempLabel->setText(Stringer::temperature(interTemp, Stringer::fontSize14));
}
else
- ui->interTempLabel->setText("℃");
+ ui->interTempLabel->setText(Stringer::unusedTemperature(Stringer::fontSize14));
int innerInterTemp = ui->innerInterTempSlider->sliderPosition();
-// if (ui->innerInterTempSlider->isSliderDown())
-// innerInterTemp = ui->innerInterTempSlider->sliderPosition();
-// else
-// innerInterTemp = oven->interTemp();
-
- ui->innerInterTempLabel->setText(buf.sprintf("%d℃", innerInterTemp));
+ ui->innerInterTempLabel->setText(Stringer::temperature(innerInterTemp, Stringer::fontSize14));
ui->curHumidityLabel->setText(buf.sprintf("%d", oven->currentHumidity()));
ui->targetHumidityLabel->setText(buf.sprintf("%d", oven->humidity()));
- ui->curTempLabel->setText(buf.sprintf("%d", oven->currentTemp()));
- ui->curInterTempLabel->setText(buf.sprintf("%d", oven->currentInterTemp()));
+
+ switch (temperatureFormat())
+ {
+ case Fahrenheit:
+ ui->curTempLabel->setText(QString::number(toFahrenheit(oven->currentTemp())));
+ ui->curInterTempLabel->setText(QString::number(toFahrenheit(oven->currentInterTemp())));
+ break;
+ case Celsius:
+ default:
+ ui->curTempLabel->setText(QString::number(oven->currentTemp()));
+ ui->curInterTempLabel->setText(QString::number(oven->currentInterTemp()));
+ break;
+ }
}
void ManualCookWindow::onOvenUpdated(Oven *oven)
@@ -339,7 +382,6 @@ void ManualCookWindow::start()
startCookingTimer.stop();
oven->startCooking();
- checkTimeTimer.start();
ManualCookSetting s;
s.mode = oven->mode();
@@ -358,7 +400,6 @@ void ManualCookWindow::stop()
{
oven->stop();
startCookingTimer.stop();
- checkTimeTimer.stop();
}
void ManualCookWindow::on_steamButton_clicked()
diff --git a/app/gui/oven_control/oven.cpp b/app/gui/oven_control/oven.cpp
index 7af2828..2cd1cb4 100644
--- a/app/gui/oven_control/oven.cpp
+++ b/app/gui/oven_control/oven.cpp
@@ -268,6 +268,19 @@ bool Oven::isInterTempValid()
return isInterTempValid_ && interTempValidTime.elapsed() > 3000;
}
+int Oven::msecs()
+{
+ int left = cookingTimer.remainingTime();
+ int interval = cookingTimer.interval();
+ if (left > interval)
+ left = interval;
+
+ if (cooking())
+ return left;
+
+ return time_ * 1000;
+}
+
bool Oven::cookingStartable()
{
if (/*door() || */cooking() || time() <= 0)
diff --git a/app/gui/oven_control/oven.h b/app/gui/oven_control/oven.h
index 2b87f9f..e3ae49d 100644
--- a/app/gui/oven_control/oven.h
+++ b/app/gui/oven_control/oven.h
@@ -136,6 +136,7 @@ public:
int currentInterTemp() { return currentInterTemp_; }
bool isInterTempValid();
+ int msecs();
bool cookingStartable();
bool preheatingStartable();
diff --git a/app/gui/oven_control/oven_control.pro b/app/gui/oven_control/oven_control.pro
index 3d6d79f..ef691b3 100644
--- a/app/gui/oven_control/oven_control.pro
+++ b/app/gui/oven_control/oven_control.pro
@@ -85,7 +85,8 @@ SOURCES += main.cpp\
autocooksettingwidget.cpp \
favoritenamepopup.cpp \
confirmpopup.cpp \
- usbcheckpopupdlg.cpp
+ usbcheckpopupdlg.cpp \
+ stringer.cpp
HEADERS += mainwindow.h \
cook.h \
@@ -160,7 +161,8 @@ HEADERS += mainwindow.h \
autocooksettingwidget.h \
favoritenamepopup.h \
confirmpopup.h \
- usbcheckpopupdlg.h
+ usbcheckpopupdlg.h \
+ stringer.h
FORMS += mainwindow.ui \
manualcookwindow.ui \
diff --git a/app/gui/oven_control/preheatpopup.cpp b/app/gui/oven_control/preheatpopup.cpp
index 1030895..6660c41 100644
--- a/app/gui/oven_control/preheatpopup.cpp
+++ b/app/gui/oven_control/preheatpopup.cpp
@@ -1,6 +1,8 @@
#include "preheatpopup.h"
#include "ui_preheatpopup.h"
+#include "stringer.h"
+
PreheatPopup::PreheatPopup(QWidget *parent, Oven *oven) :
QWidget(parent),
ui(new Ui::PreheatPopup),
@@ -36,22 +38,13 @@ PreheatPopup::~PreheatPopup()
void PreheatPopup::updateView()
{
- int time = oven->time();
- if (time >= 3600)
- ui->timeLabel->setText(QString().sprintf("%d시간 %02d분", time / 3600, (time % 3600) / 60));
- else if (time >= 60)
- ui->timeLabel->setText(QString().sprintf("%d분 %02d초", time / 60, time % 60));
- else
- ui->timeLabel->setText(QString().sprintf("%d초", time));
+ ui->timeLabel->setText(Stringer::remainingTime(oven->time(), Stringer::fontSize14));
int curInterTemp = oven->currentInterTemp();
if (oven->interTempEnabled())
- {
- int interTemp = oven->interTemp();
- ui->interTempLabel->setText(QString().sprintf("%d℃ / %d℃", curInterTemp, interTemp));
- }
+ ui->interTempLabel->setText(Stringer::temperature(curInterTemp, oven->interTemp(), Stringer::fontSize14));
else
- ui->interTempLabel->setText(QString().sprintf("%d℃", curInterTemp));
+ ui->interTempLabel->setText(Stringer::temperature(curInterTemp, Stringer::fontSize14));
int humidity;
if (showingCurrentHumidity)
@@ -67,7 +60,7 @@ void PreheatPopup::updateView()
ui->humidityLabel->setText(QString().sprintf("%d%%", humidity));
ui->humidityGauge->setValue(humidity);
- ui->heatLabel->setText(QString().sprintf("%d℃", temp));
+ ui->heatLabel->setText(Stringer::temperature(temp));
ui->heatGauge->setValue(temp);
ui->preheatGauge->setValue(oven->currentTemp());
diff --git a/app/gui/oven_control/stringer.cpp b/app/gui/oven_control/stringer.cpp
new file mode 100644
index 0000000..17969fc
--- /dev/null
+++ b/app/gui/oven_control/stringer.cpp
@@ -0,0 +1,162 @@
+#include "stringer.h"
+
+#include "config.h"
+
+namespace {
+QString heavySpan("%1");
+QString lightSpan("%1");
+QString lightestSpan("%1");
+
+enum RemainingTimeFormat { RemainingTime, FinishTime };
+RemainingTimeFormat remainingTime()
+{
+ Define::config_item item = Config::getInstance()->getConfigValue(Define::config_resttime_format);
+ switch (item.d32)
+ {
+ case Define::rest_time_target:
+ return FinishTime;
+ case Define::rest_time_rest:
+ default:
+ return RemainingTime;
+ }
+}
+
+enum TemperatureFormat { Celsius, Fahrenheit };
+TemperatureFormat temperatureFormat()
+{
+ Define::config_item item = Config::getInstance()->getConfigValue(Define::config_temptype);
+ switch (item.d32)
+ {
+ case Define::temp_type_f:
+ return Fahrenheit;
+ case Define::temp_type_c:
+ default:
+ return Celsius;
+ }
+}
+
+int toFahrenheit(int celsius)
+{
+ return celsius * 1.8 + 32;
+}
+}
+
+QString Stringer::remainingTime(int msecs)
+{
+ switch (::remainingTime())
+ {
+ case RemainingTime:
+ msecs /= 1000;
+ if (msecs >= 3600)
+ return QString("%1시간 %2분").arg(msecs / 3600).arg((msecs % 3600) / 60, 2, 10, QLatin1Char('0'));
+ if (msecs >= 60)
+ return QString("%1분 %2초").arg(msecs / 60).arg(msecs % 60, 2, 10, QLatin1Char('0'));
+
+ return QString("%1초").arg(msecs);
+ case FinishTime:
+ return QDateTime::currentDateTime().addMSecs(msecs).toString("HH:mm:ss");
+ }
+
+ return QString();
+}
+
+QString Stringer::remainingTime(int msecs, QString style)
+{
+ switch (::remainingTime())
+ {
+ case RemainingTime:
+ msecs /= 1000;
+ if (msecs >= 3600)
+ {
+ QString hour = heavySpan.arg(msecs / 3600) + lightSpan.arg("시간");
+ QString min = heavySpan.arg((msecs % 3600) / 60, 2, 10, QLatin1Char('0')) + lightSpan.arg("분");
+
+ return style + QString("%1 %2").arg(hour).arg(min);
+ }
+ if (msecs >= 60)
+ {
+ QString min = heavySpan.arg(msecs / 60) + lightSpan.arg("분");
+ QString sec = heavySpan.arg(msecs % 60, 2, 10, QLatin1Char('0')) + lightSpan.arg("초");
+
+ return style + QString("%1 %2").arg(min).arg(sec);
+ }
+
+ return style + heavySpan.arg(msecs) + lightSpan.arg("초");
+ case FinishTime:
+ return heavySpan.arg(QDateTime::currentDateTime().addMSecs(msecs).toString("HH:mm:ss"));
+ }
+
+ return QString();
+}
+
+QString Stringer::temperature(int celsius)
+{
+ switch (temperatureFormat())
+ {
+ case Fahrenheit:
+ return QString("%1℉").arg(toFahrenheit(celsius));
+ case Celsius:
+ default:
+ return QString("%1℃").arg(celsius);
+ }
+}
+
+QString Stringer::temperature(int celsius, QString style)
+{
+ switch (temperatureFormat())
+ {
+ case Fahrenheit:
+ return style + heavySpan.arg(toFahrenheit(celsius)) + lightSpan.arg("℉");
+ case Celsius:
+ default:
+ return style + heavySpan.arg(celsius) + lightSpan.arg("℃");
+ }
+}
+
+QString Stringer::temperature(int current, int target)
+{
+ switch (temperatureFormat())
+ {
+ case Fahrenheit:
+ return QString("%1℉ / %2℉").arg(toFahrenheit(current)).arg(toFahrenheit(target));
+ case Celsius:
+ default:
+ return QString("%1℃ / %2℃").arg(current).arg(target);
+ }
+}
+
+QString Stringer::temperature(int current, int target, QString style)
+{
+ switch (temperatureFormat())
+ {
+ case Fahrenheit:
+ return style + heavySpan.arg(toFahrenheit(current)) + lightSpan.arg(QString("℉ / %1").arg(toFahrenheit(target))) + lightestSpan.arg("℉");
+ case Celsius:
+ default:
+ return style + heavySpan.arg(current) + lightSpan.arg(QString("℃ / %1").arg(target)) + lightestSpan.arg("℃");
+ }
+}
+
+QString Stringer::unusedTemperature()
+{
+ switch (temperatureFormat())
+ {
+ case Fahrenheit:
+ return QString("℉");
+ case Celsius:
+ default:
+ return QString("℃");
+ }
+}
+
+QString Stringer::unusedTemperature(QString style)
+{
+ switch (temperatureFormat())
+ {
+ case Fahrenheit:
+ return style + lightSpan.arg("℉");
+ case Celsius:
+ default:
+ return style + lightSpan.arg("℃");
+ }
+}
diff --git a/app/gui/oven_control/stringer.h b/app/gui/oven_control/stringer.h
new file mode 100644
index 0000000..b5af772
--- /dev/null
+++ b/app/gui/oven_control/stringer.h
@@ -0,0 +1,26 @@
+#ifndef STRINGER_H
+#define STRINGER_H
+
+
+#include
+
+namespace Stringer {
+const QString fontSize14("\
+");
+
+QString remainingTime(int secs);
+QString remainingTime(int secs, QString style);
+QString temperature(int celsius);
+QString temperature(int celsius, QString style);
+QString temperature(int current, int target);
+QString temperature(int current, int target, QString style);
+QString unusedTemperature();
+QString unusedTemperature(QString style);
+}
+
+#endif // STRINGER_H