#include "multicookselectionwindow.h" #include "ui_multicookselectionwindow.h" #include #include "mainwindow.h" #include "configwindow.h" #include "multicookmanualwindow.h" #include "multicookautowindow.h" #include "soundplayer.h" #include "manualviewerdlg.h" MultiCookSelectionWindow::MultiCookSelectionWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MultiCookSelectionWindow) { ui->setupUi(this); ui->clockContainer->setParent(ui->upperStack); setAttribute(Qt::WA_DeleteOnClose); mode = Define::InvalidMode; updateView(); setFocus(); foreach (QPushButton *button, findChildren()) connect(button, &QPushButton::pressed, SoundPlayer::playClick); } MultiCookSelectionWindow::~MultiCookSelectionWindow() { delete ui; } void MultiCookSelectionWindow::setMode(Define::Mode mode) { this->mode = mode; book.setMode(mode); updateView(); } void MultiCookSelectionWindow::keyPressEvent(QKeyEvent *event) { switch (event->key()) { case 0x01000032: // Turn left onEncoderLeft(); break; case 0x01000031: // Push pushed = focusWidget(); break; case 0x01000030: // Turn right onEncoderRight(); break; } } void MultiCookSelectionWindow::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 MultiCookSelectionWindow::updateView() { if (mode == Define::InvalidMode) { ui->description->setText(tr("1. 다중 요리에서 사용할 요리 카테고리를 선택해주세요\n2. 스팀, 콤비, 건열 중에서 선택하시면 자동으로 다음 단계로 진행됩니다")); ui->steamButton->setEnabled(true); ui->combiButton->setEnabled(true); ui->dryheatButton->setEnabled(true); ui->poultryButton->setEnabled(false); ui->meatButton->setEnabled(false); ui->fishButton->setEnabled(false); ui->dessertButton->setEnabled(false); ui->grainButton->setEnabled(false); ui->breadButton->setEnabled(false); ui->etcButton->setEnabled(false); } else { QString modeString; switch (mode) { case Define::SteamMode: modeString = tr("스팀을"); break; case Define::CombiMode: modeString = tr("콤비를"); break; case Define::DryMode: modeString = tr("건열을"); break; } ui->description->setText(tr("1. %1 선택하였습니다\n2. 수동 메뉴 혹은 원하시는 자동 메뉴 상세 목록을 선택하세요").arg(modeString)); ui->steamButton->setEnabled(mode == Define::SteamMode); ui->combiButton->setEnabled(mode == Define::CombiMode); ui->dryheatButton->setEnabled(mode == Define::DryMode); ui->poultryButton->setEnabled(book.checkType(Define::Poultry)); ui->meatButton->setEnabled(book.checkType(Define::Meat)); ui->fishButton->setEnabled(book.checkType(Define::Fish)); ui->dessertButton->setEnabled(book.checkType(Define::Desert)); ui->grainButton->setEnabled(book.checkType(Define::Vegetable)); ui->breadButton->setEnabled(book.checkType(Define::Bread)); ui->etcButton->setEnabled(book.checkType(Define::Etc)); } ui->primeButton->setEnabled(false); ui->multiButton->setEnabled(false); ui->programmingButton->setEnabled(false); ui->washButton->setEnabled(false); } void MultiCookSelectionWindow::handleModeClick(Define::Mode mode) { setFocus(); if (this->mode == Define::InvalidMode) { setMode(mode); } else { MultiCookManualWindow *w = new MultiCookManualWindow(this); w->setMode(mode); w->setWindowModality(Qt::WindowModal); w->showFullScreen(); w->raise(); connect(w, SIGNAL(selected(MultiCook*)), SIGNAL(selected(MultiCook*))); connect(w, SIGNAL(selected(MultiCook*)), SLOT(hide())); connect(w, SIGNAL(selected(MultiCook*)), SLOT(close())); } } void MultiCookSelectionWindow::handleTypeClick(Define::CookType type) { setFocus(); book.setType(type); MultiCookAutoWindow *w = new MultiCookAutoWindow(this); w->setType(type); w->setBook(&book); w->setWindowModality(Qt::WindowModal); w->showFullScreen(); w->raise(); connect(w, SIGNAL(selected(MultiCook*)), SIGNAL(selected(MultiCook*))); connect(w, SIGNAL(selected(MultiCook*)), SLOT(hide())); connect(w, SIGNAL(selected(MultiCook*)), SLOT(close())); } void MultiCookSelectionWindow::on_steamButton_clicked() { handleModeClick(Define::SteamMode); } void MultiCookSelectionWindow::on_combiButton_clicked() { handleModeClick(Define::CombiMode); } void MultiCookSelectionWindow::on_dryheatButton_clicked() { handleModeClick(Define::DryMode); } void MultiCookSelectionWindow::on_poultryButton_clicked() { handleTypeClick(Define::Poultry); } void MultiCookSelectionWindow::on_meatButton_clicked() { handleTypeClick(Define::Meat); } void MultiCookSelectionWindow::on_fishButton_clicked() { handleTypeClick(Define::Fish); } void MultiCookSelectionWindow::on_dessertButton_clicked() { handleTypeClick(Define::Desert); } void MultiCookSelectionWindow::on_grainButton_clicked() { handleTypeClick(Define::Vegetable); } void MultiCookSelectionWindow::on_breadButton_clicked() { handleTypeClick(Define::Bread); } void MultiCookSelectionWindow::on_etcButton_clicked() { handleTypeClick(Define::Etc); } void MultiCookSelectionWindow::on_backButton_clicked() { close(); } void MultiCookSelectionWindow::on_helpButton_clicked() { ManualViewerDlg* dlg = new ManualViewerDlg(this); dlg->showFullScreen(); dlg->raise(); } void MultiCookSelectionWindow::onEncoderLeft() { focusPreviousChild(); } void MultiCookSelectionWindow::onEncoderRight() { focusNextChild(); } void MultiCookSelectionWindow::onEncoderClicked(QWidget *clicked) { QPushButton *b = qobject_cast(clicked); if (b) b->click(); }