programmingselectionwindow.cpp 3.23 KB
#include "programmingselectionwindow.h"
#include "ui_programmingselectionwindow.h"

#include "programmingmanualwindow.h"
#include "programmingautoselectionwindow.h"
#include "soundplayer.h"

ProgrammingSelectionWindow::ProgrammingSelectionWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ProgrammingSelectionWindow)
{
    ui->setupUi(this);

//    ui->clockContainer->setParent(ui->upperStack);
    setAttribute(Qt::WA_DeleteOnClose);

    setFocus();

    foreach (QPushButton *button, findChildren<QPushButton *>())
        connect(button, &QPushButton::pressed, SoundPlayer::playClick);
}

ProgrammingSelectionWindow::~ProgrammingSelectionWindow()
{
    delete ui;
}

void ProgrammingSelectionWindow::setModeEnabled(bool enabled)
{
    ui->steamButton->setEnabled(enabled);
    ui->combiButton->setEnabled(enabled);
    ui->dryheatButton->setEnabled(enabled);
}

void ProgrammingSelectionWindow::setCookTypeEnabled(bool enabled)
{
    ui->poultryButton->setEnabled(enabled);
    ui->meatButton->setEnabled(enabled);
    ui->fishButton->setEnabled(enabled);
    ui->dessertButton->setEnabled(enabled);
    ui->grainButton->setEnabled(enabled);
    ui->breadButton->setEnabled(enabled);
    ui->etcButton->setEnabled(enabled);
}

void ProgrammingSelectionWindow::onModeClicked(Define::Mode mode)
{
    ProgrammingManualWindow *w = new ProgrammingManualWindow(this, mode);
    connect(w, SIGNAL(added()), SIGNAL(added()));
    connect(w, SIGNAL(added()), SLOT(hide()));
    connect(w, SIGNAL(added()), SLOT(close()));
    w->setWindowModality(Qt::WindowModal);
    w->showFullScreen();
    w->raise();
}

void ProgrammingSelectionWindow::onCookTypeClicked(Define::CookType type)
{
    ProgrammingAutoSelectionWindow *w = new ProgrammingAutoSelectionWindow(this, type);
    connect(w, SIGNAL(added()), SIGNAL(added()));
    connect(w, SIGNAL(added()), SLOT(hide()));
    connect(w, SIGNAL(added()), SLOT(close()));
    w->setWindowModality(Qt::WindowModal);
    w->showFullScreen();
    w->raise();
}

void ProgrammingSelectionWindow::on_steamButton_clicked()
{
    onModeClicked(Define::SteamMode);
}

void ProgrammingSelectionWindow::on_combiButton_clicked()
{
    onModeClicked(Define::CombiMode);
}

void ProgrammingSelectionWindow::on_dryheatButton_clicked()
{
    onModeClicked(Define::DryMode);
}

void ProgrammingSelectionWindow::on_poultryButton_clicked()
{
    onCookTypeClicked(Define::Poultry);
}

void ProgrammingSelectionWindow::on_meatButton_clicked()
{
    onCookTypeClicked(Define::Meat);
}

void ProgrammingSelectionWindow::on_fishButton_clicked()
{
    onCookTypeClicked(Define::Fish);
}

void ProgrammingSelectionWindow::on_dessertButton_clicked()
{
    onCookTypeClicked(Define::Desert);
}

void ProgrammingSelectionWindow::on_grainButton_clicked()
{
    onCookTypeClicked(Define::Vegetable);
}

void ProgrammingSelectionWindow::on_breadButton_clicked()
{
    onCookTypeClicked(Define::Bread);
}

void ProgrammingSelectionWindow::on_etcButton_clicked()
{
    onCookTypeClicked(Define::Etc);
}

void ProgrammingSelectionWindow::on_backButton_clicked()
{
    close();
}

void ProgrammingSelectionWindow::on_configButton_clicked()
{

}

void ProgrammingSelectionWindow::on_helpButton_clicked()
{

}

void ProgrammingSelectionWindow::on_okButton_clicked()
{
    close();
}