Commit 9a89ea55c263935b147126433ff4bac99d7efd54
Committed by
고영탁
1 parent
703beed2b8
Exists in
master
and in
2 other branches
버그 수정 및 코드 정리
- 버튼 로직 정리 - 요리 시간 바를 클릭하면 버튼 클릭으로 연결 - 쓰임에 따라 변수 분리 - 요리를 시작하지 않아도 요리 시간 조절 중에 요리 시간이 흘러가는 문제 수정
Showing
3 changed files
with
50 additions
and
39 deletions
Show diff stats
app/gui/oven_control/multiautocook.cpp
| @@ -206,6 +206,9 @@ void MultiAutoCook::append(int temperature, int humidity, int time) | @@ -206,6 +206,9 @@ void MultiAutoCook::append(int temperature, int humidity, int time) | ||
| 206 | 206 | ||
| 207 | void MultiAutoCook::updateTime() | 207 | void MultiAutoCook::updateTime() |
| 208 | { | 208 | { |
| 209 | + if (state != Running) | ||
| 210 | + return; | ||
| 211 | + | ||
| 209 | int e = elapsed.restart(); | 212 | int e = elapsed.restart(); |
| 210 | 213 | ||
| 211 | while (steps.size() > 0) | 214 | while (steps.size() > 0) |
app/gui/oven_control/multicookwindow.cpp
| @@ -28,6 +28,8 @@ MultiCookWindow::MultiCookWindow(QWidget *parent) : | @@ -28,6 +28,8 @@ MultiCookWindow::MultiCookWindow(QWidget *parent) : | ||
| 28 | ui->view->setContainer(container); | 28 | ui->view->setContainer(container); |
| 29 | ui->view->setTimeBar(ui->bar); | 29 | ui->view->setTimeBar(ui->bar); |
| 30 | 30 | ||
| 31 | + connect(ui->view, SIGNAL(clicked(int)), SLOT(handleViewClick(int))); | ||
| 32 | + | ||
| 31 | 33 | ||
| 32 | buttons.append(ui->selectButton_1); | 34 | buttons.append(ui->selectButton_1); |
| 33 | buttons.append(ui->selectButton_2); | 35 | buttons.append(ui->selectButton_2); |
| @@ -49,7 +51,8 @@ MultiCookWindow::MultiCookWindow(QWidget *parent) : | @@ -49,7 +51,8 @@ MultiCookWindow::MultiCookWindow(QWidget *parent) : | ||
| 49 | 51 | ||
| 50 | mode = Define::InvalidMode; | 52 | mode = Define::InvalidMode; |
| 51 | 53 | ||
| 52 | - lastClickedButton = -1; | 54 | + lastClickedEmptyButton = -1; |
| 55 | + lastClickedCookButton = -1; | ||
| 53 | lastClickedRecentCook = -1; | 56 | lastClickedRecentCook = -1; |
| 54 | trashClicked = false; | 57 | trashClicked = false; |
| 55 | 58 | ||
| @@ -193,19 +196,19 @@ void MultiCookWindow::updateView() | @@ -193,19 +196,19 @@ void MultiCookWindow::updateView() | ||
| 193 | 196 | ||
| 194 | void MultiCookWindow::updateRecents() | 197 | void MultiCookWindow::updateRecents() |
| 195 | { | 198 | { |
| 196 | - if (favorites.size() > 0) | 199 | + if (recents.size() > 0) |
| 197 | { | 200 | { |
| 198 | - if (favorites.size() > 6) | 201 | + if (recents.size() > 6) |
| 199 | { | 202 | { |
| 200 | int currentPage = ui->pageIndicator->currentIndex(); | 203 | int currentPage = ui->pageIndicator->currentIndex(); |
| 201 | int from = currentPage * 6; | 204 | int from = currentPage * 6; |
| 202 | - int to = qMin(6, favorites.size() - from) + from; | 205 | + int to = qMin(6, recents.size() - from) + from; |
| 203 | 206 | ||
| 204 | for (int i = from; i < to; i++) | 207 | for (int i = from; i < to; i++) |
| 205 | { | 208 | { |
| 206 | QPushButton *b = recentButtons.at(i - from); | 209 | QPushButton *b = recentButtons.at(i - from); |
| 207 | b->show(); | 210 | b->show(); |
| 208 | - b->setText(favorites.at(i)->name()); | 211 | + b->setText(recents.at(i)->name()); |
| 209 | } | 212 | } |
| 210 | 213 | ||
| 211 | for (int i = to - from; i < 6; i++) | 214 | for (int i = to - from; i < 6; i++) |
| @@ -217,12 +220,12 @@ void MultiCookWindow::updateRecents() | @@ -217,12 +220,12 @@ void MultiCookWindow::updateRecents() | ||
| 217 | } | 220 | } |
| 218 | else | 221 | else |
| 219 | { | 222 | { |
| 220 | - int max = qMin(6, favorites.size()); | 223 | + int max = qMin(6, recents.size()); |
| 221 | for (int i = 0; i < max; i++) | 224 | for (int i = 0; i < max; i++) |
| 222 | { | 225 | { |
| 223 | QPushButton *b = recentButtons.at(i); | 226 | QPushButton *b = recentButtons.at(i); |
| 224 | b->show(); | 227 | b->show(); |
| 225 | - b->setText(favorites.at(i)->name()); | 228 | + b->setText(recents.at(i)->name()); |
| 226 | } | 229 | } |
| 227 | 230 | ||
| 228 | for (int i = max; i < 6; i++) | 231 | for (int i = max; i < 6; i++) |
| @@ -244,13 +247,22 @@ void MultiCookWindow::updateRecents() | @@ -244,13 +247,22 @@ void MultiCookWindow::updateRecents() | ||
| 244 | } | 247 | } |
| 245 | } | 248 | } |
| 246 | 249 | ||
| 250 | +void MultiCookWindow::handleViewClick(int slot) | ||
| 251 | +{ | ||
| 252 | + buttons.at(slot)->setFocus(); | ||
| 253 | + | ||
| 254 | + handleButtonClick(slot); | ||
| 255 | +} | ||
| 256 | + | ||
| 247 | void MultiCookWindow::handleButtonClick(int button) | 257 | void MultiCookWindow::handleButtonClick(int button) |
| 248 | { | 258 | { |
| 249 | - if (lastClickedButton != -1) | 259 | + if (lastClickedCookButton != -1) |
| 250 | { | 260 | { |
| 251 | - MultiCook *cook = container->at(lastClickedButton); | 261 | + MultiCook *cook = container->at(lastClickedCookButton); |
| 252 | if (cook) | 262 | if (cook) |
| 253 | cook->setTime(); | 263 | cook->setTime(); |
| 264 | + | ||
| 265 | + lastClickedCookButton = -1; | ||
| 254 | } | 266 | } |
| 255 | 267 | ||
| 256 | MultiCook *cook = container->at(button); | 268 | MultiCook *cook = container->at(button); |
| @@ -263,22 +275,19 @@ void MultiCookWindow::handleButtonClick(int button) | @@ -263,22 +275,19 @@ void MultiCookWindow::handleButtonClick(int button) | ||
| 263 | cook->deleteLater(); | 275 | cook->deleteLater(); |
| 264 | } | 276 | } |
| 265 | else | 277 | else |
| 266 | - { | ||
| 267 | - lastClickedButton = button; | ||
| 268 | - } | 278 | + lastClickedCookButton = button; |
| 269 | } | 279 | } |
| 270 | else | 280 | else |
| 271 | { | 281 | { |
| 272 | if (lastClickedRecentCook != -1) | 282 | if (lastClickedRecentCook != -1) |
| 273 | { | 283 | { |
| 274 | - MultiCook *c = favorites.at(lastClickedRecentCook)->clone(this); | ||
| 275 | - addCook(button, c); | 284 | + addCook(button, recents.at(lastClickedRecentCook)->clone(this)); |
| 276 | 285 | ||
| 277 | lastClickedRecentCook = -1; | 286 | lastClickedRecentCook = -1; |
| 278 | } | 287 | } |
| 279 | else | 288 | else |
| 280 | { | 289 | { |
| 281 | - lastClickedButton = button; | 290 | + lastClickedEmptyButton = button; |
| 282 | 291 | ||
| 283 | ui->upperStack->setCurrentIndex(0); | 292 | ui->upperStack->setCurrentIndex(0); |
| 284 | setFocus(); | 293 | setFocus(); |
| @@ -311,19 +320,19 @@ void MultiCookWindow::onCookSelected(MultiCook *cook) | @@ -311,19 +320,19 @@ void MultiCookWindow::onCookSelected(MultiCook *cook) | ||
| 311 | { | 320 | { |
| 312 | cook->setParent(this); | 321 | cook->setParent(this); |
| 313 | 322 | ||
| 314 | - if (lastClickedButton != -1) | 323 | + if (lastClickedEmptyButton != -1) |
| 315 | { | 324 | { |
| 316 | - addCook(lastClickedButton, cook); | ||
| 317 | - lastClickedButton = -1; | 325 | + addCook(lastClickedEmptyButton, cook); |
| 326 | + lastClickedEmptyButton = -1; | ||
| 318 | } | 327 | } |
| 319 | } | 328 | } |
| 320 | 329 | ||
| 321 | void MultiCookWindow::showRecents() | 330 | void MultiCookWindow::showRecents() |
| 322 | { | 331 | { |
| 323 | - favorites = MultiCookRecorder::list(); | 332 | + recents = MultiCookRecorder::list(); |
| 324 | 333 | ||
| 325 | ui->upperStack->setCurrentIndex(1); | 334 | ui->upperStack->setCurrentIndex(1); |
| 326 | - ui->pageIndicator->setMaximum(favorites.size() / 6); | 335 | + ui->pageIndicator->setMaximum(recents.size() / 6); |
| 327 | ui->pageIndicator->setCurrentIndex(0); | 336 | ui->pageIndicator->setCurrentIndex(0); |
| 328 | 337 | ||
| 329 | updateRecents(); | 338 | updateRecents(); |
| @@ -443,12 +452,8 @@ void MultiCookWindow::onEncoderLeft() | @@ -443,12 +452,8 @@ void MultiCookWindow::onEncoderLeft() | ||
| 443 | { | 452 | { |
| 444 | MultiCook *c = Q_NULLPTR; | 453 | MultiCook *c = Q_NULLPTR; |
| 445 | 454 | ||
| 446 | - if (lastClickedButton != -1) | ||
| 447 | - { | ||
| 448 | - QPushButton *b = buttons.at(lastClickedButton); | ||
| 449 | - if (b == focusWidget()) | ||
| 450 | - c = container->at(lastClickedButton); | ||
| 451 | - } | 455 | + if (lastClickedCookButton != -1) |
| 456 | + c = container->at(lastClickedCookButton); | ||
| 452 | 457 | ||
| 453 | if (c) | 458 | if (c) |
| 454 | c->decreaseTime(); | 459 | c->decreaseTime(); |
| @@ -460,12 +465,8 @@ void MultiCookWindow::onEncoderRight() | @@ -460,12 +465,8 @@ void MultiCookWindow::onEncoderRight() | ||
| 460 | { | 465 | { |
| 461 | MultiCook *c = Q_NULLPTR; | 466 | MultiCook *c = Q_NULLPTR; |
| 462 | 467 | ||
| 463 | - if (lastClickedButton != -1) | ||
| 464 | - { | ||
| 465 | - QPushButton *b = buttons.at(lastClickedButton); | ||
| 466 | - if (b == focusWidget()) | ||
| 467 | - c = container->at(lastClickedButton); | ||
| 468 | - } | 468 | + if (lastClickedCookButton != -1) |
| 469 | + c = container->at(lastClickedCookButton); | ||
| 469 | 470 | ||
| 470 | if (c) | 471 | if (c) |
| 471 | c->increaseTime(); | 472 | c->increaseTime(); |
| @@ -477,13 +478,11 @@ void MultiCookWindow::onEncoderClicked(QWidget *clicked) | @@ -477,13 +478,11 @@ void MultiCookWindow::onEncoderClicked(QWidget *clicked) | ||
| 477 | { | 478 | { |
| 478 | MultiCook *c = Q_NULLPTR; | 479 | MultiCook *c = Q_NULLPTR; |
| 479 | 480 | ||
| 480 | - if (lastClickedButton != -1) | 481 | + if (lastClickedCookButton != -1) |
| 481 | { | 482 | { |
| 482 | - QPushButton *b = buttons.at(lastClickedButton); | ||
| 483 | - if (b == focusWidget()) | ||
| 484 | - c = container->at(lastClickedButton); | 483 | + c = container->at(lastClickedCookButton); |
| 485 | 484 | ||
| 486 | - lastClickedButton = -1; | 485 | + lastClickedCookButton = -1; |
| 487 | } | 486 | } |
| 488 | 487 | ||
| 489 | if (c) | 488 | if (c) |
| @@ -587,3 +586,8 @@ void MultiCookWindow::on_showNextPageButton_clicked() | @@ -587,3 +586,8 @@ void MultiCookWindow::on_showNextPageButton_clicked() | ||
| 587 | ui->pageIndicator->setCurrentIndex(ui->pageIndicator->currentIndex() + 1); | 586 | ui->pageIndicator->setCurrentIndex(ui->pageIndicator->currentIndex() + 1); |
| 588 | updateView(); | 587 | updateView(); |
| 589 | } | 588 | } |
| 589 | + | ||
| 590 | +void MultiCookWindow::on_homeButton_clicked() | ||
| 591 | +{ | ||
| 592 | + close(); | ||
| 593 | +} |
app/gui/oven_control/multicookwindow.h
| @@ -26,6 +26,7 @@ protected: | @@ -26,6 +26,7 @@ protected: | ||
| 26 | private slots: | 26 | private slots: |
| 27 | void updateView(); | 27 | void updateView(); |
| 28 | void updateRecents(); | 28 | void updateRecents(); |
| 29 | + void handleViewClick(int slot); | ||
| 29 | void handleButtonClick(int button); | 30 | void handleButtonClick(int button); |
| 30 | void handleRecentButtonClick(int button); | 31 | void handleRecentButtonClick(int button); |
| 31 | void selectCook(); | 32 | void selectCook(); |
| @@ -72,6 +73,8 @@ private slots: | @@ -72,6 +73,8 @@ private slots: | ||
| 72 | void on_showPrevPageButton_clicked(); | 73 | void on_showPrevPageButton_clicked(); |
| 73 | void on_showNextPageButton_clicked(); | 74 | void on_showNextPageButton_clicked(); |
| 74 | 75 | ||
| 76 | + void on_homeButton_clicked(); | ||
| 77 | + | ||
| 75 | private: | 78 | private: |
| 76 | Ui::MultiCookWindow *ui; | 79 | Ui::MultiCookWindow *ui; |
| 77 | 80 | ||
| @@ -80,10 +83,11 @@ private: | @@ -80,10 +83,11 @@ private: | ||
| 80 | 83 | ||
| 81 | QList<QPushButton *> buttons; | 84 | QList<QPushButton *> buttons; |
| 82 | QList<QPushButton *> recentButtons; | 85 | QList<QPushButton *> recentButtons; |
| 83 | - QList<MultiCook *> favorites; | 86 | + QList<MultiCook *> recents; |
| 84 | QTimer updateViewTimer; | 87 | QTimer updateViewTimer; |
| 85 | 88 | ||
| 86 | - int lastClickedButton; | 89 | + int lastClickedEmptyButton; |
| 90 | + int lastClickedCookButton; | ||
| 87 | int lastClickedRecentCook; | 91 | int lastClickedRecentCook; |
| 88 | bool trashClicked; | 92 | bool trashClicked; |
| 89 | 93 |