preheatpopup.cpp 1.36 KB
#include "preheatpopup.h"
#include "ui_preheatpopup.h"

PreheatPopup::PreheatPopup(QWidget *parent, Oven *oven) :
    QWidget(parent),
    ui(new Ui::PreheatPopup),
    oven(oven)
{
    ui->setupUi(this);

    setAttribute(Qt::WA_DeleteOnClose);

    connect(oven, SIGNAL(changed(Oven*)), SLOT(updateView()));

    oven->startPreheating();
}

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

void PreheatPopup::updateView()
{
    int time = oven->time();
    if (time >= 3600)
        ui->timeLabel->setText(QString().sprintf("%d<span style=\"font-size:11pt;\">시간</span> %02d<span style=\"font-size:11pt;\">분</span>", time / 3600, (time % 3600) / 60));
    else if (time >= 60)
        ui->timeLabel->setText(QString().sprintf("%d<span style=\"font-size:11pt;\">분</span> %02d<span style=\"font-size:11pt;\">초</span>", time / 60, time % 60));
    else
        ui->timeLabel->setText(QString().sprintf("%d<span style=\"font-size:11pt;\">초</span>", time));

    if (oven->interTempEnabled())
    {
        int interTemp = oven->interTemp();
        ui->interTempLabel->setText(QString().sprintf("%d<span style=\"font-size:11pt;\">℃</span>", interTemp));
    }
    else
        ui->interTempLabel->setText("<span style=\"font-size:11pt;\">℃</span>");

}

void PreheatPopup::on_closeButton_clicked()
{
    close();
}

void PreheatPopup::on_closeButton_2_clicked()
{
    close();
}