68c06e96f
김태훈
자동 요리 세부 사항 구현
|
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
|
#include "autocookcheckwindow.h"
#include "ui_autocookcheckwindow.h"
#include <QKeyEvent>
#include "mainwindow.h"
#include "configwindow.h"
#include "washwindow.h"
#include "confirmpopup.h"
#include "favoritenamepopup.h"
#include "stringer.h"
#include "soundplayer.h"
AutoCookCheckWindow::AutoCookCheckWindow(QWidget *parent, Cook cook) :
QMainWindow(parent),
ui(new Ui::AutoCookCheckWindow),
cook(cook)
{
ui->setupUi(this);
ui->clockContainer->setParent(ui->upperStack);
setAttribute(Qt::WA_DeleteOnClose);
if (!this->cook.isLoaded())
this->cook.load();
setupUi();
foreach (QPushButton *button, findChildren<QPushButton *>())
connect(button, &QPushButton::pressed, SoundPlayer::playClick);
foreach (QWidget *w, findChildren<QWidget *>())
w->installEventFilter(this);
afterThreeSecsTimer.setSingleShot(true);
afterThreeSecsTimer.setInterval(3000);
afterThreeSecsTimer.start();
connect(&afterThreeSecsTimer, SIGNAL(timeout()), SLOT(afterThreeSecs()));
setFocus();
}
AutoCookCheckWindow::~AutoCookCheckWindow()
{
delete ui;
}
bool AutoCookCheckWindow::eventFilter(QObject */*watched*/, QEvent *event)
{
switch (event->type())
{
case QEvent::KeyPress:
case QEvent::KeyRelease:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
afterThreeSecsTimer.start();
break;
default:
break;
}
return false;
}
void AutoCookCheckWindow::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
|
01249f413
김태훈
엔코더 방향 반전. 하드웨어가 변경됨
|
70
|
case 0x01000032: // Turn left
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
71
72
73
74
75
|
onEncoderLeft();
break;
case 0x01000031: // Push
pushed = focusWidget();
break;
|
01249f413
김태훈
엔코더 방향 반전. 하드웨어가 변경됨
|
76
|
case 0x01000030: // Turn right
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
77
78
79
80
81
82
83
84
85
|
onEncoderRight();
break;
}
}
void AutoCookCheckWindow::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
|
01249f413
김태훈
엔코더 방향 반전. 하드웨어가 변경됨
|
86
|
case 0x01000032: // Turn left
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
87
88
89
90
91
92
93
94
|
onEncoderLeft();
break;
case 0x01000031: // Push
if (focusWidget() == pushed)
onEncoderClicked(pushed);
pushed = NULL;
break;
|
01249f413
김태훈
엔코더 방향 반전. 하드웨어가 변경됨
|
95
|
case 0x01000030: // Turn right
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
onEncoderRight();
break;
}
}
void AutoCookCheckWindow::setupUi()
{
steamModeIcon.load(":/images/cook_mode/small_steam.png");
dryModeIcon.load(":/images/cook_mode/small_dryheat.png");
combiModeIcon.load(":/images/cook_mode/small_combi.png");
ui->cookTypeIcon->setPixmap(Define::icon(cook.type));
ui->selectCookButton->setText(cook.name);
int msecs = 0;
for (int i = 0; i < cook.steps.size(); i++)
msecs += cook.steps[i].time * 1000;
ui->timeLabel->setText(Stringer::remainingTime(msecs));
if (cook.isCoreTempValid())
ui->interTempLabel->setText(Stringer::temperature(cook.coreTemp()));
else
{
ui->interTempIcon->hide();
ui->interTempLabel->hide();
}
ui->stepIndicator->setMaximum(cook.steps.size() - 1);
ui->cookStepAnimation->start(300);
ui->humidityGauge->setMinimum(0);
ui->humidityGauge->setMaximum(100);
ui->humidityGauge->setValue(0);
ui->heatGauge->setMinimum(30);
ui->heatGauge->setMaximum(300);
ui->heatGauge->setValue(30);
ui->doorStepLabel->hide();
selectedStepIndex = 0;
lastViewCookMode = Define::InvalidMode;
lastViewCookType = Define::Invalid;
lastViewDoorType = Define::Invalid;
updateView();
}
void AutoCookCheckWindow::onEncoderLeft()
{
focusPreviousChild();
}
void AutoCookCheckWindow::onEncoderRight()
{
focusNextChild();
}
void AutoCookCheckWindow::onEncoderClicked(QWidget *clicked)
{
QPushButton *b = qobject_cast<QPushButton *>(clicked);
if (b)
b->click();
}
void AutoCookCheckWindow::updateView()
{
ui->stepIndicator->setCurrentIndex(selectedStepIndex);
CookStep showingStep = cook.steps[selectedStepIndex];
if (Define::classify(showingStep.type) == Define::DoorClass)
{
ui->cookStepIcon->hide();
ui->cookStepLabel->hide();
ui->cookModeIcon->hide();
ui->humidityGauge->hide();
ui->humidityLabel->hide();
ui->heatGauge->hide();
ui->heatLabel->hide();
ui->doorStepLabel->show();
ui->cookStepAnimation->show();
if (showingStep.type != lastViewDoorType)
{
lastViewDoorType = showingStep.type;
ui->doorStepLabel->setText(Define::name(showingStep.type));
ui->cookStepAnimation->clear();
switch (showingStep.type)
{
case Define::PutThermometer:
ui->doorStepLabel->setText(tr("중심 온도계 삽입"));
ui->cookStepAnimation->load(":/images/animation/thermometer_01.png");
ui->cookStepAnimation->load(":/images/animation/thermometer_02.png");
|
b3e47756e
김태훈
소스 파일 일괄 변경
|
192
|
ui->cookStepAnimation->setGeometry((1080-252)/2, 960, 252, 368);
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
193
194
195
196
197
198
199
200
201
202
203
|
ui->cookStepAnimation->start(300);
break;
case Define::Load:
ui->doorStepLabel->setText(tr("식재료 적재"));
ui->cookStepAnimation->load(":/images/animation/load_01.png");
ui->cookStepAnimation->load(":/images/animation/load_02.png");
ui->cookStepAnimation->load(":/images/animation/load_03.png");
ui->cookStepAnimation->load(":/images/animation/load_04.png");
ui->cookStepAnimation->load(":/images/animation/load_03.png");
ui->cookStepAnimation->load(":/images/animation/load_02.png");
ui->cookStepAnimation->load(":/images/animation/load_01.png");
|
b3e47756e
김태훈
소스 파일 일괄 변경
|
204
|
ui->cookStepAnimation->setGeometry((1080-317)/2, 960, 317, 368);
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
205
206
207
208
209
210
211
|
ui->cookStepAnimation->start(300);
break;
case Define::Cut:
ui->doorStepLabel->setText(tr("자르기"));
ui->cookStepAnimation->load(":/images/animation/cut_01.png");
ui->cookStepAnimation->load(":/images/animation/cut_02.png");
ui->cookStepAnimation->load(":/images/animation/cut_03.png");
|
b3e47756e
김태훈
소스 파일 일괄 변경
|
212
|
ui->cookStepAnimation->setGeometry((1080-317)/2, 960, 317, 368);
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
213
214
215
216
217
218
219
220
|
ui->cookStepAnimation->start(300);
break;
case Define::Pour:
ui->doorStepLabel->setText(tr("물 붓기"));
ui->cookStepAnimation->load(":/images/animation/pour_01.png");
ui->cookStepAnimation->load(":/images/animation/pour_02.png");
ui->cookStepAnimation->load(":/images/animation/pour_03.png");
ui->cookStepAnimation->load(":/images/animation/pour_04.png");
|
b3e47756e
김태훈
소스 파일 일괄 변경
|
221
|
ui->cookStepAnimation->setGeometry((1080-317)/2, 960, 317, 368);
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
ui->cookStepAnimation->start(300);
break;
default:
ui->doorStepLabel->hide();
ui->cookStepAnimation->hide();
}
}
}
else
{
ui->doorStepLabel->hide();
ui->cookStepAnimation->hide();
ui->cookStepIcon->show();
ui->cookStepLabel->show();
ui->cookModeIcon->show();
ui->humidityGauge->show();
ui->humidityLabel->show();
ui->heatGauge->show();
ui->heatLabel->show();
if (showingStep.type != lastViewCookType)
{
lastViewCookType = showingStep.type;
ui->cookStepIcon->setPixmap(Define::icon(showingStep.type));
ui->cookStepLabel->setText(Define::name(showingStep.type));
}
if (showingStep.mode != lastViewCookMode)
{
lastViewCookMode = showingStep.mode;
switch (showingStep.mode)
{
case Define::SteamMode:
ui->cookModeIcon->setPixmap(steamModeIcon);
break;
case Define::CombiMode:
ui->cookModeIcon->setPixmap(combiModeIcon);
break;
case Define::DryMode:
ui->cookModeIcon->setPixmap(dryModeIcon);
break;
case Define::InvalidClass:
ui->cookModeIcon->hide();
break;
}
}
ui->humidityLabel->setText(QString("%1%").arg(showingStep.humidity));
ui->humidityGauge->setValue(showingStep.humidity);
ui->heatLabel->setText(Stringer::temperature(showingStep.temp));
ui->heatGauge->setValue(showingStep.temp);
}
}
void AutoCookCheckWindow::addFavorite()
{
AutoCookSetting s;
s.type = cook.type;
s.root = cook.root;
for (int i = 0; i < 5; i++)
s.configs[i] = cook.configs[i].current;
FavoriteNamePopup *p = new FavoriteNamePopup(this, s);
p->showFullScreen();
}
void AutoCookCheckWindow::afterThreeSecs()
{
emit back();
close();
}
void AutoCookCheckWindow::on_selectCookButton_clicked()
{
}
void AutoCookCheckWindow::on_showPrevStepButton_clicked()
{
if (selectedStepIndex > 0)
{
selectedStepIndex--;
updateView();
}
}
void AutoCookCheckWindow::on_showNextStepButton_clicked()
{
if (selectedStepIndex + 1 < cook.steps.size())
{
selectedStepIndex++;
updateView();
}
}
void AutoCookCheckWindow::on_backButton_clicked()
{
emit back();
close();
}
|