manualcooksettingwidget.cpp
3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#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;
default:
return;
}
}
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;
}
}