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
app/gui/oven_control/multicookwindow.cpp
| ... | ... | @@ -28,6 +28,8 @@ MultiCookWindow::MultiCookWindow(QWidget *parent) : |
| 28 | 28 | ui->view->setContainer(container); |
| 29 | 29 | ui->view->setTimeBar(ui->bar); |
| 30 | 30 | |
| 31 | + connect(ui->view, SIGNAL(clicked(int)), SLOT(handleViewClick(int))); | |
| 32 | + | |
| 31 | 33 | |
| 32 | 34 | buttons.append(ui->selectButton_1); |
| 33 | 35 | buttons.append(ui->selectButton_2); |
| ... | ... | @@ -49,7 +51,8 @@ MultiCookWindow::MultiCookWindow(QWidget *parent) : |
| 49 | 51 | |
| 50 | 52 | mode = Define::InvalidMode; |
| 51 | 53 | |
| 52 | - lastClickedButton = -1; | |
| 54 | + lastClickedEmptyButton = -1; | |
| 55 | + lastClickedCookButton = -1; | |
| 53 | 56 | lastClickedRecentCook = -1; |
| 54 | 57 | trashClicked = false; |
| 55 | 58 | |
| ... | ... | @@ -193,19 +196,19 @@ void MultiCookWindow::updateView() |
| 193 | 196 | |
| 194 | 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 | 203 | int currentPage = ui->pageIndicator->currentIndex(); |
| 201 | 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 | 207 | for (int i = from; i < to; i++) |
| 205 | 208 | { |
| 206 | 209 | QPushButton *b = recentButtons.at(i - from); |
| 207 | 210 | b->show(); |
| 208 | - b->setText(favorites.at(i)->name()); | |
| 211 | + b->setText(recents.at(i)->name()); | |
| 209 | 212 | } |
| 210 | 213 | |
| 211 | 214 | for (int i = to - from; i < 6; i++) |
| ... | ... | @@ -217,12 +220,12 @@ void MultiCookWindow::updateRecents() |
| 217 | 220 | } |
| 218 | 221 | else |
| 219 | 222 | { |
| 220 | - int max = qMin(6, favorites.size()); | |
| 223 | + int max = qMin(6, recents.size()); | |
| 221 | 224 | for (int i = 0; i < max; i++) |
| 222 | 225 | { |
| 223 | 226 | QPushButton *b = recentButtons.at(i); |
| 224 | 227 | b->show(); |
| 225 | - b->setText(favorites.at(i)->name()); | |
| 228 | + b->setText(recents.at(i)->name()); | |
| 226 | 229 | } |
| 227 | 230 | |
| 228 | 231 | for (int i = max; i < 6; i++) |
| ... | ... | @@ -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 | 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 | 262 | if (cook) |
| 253 | 263 | cook->setTime(); |
| 264 | + | |
| 265 | + lastClickedCookButton = -1; | |
| 254 | 266 | } |
| 255 | 267 | |
| 256 | 268 | MultiCook *cook = container->at(button); |
| ... | ... | @@ -263,22 +275,19 @@ void MultiCookWindow::handleButtonClick(int button) |
| 263 | 275 | cook->deleteLater(); |
| 264 | 276 | } |
| 265 | 277 | else |
| 266 | - { | |
| 267 | - lastClickedButton = button; | |
| 268 | - } | |
| 278 | + lastClickedCookButton = button; | |
| 269 | 279 | } |
| 270 | 280 | else |
| 271 | 281 | { |
| 272 | 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 | 286 | lastClickedRecentCook = -1; |
| 278 | 287 | } |
| 279 | 288 | else |
| 280 | 289 | { |
| 281 | - lastClickedButton = button; | |
| 290 | + lastClickedEmptyButton = button; | |
| 282 | 291 | |
| 283 | 292 | ui->upperStack->setCurrentIndex(0); |
| 284 | 293 | setFocus(); |
| ... | ... | @@ -311,19 +320,19 @@ void MultiCookWindow::onCookSelected(MultiCook *cook) |
| 311 | 320 | { |
| 312 | 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 | 330 | void MultiCookWindow::showRecents() |
| 322 | 331 | { |
| 323 | - favorites = MultiCookRecorder::list(); | |
| 332 | + recents = MultiCookRecorder::list(); | |
| 324 | 333 | |
| 325 | 334 | ui->upperStack->setCurrentIndex(1); |
| 326 | - ui->pageIndicator->setMaximum(favorites.size() / 6); | |
| 335 | + ui->pageIndicator->setMaximum(recents.size() / 6); | |
| 327 | 336 | ui->pageIndicator->setCurrentIndex(0); |
| 328 | 337 | |
| 329 | 338 | updateRecents(); |
| ... | ... | @@ -443,12 +452,8 @@ void MultiCookWindow::onEncoderLeft() |
| 443 | 452 | { |
| 444 | 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 | 458 | if (c) |
| 454 | 459 | c->decreaseTime(); |
| ... | ... | @@ -460,12 +465,8 @@ void MultiCookWindow::onEncoderRight() |
| 460 | 465 | { |
| 461 | 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 | 471 | if (c) |
| 471 | 472 | c->increaseTime(); |
| ... | ... | @@ -477,13 +478,11 @@ void MultiCookWindow::onEncoderClicked(QWidget *clicked) |
| 477 | 478 | { |
| 478 | 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 | 488 | if (c) |
| ... | ... | @@ -587,3 +586,8 @@ void MultiCookWindow::on_showNextPageButton_clicked() |
| 587 | 586 | ui->pageIndicator->setCurrentIndex(ui->pageIndicator->currentIndex() + 1); |
| 588 | 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 | 26 | private slots: |
| 27 | 27 | void updateView(); |
| 28 | 28 | void updateRecents(); |
| 29 | + void handleViewClick(int slot); | |
| 29 | 30 | void handleButtonClick(int button); |
| 30 | 31 | void handleRecentButtonClick(int button); |
| 31 | 32 | void selectCook(); |
| ... | ... | @@ -72,6 +73,8 @@ private slots: |
| 72 | 73 | void on_showPrevPageButton_clicked(); |
| 73 | 74 | void on_showNextPageButton_clicked(); |
| 74 | 75 | |
| 76 | + void on_homeButton_clicked(); | |
| 77 | + | |
| 75 | 78 | private: |
| 76 | 79 | Ui::MultiCookWindow *ui; |
| 77 | 80 | |
| ... | ... | @@ -80,10 +83,11 @@ private: |
| 80 | 83 | |
| 81 | 84 | QList<QPushButton *> buttons; |
| 82 | 85 | QList<QPushButton *> recentButtons; |
| 83 | - QList<MultiCook *> favorites; | |
| 86 | + QList<MultiCook *> recents; | |
| 84 | 87 | QTimer updateViewTimer; |
| 85 | 88 | |
| 86 | - int lastClickedButton; | |
| 89 | + int lastClickedEmptyButton; | |
| 90 | + int lastClickedCookButton; | |
| 87 | 91 | int lastClickedRecentCook; |
| 88 | 92 | bool trashClicked; |
| 89 | 93 | ... | ... |