2f6b55128
김태훈
다중 요리 구현
|
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
|
#include "multicookwindow.h"
#include "ui_multicookwindow.h"
#include <QDebug>
#include <QKeyEvent>
#include "multimanualcook.h"
#include "multiautocook.h"
#include "multicookrecorder.h"
#include "multicookselectionwindow.h"
#include "oven.h"
#include "stringer.h"
#include "confirmpopup.h"
#include "configwindow.h"
#include "washwindow.h"
#include "mainwindow.h"
MultiCookWindow::MultiCookWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MultiCookWindow)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
controller = new MultiCookController(this);
container = new MultiCookContainer(this);
controller->setContainer(container);
ui->view->setContainer(container);
ui->view->setTimeBar(ui->bar);
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
30
|
connect(ui->view, SIGNAL(clicked(int)), SLOT(handleViewClick(int)));
|
2f6b55128
김태훈
다중 요리 구현
|
31
32
33
34
35
36
37
38
39
40
41
|
buttons.append(ui->selectButton_1);
buttons.append(ui->selectButton_2);
buttons.append(ui->selectButton_3);
buttons.append(ui->selectButton_4);
buttons.append(ui->selectButton_5);
buttons.append(ui->selectButton_6);
buttons.append(ui->selectButton_7);
buttons.append(ui->selectButton_8);
buttons.append(ui->selectButton_9);
buttons.append(ui->selectButton_10);
|
703beed2b
김태훈
디자인 안 반영
|
42
43
44
45
46
47
|
recentButtons.append(ui->recentButton_1);
recentButtons.append(ui->recentButton_2);
recentButtons.append(ui->recentButton_3);
recentButtons.append(ui->recentButton_4);
recentButtons.append(ui->recentButton_5);
recentButtons.append(ui->recentButton_6);
|
2f6b55128
김태훈
다중 요리 구현
|
48
49
|
mode = Define::InvalidMode;
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
50
51
|
lastClickedEmptyButton = -1;
lastClickedCookButton = -1;
|
703beed2b
김태훈
디자인 안 반영
|
52
|
lastClickedRecentCook = -1;
|
2f6b55128
김태훈
다중 요리 구현
|
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
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
|
trashClicked = false;
updateViewTimer.start(100);
connect(&updateViewTimer, SIGNAL(timeout()), SLOT(updateView()));
setFocus();
ui->closeDoorAnimationArea->hide();
ui->closeDoorAnimation->load(":/images/animation/door_big_09.png");
ui->closeDoorAnimation->load(":/images/animation/door_big_08.png");
ui->closeDoorAnimation->load(":/images/animation/door_big_07.png");
ui->closeDoorAnimation->load(":/images/animation/door_big_06.png");
ui->closeDoorAnimation->load(":/images/animation/door_big_05.png");
ui->closeDoorAnimation->load(":/images/animation/door_big_04.png");
ui->closeDoorAnimation->load(":/images/animation/door_big_03.png");
ui->closeDoorAnimation->load(":/images/animation/door_big_02.png");
ui->closeDoorAnimation->load(":/images/animation/door_big_01.png");
ui->closeDoorAnimation->start(300);
ui->openDoorAnimationArea->hide();
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");
ui->openDoorAnimation->load(":/images/animation/door_big_04.png");
ui->openDoorAnimation->load(":/images/animation/door_big_05.png");
ui->openDoorAnimation->load(":/images/animation/door_big_06.png");
ui->openDoorAnimation->load(":/images/animation/door_big_07.png");
ui->openDoorAnimation->load(":/images/animation/door_big_08.png");
ui->openDoorAnimation->load(":/images/animation/door_big_09.png");
ui->openDoorAnimation->start(300);
}
MultiCookWindow::~MultiCookWindow()
{
delete ui;
Oven::getInstance()->stop();
}
void MultiCookWindow::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
case 0x01000032: // Turn left
onEncoderLeft();
break;
case 0x01000031: // Push
if (focusWidget() != this)
pushed = focusWidget();
break;
case 0x01000030: // Turn right
onEncoderRight();
break;
}
}
void MultiCookWindow::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
case 0x01000032: // Turn left
onEncoderLeft();
break;
case 0x01000031: // Push
if (focusWidget() == pushed)
onEncoderClicked(pushed);
pushed = NULL;
break;
case 0x01000030: // Turn right
onEncoderRight();
break;
}
}
void MultiCookWindow::updateView()
{
Oven *oven = Oven::getInstance();
if (controller->requireOpen() && !oven->door())
{
ui->blockingArea->setEnabled(false);
ui->closeDoorAnimationArea->hide();
ui->openDoorAnimationArea->show();
}
else if (controller->requireClose() && oven->door())
{
ui->blockingArea->setEnabled(false);
ui->closeDoorAnimationArea->show();
ui->openDoorAnimationArea->hide();
}
else
{
ui->blockingArea->setEnabled(true);
ui->closeDoorAnimationArea->hide();
ui->openDoorAnimationArea->hide();
}
QTime currentTime = QTime::currentTime();
ui->showNowButton->setText(QString("%1:%2")
.arg(currentTime.hour(), 2, 10, QLatin1Char('0'))
.arg(currentTime.minute(), 2, 10, QLatin1Char('0')));
|
703beed2b
김태훈
디자인 안 반영
|
156
|
QString infoText;
|
2f6b55128
김태훈
다중 요리 구현
|
157
158
159
160
161
162
163
164
|
for (int i = 0; i < 10; i++)
{
QPushButton *button = buttons.at(i);
MultiCook *cook = container->at(i);
if (cook == Q_NULLPTR)
button->setText("-");
else
|
703beed2b
김태훈
디자인 안 반영
|
165
166
167
168
169
170
171
172
173
174
|
{
if (cook->remainingTime() <= 0)
{
if (!infoText.isEmpty())
infoText += "
";
infoText += tr("%1번 단 요리(%2)가 종료되었습니다")
.arg(i + 1).arg(cook->name());
}
|
2f6b55128
김태훈
다중 요리 구현
|
175
|
button->setText(Stringer::time(cook->remainingTime()));
|
703beed2b
김태훈
디자인 안 반영
|
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
}
}
if (!infoText.isEmpty())
{
ui->upperStack->setCurrentIndex(2);
ui->info->setText(infoText);
}
else if (ui->upperStack->currentIndex() == 2)
ui->upperStack->setCurrentIndex(0);
if (ui->upperStack->currentIndex() == 1)
updateRecents();
}
void MultiCookWindow::updateRecents()
{
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
193
|
if (recents.size() > 0)
|
703beed2b
김태훈
디자인 안 반영
|
194
|
{
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
195
|
if (recents.size() > 6)
|
703beed2b
김태훈
디자인 안 반영
|
196
197
198
|
{
int currentPage = ui->pageIndicator->currentIndex();
int from = currentPage * 6;
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
199
|
int to = qMin(6, recents.size() - from) + from;
|
703beed2b
김태훈
디자인 안 반영
|
200
201
202
203
204
|
for (int i = from; i < to; i++)
{
QPushButton *b = recentButtons.at(i - from);
b->show();
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
205
|
b->setText(recents.at(i)->name());
|
703beed2b
김태훈
디자인 안 반영
|
206
207
208
209
210
211
212
213
214
215
216
|
}
for (int i = to - from; i < 6; i++)
recentButtons.at(i)->hide();
ui->showNextPageButton->show();
ui->showPrevPageButton->show();
ui->pageIndicator->show();
}
else
{
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
217
|
int max = qMin(6, recents.size());
|
703beed2b
김태훈
디자인 안 반영
|
218
219
220
221
|
for (int i = 0; i < max; i++)
{
QPushButton *b = recentButtons.at(i);
b->show();
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
222
|
b->setText(recents.at(i)->name());
|
703beed2b
김태훈
디자인 안 반영
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
}
for (int i = max; i < 6; i++)
recentButtons.at(i)->hide();
ui->showNextPageButton->hide();
ui->showPrevPageButton->hide();
ui->pageIndicator->hide();
}
}
else
{
foreach (QPushButton *b, recentButtons)
b->hide();
ui->showNextPageButton->hide();
ui->showPrevPageButton->hide();
ui->pageIndicator->hide();
|
2f6b55128
김태훈
다중 요리 구현
|
241
242
|
}
}
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
243
244
245
246
247
248
|
void MultiCookWindow::handleViewClick(int slot)
{
buttons.at(slot)->setFocus();
handleButtonClick(slot);
}
|
2f6b55128
김태훈
다중 요리 구현
|
249
250
|
void MultiCookWindow::handleButtonClick(int button)
{
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
251
|
if (lastClickedCookButton != -1)
|
703beed2b
김태훈
디자인 안 반영
|
252
|
{
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
253
|
MultiCook *cook = container->at(lastClickedCookButton);
|
703beed2b
김태훈
디자인 안 반영
|
254
255
|
if (cook)
cook->setTime();
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
256
257
|
lastClickedCookButton = -1;
|
703beed2b
김태훈
디자인 안 반영
|
258
|
}
|
2f6b55128
김태훈
다중 요리 구현
|
259
260
261
262
263
264
265
266
267
268
|
MultiCook *cook = container->at(button);
if (cook)
{
if (trashClicked)
{
trashClicked = false;
container->remove(button);
cook->deleteLater();
}
else
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
269
|
lastClickedCookButton = button;
|
2f6b55128
김태훈
다중 요리 구현
|
270
271
272
|
}
else
{
|
703beed2b
김태훈
디자인 안 반영
|
273
|
if (lastClickedRecentCook != -1)
|
2f6b55128
김태훈
다중 요리 구현
|
274
|
{
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
275
|
addCook(button, recents.at(lastClickedRecentCook)->clone(this));
|
2f6b55128
김태훈
다중 요리 구현
|
276
|
|
703beed2b
김태훈
디자인 안 반영
|
277
|
lastClickedRecentCook = -1;
|
2f6b55128
김태훈
다중 요리 구현
|
278
279
280
|
}
else
{
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
281
|
lastClickedEmptyButton = button;
|
2f6b55128
김태훈
다중 요리 구현
|
282
283
284
285
286
287
288
289
|
ui->upperStack->setCurrentIndex(0);
setFocus();
selectCook();
}
}
}
|
703beed2b
김태훈
디자인 안 반영
|
290
|
void MultiCookWindow::handleRecentButtonClick(int button)
|
2f6b55128
김태훈
다중 요리 구현
|
291
|
{
|
703beed2b
김태훈
디자인 안 반영
|
292
|
lastClickedRecentCook = button + ui->pageIndicator->currentIndex() * 6;
|
2f6b55128
김태훈
다중 요리 구현
|
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
}
void MultiCookWindow::selectCook()
{
MultiCookSelectionWindow *w = new MultiCookSelectionWindow(this);
if (mode != Define::InvalidMode)
w->setMode(mode);
w->setWindowModality(Qt::WindowModal);
w->showFullScreen();
w->raise();
connect(w, SIGNAL(selected(MultiCook*)), SLOT(onCookSelected(MultiCook*)));
}
void MultiCookWindow::onCookSelected(MultiCook *cook)
{
cook->setParent(this);
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
312
|
if (lastClickedEmptyButton != -1)
|
2f6b55128
김태훈
다중 요리 구현
|
313
|
{
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
314
315
|
addCook(lastClickedEmptyButton, cook);
lastClickedEmptyButton = -1;
|
2f6b55128
김태훈
다중 요리 구현
|
316
317
|
}
}
|
703beed2b
김태훈
디자인 안 반영
|
318
|
void MultiCookWindow::showRecents()
|
2f6b55128
김태훈
다중 요리 구현
|
319
|
{
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
320
|
recents = MultiCookRecorder::list();
|
2f6b55128
김태훈
다중 요리 구현
|
321
|
|
2f6b55128
김태훈
다중 요리 구현
|
322
|
ui->upperStack->setCurrentIndex(1);
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
323
|
ui->pageIndicator->setMaximum(recents.size() / 6);
|
703beed2b
김태훈
디자인 안 반영
|
324
325
326
|
ui->pageIndicator->setCurrentIndex(0);
updateRecents();
|
2f6b55128
김태훈
다중 요리 구현
|
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
|
}
void MultiCookWindow::showClock()
{
ui->upperStack->setCurrentIndex(0);
}
void MultiCookWindow::addCook(int slot, MultiCook *cook)
{
mode = cook->mode();
MultiCookRecorder::record(cook);
container->add(slot, cook);
}
void MultiCookWindow::jumpConfig()
{
ConfigWindow *w = new ConfigWindow(MainWindow::getInstance());
w->setWindowModality(Qt::WindowModal);
w->showFullScreen();
w->raise();
MainWindow::jump(w);
}
void MultiCookWindow::jumpWash()
{
WashWindow *w = new WashWindow(MainWindow::getInstance());
w->setWindowModality(Qt::WindowModal);
w->showFullScreen();
w->raise();
MainWindow::jump(w);
}
void MultiCookWindow::on_showPrevButton_clicked()
{
ui->view->showPrev();
}
void MultiCookWindow::on_showNowButton_clicked()
{
ui->view->showNow();
}
void MultiCookWindow::on_showNextButton_clicked()
{
ui->view->showNext();
}
void MultiCookWindow::on_showFavoritesButton_clicked()
{
if (ui->upperStack->currentIndex() == 0)
|
703beed2b
김태훈
디자인 안 반영
|
379
|
showRecents();
|
2f6b55128
김태훈
다중 요리 구현
|
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
|
else
showClock();
}
void MultiCookWindow::on_backButton_clicked()
{
if (container->isEmpty() || container->isFinished())
{
close();
}
else
{
ConfirmPopup *p = new ConfirmPopup(this, tr("요리를 취소하시겠습니까?"));
p->showFullScreen();
connect(p, SIGNAL(accepted()), SLOT(close()));
}
}
void MultiCookWindow::on_configButton_clicked()
{
if (container->isEmpty() || container->isFinished())
{
jumpConfig();
}
else
{
ConfirmPopup *p = new ConfirmPopup(this, tr("요리를 취소하시겠습니까?"));
p->showFullScreen();
connect(p, SIGNAL(accepted()), SLOT(jumpConfig()));
}
}
void MultiCookWindow::on_washButton_clicked()
{
if (container->isEmpty() || container->isFinished())
{
jumpConfig();
}
else
{
ConfirmPopup *p = new ConfirmPopup(this, tr("요리를 취소하시겠습니까?"));
p->showFullScreen();
connect(p, SIGNAL(accepted()), SLOT(jumpWash()));
}
}
void MultiCookWindow::on_deleteButton_clicked()
{
trashClicked = true;
}
void MultiCookWindow::on_helpButton_clicked()
{
}
void MultiCookWindow::onEncoderLeft()
{
MultiCook *c = Q_NULLPTR;
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
442
443
|
if (lastClickedCookButton != -1)
c = container->at(lastClickedCookButton);
|
2f6b55128
김태훈
다중 요리 구현
|
444
445
446
447
448
449
450
451
452
453
|
if (c)
c->decreaseTime();
else
focusPreviousChild();
}
void MultiCookWindow::onEncoderRight()
{
MultiCook *c = Q_NULLPTR;
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
454
455
|
if (lastClickedCookButton != -1)
c = container->at(lastClickedCookButton);
|
2f6b55128
김태훈
다중 요리 구현
|
456
457
458
459
460
461
462
463
464
465
|
if (c)
c->increaseTime();
else
focusNextChild();
}
void MultiCookWindow::onEncoderClicked(QWidget *clicked)
{
MultiCook *c = Q_NULLPTR;
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
466
|
if (lastClickedCookButton != -1)
|
2f6b55128
김태훈
다중 요리 구현
|
467
|
{
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
468
|
c = container->at(lastClickedCookButton);
|
2f6b55128
김태훈
다중 요리 구현
|
469
|
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
470
|
lastClickedCookButton = -1;
|
2f6b55128
김태훈
다중 요리 구현
|
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
|
}
if (c)
c->setTime();
else
{
QPushButton *b = qobject_cast<QPushButton *>(clicked);
if (b)
b->click();
}
}
void MultiCookWindow::on_selectButton_1_clicked()
{
handleButtonClick(0);
}
void MultiCookWindow::on_selectButton_2_clicked()
{
handleButtonClick(1);
}
void MultiCookWindow::on_selectButton_3_clicked()
{
handleButtonClick(2);
}
void MultiCookWindow::on_selectButton_4_clicked()
{
handleButtonClick(3);
}
void MultiCookWindow::on_selectButton_5_clicked()
{
handleButtonClick(4);
}
void MultiCookWindow::on_selectButton_6_clicked()
{
handleButtonClick(5);
}
void MultiCookWindow::on_selectButton_7_clicked()
{
handleButtonClick(6);
}
void MultiCookWindow::on_selectButton_8_clicked()
{
handleButtonClick(7);
}
void MultiCookWindow::on_selectButton_9_clicked()
{
handleButtonClick(8);
}
void MultiCookWindow::on_selectButton_10_clicked()
{
handleButtonClick(9);
}
|
703beed2b
김태훈
디자인 안 반영
|
532
|
void MultiCookWindow::on_recentButton_1_clicked()
|
2f6b55128
김태훈
다중 요리 구현
|
533
|
{
|
703beed2b
김태훈
디자인 안 반영
|
534
|
handleRecentButtonClick(0);
|
2f6b55128
김태훈
다중 요리 구현
|
535
|
}
|
703beed2b
김태훈
디자인 안 반영
|
536
|
void MultiCookWindow::on_recentButton_2_clicked()
|
2f6b55128
김태훈
다중 요리 구현
|
537
|
{
|
703beed2b
김태훈
디자인 안 반영
|
538
|
handleRecentButtonClick(1);
|
2f6b55128
김태훈
다중 요리 구현
|
539
|
}
|
703beed2b
김태훈
디자인 안 반영
|
540
|
void MultiCookWindow::on_recentButton_3_clicked()
|
2f6b55128
김태훈
다중 요리 구현
|
541
|
{
|
703beed2b
김태훈
디자인 안 반영
|
542
|
handleRecentButtonClick(2);
|
2f6b55128
김태훈
다중 요리 구현
|
543
|
}
|
703beed2b
김태훈
디자인 안 반영
|
544
|
void MultiCookWindow::on_recentButton_4_clicked()
|
2f6b55128
김태훈
다중 요리 구현
|
545
|
{
|
703beed2b
김태훈
디자인 안 반영
|
546
|
handleRecentButtonClick(3);
|
2f6b55128
김태훈
다중 요리 구현
|
547
|
}
|
703beed2b
김태훈
디자인 안 반영
|
548
|
void MultiCookWindow::on_recentButton_5_clicked()
|
2f6b55128
김태훈
다중 요리 구현
|
549
|
{
|
703beed2b
김태훈
디자인 안 반영
|
550
|
handleRecentButtonClick(4);
|
2f6b55128
김태훈
다중 요리 구현
|
551
|
}
|
703beed2b
김태훈
디자인 안 반영
|
552
|
void MultiCookWindow::on_recentButton_6_clicked()
|
2f6b55128
김태훈
다중 요리 구현
|
553
|
{
|
703beed2b
김태훈
디자인 안 반영
|
554
|
handleRecentButtonClick(5);
|
2f6b55128
김태훈
다중 요리 구현
|
555
|
}
|
703beed2b
김태훈
디자인 안 반영
|
556
|
void MultiCookWindow::on_showPrevPageButton_clicked()
|
2f6b55128
김태훈
다중 요리 구현
|
557
|
{
|
703beed2b
김태훈
디자인 안 반영
|
558
559
|
ui->pageIndicator->setCurrentIndex(ui->pageIndicator->currentIndex() - 1);
updateView();
|
2f6b55128
김태훈
다중 요리 구현
|
560
|
}
|
703beed2b
김태훈
디자인 안 반영
|
561
|
void MultiCookWindow::on_showNextPageButton_clicked()
|
2f6b55128
김태훈
다중 요리 구현
|
562
|
{
|
703beed2b
김태훈
디자인 안 반영
|
563
564
|
ui->pageIndicator->setCurrentIndex(ui->pageIndicator->currentIndex() + 1);
updateView();
|
2f6b55128
김태훈
다중 요리 구현
|
565
|
}
|
9a89ea55c
김태훈
버그 수정 및 코드 정리
|
566
567
568
569
570
|
void MultiCookWindow::on_homeButton_clicked()
{
close();
}
|