#include "manualcooksettingwidget.h" #include "ui_manualcooksettingwidget.h" #include "stringer.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(Stringer::temperature(celsius, Stringer::fontSize14)); } void ManualCookSettingWidget::setTime(int secs) { ui->timeSlider->setValue(secs); ui->timeLabel->setText(Stringer::remainingTime(secs * 1000, Stringer::fontSize14)); } void ManualCookSettingWidget::setCoreTempEnabled(bool enabled) { ui->coreTempButton->setEnabled(enabled); ui->coreTempSlider->setEnabled(enabled); if (enabled) ui->coreTempLabel->setText(Stringer::temperature(ui->coreTempSlider->value(), Stringer::fontSize14)); else ui->coreTempLabel->setText(Stringer::unusedTemperature(Stringer::fontSize14)); } void ManualCookSettingWidget::setCoreTemp(int celsius) { ui->coreTempSlider->setValue(celsius); if (ui->coreTempSlider->isEnabled()) ui->coreTempLabel->setText(Stringer::temperature(celsius, Stringer::fontSize14)); } 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; } }