diff --git a/app/gui/oven_control/cooldownpopup.cpp b/app/gui/oven_control/cooldownpopup.cpp new file mode 100644 index 0000000..c0f4349 --- /dev/null +++ b/app/gui/oven_control/cooldownpopup.cpp @@ -0,0 +1,205 @@ +#include "cooldownpopup.h" +#include "ui_cooldownpopup.h" + +CooldownPopup::CooldownPopup(QWidget *parent, Oven *oven) : + QWidget(parent), + ui(new Ui::CooldownPopup), + oven(oven), + showingCurrentTemp(false) +{ + ui->setupUi(this); + + setAttribute(Qt::WA_DeleteOnClose); + + ui->openDoorAnimation->load(":/images/animation/door_big_01.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_02.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_03.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_04.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_05.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_06.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_07.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_08.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_09.png"); + ui->openDoorAnimation->start(300); + + cookingFanLevel = oven->fan(); + expectingFanLevel = oven->maxFan(); + started = false; + opened = false; + + connect(oven, SIGNAL(changed(Oven*)), SLOT(updateView())); + + cooldownStartTimer.setSingleShot(true); + cooldownStartTimer.setInterval(2000); + connect(&cooldownStartTimer, SIGNAL(timeout()), SLOT(start())); + + showCurrentTempTimer.setSingleShot(true); + showCurrentTempTimer.setInterval(2000); + connect(&showCurrentTempTimer, SIGNAL(timeout()), SLOT(showCurrentTemp())); + + checkOvenTimer.setInterval(100); + connect(&checkOvenTimer, SIGNAL(timeout()), SLOT(checkOven())); + + connect(ui->tempSlider, SIGNAL(valueChanged(int)), SLOT(updateView())); + + updateView(); + + cooldownStartTimer.start(); +} + +CooldownPopup::~CooldownPopup() +{ + delete ui; +} + +void CooldownPopup::start() +{ + started = true; + opened = false; + + checkOvenTimer.start(); + + updateView(); +} + +void CooldownPopup::stop() +{ + started = false; + + oven->stopCooldown(); + oven->setFan(cookingFanLevel); + + close(); +} + +void CooldownPopup::showCurrentTemp() +{ + showingCurrentTemp = true; + updateView(); +} + +void CooldownPopup::updateView() +{ + int temp; + if (showingCurrentTemp) + temp = oven->currentTemp(); + else + temp = ui->tempSlider->value(); + + ui->tempCurrentLabel->setText(QString("%1<span style=\"font-size:11pt;\">℃</span>").arg(temp)); + + switch (expectingFanLevel) + { + case 1: + ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan1.png);"); + break; + case 2: + ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan2.png);"); + break; + case 3: + ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan3.png);"); + break; + case 4: + ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan4.png);"); + break; + case 5: + ui->fanButton->setStyleSheet("background-image: url(:/images/cooldown/fan5.png);"); + break; + } + + if (oven->humidification()) + ui->humidificationButton->setStyleSheet("background-image: url(:/images/cooldown/side_nozzle_ov.png);"); + else + ui->humidificationButton->setStyleSheet("background-image: url(:/images/cooldown/side_nozzle.png);"); + + if (started && !oven->door()) + ui->openDoorWidget->show(); + else + ui->openDoorWidget->hide(); +} + +void CooldownPopup::checkOven() +{ + updateView(); + + if (!started) + return; + + if (!opened) + { + if (oven->door()) + { + opened = true; + oven->setFan(expectingFanLevel); + oven->startCooldown(); + } + } + else + { + if (oven->currentTemp() <= ui->tempSlider->value()) + { + stop(); + } + } +} + +void CooldownPopup::on_closeButton_clicked() +{ + stop(); + close(); +} + +void CooldownPopup::on_closeButton_2_clicked() +{ + stop(); + close(); +} + +void CooldownPopup::on_tempButton_pressed() +{ + showCurrentTempTimer.start(); +} + +void CooldownPopup::on_tempButton_released() +{ + if (showCurrentTempTimer.isActive()) + showCurrentTempTimer.stop(); + + if (showingCurrentTemp) + { + showingCurrentTemp = false; + updateView(); + } +} + +void CooldownPopup::on_runButton_clicked() +{ + if (cooldownStartTimer.isActive()) + { + cooldownStartTimer.stop(); + start(); + } +} + +void CooldownPopup::on_fanButton_clicked() +{ + expectingFanLevel--; + if (expectingFanLevel < oven->minFan()) + expectingFanLevel = oven->maxFan(); + + if (oven->cooldown()) + oven->setFan(expectingFanLevel); + else + updateView(); + + if (cooldownStartTimer.isActive()) + cooldownStartTimer.start(); +} + +void CooldownPopup::on_humidificationButton_clicked() +{ + if (oven->humidification()) + oven->stopHumidification(); + else + oven->startHumidification(); +} diff --git a/app/gui/oven_control/cooldownpopup.h b/app/gui/oven_control/cooldownpopup.h new file mode 100644 index 0000000..3a56cec --- /dev/null +++ b/app/gui/oven_control/cooldownpopup.h @@ -0,0 +1,58 @@ +#ifndef COOLDOWNPOPUP_H +#define COOLDOWNPOPUP_H + +#include <QWidget> +#include <QTimer> + +#include "oven.h" + +namespace Ui { +class CooldownPopup; +} + +class CooldownPopup : public QWidget +{ + Q_OBJECT + +public: + explicit CooldownPopup(QWidget *parent = 0, Oven *oven = 0); + ~CooldownPopup(); + +private slots: + void start(); + void stop(); + void showCurrentTemp(); + void updateView(); + void checkOven(); + + void on_closeButton_clicked(); + + void on_closeButton_2_clicked(); + + void on_tempButton_pressed(); + + void on_tempButton_released(); + + void on_runButton_clicked(); + + void on_fanButton_clicked(); + + void on_humidificationButton_clicked(); + +private: + Ui::CooldownPopup *ui; + Oven *oven; + + QTimer cooldownStartTimer; + QTimer checkOvenTimer; + + bool showingCurrentTemp; + QTimer showCurrentTempTimer; + + int cookingFanLevel; + int expectingFanLevel; + bool started; + bool opened; +}; + +#endif // COOLDOWNPOPUP_H diff --git a/app/gui/oven_control/cooldownpopup.ui b/app/gui/oven_control/cooldownpopup.ui new file mode 100644 index 0000000..abbdf78 --- /dev/null +++ b/app/gui/oven_control/cooldownpopup.ui @@ -0,0 +1,445 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CooldownPopup</class> + <widget class="QWidget" name="CooldownPopup"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>900</width> + <height>1600</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <property name="styleSheet"> + <string notr="true">#closeButton { border: none; } +#closeButton_2 { border: none; } +#background { background-image: url(:/images/background/popup/373.png); } + +QPushButton { +background-position: center; +background-repeat: no-repeat; +border: none; +} + +QPushButton[style="icon"] { background-image: url(:/images/slider_icon/background.png); } + +QSlider::groove { +background-image: url(:/images/slider/groove.png); +background-repeat: no-repeat; +background-position: center; +} + +QSlider::sub-page { +background-repeat: no-repeat; +background-position: left center; +margin: 0px 5px; +} + +QSlider[sliderColor="red"]::sub-page { +background-image: url(:/images/slider/sub_red.png); +} + +QSlider[sliderColor="yellow"]::sub-page { +background-image: url(:/images/slider/sub_yellow.png); +} + +QSlider[sliderColor="white"]::sub-page { +background-image: url(:/images/slider/sub_white.png); +} + +QSlider[sliderColor="blue"]::sub-page { +background-image: url(:/images/slider/sub_blue.png); +} + +QSlider[sliderColor="green"]::sub-page { +background-image: url(:/images/slider/sub_green.png); +} + +QSlider::handle { +background-image: url(:/images/slider/handle_big.png); +background-repeat: no-repeat; +background-position: center; +width: 23px; +height: 33px; +}</string> + </property> + <widget class="QPushButton" name="closeButton_2"> + <property name="geometry"> + <rect> + <x>0</x> + <y>801</y> + <width>900</width> + <height>799</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + </widget> + <widget class="QWidget" name="background" native="true"> + <property name="geometry"> + <rect> + <x>0</x> + <y>426</y> + <width>900</width> + <height>373</height> + </rect> + </property> + <widget class="QPushButton" name="tempButton"> + <property name="geometry"> + <rect> + <x>30</x> + <y>50</y> + <width>140</width> + <height>140</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton { image: url(:/images/slider_icon/cooldown.png); } +QPushButton::pressed { image: url(:/images/slider_icon/cooldown_ov.png); }</string> + </property> + <property name="text"> + <string notr="true"/> + </property> + <property name="style" stdset="0"> + <string notr="true">icon</string> + </property> + </widget> + <widget class="QPushButton" name="runButton"> + <property name="geometry"> + <rect> + <x>590</x> + <y>260</y> + <width>78</width> + <height>78</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton { background-image: url(:/images/cooldown/run.png); } +QPushButton:pressed { background-image: url(:/images/cooldown/run_ov.png); }</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + <widget class="QPushButton" name="fanButton"> + <property name="geometry"> + <rect> + <x>690</x> + <y>260</y> + <width>78</width> + <height>78</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton { background-image: url(:/images/cooldown/fan5.png); }</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + <widget class="QPushButton" name="humidificationButton"> + <property name="geometry"> + <rect> + <x>790</x> + <y>260</y> + <width>78</width> + <height>78</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton { background-image: url(:/images/cooldown/side_nozzle.png); } +QPushButton:pressed { background-image: url(:/images/cooldown/side_nozzle_ov.png); }</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + <widget class="QLabel" name="tempMaxLabel"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>711</x> + <y>60</y> + <width>151</width> + <height>51</height> + </rect> + </property> + <property name="palette"> + <palette> + <active> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + </active> + <inactive> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + </inactive> + <disabled> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>123</red> + <green>123</green> + <blue>123</blue> + </color> + </brush> + </colorrole> + </disabled> + </palette> + </property> + <property name="font"> + <font> + <family>Malgun Gothic</family> + <pointsize>9</pointsize> + </font> + </property> + <property name="text"> + <string>증가</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="tempMinLabel"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>196</x> + <y>60</y> + <width>151</width> + <height>51</height> + </rect> + </property> + <property name="palette"> + <palette> + <active> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + </active> + <inactive> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + </inactive> + <disabled> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>123</red> + <green>123</green> + <blue>123</blue> + </color> + </brush> + </colorrole> + </disabled> + </palette> + </property> + <property name="font"> + <font> + <family>Malgun Gothic</family> + <pointsize>9</pointsize> + </font> + </property> + <property name="text"> + <string>감소</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QSlider" name="tempSlider"> + <property name="geometry"> + <rect> + <x>196</x> + <y>103</y> + <width>666</width> + <height>33</height> + </rect> + </property> + <property name="minimum"> + <number>30</number> + </property> + <property name="maximum"> + <number>300</number> + </property> + <property name="pageStep"> + <number>10</number> + </property> + <property name="tracking"> + <bool>true</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sliderColor" stdset="0"> + <string>red</string> + </property> + </widget> + <widget class="QLabel" name="tempCurrentLabel"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>210</x> + <y>130</y> + <width>641</width> + <height>51</height> + </rect> + </property> + <property name="palette"> + <palette> + <active> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + </active> + <inactive> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + </inactive> + <disabled> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>123</red> + <green>123</green> + <blue>123</blue> + </color> + </brush> + </colorrole> + </disabled> + </palette> + </property> + <property name="font"> + <font> + <family>Roboto</family> + <pointsize>16</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>스팀</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </widget> + <widget class="QPushButton" name="closeButton"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>900</width> + <height>426</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + </widget> + <widget class="QWidget" name="openDoorWidget" native="true"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>900</width> + <height>426</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">#openDoorWidget { background-image: url(:/images/clock/background.png); }</string> + </property> + <widget class="AnimatedImageBox" name="openDoorAnimation"> + <property name="geometry"> + <rect> + <x>366</x> + <y>20</y> + <width>251</width> + <height>292</height> + </rect> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + <widget class="QLabel" name="label_5"> + <property name="geometry"> + <rect> + <x>430</x> + <y>170</y> + <width>85</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap resource="resources.qrc">:/images/animation/open_door_arrow.png</pixmap> + </property> + </widget> + </widget> + </widget> + <customwidgets> + <customwidget> + <class>AnimatedImageBox</class> + <extends>QLabel</extends> + <header>animatedimagebox.h</header> + </customwidget> + </customwidgets> + <resources> + <include location="resources.qrc"/> + </resources> + <connections/> +</ui> diff --git a/app/gui/oven_control/manualcookwindow.cpp b/app/gui/oven_control/manualcookwindow.cpp index f6f8e5a..df0f6e3 100644 --- a/app/gui/oven_control/manualcookwindow.cpp +++ b/app/gui/oven_control/manualcookwindow.cpp @@ -6,6 +6,7 @@ #include <QtDebug> #include "preheatpopup.h" +#include "cooldownpopup.h" ManualCookWindow::ManualCookWindow(QWidget *parent, Oven *oven, UdpHandler *udp) : QMainWindow(parent), @@ -14,6 +15,7 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Oven *oven, UdpHandler *udp) ui->setupUi(this); ui->clockContainer->setParent(ui->upperStack); + ui->closeDoorWidget->setParent(ui->upperStack); ui->outerStack->setParent(ui->bodyStack); ui->innerStack->setParent(ui->bodyStack); setAttribute(Qt::WA_DeleteOnClose); @@ -91,6 +93,17 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Oven *oven, UdpHandler *udp) connect(this, SIGNAL(cookStopRequested()), cookingStartTimer, SLOT(stop())); ui->bodyStack->setCurrentIndex(0); + + ui->openDoorAnimation->load(":/images/animation/door_big_09.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_08.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_07.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_06.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_05.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_04.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_03.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_02.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_01.png"); + ui->openDoorAnimation->start(300); } ManualCookWindow::~ManualCookWindow() @@ -318,6 +331,11 @@ QPushButton:pressed {\ break; } + if (oven->paused() && !oven->cooldown() && oven->door()) + ui->upperStack->setCurrentIndex(1); + else + ui->upperStack->setCurrentIndex(0); + updateLabels(); } @@ -394,10 +412,11 @@ void ManualCookWindow::on_repeatButton_clicked() void ManualCookWindow::on_cooldownButton_clicked() { - if (oven->cooldown()) - oven->stopCooldown(); - else - oven->startCooldown(); + cookingStartTimer->stop(); + + CooldownPopup *p = new CooldownPopup(this, oven); + p->setWindowModality(Qt::WindowModal); + p->showFullScreen(); } void ManualCookWindow::on_reserveButton_clicked() diff --git a/app/gui/oven_control/manualcookwindow.ui b/app/gui/oven_control/manualcookwindow.ui index faa9a06..38c5a5b 100644 --- a/app/gui/oven_control/manualcookwindow.ui +++ b/app/gui/oven_control/manualcookwindow.ui @@ -106,6 +106,43 @@ height: 33px; </property> </widget> </widget> + <widget class="QWidget" name="closeDoorWidget"> + <property name="styleSheet"> + <string notr="true">#closeDoorWidget { background-image: url(:/images/clock/background.png); }</string> + </property> + <widget class="AnimatedImageBox" name="openDoorAnimation"> + <property name="geometry"> + <rect> + <x>366</x> + <y>20</y> + <width>251</width> + <height>292</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap resource="resources.qrc">:/images/animation/door_big_02.png</pixmap> + </property> + </widget> + <widget class="QLabel" name="label_5"> + <property name="geometry"> + <rect> + <x>430</x> + <y>170</y> + <width>85</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap resource="resources.qrc">:/images/animation/close_door_arrow.png</pixmap> + </property> + </widget> + </widget> </widget> <widget class="QPushButton" name="combiButton"> <property name="geometry"> @@ -2427,6 +2464,11 @@ QPushButton:pressed { border-image: url(:/images/manual_button/ok_ov.png); }</st <header>clock.h</header> <container>1</container> </customwidget> + <customwidget> + <class>AnimatedImageBox</class> + <extends>QLabel</extends> + <header>animatedimagebox.h</header> + </customwidget> </customwidgets> <resources> <include location="resources.qrc"/> diff --git a/app/gui/oven_control/oven_control.pro b/app/gui/oven_control/oven_control.pro index 22b8f97..c9d339a 100644 --- a/app/gui/oven_control/oven_control.pro +++ b/app/gui/oven_control/oven_control.pro @@ -41,7 +41,8 @@ SOURCES += main.cpp\ washwindow.cpp \ washstepgauge.cpp \ preheatpopup.cpp \ - longpreheattempgauge.cpp + longpreheattempgauge.cpp \ + cooldownpopup.cpp HEADERS += mainwindow.h \ cook.h \ @@ -71,7 +72,8 @@ HEADERS += mainwindow.h \ washwindow.h \ washstepgauge.h \ preheatpopup.h \ - longpreheattempgauge.h + longpreheattempgauge.h \ + cooldownpopup.h FORMS += mainwindow.ui \ manualcookwindow.ui \ @@ -87,7 +89,8 @@ FORMS += mainwindow.ui \ autocookwindow.ui \ autocookconfigwindow.ui \ washwindow.ui \ - preheatpopup.ui + preheatpopup.ui \ + cooldownpopup.ui RESOURCES += \ resources.qrc