#include "manualcooksettingwidget.h" #include "ui_manualcooksettingwidget.h" ManualCookSettingWidget::ManualCookSettingWidget(ManualCookSetting setting, QWidget *parent) : QWidget(parent), ui(new Ui::ManualCookSettingWidget) { ui->setupUi(this); setMode(setting.mode); setHumidity(setting.humidity); setTemp(setting.temp); setTime(setting.time); setCoreTempEnabled(setting.coreTempEnabled); setCoreTemp(setting.coreTemp); setFan(setting.fan); } ManualCookSettingWidget::~ManualCookSettingWidget() { delete ui; } void ManualCookSettingWidget::setMode(Define::Mode mode) { switch (mode) { case Define::SteamMode: ui->steamButton->setChecked(true); ui->tempSlider->setRange(30, 130); break; case Define::CombiMode: ui->combiButton->setChecked(true); ui->tempSlider->setRange(30, 300); break; case Define::DryMode: ui->dryheatButton->setChecked(true); ui->tempSlider->setRange(30, 300); break; } } void ManualCookSettingWidget::setHumidity(int percentage) { ui->humiditySlider->setValue(percentage); ui->humidityLabel->setText(QString("%1%").arg(percentage)); } void ManualCookSettingWidget::setTemp(int celsius) { ui->tempSlider->setValue(celsius); ui->tempLabel->setText(QString("%1<span style=\"font-size:11pt;\">℃</span>").arg(celsius)); } void ManualCookSettingWidget::setTime(int secs) { ui->timeSlider->setValue(secs); if (secs >= 3600) ui->timeLabel->setText( QString("%1<span style=\"font-size:11pt;\">시간</span> %2<span style=\"font-size:11pt;\">분</span>") .arg(secs / 3600) .arg((secs % 3600) / 60, 2, 10, QLatin1Char('0'))); else if (secs >= 60) ui->timeLabel->setText( QString("%1<span style=\"font-size:11pt;\">분</span> %2<span style=\"font-size:11pt;\">초</span>") .arg(secs / 60) .arg(secs % 60, 2, 10, QLatin1Char('0'))); else ui->timeLabel->setText(QString("%1<span style=\"font-size:11pt;\">초</span>").arg(secs)); } void ManualCookSettingWidget::setCoreTempEnabled(bool enabled) { ui->coreTempButton->setEnabled(enabled); ui->coreTempSlider->setEnabled(enabled); if (enabled) ui->coreTempLabel->setText(QString("%1<span style=\"font-size:11pt;\">℃</span>").arg(ui->coreTempSlider->value())); else ui->coreTempLabel->setText("<span style=\"font-size:11pt;\">℃</span>"); } void ManualCookSettingWidget::setCoreTemp(int celsius) { ui->coreTempSlider->setValue(celsius); if (ui->coreTempSlider->isEnabled()) ui->coreTempLabel->setText(QString("%1<span style=\"font-size:11pt;\">℃</span>").arg(celsius)); } void ManualCookSettingWidget::setFan(int level) { switch (level) { 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; } }