diff --git a/app/gui/oven_control/manualcookfinishpopup.cpp b/app/gui/oven_control/manualcookfinishpopup.cpp new file mode 100644 index 0000000..d60b9af --- /dev/null +++ b/app/gui/oven_control/manualcookfinishpopup.cpp @@ -0,0 +1,115 @@ +#include "manualcookfinishpopup.h" +#include "ui_manualcookfinishpopup.h" + +#include <QKeyEvent> + +#include "soundplayer.h" + +ManualCookFinishPopup::ManualCookFinishPopup(QWidget *parent) : + QWidget(parent), + ui(new Ui::ManualCookFinishPopup) +{ + ui->setupUi(this); + + setAttribute(Qt::WA_DeleteOnClose); + + foreach (QPushButton *button, findChildren<QPushButton *>()) + connect(button, &QPushButton::pressed, SoundPlayer::playClick); + + ui->background->setFocus(); +} + +ManualCookFinishPopup::~ManualCookFinishPopup() +{ + delete ui; +} + +void ManualCookFinishPopup::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 ManualCookFinishPopup::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 ManualCookFinishPopup::onEncoderLeft() +{ + QWidget *focused = focusWidget(); + if (focused == ui->background) + ui->okButton->setFocus(); + else + focusPreviousChild(); +} + +void ManualCookFinishPopup::onEncoderRight() +{ + if (focusWidget() == ui->okButton) + ui->background->setFocus(); + else + focusNextChild(); +} + +void ManualCookFinishPopup::onEncoderClicked(QWidget *clicked) +{ + if (clicked == ui->background) + { + close(); + return; + } + + QPushButton *b = qobject_cast<QPushButton *>(clicked); + if (b) + { + b->click(); + return; + } +} + +void ManualCookFinishPopup::on_closeButton_clicked() +{ + close(); +} + +void ManualCookFinishPopup::on_closeButton_2_clicked() +{ + close(); +} + +void ManualCookFinishPopup::on_warmupButton_clicked() +{ + close(); + + emit keepWarm(); +} + +void ManualCookFinishPopup::on_okButton_clicked() +{ + close(); +} diff --git a/app/gui/oven_control/manualcookfinishpopup.h b/app/gui/oven_control/manualcookfinishpopup.h new file mode 100644 index 0000000..93c094b --- /dev/null +++ b/app/gui/oven_control/manualcookfinishpopup.h @@ -0,0 +1,41 @@ +#ifndef MANUALCOOKFINISHPOPUP_H +#define MANUALCOOKFINISHPOPUP_H + +#include <QWidget> + +namespace Ui { +class ManualCookFinishPopup; +} + +class ManualCookFinishPopup : public QWidget +{ + Q_OBJECT + +public: + explicit ManualCookFinishPopup(QWidget *parent = nullptr); + ~ManualCookFinishPopup(); + +signals: + void keepWarm(); + +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + +private: + Ui::ManualCookFinishPopup *ui; + + QWidget *pushed = Q_NULLPTR; + + void onEncoderLeft(); + void onEncoderRight(); + void onEncoderClicked(QWidget *clicked); + +private slots: + void on_closeButton_clicked(); + void on_closeButton_2_clicked(); + void on_warmupButton_clicked(); + void on_okButton_clicked(); +}; + +#endif // MANUALCOOKFINISHPOPUP_H diff --git a/app/gui/oven_control/manualcookfinishpopup.ui b/app/gui/oven_control/manualcookfinishpopup.ui new file mode 100644 index 0000000..26537c0 --- /dev/null +++ b/app/gui/oven_control/manualcookfinishpopup.ui @@ -0,0 +1,151 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ManualCookFinishPopup</class> + <widget class="QWidget" name="ManualCookFinishPopup"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>1080</width> + <height>1920</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); } +#background:focus { border: 4px solid gray; } + +QPushButton { +background-position: center; +background-repeat: no-repeat; +border: none; +} + +QPushButton[style="icon"] { background-image: url(:/images/slider_icon/background.png); } + +QPushButton { color: white; border: none; } +QPushButton:pressed, QPushButton:focus { color: yellow; } + +QLabel { color: white; }</string> + </property> + <widget class="QPushButton" name="closeButton_2"> + <property name="geometry"> + <rect> + <x>0</x> + <y>961</y> + <width>1080</width> + <height>958</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + </widget> + <widget class="QWidget" name="background" native="true"> + <property name="geometry"> + <rect> + <x>0</x> + <y>511</y> + <width>1080</width> + <height>447</height> + </rect> + </property> + <property name="focusPolicy"> + <enum>Qt::TabFocus</enum> + </property> + <widget class="QPushButton" name="warmupButton"> + <property name="geometry"> + <rect> + <x>650</x> + <y>320</y> + <width>182</width> + <height>84</height> + </rect> + </property> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + <underline>true</underline> + </font> + </property> + <property name="styleSheet"> + <string notr="true"/> + </property> + <property name="text"> + <string>보온</string> + </property> + </widget> + <widget class="QPushButton" name="okButton"> + <property name="geometry"> + <rect> + <x>850</x> + <y>320</y> + <width>182</width> + <height>84</height> + </rect> + </property> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + <underline>true</underline> + </font> + </property> + <property name="styleSheet"> + <string notr="true"/> + </property> + <property name="text"> + <string>확인</string> + </property> + </widget> + <widget class="QLabel" name="text"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>1080</width> + <height>240</height> + </rect> + </property> + <property name="font"> + <font> + <pointsize>16</pointsize> + </font> + </property> + <property name="text"> + <string>요리가 끝났습니다</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </widget> + <widget class="QPushButton" name="closeButton"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>1080</width> + <height>511</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + </widget> + </widget> + <tabstops> + <tabstop>closeButton_2</tabstop> + <tabstop>background</tabstop> + <tabstop>warmupButton</tabstop> + <tabstop>okButton</tabstop> + <tabstop>closeButton</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/app/gui/oven_control/manualcookwindow.cpp b/app/gui/oven_control/manualcookwindow.cpp index b55f233..166fb19 100644 --- a/app/gui/oven_control/manualcookwindow.cpp +++ b/app/gui/oven_control/manualcookwindow.cpp @@ -24,6 +24,7 @@ #include "errorpopupdlg.h" #include "manualviewerdlg.h" #include "haccp.h" +#include "manualcookfinishpopup.h" #include <QTime> @@ -616,6 +617,19 @@ void ManualCookWindow::showInfoText(QString text, QString icon) showInfoTextTimer.start(); } +void ManualCookWindow::startKeepWarm() +{ + if (oven->mode() == Define::CombiMode) + return; + + cookDone = false; + + oven->setTemp(70); + oven->setTime(60*60); + + start(); +} + void ManualCookWindow::onOvenUpdated(Oven *oven) { updateView(); @@ -650,6 +664,12 @@ void ManualCookWindow::onOvenUpdated(Oven *oven) HACCP::done(); emit done(); + + if (oven->mode() != Define::CombiMode) { + ManualCookFinishPopup *p = new ManualCookFinishPopup(this); + p->showFullScreen(); + connect(p, SIGNAL(keepWarm()), SLOT(startKeepWarm())); + } } } diff --git a/app/gui/oven_control/manualcookwindow.h b/app/gui/oven_control/manualcookwindow.h index c35d461..f757e6c 100644 --- a/app/gui/oven_control/manualcookwindow.h +++ b/app/gui/oven_control/manualcookwindow.h @@ -42,6 +42,7 @@ private slots: void showCurrentTemp(); void hideCurrentTemp(); void showInfoText(QString text, QString icon); + void startKeepWarm(); void onOvenUpdated(Oven *oven); diff --git a/app/gui/oven_control/oven_control.pro b/app/gui/oven_control/oven_control.pro index fd87cb9..85f5f0b 100644 --- a/app/gui/oven_control/oven_control.pro +++ b/app/gui/oven_control/oven_control.pro @@ -16,6 +16,7 @@ SOURCES += main.cpp\ commicon.cpp \ mainwindow.cpp \ cook.cpp \ + manualcookfinishpopup.cpp \ oven.cpp \ abstractoveninterface.cpp \ clock.cpp \ @@ -156,6 +157,7 @@ SOURCES += main.cpp\ HEADERS += mainwindow.h \ commicon.h \ cook.h \ + manualcookfinishpopup.h \ oven.h \ abstractoveninterface.h \ clock.h \ @@ -294,6 +296,7 @@ HEADERS += mainwindow.h \ waterlevelicon.h FORMS += mainwindow.ui \ + manualcookfinishpopup.ui \ manualcookwindow.ui \ configwindow.ui \ functiontestwindow.ui \