From f588aa273e875883f46c192d147b65e4a1f4edf3 Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 16 May 2017 16:29:24 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B6=80=EA=B0=80=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/gui/oven_control/autocookconfigwindow.cpp | 28 + app/gui/oven_control/autocookconfigwindow.h | 2 + app/gui/oven_control/autocooksettingwidget.cpp | 159 +++ app/gui/oven_control/autocooksettingwidget.h | 40 + app/gui/oven_control/autocooksettingwidget.ui | 1347 ++++++++++++++++++++++ app/gui/oven_control/autocookwindow.cpp | 42 +- app/gui/oven_control/autocookwindow.h | 2 + app/gui/oven_control/confirmpopup.cpp | 27 + app/gui/oven_control/confirmpopup.h | 31 + app/gui/oven_control/confirmpopup.ui | 138 +++ app/gui/oven_control/cookbook.cpp | 12 + app/gui/oven_control/cookbook.h | 1 + app/gui/oven_control/cookhistory.cpp | 1335 ++++++++++++++++++++- app/gui/oven_control/cookhistory.h | 63 +- app/gui/oven_control/cookpanelbutton.cpp | 62 +- app/gui/oven_control/cookpanelbutton.h | 33 +- app/gui/oven_control/cookpanelbutton.ui | 6 + app/gui/oven_control/favoritenamepopup.cpp | 71 ++ app/gui/oven_control/favoritenamepopup.h | 37 + app/gui/oven_control/favoritenamepopup.ui | 176 +++ app/gui/oven_control/mainwindow.cpp | 26 +- app/gui/oven_control/manualcooksettingwidget.cpp | 120 ++ app/gui/oven_control/manualcooksettingwidget.h | 33 + app/gui/oven_control/manualcooksettingwidget.ui | 917 +++++++++++++++ app/gui/oven_control/manualcookwindow.cpp | 70 +- app/gui/oven_control/manualcookwindow.h | 3 + app/gui/oven_control/oven_control.pro | 18 +- app/gui/oven_control/primewindow.cpp | 160 ++- app/gui/oven_control/primewindow.h | 28 +- app/gui/oven_control/primewindow.ui | 16 +- app/gui/oven_control/programmingwindow.cpp | 8 + app/gui/oven_control/programmingwindow.h | 3 + app/gui/oven_control/programmingwindow.ui | 2 +- 33 files changed, 4965 insertions(+), 51 deletions(-) create mode 100644 app/gui/oven_control/autocooksettingwidget.cpp create mode 100644 app/gui/oven_control/autocooksettingwidget.h create mode 100644 app/gui/oven_control/autocooksettingwidget.ui create mode 100644 app/gui/oven_control/confirmpopup.cpp create mode 100644 app/gui/oven_control/confirmpopup.h create mode 100644 app/gui/oven_control/confirmpopup.ui create mode 100644 app/gui/oven_control/favoritenamepopup.cpp create mode 100644 app/gui/oven_control/favoritenamepopup.h create mode 100644 app/gui/oven_control/favoritenamepopup.ui create mode 100644 app/gui/oven_control/manualcooksettingwidget.cpp create mode 100644 app/gui/oven_control/manualcooksettingwidget.h create mode 100644 app/gui/oven_control/manualcooksettingwidget.ui diff --git a/app/gui/oven_control/autocookconfigwindow.cpp b/app/gui/oven_control/autocookconfigwindow.cpp index feca51e..fa2ead5 100644 --- a/app/gui/oven_control/autocookconfigwindow.cpp +++ b/app/gui/oven_control/autocookconfigwindow.cpp @@ -2,6 +2,8 @@ #include "ui_autocookconfigwindow.h" #include "autocookwindow.h" +#include "confirmpopup.h" +#include "favoritenamepopup.h" AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Cook cook) : QMainWindow(parent), @@ -223,7 +225,33 @@ void AutoCookConfigWindow::start() w->raise(); } +void AutoCookConfigWindow::addFavorite() +{ + AutoCookSetting s; + s.type = cook.type; + s.root = cook.root; + for (int i = 0; i < 5; i++) + s.configs[i] = cook.configs[i].current; + + FavoriteNamePopup *p = new FavoriteNamePopup(this, s); + p->showFullScreen(); +} + void AutoCookConfigWindow::on_backButton_clicked() { close(); } + +void AutoCookConfigWindow::on_favoritesButton_clicked() +{ + ConfirmPopup *p = new ConfirmPopup(this, tr("즐겨찾기 항목에 추가하시겠습니까?")); + p->showFullScreen(); + + connect(p, SIGNAL(accepted()), SLOT(addFavorite())); + + if (cookStartTimer.isActive()) + { + cookStartTimer.stop(); + connect(p, SIGNAL(rejected()), &cookStartTimer, SLOT(start())); + } +} diff --git a/app/gui/oven_control/autocookconfigwindow.h b/app/gui/oven_control/autocookconfigwindow.h index 42f4d19..b8f6c44 100644 --- a/app/gui/oven_control/autocookconfigwindow.h +++ b/app/gui/oven_control/autocookconfigwindow.h @@ -47,8 +47,10 @@ private slots: void startTimer(); void stopTimer(); void start(); + void addFavorite(); void on_backButton_clicked(); + void on_favoritesButton_clicked(); }; #endif // AUTOCOOKCONFIGWINDOW_H diff --git a/app/gui/oven_control/autocooksettingwidget.cpp b/app/gui/oven_control/autocooksettingwidget.cpp new file mode 100644 index 0000000..f804925 --- /dev/null +++ b/app/gui/oven_control/autocooksettingwidget.cpp @@ -0,0 +1,159 @@ +#include "autocooksettingwidget.h" +#include "ui_autocooksettingwidget.h" + + +AutoCookSettingWidget::AutoCookSettingWidget(AutoCookSetting setting, QWidget *parent) : + QWidget(parent), + ui(new Ui::AutoCookSettingWidget) +{ + ui->setupUi(this); + + Cook cook(setting.type, setting.root, setting.name); + cook.setConfig(setting.configs[0], + setting.configs[1], + setting.configs[2], + setting.configs[3], + setting.configs[4]); + + configWidgets.append( + ConfigWidget { + ui->configButton_1, + ui->configMinLabel_1, + ui->configMaxLabel_1, + ui->configCurrentLabel_1, + ui->configSlider_1 + }); + configWidgets.append( + ConfigWidget { + ui->configButton_2, + ui->configMinLabel_2, + ui->configMaxLabel_2, + ui->configCurrentLabel_2, + ui->configSlider_2 + }); + configWidgets.append( + ConfigWidget { + ui->configButton_3, + ui->configMinLabel_3, + ui->configMaxLabel_3, + ui->configCurrentLabel_3, + ui->configSlider_3 + }); + configWidgets.append( + ConfigWidget { + ui->configButton_4, + ui->configMinLabel_4, + ui->configMaxLabel_4, + ui->configCurrentLabel_4, + ui->configSlider_4 + }); + configWidgets.append( + ConfigWidget { + ui->configButton_5, + ui->configMinLabel_5, + ui->configMaxLabel_5, + ui->configCurrentLabel_5, + ui->configSlider_5 + }); + + setupUi(cook); +} + +AutoCookSettingWidget::~AutoCookSettingWidget() +{ + delete ui; +} + +void AutoCookSettingWidget::setupUi(Cook cook) +{ + ui->cookTypeIcon->setPixmap(Define::icon(cook.type)); + ui->selectCookButton->setText(cook.name); + + for (int idx = 0; idx < 5; idx++) + { + ConfigWidget cw = configWidgets.at(idx); + + CookConfig config = cook.configs[idx]; + if (config.type == Define::ConfigNotUsed) + { + cw.button->hide(); + cw.minimum->hide(); + cw.maximum->hide(); + cw.current->hide(); + cw.slider->hide(); + } + else + { + cw.button->setStyleSheet( + QString("QPushButton { image: url(%1); } QPushButton:pressed { image: url(%2); }") + .arg(Define::icon(config.type)) + .arg(Define::iconOverlay(config.type))); + + cw.minimum->setText(Define::minimum(config.type)); + cw.maximum->setText(Define::maximum(config.type)); + cw.slider->blockSignals(true); + cw.slider->setMinimum(1); + cw.slider->setMaximum(config.maximum); + cw.slider->setValue(config.current); + cw.slider->blockSignals(false); + + switch (config.type) + { + case Define::Time: + cw.slider->setProperty("sliderColor", "white"); + break; + case Define::BurnDegree: + cw.slider->setProperty("sliderColor", "yellow"); + break; + case Define::Brightness: + cw.slider->setProperty("sliderColor", "red"); + break; + default: + cw.slider->setProperty("sliderColor", "blue"); + break; + } + + switch (config.type) + { + case Define::Time: + { + int time = cook.time(); + if (time >= 3600) + cw.current->setText(QString().sprintf( + "%d" + "시간" + " %02d" + "", + time / 3600, + (time % 3600) / 60)); + else if (time >= 60) + cw.current->setText(QString().sprintf( + "%d" + "" + " %02d" + "", + time / 60, + time % 60)); + else + cw.current->setText(QString().sprintf( + "%d" + "", + time)); + break; + } + case Define::BurnDegree: + cw.current->setText(QString().sprintf( + "%d" + "", + cook.coreTemp())); + break; + default: + cw.current->setText(QString().sprintf( + "%d" + "/%d", + config.current, config.maximum)); + break; + } + } + } +} diff --git a/app/gui/oven_control/autocooksettingwidget.h b/app/gui/oven_control/autocooksettingwidget.h new file mode 100644 index 0000000..9697a94 --- /dev/null +++ b/app/gui/oven_control/autocooksettingwidget.h @@ -0,0 +1,40 @@ +#ifndef AUTOCOOKSETTINGWIDGET_H +#define AUTOCOOKSETTINGWIDGET_H + +#include +#include +#include +#include + +#include "define.h" +#include "cook.h" +#include "cookhistory.h" + +namespace Ui { +class AutoCookSettingWidget; +} + +class AutoCookSettingWidget : public QWidget +{ + Q_OBJECT + + struct ConfigWidget { + QPushButton *button; + QLabel *minimum; + QLabel *maximum; + QLabel *current; + QSlider *slider; + }; + +public: + explicit AutoCookSettingWidget(AutoCookSetting setting, QWidget *parent = 0); + ~AutoCookSettingWidget(); + +private: + Ui::AutoCookSettingWidget *ui; + QList configWidgets; + + void setupUi(Cook cook); +}; + +#endif // AUTOCOOKSETTINGWIDGET_H diff --git a/app/gui/oven_control/autocooksettingwidget.ui b/app/gui/oven_control/autocooksettingwidget.ui new file mode 100644 index 0000000..62d5a15 --- /dev/null +++ b/app/gui/oven_control/autocooksettingwidget.ui @@ -0,0 +1,1347 @@ + + + AutoCookSettingWidget + + + + 0 + 0 + 900 + 1024 + + + + Form + + + #background { +background-image: url(:/images/background/auto.png); +margin-top: -426px; +border-top: 426px; +} + +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; +} + +QPushButton[style="icon"] { +background-image: url(:/images/slider_icon/background.png); +background-repeat: no-repeat; +background-position: center; +border: none; +} + + + + true + + + + 700 + 354 + 151 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 증가 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 27 + 689 + 140 + 140 + + + + + + + icon + + + + + + 27 + 509 + 140 + 140 + + + + + + + icon + + + + + true + + + + 700 + 874 + 151 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 증가 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + true + + + + 199 + 264 + 641 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 스팀 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + true + + + + 185 + 874 + 151 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 감소 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 27 + 339 + 140 + 140 + + + + + + + icon + + + + + + 185 + 917 + 666 + 33 + + + + 100 + + + 1 + + + 0 + + + true + + + Qt::Horizontal + + + + + true + + + + 199 + 424 + 641 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 스팀 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + true + + + + 189 + 944 + 651 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 스팀 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 185 + 567 + 666 + 33 + + + + 100 + + + 1 + + + 0 + + + true + + + Qt::Horizontal + + + + + + 185 + 397 + 666 + 33 + + + + 100 + + + 1 + + + 10 + + + true + + + Qt::Horizontal + + + + + true + + + + 199 + 594 + 641 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 스팀 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 0 + 4 + 250 + 150 + + + + + + + :/images/images/auto/005_auto_icon_01_ov.png + + + Qt::AlignCenter + + + + + true + + + + 700 + 704 + 151 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 증가 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 27 + 859 + 140 + 140 + + + + + + + icon + + + + + true + + + + 185 + 194 + 151 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 감소 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 720 + 54 + 152 + 70 + + + + QPushButton { +border-image: url(:/images/button/152.png); +} +QPushButton::pressed { +border-image: url(:/images/button/152_ov.png); +} + + + + + + + :/images/auto_button/btn_icon_01.png:/images/auto_button/btn_icon_01.png + + + + 40 + 51 + + + + + + + 27 + 179 + 140 + 140 + + + + + + + icon + + + + + true + + + + 185 + 354 + 151 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 감소 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 185 + 747 + 666 + 33 + + + + 100 + + + 1 + + + 0 + + + true + + + Qt::Horizontal + + + + + true + + + + 199 + 774 + 641 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 스팀 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + true + + + + 700 + 194 + 151 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 증가 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + true + + + + 185 + 524 + 151 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 감소 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + true + + + + 185 + 704 + 151 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 감소 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 185 + 237 + 666 + 33 + + + + 100 + + + 1 + + + 39 + + + true + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 1 + + + + + true + + + + 700 + 524 + 151 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 증가 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 420 + 54 + 288 + 70 + + + + + Roboto + 10 + 75 + true + + + + QPushButton { +border-image: url(:/images/button/288.png); +} +QPushButton::pressed { +border-image: url(:/images/button/288_ov.png); +} + + + + + + + + + 0 + 0 + 900 + 1024 + + + + + + + background + configMaxLabel_2 + configButton_4 + configButton_3 + configMaxLabel_5 + configCurrentLabel_1 + configMinLabel_5 + configButton_2 + configSlider_5 + configCurrentLabel_2 + configCurrentLabel_5 + configSlider_3 + configSlider_2 + configCurrentLabel_3 + cookTypeIcon + configMaxLabel_4 + configButton_5 + configMinLabel_1 + pushButton_4 + configButton_1 + configMinLabel_2 + configSlider_4 + configCurrentLabel_4 + configMaxLabel_1 + configMinLabel_3 + configMinLabel_4 + configSlider_1 + configMaxLabel_3 + selectCookButton + + + + + + diff --git a/app/gui/oven_control/autocookwindow.cpp b/app/gui/oven_control/autocookwindow.cpp index aa63015..f4f0dc5 100644 --- a/app/gui/oven_control/autocookwindow.cpp +++ b/app/gui/oven_control/autocookwindow.cpp @@ -2,6 +2,9 @@ #include "ui_autocookwindow.h" #include "keepwarmpopup.h" +#include "cookhistory.h" +#include "confirmpopup.h" +#include "favoritenamepopup.h" AutoCookWindow::AutoCookWindow(QWidget *parent, Cook cook) : QMainWindow(parent), @@ -13,7 +16,10 @@ AutoCookWindow::AutoCookWindow(QWidget *parent, Cook cook) : ui->clockContainer->setParent(ui->upperStack); setAttribute(Qt::WA_DeleteOnClose); - autocook = AutoCook(cook); + if (!this->cook.isLoaded()) + this->cook.load(); + + autocook = AutoCook(this->cook); processSelected = false; setupUi(); @@ -37,6 +43,16 @@ AutoCookWindow::AutoCookWindow(QWidget *parent, Cook cook) : checkCookTimer.start(100); connect(&checkProcessTimer, SIGNAL(timeout()), SLOT(checkProcess())); + + AutoCookSetting setting; + setting.type = cook.type; + setting.root = cook.root; + setting.name = cook.name; + + for (int i = 0; i < 5; i++) + setting.configs[i] = cook.configs[i].current; + + CookHistory::record(setting); } AutoCookWindow::~AutoCookWindow() @@ -164,6 +180,7 @@ void AutoCookWindow::setupUi() } ui->processContainer->hide(); + ui->doorStepLabel->hide(); updateView(); } @@ -631,6 +648,18 @@ void AutoCookWindow::showCurrentTemp() updateView(); } +void AutoCookWindow::addFavorite() +{ + AutoCookSetting s; + s.type = cook.type; + s.root = cook.root; + for (int i = 0; i < 5; i++) + s.configs[i] = cook.configs[i].current; + + FavoriteNamePopup *p = new FavoriteNamePopup(this, s); + p->showFullScreen(); +} + void AutoCookWindow::on_humidityGaugeButton_pressed() { showCurrentHumidityTimer.start(); @@ -692,3 +721,14 @@ void AutoCookWindow::on_showNextStepButton_clicked() updateView(); } } + +void AutoCookWindow::on_favoritesButton_clicked() +{ + if (!autocook.done()) + return; + + ConfirmPopup *p = new ConfirmPopup(this, tr("즐겨찾기 항목에 추가하시겠습니까?")); + p->showFullScreen(); + + connect(p, SIGNAL(accepted()), SLOT(addFavorite())); +} diff --git a/app/gui/oven_control/autocookwindow.h b/app/gui/oven_control/autocookwindow.h index 492b703..e1882d5 100644 --- a/app/gui/oven_control/autocookwindow.h +++ b/app/gui/oven_control/autocookwindow.h @@ -65,6 +65,7 @@ private slots: void returnToCurrentStep(); void showCurrentHumidity(); void showCurrentTemp(); + void addFavorite(); void on_humidityGaugeButton_pressed(); void on_humidityGaugeButton_released(); void on_heatGaugeButton_pressed(); @@ -72,6 +73,7 @@ private slots: void on_backButton_clicked(); void on_showPrevStepButton_clicked(); void on_showNextStepButton_clicked(); + void on_favoritesButton_clicked(); }; #endif // AUTOCOOKWINDOW_H diff --git a/app/gui/oven_control/confirmpopup.cpp b/app/gui/oven_control/confirmpopup.cpp new file mode 100644 index 0000000..b938aba --- /dev/null +++ b/app/gui/oven_control/confirmpopup.cpp @@ -0,0 +1,27 @@ +#include "confirmpopup.h" +#include "ui_confirmpopup.h" + +ConfirmPopup::ConfirmPopup(QWidget *parent, QString text) : + QWidget(parent), + ui(new Ui::ConfirmPopup) +{ + ui->setupUi(this); + ui->text->setText(text); +} + +ConfirmPopup::~ConfirmPopup() +{ + delete ui; +} + +void ConfirmPopup::on_okButton_clicked() +{ + deleteLater(); + emit accepted(); +} + +void ConfirmPopup::on_cancelButton_clicked() +{ + deleteLater(); + emit rejected(); +} diff --git a/app/gui/oven_control/confirmpopup.h b/app/gui/oven_control/confirmpopup.h new file mode 100644 index 0000000..92aee5e --- /dev/null +++ b/app/gui/oven_control/confirmpopup.h @@ -0,0 +1,31 @@ +#ifndef CONFIRMPOPUP_H +#define CONFIRMPOPUP_H + +#include + +namespace Ui { +class ConfirmPopup; +} + +class ConfirmPopup : public QWidget +{ + Q_OBJECT + +signals: + void accepted(); + void rejected(); + +public: + explicit ConfirmPopup(QWidget *parent, QString text); + ~ConfirmPopup(); + +private slots: + void on_okButton_clicked(); + + void on_cancelButton_clicked(); + +private: + Ui::ConfirmPopup *ui; +}; + +#endif // CONFIRMPOPUP_H diff --git a/app/gui/oven_control/confirmpopup.ui b/app/gui/oven_control/confirmpopup.ui new file mode 100644 index 0000000..f80787f --- /dev/null +++ b/app/gui/oven_control/confirmpopup.ui @@ -0,0 +1,138 @@ + + + ConfirmPopup + + + + 0 + 0 + 900 + 1600 + + + + Form + + + #text { color: white; } +QPushButton { color: white; border: none; } +QPushButton:pressed, QPushButton:focus { color: yellow; } + + + + + 0 + 426 + 900 + 150 + + + + + + + :/images/symbol/warning_big.png + + + Qt::AlignBottom|Qt::AlignHCenter + + + + + + 0 + 576 + 900 + 200 + + + + + 14 + + + + 즐겨찾기 항목에 추가하시겠습니까? + + + Qt::AlignCenter + + + + + + 430 + 776 + 261 + 100 + + + + + + + + 0 + 0 + + + + + 75 + true + true + + + + + + + + + + + + 0 + 0 + + + + + 75 + true + true + + + + 아니오 + + + + + + + + + 0 + 426 + 900 + 503 + + + + + + + :/images/background/popup/503.png + + + background + label + text + horizontalLayoutWidget + + + + + + diff --git a/app/gui/oven_control/cookbook.cpp b/app/gui/oven_control/cookbook.cpp index 82d9954..eb1213e 100644 --- a/app/gui/oven_control/cookbook.cpp +++ b/app/gui/oven_control/cookbook.cpp @@ -100,3 +100,15 @@ Cook CookBook::get(int index) return Cook(); } +QString CookBook::name(QString root) +{ + QString directory = root.replace(this->root, "").replace("/", "").trimmed(); + foreach (ListEntity e, book) + { + if (e.directory == directory) + return e.name; + } + + return QString(); +} + diff --git a/app/gui/oven_control/cookbook.h b/app/gui/oven_control/cookbook.h index 4200492..d04069e 100644 --- a/app/gui/oven_control/cookbook.h +++ b/app/gui/oven_control/cookbook.h @@ -14,6 +14,7 @@ public: CookBook(Define::CookType type); QList list; Cook get(int index); + QString name(QString root); private: struct ListEntity { diff --git a/app/gui/oven_control/cookhistory.cpp b/app/gui/oven_control/cookhistory.cpp index 1eb3b2b..518565c 100644 --- a/app/gui/oven_control/cookhistory.cpp +++ b/app/gui/oven_control/cookhistory.cpp @@ -1,6 +1,1339 @@ #include "cookhistory.h" -CookHistory::CookHistory() +#include "autocookwindow.h" +#include "manualcookwindow.h" +#include "manualcooksettingwidget.h" +#include "autocooksettingwidget.h" +#include "cookbook.h" + +namespace { + +Define::CookType toCookType(QString type) +{ + if (type == "poutry") + return Define::Poultry; + if (type == "meat") + return Define::Meat; + if (type == "fish") + return Define::Fish; + if (type == "desert") + return Define::Desert; + if (type == "vegetable") + return Define::Vegetable; + if (type == "bread") + return Define::Bread; + if (type == "etc") + return Define::Etc; + + return Define::InvalidCookType; +} + +QString toString(Define::CookType type) +{ + switch (type) + { + case Define::Poultry: + return "poultry"; + case Define::Meat: + return "meat"; + case Define::Fish: + return "fish"; + case Define::Desert: + return "desert"; + case Define::Vegetable: + return "vegetable"; + case Define::Bread: + return "bread"; + case Define::Etc: + return "etc"; + default: + return QString(); + } +} + +Define::Mode toMode(QString mode) +{ + if (mode == "steam") + return Define::SteamMode; + if (mode == "combi") + return Define::CombiMode; + if (mode == "dry") + return Define::DryMode; + + return Define::InvalidMode; +} + +QString toString(Define::Mode mode) +{ + switch (mode) + { + case Define::SteamMode: + return "steam"; + case Define::CombiMode: + return "combi"; + case Define::DryMode: + return "dry"; + default: + return QString(); + } +} + +QString name(Define::CookType type, QString root) +{ + CookBook book(type); + return book.name(root); +} + +} + +namespace { + +const int maxMostCooked = 20; +const int maxRecents = 20; +const int maxFavorites = 20; + +struct CountsEntry +{ + QString root; + Define::CookType type; + int count; + int configs[5]; +}; + +struct RecentsEntry +{ + enum Type { Manual, Auto } type; + struct { + Define::CookType type; + QString root; + int configs[5]; + } autoCook; + struct { + Define::Mode mode; + int humidity; + int temp; + int time; + int fan; + int coreTemp; + QDateTime cookedTime; + } manualCook; + + bool operator==(const RecentsEntry &other); +}; + +struct FavoritesEntry +{ + int id; + QString name; + enum Type { Manual, Auto } type; + struct { + Define::CookType type; + QString root; + int configs[5]; + } autoCook; + struct { + Define::Mode mode; + int humidity; + int temp; + int time; + int fan; + int coreTemp; + } manualCook; + + bool operator==(const FavoritesEntry &other); +}; + +QMap countMap; +QList countList; +QList recentList; +QList favoriteList; + +QTimer saveCounts; +QTimer saveRecents; +QTimer saveFavorites; + +bool RecentsEntry::operator==(const RecentsEntry &other) +{ + if (type != other.type) + return false; + + switch (type) + { + case Manual: + if (manualCook.mode != other.manualCook.mode) + return false; + if (manualCook.humidity != other.manualCook.humidity) + return false; + if (manualCook.temp != other.manualCook.temp) + return false; + if (manualCook.time != other.manualCook.time) + return false; + if (manualCook.fan != other.manualCook.fan) + return false; + if (manualCook.coreTemp != other.manualCook.coreTemp) + return false; + if (manualCook.cookedTime != other.manualCook.cookedTime) + return false; + return true; + case Auto: + if (autoCook.type != other.autoCook.type) + return false; + if (autoCook.root != other.autoCook.root) + return false; + return true; + default: + return false; + } +} + +bool FavoritesEntry::operator==(const FavoritesEntry &other) +{ + return id == other.id; +} + +void sortCounts() +{ + countList.clear(); + foreach (CountsEntry e, countMap) + { + bool inserted = false; + for (int i = 0; i < countList.size(); i++) + if (countList.at(i).count < e.count) + { + inserted = true; + countList.insert(i, e); + break; + } + + if (!inserted) + countList.append(e); + + while (countList.size() > maxMostCooked) + countList.takeLast(); + } +} + +void readCounts() +{ + QFile file("/prime/history/counts.csv"); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + qDebug() << "File not found: " + file.fileName(); + return; + } + + QString errorMessage = QString("%3: %1, line %2").arg(file.fileName()); + int lineCount = 0; + while (!file.atEnd()) + { + lineCount++; + + QString line = QString::fromUtf8(file.readLine()).trimmed(); + if (line.isEmpty()) + continue; + + QString error = errorMessage.arg(lineCount); + + QString root = line.section(',', 0, 0).trimmed(); + if (root.isEmpty()) + { + qDebug() << error.arg("Invalid root"); + continue; + } + + QString type = line.section(',', 1, 1).trimmed(); + if (type.isEmpty()) + { + qDebug() << error.arg("Invalid type"); + continue; + } + + QString count = line.section(',', 2, 2).trimmed(); + if (count.isEmpty()) + { + qDebug() << error.arg("Invalid count"); + continue; + } + + QString config1 = line.section(',', 3, 3).trimmed(); + if (config1.isEmpty()) + { + qDebug() << error.arg("Invalid config1"); + continue; + } + + QString config2 = line.section(',', 4, 4).trimmed(); + if (config2.isEmpty()) + { + qDebug() << error.arg("Invalid config2"); + continue; + } + + QString config3 = line.section(',', 5, 5).trimmed(); + if (config3.isEmpty()) + { + qDebug() << error.arg("Invalid config3"); + continue; + } + + QString config4 = line.section(',', 6, 6).trimmed(); + if (config4.isEmpty()) + { + qDebug() << error.arg("Invalid config4"); + continue; + } + + QString config5 = line.section(',', 7, 7).trimmed(); + if (config5.isEmpty()) + { + qDebug() << error.arg("Invalid config5"); + continue; + } + + CountsEntry e; + e.root = root; + + e.type = toCookType(type); + if (e.type == Define::InvalidCookType) + { + qDebug() << error.arg("Invalid type"); + continue; + } + + bool ok; + e.count = count.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid count"); + continue; + } + + e.configs[0] = config1.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config1"); + continue; + } + + e.configs[1] = config2.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config2"); + continue; + } + + e.configs[2] = config3.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config3"); + continue; + } + + e.configs[3] = config4.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config4"); + continue; + } + + e.configs[4] = config5.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config5"); + continue; + } + + countMap.insert(root, e); + } + + sortCounts(); +} + +void writeCounts() { + qDebug() << "Writing counts"; + QFile file("/prime/history/counts.csv"); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + { + qDebug() << "File not opened: " + file.fileName(); + return; + } + + QTextStream stream(&file); + foreach (CountsEntry e, countMap) + { + stream << e.root << "," << toString(e.type) << "," << e.count; + for (int i = 0; i < 5; i++) + stream << "," << e.configs[i]; + + stream << "\n"; + } +} + +void appendRecent(RecentsEntry e) +{ + if (e.type == RecentsEntry::Auto) + { + for (int i = 0; i < recentList.size(); i++) + { + RecentsEntry entry = recentList.at(i); + if (entry.autoCook.root == e.autoCook.root) + { + recentList.removeAt(i); + break; + } + } + } + + recentList.prepend(e); + + while (recentList.size() > maxRecents) + recentList.takeLast(); +} + +void readRecents() +{ + QFile file("/prime/history/recents.csv"); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + qDebug() << "File not found: " + file.fileName(); + return; + } + + QString errorMessage = QString("%3: %1, line %2").arg(file.fileName()); + int lineCount = 0; + while (!file.atEnd()) + { + lineCount++; + + QString line = QString::fromUtf8(file.readLine()).trimmed(); + if (line.isEmpty()) + continue; + + QString error = errorMessage.arg(lineCount); + + RecentsEntry e; + + QString type = line.section(',', 0, 0).trimmed(); + if (type.isEmpty()) + { + qDebug() << error.arg("Invalid type"); + continue; + } + + if (type == "manual") + { + QString mode = line.section(',', 1, 1).trimmed(); + if (mode.isEmpty()) + { + qDebug() << error.arg("Invalid mode"); + continue; + } + + QString humidity = line.section(',', 2, 2).trimmed(); + if (humidity.isEmpty()) + { + qDebug() << error.arg("Invalid humidity"); + continue; + } + + QString temp = line.section(',', 3, 3).trimmed(); + if (temp.isEmpty()) + { + qDebug() << error.arg("Invalid temp"); + continue; + } + + QString time = line.section(',', 4, 4).trimmed(); + if (time.isEmpty()) + { + qDebug() << error.arg("Invalid time"); + continue; + } + + QString fan = line.section(',', 5, 5).trimmed(); + if (fan.isEmpty()) + { + qDebug() << error.arg("Invalid fan"); + continue; + } + + QString coreTemp = line.section(',', 6, 6).trimmed(); + if (coreTemp.isEmpty()) + { + qDebug() << error.arg("Invalid coreTemp"); + continue; + } + + QString cookedTime = line.section(',', 7, 7).trimmed(); + if (cookedTime.isEmpty()) + { + qDebug() << error.arg("Invalid cookedTime"); + continue; + } + + e.type = RecentsEntry::Manual; + + e.manualCook.mode = toMode(mode); + if (e.manualCook.mode == Define::InvalidMode) + { + qDebug() << error.arg("Invalid mode"); + continue; + } + + bool ok; + e.manualCook.humidity = humidity.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid humidity"); + continue; + } + + e.manualCook.temp = temp.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid temp"); + continue; + } + + e.manualCook.time = time.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid time"); + continue; + } + + e.manualCook.fan = fan.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid fan"); + continue; + } + + e.manualCook.coreTemp = coreTemp.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid coreTemp"); + continue; + } + + e.manualCook.cookedTime = QDateTime::fromString(cookedTime); + if (!e.manualCook.cookedTime.isValid()) + { + qDebug() << error.arg("Invalid cookedTime"); + continue; + } + } + else if (type == "auto") + { + QString type = line.section(',', 1, 1).trimmed(); + if (type.isEmpty()) + { + qDebug() << error.arg("Invalid cooktype"); + continue; + } + + QString root = line.section(',', 2, 2).trimmed(); + if (root.isEmpty()) + { + qDebug() << error.arg("Invalid root"); + continue; + } + + QString config1 = line.section(',', 3, 3).trimmed(); + if (config1.isEmpty()) + { + qDebug() << error.arg("Invalid config1"); + continue; + } + + QString config2 = line.section(',', 4, 4).trimmed(); + if (config2.isEmpty()) + { + qDebug() << error.arg("Invalid config2"); + continue; + } + + QString config3 = line.section(',', 5, 5).trimmed(); + if (config3.isEmpty()) + { + qDebug() << error.arg("Invalid config3"); + continue; + } + + QString config4 = line.section(',', 6, 6).trimmed(); + if (config4.isEmpty()) + { + qDebug() << error.arg("Invalid config4"); + continue; + } + + QString config5 = line.section(',', 7, 7).trimmed(); + if (config5.isEmpty()) + { + qDebug() << error.arg("Invalid config5"); + continue; + } + + e.type = RecentsEntry::Auto; + + e.autoCook.type = toCookType(type); + if (e.autoCook.type == Define::InvalidCookType) + { + qDebug() << error.arg("Invalid cooktype"); + continue; + } + + e.autoCook.root = root; + + bool ok; + e.autoCook.configs[0] = config1.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config1"); + continue; + } + + e.autoCook.configs[1] = config2.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config2"); + continue; + } + + e.autoCook.configs[2] = config3.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config3"); + continue; + } + + e.autoCook.configs[3] = config4.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config4"); + continue; + } + + e.autoCook.configs[4] = config5.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config5"); + continue; + } + } + else + continue; + + appendRecent(e); + } +} + +void writeRecents() +{ + qDebug() << "Writing recents"; + QFile file("/prime/history/recents.csv"); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + { + qDebug() << "File not opened: " + file.fileName(); + return; + } + + QTextStream stream(&file); + foreach (RecentsEntry e, recentList) + { + switch (e.type) + { + case RecentsEntry::Manual: + stream << "manual," + << toString(e.manualCook.mode) << "," + << e.manualCook.humidity << "," + << e.manualCook.temp << "," + << e.manualCook.time << "," + << e.manualCook.fan << "," + << e.manualCook.coreTemp << "," + << e.manualCook.cookedTime.toString() << "\n"; + break; + case RecentsEntry::Auto: + stream << "auto," + << toString(e.autoCook.type) << "," + << e.autoCook.root; + for (int i = 0; i < 5; i++) + stream << "," << e.autoCook.configs[i]; + + stream << "\n"; + break; + } + } +} + +void appendFavorite(FavoritesEntry e) +{ + favoriteList.prepend(e); + while (favoriteList.size() > maxFavorites) + favoriteList.takeLast(); +} + +int newFavoriteId() +{ + for (int i = 0; i < 10000; i++) + { + bool absent = true; + foreach (FavoritesEntry e, favoriteList) + if (e.id == i) + { + absent = false; + break; + } + + if (absent) + return i; + } + + return -1; +} + +void readFavorites() +{ + QFile file("/prime/history/favorites.csv"); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + qDebug() << "File not found: " + file.fileName(); + return; + } + + QString errorMessage = QString("%3: %1, line %2").arg(file.fileName()); + int lineCount = 0; + while (!file.atEnd()) + { + lineCount++; + + QString line = QString::fromUtf8(file.readLine()).trimmed(); + if (line.isEmpty()) + continue; + + QString error = errorMessage.arg(lineCount); + + FavoritesEntry e; + + QString id = line.section(',', 0, 0).trimmed(); + if (id.isEmpty()) + { + qDebug() << error.arg("Invalid id"); + continue; + } + + QString name = line.section(',', 1, 1).trimmed(); + if (name.isEmpty()) + { + qDebug() << error.arg("Invalid name"); + continue; + } + + bool ok; + e.id = id.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid id"); + continue; + } + + e.name = name.replace("\\c", ","); + + QString type = line.section(',', 2, 2).trimmed(); + if (type.isEmpty()) + { + qDebug() << error.arg("Invalid type"); + continue; + } + + if (type == "manual") + { + QString mode = line.section(',', 3, 3).trimmed(); + if (mode.isEmpty()) + { + qDebug() << error.arg("Invalid mode"); + continue; + } + + QString humidity = line.section(',', 4, 4).trimmed(); + if (humidity.isEmpty()) + { + qDebug() << error.arg("Invalid humidity"); + continue; + } + + QString temp = line.section(',', 5, 5).trimmed(); + if (temp.isEmpty()) + { + qDebug() << error.arg("Invalid temp"); + continue; + } + + QString time = line.section(',', 6, 6).trimmed(); + if (time.isEmpty()) + { + qDebug() << error.arg("Invalid time"); + continue; + } + + QString fan = line.section(',', 7, 7).trimmed(); + if (fan.isEmpty()) + { + qDebug() << error.arg("Invalid fan"); + continue; + } + + QString coreTemp = line.section(',', 8, 8).trimmed(); + if (coreTemp.isEmpty()) + { + qDebug() << error.arg("Invalid coreTemp"); + continue; + } + + e.type = FavoritesEntry::Manual; + + e.manualCook.mode = toMode(mode); + if (e.manualCook.mode == Define::InvalidMode) + { + qDebug() << error.arg("Invalid mode"); + continue; + } + + bool ok; + e.manualCook.humidity = humidity.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid humidity"); + continue; + } + + e.manualCook.temp = temp.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid temp"); + continue; + } + + e.manualCook.time = time.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid time"); + continue; + } + + e.manualCook.fan = fan.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid fan"); + continue; + } + + e.manualCook.coreTemp = coreTemp.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid coreTemp"); + continue; + } + } + else if (type == "auto") + { + QString type = line.section(',', 3, 3).trimmed(); + if (type.isEmpty()) + { + qDebug() << error.arg("Invalid cooktype"); + continue; + } + + QString root = line.section(',', 4, 4).trimmed(); + if (root.isEmpty()) + { + qDebug() << error.arg("Invalid root"); + continue; + } + + QString config1 = line.section(',', 5, 5).trimmed(); + if (config1.isEmpty()) + { + qDebug() << error.arg("Invalid config1"); + continue; + } + + QString config2 = line.section(',', 6, 6).trimmed(); + if (config2.isEmpty()) + { + qDebug() << error.arg("Invalid config2"); + continue; + } + + QString config3 = line.section(',', 7, 7).trimmed(); + if (config3.isEmpty()) + { + qDebug() << error.arg("Invalid config3"); + continue; + } + + QString config4 = line.section(',', 8, 8).trimmed(); + if (config4.isEmpty()) + { + qDebug() << error.arg("Invalid config4"); + continue; + } + + QString config5 = line.section(',', 9, 9).trimmed(); + if (config5.isEmpty()) + { + qDebug() << error.arg("Invalid config5"); + continue; + } + + e.type = FavoritesEntry::Auto; + + e.autoCook.type = toCookType(type); + if (e.autoCook.type == Define::InvalidCookType) + { + qDebug() << error.arg("Invalid cooktype"); + continue; + } + + e.autoCook.root = root; + + bool ok; + e.autoCook.configs[0] = config1.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config1"); + continue; + } + + e.autoCook.configs[1] = config2.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config2"); + continue; + } + + e.autoCook.configs[2] = config3.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config3"); + continue; + } + + e.autoCook.configs[3] = config4.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config4"); + continue; + } + + e.autoCook.configs[4] = config5.toInt(&ok); + if (!ok) + { + qDebug() << error.arg("Invalid config5"); + continue; + } + } + else + continue; + + if (favoriteList.size() < maxFavorites) + favoriteList.append(e); + } +} + +void writeFavorites() +{ + qDebug() << "Writing favorites"; + QFile file("/prime/history/favorites.csv"); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + { + qDebug() << "File not opened: " + file.fileName(); + return; + } + + QTextStream stream(&file); + stream.setCodec("UTF-8"); + foreach (FavoritesEntry e, favoriteList) + { + stream << e.id << "," << e.name.replace(",", "\\c").toUtf8() << ","; + switch (e.type) + { + case FavoritesEntry::Manual: + stream << "manual," + << toString(e.manualCook.mode) << "," + << e.manualCook.humidity << "," + << e.manualCook.temp << "," + << e.manualCook.time << "," + << e.manualCook.fan << "," + << e.manualCook.coreTemp << "\n"; + break; + case FavoritesEntry::Auto: + stream << "auto," + << toString(e.autoCook.type) << "," + << e.autoCook.root; + for (int i = 0; i < 5; i++) + stream << "," << e.autoCook.configs[i]; + + stream << "\n"; + break; + } + } +} + +bool initialized = false; +void initialize() +{ + initialized = true; + + readCounts(); + readRecents(); + readFavorites(); + + saveCounts.setSingleShot(true); + saveCounts.setInterval(1 * 1000); + QObject::connect(&saveCounts, &QTimer::timeout, writeCounts); + + saveRecents.setSingleShot(true); + saveRecents.setInterval(1 * 1000); + QObject::connect(&saveRecents, &QTimer::timeout, writeRecents); + + saveFavorites.setSingleShot(true); + saveFavorites.setInterval(1 * 1000); + QObject::connect(&saveFavorites, &QTimer::timeout, writeFavorites); +} + +void checkInitialized() +{ + if (!initialized) + initialize(); +} + +} + +void CookHistory::record(ManualCookSetting cook) +{ + checkInitialized(); + + RecentsEntry e; + e.type = RecentsEntry::Manual; + e.manualCook.mode = cook.mode; + e.manualCook.humidity = cook.humidity; + e.manualCook.temp = cook.temp; + e.manualCook.time = cook.time; + e.manualCook.fan = cook.fan; + e.manualCook.coreTemp = cook.coreTempEnabled ? cook.coreTemp : -1; + e.manualCook.cookedTime = QDateTime::currentDateTime(); + + appendRecent(e); + saveRecents.start(); +} + +void CookHistory::record(AutoCookSetting cook) +{ + checkInitialized(); + + RecentsEntry e; + e.type = RecentsEntry::Auto; + e.autoCook.type = cook.type; + e.autoCook.root = cook.root; + + for (int i = 0; i < 5; i++) + e.autoCook.configs[i] = cook.configs[i]; + + appendRecent(e); + saveRecents.start(); + + if (countMap.contains(cook.root)) + { + CountsEntry &e = countMap[cook.root]; + e.count++; + + for (int i = 0; i < 5; i++) + e.configs[i] = cook.configs[i]; + } + else + { + CountsEntry e; + e.type = cook.type; + e.root = cook.root; + + for (int i = 0; i < 5; i++) + e.configs[i] = cook.configs[i]; + + e.count = 1; + + countMap.insert(cook.root, e); + } + + sortCounts(); + saveCounts.start(); +} + +int CookHistory::addFavorite(ManualCookSetting cook, QString name) +{ + checkInitialized(); + + FavoritesEntry e; + e.id = newFavoriteId(); + e.name = name; + e.type = FavoritesEntry::Manual; + e.manualCook.mode = cook.mode; + e.manualCook.humidity = cook.humidity; + e.manualCook.temp = cook.temp; + e.manualCook.time = cook.time; + e.manualCook.fan = cook.fan; + e.manualCook.coreTemp = cook.coreTempEnabled ? cook.coreTemp : -1; + + appendFavorite(e); + saveFavorites.start(); + + return e.id; +} + +int CookHistory::addFavorite(AutoCookSetting cook, QString name) +{ + checkInitialized(); + + FavoritesEntry e; + e.id = newFavoriteId(); + e.name = name; + e.type = FavoritesEntry::Auto; + e.autoCook.type = cook.type; + e.autoCook.root = cook.root; + + for (int i = 0; i < 5; i++) + e.autoCook.configs[i] = cook.configs[i]; + + appendFavorite(e); + saveFavorites.start(); + + return e.id; +} + +QList CookHistory::listMostCooked() +{ + checkInitialized(); + + QList list; + foreach (CountsEntry e, countList) + { + CookRecord r; + r.type = CookRecord::Auto; + r.name = name(e.type, e.root); + r.autoRecord.setting.name = r.name; + r.autoRecord.setting.root = e.root; + r.autoRecord.setting.type = e.type; + + for (int i = 0; i < 5; i++) + r.autoRecord.setting.configs[i] = e.configs[i]; + + list.append(r); + } + + return list; +} + +QList CookHistory::listRecents() +{ + checkInitialized(); + + QList list; + foreach (RecentsEntry e, recentList) + { + CookRecord r; + + switch (e.type) + { + case RecentsEntry::Auto: + r.type = CookRecord::Auto; + r.name = name(e.autoCook.type, e.autoCook.root); + r.autoRecord.setting.name = r.name; + r.autoRecord.setting.type = e.autoCook.type; + r.autoRecord.setting.root = e.autoCook.root; + + for (int i = 0; i < 5; i++) + r.autoRecord.setting.configs[i] = e.autoCook.configs[i]; + + break; + case RecentsEntry::Manual: + r.type = CookRecord::Manual; + r.name = e.manualCook.cookedTime.toString("yy.MM.dd HH:mm:ss"); + switch (e.manualCook.mode) + { + case Define::SteamMode: + r.name += " - " + QObject::tr("스팀"); + break; + case Define::CombiMode: + r.name += " - " + QObject::tr("콤비"); + break; + case Define::DryMode: + r.name += " - " + QObject::tr("건열"); + break; + default: + break; + } + + r.manualRecord.cookedTime = e.manualCook.cookedTime; + r.manualRecord.setting.mode = e.manualCook.mode; + r.manualRecord.setting.humidity = e.manualCook.humidity; + r.manualRecord.setting.temp = e.manualCook.temp; + r.manualRecord.setting.time = e.manualCook.time; + r.manualRecord.setting.fan = e.manualCook.fan; + r.manualRecord.setting.coreTempEnabled = e.manualCook.coreTemp > 0; + r.manualRecord.setting.coreTemp = e.manualCook.coreTemp; + break; + default: + continue; + } + + list.append(r); + } + + return list; +} + +QList CookHistory::listFavorites() +{ + checkInitialized(); + + QList list; + foreach (FavoritesEntry e, favoriteList) + { + CookRecord r; + r.id = e.id; + r.name = e.name; + + switch (e.type) + { + case FavoritesEntry::Auto: + r.type = CookRecord::Auto; + r.autoRecord.setting.name = name(e.autoCook.type, e.autoCook.root); + r.autoRecord.setting.type = e.autoCook.type; + r.autoRecord.setting.root = e.autoCook.root; + + for (int i = 0; i < 5; i++) + r.autoRecord.setting.configs[i] = e.autoCook.configs[i]; + + break; + case FavoritesEntry::Manual: + r.type = CookRecord::Manual; + r.manualRecord.setting.mode = e.manualCook.mode; + r.manualRecord.setting.humidity = e.manualCook.humidity; + r.manualRecord.setting.temp = e.manualCook.temp; + r.manualRecord.setting.time = e.manualCook.time; + r.manualRecord.setting.fan = e.manualCook.fan; + r.manualRecord.setting.coreTempEnabled = e.manualCook.coreTemp > 0; + r.manualRecord.setting.coreTemp = e.manualCook.coreTemp; + break; + default: + continue; + } + + list.append(r); + } + + return list; +} + +QPixmap CookHistory::render(CookRecord record) +{ + if (record.type == CookRecord::Manual) + { + ManualCookSettingWidget *w = new ManualCookSettingWidget(record.manualRecord.setting); + + QPixmap p = w->grab().scaledToHeight(630, Qt::SmoothTransformation); + + w->deleteLater(); + + return p; + } + else if (record.type == CookRecord::Auto) + { + AutoCookSettingWidget *w = new AutoCookSettingWidget(record.autoRecord.setting); + + QPixmap p = w->grab().scaledToHeight(630, Qt::SmoothTransformation); + + w->deleteLater(); + + return p; + } + + return QPixmap(); +} + +void CookHistory::start(CookRecord record, QWidget *parent) +{ + if (record.type == CookRecord::Manual) + { + ManualCookWindow *w = new ManualCookWindow(parent, record.manualRecord.setting); + w->setWindowModality(Qt::WindowModal); + w->showFullScreen(); + w->raise(); + } + else if (record.type == CookRecord::Auto) + { + Cook cook(record.autoRecord.setting.type, record.autoRecord.setting.root, record.autoRecord.setting.name); + int *configs = record.autoRecord.setting.configs; + cook.setConfig(configs[0], + configs[1], + configs[2], + configs[3], + configs[4]); + + AutoCookWindow *w = new AutoCookWindow(parent, cook); + w->setWindowModality(Qt::WindowModal); + w->showFullScreen(); + w->raise(); + } +} + +void CookHistory::removeMostCooked(CookRecord record) +{ + if (countMap.contains(record.autoRecord.setting.root)) + { + countMap.remove(record.autoRecord.setting.root); + sortCounts(); + + saveCounts.start(); + } +} + +void CookHistory::removeRecent(CookRecord record) +{ + RecentsEntry e; + switch (record.type) + { + case CookRecord::Manual: + e.type = RecentsEntry::Manual; + e.manualCook.mode = record.manualRecord.setting.mode; + e.manualCook.humidity = record.manualRecord.setting.humidity; + e.manualCook.temp = record.manualRecord.setting.temp; + e.manualCook.time = record.manualRecord.setting.time; + e.manualCook.fan = record.manualRecord.setting.fan; + e.manualCook.coreTemp = record.manualRecord.setting.coreTempEnabled ? record.manualRecord.setting.coreTemp : -1; + e.manualCook.cookedTime = record.manualRecord.cookedTime; + break; + case CookRecord::Auto: + e.type = RecentsEntry::Auto; + e.autoCook.type = record.autoRecord.setting.type; + e.autoCook.root = record.autoRecord.setting.root; + break; + default: + return; + } + + recentList.removeAll(e); + + saveRecents.start(); +} + +void CookHistory::removeFavorite(CookRecord record) +{ + FavoritesEntry e; + e.id = record.id; + + favoriteList.removeAll(e); + saveFavorites.start(); } diff --git a/app/gui/oven_control/cookhistory.h b/app/gui/oven_control/cookhistory.h index 4f2d4bb..c1cc552 100644 --- a/app/gui/oven_control/cookhistory.h +++ b/app/gui/oven_control/cookhistory.h @@ -2,14 +2,67 @@ #define COOKHISTORY_H -class CookHistory +#include + +#include "cook.h" + +struct ManualCookSetting { - static CookHistory *instance; + Define::Mode mode; + int humidity; + int temp; + int time; + bool coreTempEnabled; + int coreTemp; + int fan; +}; - CookHistory(); +struct ManualCookRecord +{ + ManualCookSetting setting; + QDateTime cookedTime; +}; -public: - static CookHistory *getInstance(); +struct AutoCookSetting +{ + Define::CookType type; + QString name; + QString root; + int configs[5]; +}; + +struct AutoCookRecord +{ + AutoCookSetting setting; + int count; }; +struct CookRecord +{ + QString name; + int id; + enum Type { Manual, Auto } type; + ManualCookRecord manualRecord; + AutoCookRecord autoRecord; +}; + +namespace CookHistory +{ +void record(ManualCookSetting cook); +void record(AutoCookSetting cook); +int addFavorite(ManualCookSetting cook, QString name); +int addFavorite(AutoCookSetting cook, QString name); + +void removeMostCooked(CookRecord record); +void removeRecent(CookRecord record); +void removeFavorite(CookRecord record); + +QList listMostCooked(); +QList listRecents(); +QList listFavorites(); + +QPixmap render(CookRecord record); +void start(CookRecord record, QWidget *parent = 0); +} + #endif // COOKHISTORY_H diff --git a/app/gui/oven_control/cookpanelbutton.cpp b/app/gui/oven_control/cookpanelbutton.cpp index 42e0c1b..cff04f7 100644 --- a/app/gui/oven_control/cookpanelbutton.cpp +++ b/app/gui/oven_control/cookpanelbutton.cpp @@ -1,11 +1,17 @@ #include "cookpanelbutton.h" #include "ui_cookpanelbutton.h" -CookPanelButton::CookPanelButton(QWidget *parent) : +#include "manualcooksettingwidget.h" + +CookPanelButton::CookPanelButton(CookRecord record, QWidget *parent) : QWidget(parent), - ui(new Ui::CookPanelButton) + record(record), + ui(new Ui::CookPanelButton), + rendered(false) { ui->setupUi(this); + + setText(record.name); } CookPanelButton::~CookPanelButton() @@ -17,3 +23,55 @@ void CookPanelButton::setText(QString text) { ui->pushButton->setText(text); } + +void CookPanelButton::showInfo() +{ + if (!rendered) + { + QPixmap p = CookHistory::render(record); + + label = new QLabel(this); + label->setPixmap(p); + label->setGeometry((width() - p.width()) / 2, 65, p.width(), p.height()); + } + + label->show(); + setMinimumHeight(ui->pushButton->height() + label->height()); +} + +void CookPanelButton::hideInfo() +{ + label->hide(); + setMinimumHeight(ui->pushButton->height()); +} + +void CookPanelButton::focusBar() +{ + ui->pushButton->setFocus(); +} + +void CookPanelButton::focusInfoButton() +{ + ui->showInfoButton->setFocus(); +} + +void CookPanelButton::focusDeleteButton() +{ + ui->deleteButton->setFocus(); +} + + +void CookPanelButton::on_showInfoButton_toggled(bool checked) +{ + emit infoClicked(this); +} + +void CookPanelButton::on_pushButton_clicked() +{ + CookHistory::start(record, parentWidget()); +} + +void CookPanelButton::on_deleteButton_clicked() +{ + emit deleteClicked(this); +} diff --git a/app/gui/oven_control/cookpanelbutton.h b/app/gui/oven_control/cookpanelbutton.h index 51e35db..e5d33f8 100644 --- a/app/gui/oven_control/cookpanelbutton.h +++ b/app/gui/oven_control/cookpanelbutton.h @@ -2,6 +2,10 @@ #define COOKPANELBUTTON_H #include +#include +#include + +#include "cookhistory.h" namespace Ui { class CookPanelButton; @@ -12,18 +16,39 @@ class CookPanelButton : public QWidget Q_OBJECT signals: - void clicked(QWidget *); - void showInfoRequested(QWidget *); - void deleteRequested(QWidget *); + void resized(); + void clicked(CookPanelButton *); + void infoClicked(CookPanelButton *); + void deleteClicked(CookPanelButton *); public: - explicit CookPanelButton(QWidget *parent = 0); + explicit CookPanelButton(CookRecord record, QWidget *parent = 0); ~CookPanelButton(); void setText(QString text); + void showInfo(); + void hideInfo(); + + void focusBar(); + void focusInfoButton(); + void focusDeleteButton(); + + CookRecord record; + +private slots: + + + void on_showInfoButton_toggled(bool checked); + + void on_pushButton_clicked(); + + void on_deleteButton_clicked(); private: Ui::CookPanelButton *ui; + + bool rendered; + QLabel *label; }; #endif // COOKPANELBUTTON_H diff --git a/app/gui/oven_control/cookpanelbutton.ui b/app/gui/oven_control/cookpanelbutton.ui index 6d8677d..1452177 100644 --- a/app/gui/oven_control/cookpanelbutton.ui +++ b/app/gui/oven_control/cookpanelbutton.ui @@ -96,6 +96,12 @@ QPushButton:focus { background-image: url(:/images/etc/bar_icon_01_ov.png); } + + true + + + true + diff --git a/app/gui/oven_control/favoritenamepopup.cpp b/app/gui/oven_control/favoritenamepopup.cpp new file mode 100644 index 0000000..ff5783d --- /dev/null +++ b/app/gui/oven_control/favoritenamepopup.cpp @@ -0,0 +1,71 @@ +#include "favoritenamepopup.h" +#include "ui_favoritenamepopup.h" + +#include "primewindow.h" + +FavoriteNamePopup::FavoriteNamePopup(QWidget *parent) : + QWidget(parent), + ui(new Ui::FavoriteNamePopup) +{ + ui->setupUi(this); + + ui->lineEdit->setFocus(); + ui->lineEdit->selectAll(); +} + +FavoriteNamePopup::FavoriteNamePopup(QWidget *parent, ManualCookSetting setting) : FavoriteNamePopup(parent) +{ + type = Manual; + manualSetting = setting; +} + +FavoriteNamePopup::FavoriteNamePopup(QWidget *parent, AutoCookSetting setting) : FavoriteNamePopup(parent) +{ + type = Auto; + autoSetting = setting; +} + +FavoriteNamePopup::~FavoriteNamePopup() +{ + delete ui; +} + +void FavoriteNamePopup::ok() +{ + int id; + switch (type) + { + case Manual: + id = CookHistory::addFavorite(manualSetting, ui->lineEdit->text()); + break; + case Auto: + id = CookHistory::addFavorite(autoSetting, ui->lineEdit->text()); + break; + default: + return; + } + + PrimeWindow *w = new PrimeWindow(parentWidget()); + w->setWindowModality(Qt::WindowModal); + w->listFavorites(); + w->focusFavorite(id); + w->showFullScreen(); + w->raise(); + + deleteLater(); +} + +void FavoriteNamePopup::cancel() +{ + deleteLater(); +} + +void FavoriteNamePopup::on_okButton_clicked() +{ + ok(); +} + +void FavoriteNamePopup::on_cancelButton_clicked() +{ + cancel(); +} diff --git a/app/gui/oven_control/favoritenamepopup.h b/app/gui/oven_control/favoritenamepopup.h new file mode 100644 index 0000000..456b4c6 --- /dev/null +++ b/app/gui/oven_control/favoritenamepopup.h @@ -0,0 +1,37 @@ +#ifndef FAVORITENAMEPOPUP_H +#define FAVORITENAMEPOPUP_H + +#include + +#include "cookhistory.h" + +namespace Ui { +class FavoriteNamePopup; +} + +class FavoriteNamePopup : public QWidget +{ + Q_OBJECT + + explicit FavoriteNamePopup(QWidget *parent); + +public: + explicit FavoriteNamePopup(QWidget *parent, ManualCookSetting setting); + explicit FavoriteNamePopup(QWidget *parent, AutoCookSetting setting); + ~FavoriteNamePopup(); + +private: + Ui::FavoriteNamePopup *ui; + + enum { Manual, Auto } type; + ManualCookSetting manualSetting; + AutoCookSetting autoSetting; + +private slots: + void ok(); + void cancel(); + void on_okButton_clicked(); + void on_cancelButton_clicked(); +}; + +#endif // FAVORITENAMEPOPUP_H diff --git a/app/gui/oven_control/favoritenamepopup.ui b/app/gui/oven_control/favoritenamepopup.ui new file mode 100644 index 0000000..821e280 --- /dev/null +++ b/app/gui/oven_control/favoritenamepopup.ui @@ -0,0 +1,176 @@ + + + FavoriteNamePopup + + + + 0 + 0 + 900 + 1600 + + + + Form + + + #background { background-image: url(:/images/background/popup/503.png); } +QLabel, QPushButton, QLineEdit { color: white; } +QLineEdit { background : transparent; border: none; } +QPushButton { border: none; } +QPushButton:pressed { color: yellow; } + + + + + 0 + 426 + 900 + 1024 + + + + + + 0 + 95 + 900 + 3 + + + + color: rgb(255, 255, 255); + + + Qt::Horizontal + + + + + + 460 + 320 + 371 + 101 + + + + + + + + 0 + 0 + + + + + 나눔고딕 + 12 + true + + + + 확인 + + + true + + + + + + + + 0 + 0 + + + + + 나눔고딕 + 12 + true + + + + 취소 + + + true + + + + + + + + + 0 + 0 + 900 + 95 + + + + + 14 + + + + 즐겨찾기 추가 + + + Qt::AlignCenter + + + + + + 0 + 100 + 900 + 200 + + + + + 12 + true + + + + 즐겨찾기 이름 + + + Qt::AlignCenter + + + line + horizontalLayoutWidget + titleLabel + lineEdit + keyboard + + + + + 0 + 850 + 900 + 600 + + + + + + + KeyboardWidget + QWidget +
keyboardwidget.h
+ 1 +
+
+ + +
diff --git a/app/gui/oven_control/mainwindow.cpp b/app/gui/oven_control/mainwindow.cpp index 7da23fc..b3fcf5c 100644 --- a/app/gui/oven_control/mainwindow.cpp +++ b/app/gui/oven_control/mainwindow.cpp @@ -95,10 +95,10 @@ void MainWindow::on_etcButton_clicked() void MainWindow::on_primeButton_clicked() { -// PrimeWindow *w = new PrimeWindow(this); -// w->setWindowModality(Qt::WindowModal); -// w->showFullScreen(); -// w->raise(); + PrimeWindow *w = new PrimeWindow(this); + w->setWindowModality(Qt::WindowModal); + w->showFullScreen(); + w->raise(); } void MainWindow::on_washButton_clicked() @@ -111,14 +111,14 @@ void MainWindow::on_washButton_clicked() void MainWindow::on_configButton_clicked() { -// ConfigWindow *w = new ConfigWindow(this); -// w->setWindowModality(Qt::WindowModal); -// w->showFullScreen(); -// w->raise(); - EngineerMenuWindow *w = new EngineerMenuWindow(this); + ConfigWindow *w = new ConfigWindow(this); w->setWindowModality(Qt::WindowModal); w->showFullScreen(); w->raise(); +// EngineerMenuWindow *w = new EngineerMenuWindow(this); +// w->setWindowModality(Qt::WindowModal); +// w->showFullScreen(); +// w->raise(); } void MainWindow::on_helpButton_clicked() @@ -128,8 +128,8 @@ void MainWindow::on_helpButton_clicked() void MainWindow::on_programmingButton_clicked() { -// ProgrammingWindow *w = new ProgrammingWindow(this); -// w->setWindowModality(Qt::WindowModal); -// w->showFullScreen(); -// w->raise(); + ProgrammingWindow *w = new ProgrammingWindow(this); + w->setWindowModality(Qt::WindowModal); + w->showFullScreen(); + w->raise(); } diff --git a/app/gui/oven_control/manualcooksettingwidget.cpp b/app/gui/oven_control/manualcooksettingwidget.cpp new file mode 100644 index 0000000..5e6d506 --- /dev/null +++ b/app/gui/oven_control/manualcooksettingwidget.cpp @@ -0,0 +1,120 @@ +#include "manualcooksettingwidget.h" +#include "ui_manualcooksettingwidget.h" + +ManualCookSettingWidget::ManualCookSettingWidget(ManualCookSetting setting, QWidget *parent) : + QWidget(parent), + ui(new Ui::ManualCookSettingWidget) +{ + ui->setupUi(this); + + setMode(setting.mode); + setHumidity(setting.humidity); + setTemp(setting.temp); + setTime(setting.time); + setCoreTempEnabled(setting.coreTempEnabled); + setCoreTemp(setting.coreTemp); + setFan(setting.fan); +} + +ManualCookSettingWidget::~ManualCookSettingWidget() +{ + delete ui; +} + +void ManualCookSettingWidget::setMode(Define::Mode mode) +{ + switch (mode) + { + case Define::SteamMode: + ui->steamButton->setChecked(true); + ui->tempSlider->setRange(30, 130); + break; + case Define::CombiMode: + ui->combiButton->setChecked(true); + ui->tempSlider->setRange(30, 300); + break; + case Define::DryMode: + ui->dryheatButton->setChecked(true); + ui->tempSlider->setRange(30, 300); + break; + } +} + +void ManualCookSettingWidget::setHumidity(int percentage) +{ + ui->humiditySlider->setValue(percentage); + ui->humidityLabel->setText(QString("%1%").arg(percentage)); +} + +void ManualCookSettingWidget::setTemp(int celsius) +{ + ui->tempSlider->setValue(celsius); + ui->tempLabel->setText(QString("%1").arg(celsius)); +} + +void ManualCookSettingWidget::setTime(int secs) +{ + ui->timeSlider->setValue(secs); + + if (secs >= 3600) + ui->timeLabel->setText( + QString("%1시간 %2") + .arg(secs / 3600) + .arg((secs % 3600) / 60, 2, 10, QLatin1Char('0'))); + else if (secs >= 60) + ui->timeLabel->setText( + QString("%1 %2") + .arg(secs / 60) + .arg(secs % 60, 2, 10, QLatin1Char('0'))); + else + ui->timeLabel->setText(QString("%1").arg(secs)); +} + +void ManualCookSettingWidget::setCoreTempEnabled(bool enabled) +{ + ui->coreTempButton->setEnabled(enabled); + ui->coreTempSlider->setEnabled(enabled); + + if (enabled) + ui->coreTempLabel->setText(QString("%1").arg(ui->coreTempSlider->value())); + else + ui->coreTempLabel->setText(""); +} + +void ManualCookSettingWidget::setCoreTemp(int celsius) +{ + ui->coreTempSlider->setValue(celsius); + if (ui->coreTempSlider->isEnabled()) + ui->coreTempLabel->setText(QString("%1").arg(celsius)); +} + +void ManualCookSettingWidget::setFan(int level) +{ + switch (level) + { + case 1: + ui->fanButton->setStyleSheet( + "background-image: url(:/images/manual_button/fan_1.png)"); + break; + case 2: + ui->fanButton->setStyleSheet( + "background-image: url(:/images/manual_button/fan_2.png)"); + break; + case 3: + ui->fanButton->setStyleSheet( + "background-image: url(:/images/manual_button/fan_3.png)"); + break; + case 4: + ui->fanButton->setStyleSheet( + "background-image: url(:/images/manual_button/fan_4.png)"); + break; + case 5: + ui->fanButton->setStyleSheet( + "background-image: url(:/images/manual_button/fan_5.png)"); + break; + default: + ui->fanButton->setStyleSheet( + "background-image: url(:/images/manual_button/fan_1.png)"); + break; + } +} diff --git a/app/gui/oven_control/manualcooksettingwidget.h b/app/gui/oven_control/manualcooksettingwidget.h new file mode 100644 index 0000000..33270aa --- /dev/null +++ b/app/gui/oven_control/manualcooksettingwidget.h @@ -0,0 +1,33 @@ +#ifndef MANUALCOOKSETTINGWIDGET_H +#define MANUALCOOKSETTINGWIDGET_H + +#include + +#include "define.h" +#include "cookhistory.h" + +namespace Ui { +class ManualCookSettingWidget; +} + +class ManualCookSettingWidget : public QWidget +{ + Q_OBJECT + +public: + explicit ManualCookSettingWidget(ManualCookSetting setting, QWidget *parent = 0); + ~ManualCookSettingWidget(); + + void setMode(Define::Mode mode); + void setHumidity(int percentage); + void setTemp(int celsius); + void setTime(int secs); + void setCoreTempEnabled(bool enabled); + void setCoreTemp(int celsius); + void setFan(int level); + +private: + Ui::ManualCookSettingWidget *ui; +}; + +#endif // MANUALCOOKSETTINGWIDGET_H diff --git a/app/gui/oven_control/manualcooksettingwidget.ui b/app/gui/oven_control/manualcooksettingwidget.ui new file mode 100644 index 0000000..9393bae --- /dev/null +++ b/app/gui/oven_control/manualcooksettingwidget.ui @@ -0,0 +1,917 @@ + + + ManualCookSettingWidget + + + + 0 + 0 + 900 + 1024 + + + + Form + + + #background { +background-image: url(:/images/background/manual.png); +margin-top: -426px; +border-top: 426px; +} + +QPushButton { +background-repeat: no-repeat; +background-position: center; +border: none; +} + +QPushButton[style="mode"] { +background-repeat: no-repeat; +background-position: center; +background-clip: border; +background-origin: border; +margin-bottom: 50px; + +border-top: 200px; +border-bottom: -50px; +border-style: hidden; +color: #7B7B7B; +font-size: 40px; +} + +QPushButton[style="mode"]:checked { +color: white; +image: url(:/images/cook_mode/indicator.png); +image-position: bottom; +} + +QPushButton[style="icon"] { +background-image: url(:/images/slider_icon/background.png); +background-repeat: no-repeat; +background-position: center; +border: none; +} + +QPushButton[style="interTemp"] { +background-repeat: no-repeat; +background-position: center; +background-clip: border; +background-origin: border; + +border-top: 130px; +border-style: hidden; +color: white; +font-size: 30px; +} + +QSlider::groove { +background-image: url(:/images/slider/groove_ticks.png); +background-repeat: no-repeat; +} + +QSlider::sub-page { +background-repeat: no-repeat; +margin: 5px; +} + +QSlider::handle { +background-image: url(:/images/slider/handle_big.png); +background-repeat: no-repeat; +width: 23px; +height: 33px; +} + + + + + 600 + 0 + 300 + 293 + + + + QPushButton { background-image: url(:/images/cook_mode/big_dryheat_hide.png); } +QPushButton:pressed { background-image: url(:/images/cook_mode/big_dryheat_ov.png); } +QPushButton:checked { background-image: url(:/images/cook_mode/big_dryheat.png); } + + + 건열 + + + true + + + true + + + mode + + + + + + 0 + 0 + 300 + 293 + + + + QPushButton { background-image: url(:/images/cook_mode/big_steam_hide.png); } +QPushButton:pressed { background-image: url(:/images/cook_mode/big_steam_ov.png); } +QPushButton:checked { background-image: url(:/images/cook_mode/big_steam.png); } + + + 스팀 + + + true + + + true + + + true + + + mode + + + + + + 300 + 0 + 300 + 293 + + + + QPushButton { background-image: url(:/images/cook_mode/big_combi_hide.png); } +QPushButton:pressed { background-image: url(:/images/cook_mode/big_combi_ov.png); } +QPushButton:checked { background-image: url(:/images/cook_mode/big_combi.png); } + + + 콤비 + + + true + + + true + + + mode + + + + + true + + + + 690 + 384 + 150 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 100% + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 185 + 357 + 666 + 33 + + + + QSlider::sub-page { background-image: url(:/images/slider/humidity.png); } + + + 100 + + + false + + + Qt::Horizontal + + + + + true + + + + 160 + 314 + 91 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 감소 + + + Qt::AlignCenter + + + + + false + + + + 185 + 807 + 666 + 33 + + + + QSlider::sub-page { background-image: url(:/images/slider/core.png); } +QSlider::sub-page:disabled { background: #00000000; } +QSlider::handle:disabled { background: #00000000; } + + + 30 + + + 99 + + + 30 + + + false + + + Qt::Horizontal + + + + + + 27 + 599 + 140 + 140 + + + + QPushButton { image: url(:/images/slider_icon/time.png); } +QPushButton:pressed { image: url(:/images/slider_icon/time_ov.png); } + + + + + + icon + + + + + + 27 + 299 + 140 + 140 + + + + QPushButton { image: url(:/images/slider_icon/humidity.png); } +QPushButton:pressed { image: url(:/images/slider_icon/humidity_ov.png); } + + + + + + icon + + + + + + 185 + 507 + 666 + 33 + + + + QSlider::sub-page { background-image: url(:/images/slider/temp.png); } + + + 30 + + + 130 + + + false + + + Qt::Horizontal + + + + + true + + + + 690 + 534 + 150 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 30<span style="font-size:11pt;">℃</span> + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + true + + + + 160 + 464 + 91 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 감소 + + + Qt::AlignCenter + + + + + true + + + + 690 + 834 + 150 + 50 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + <span style="font-size:11pt;">℃</span> + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + true + + + + 780 + 464 + 91 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 증가 + + + Qt::AlignCenter + + + + + false + + + + 27 + 749 + 140 + 140 + + + + QPushButton:disabled { image: url(:/images/slider_icon/core_temp.png); } +QPushButton:enabled { image: url(:/images/slider_icon/core_temp_enabled.png); } + + + + + + icon + + + + + true + + + + 539 + 684 + 301 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 0<span style="font-size:11pt;">초</span> + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 185 + 657 + 666 + 33 + + + + QSlider::sub-page { background-image: url(:/images/slider/time.png); } + + + 86400 + + + 60 + + + 3600 + + + false + + + Qt::Horizontal + + + + + + 27 + 449 + 140 + 140 + + + + QPushButton { image: url(:/images/slider_icon/temp.png); } +QPushButton:pressed { image: url(:/images/slider_icon/temp_ov.png); } + + + + + + icon + + + + + true + + + + 780 + 314 + 91 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 증가 + + + Qt::AlignCenter + + + + + + 449 + 893 + 112 + 131 + + + + QPushButton { background-image: url(:/images/manual_button/fan_4.png); } + + + + + + + + + 0 + 0 + 900 + 1024 + + + + + + + background + dryheatButton + steamButton + combiButton + humidityLabel + humiditySlider + steamLabel_2 + coreTempSlider + timeButton + humidityButton + tempSlider + tempLabel + steamLabel_4 + coreTempLabel + steamLabel_5 + coreTempButton + timeLabel + timeSlider + tempButton + steamLabel_3 + fanButton + + + + diff --git a/app/gui/oven_control/manualcookwindow.cpp b/app/gui/oven_control/manualcookwindow.cpp index 76cca91..d689c9f 100644 --- a/app/gui/oven_control/manualcookwindow.cpp +++ b/app/gui/oven_control/manualcookwindow.cpp @@ -7,6 +7,9 @@ #include "preheatpopup.h" #include "cooldownpopup.h" +#include "cookhistory.h" +#include "favoritenamepopup.h" +#include "confirmpopup.h" #include @@ -65,6 +68,21 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) : setupAnimationTimer->start(0); } +ManualCookWindow::ManualCookWindow(QWidget *parent, ManualCookSetting setting) + : ManualCookWindow(parent, setting.mode) +{ + oven->setHumidity(setting.humidity); + oven->setTemp(setting.temp); + oven->setTime(setting.time); + oven->setFan(setting.fan); + oven->setInterTempEnabled(setting.coreTempEnabled); + oven->setInterTemp(setting.coreTemp); + + startCookingTimer.start(); + + onOvenUpdated(oven); +} + ManualCookWindow::~ManualCookWindow() { delete ui; @@ -315,8 +333,25 @@ void ManualCookWindow::setOvenDefault(Define::Mode mode) void ManualCookWindow::start() { - oven->startCooking(); - checkTimeTimer.start(); + if (oven->time() > 0) + { + if (startCookingTimer.isActive()) + startCookingTimer.stop(); + + oven->startCooking(); + checkTimeTimer.start(); + + ManualCookSetting s; + s.mode = oven->mode(); + s.humidity = oven->humidity(); + s.temp = oven->temp(); + s.time = oven->time(); + s.fan = oven->fan(); + s.coreTempEnabled = oven->interTempEnabled(); + s.coreTemp = oven->interTemp(); + + CookHistory::record(s); + } } void ManualCookWindow::stop() @@ -391,11 +426,9 @@ void ManualCookWindow::on_applyButton_clicked() void ManualCookWindow::on_runStopButton_clicked() { if (oven->cooking()) - { stop(); - } else - oven->startCooking(); + start(); } void ManualCookWindow::on_fanButton_clicked() @@ -453,7 +486,19 @@ void ManualCookWindow::on_reserveButton_clicked() void ManualCookWindow::on_favoritesButton_clicked() { + if (oven->cooking()) + return; + + ConfirmPopup *p = new ConfirmPopup(this, tr("즐겨찾기 항목에 추가하시겠습니까?")); + p->showFullScreen(); + connect(p, SIGNAL(accepted()), SLOT(addFavorite())); + + if (startCookingTimer.isActive()) + { + startCookingTimer.stop(); + connect(p, SIGNAL(rejected()), &startCookingTimer, SLOT(start())); + } } void ManualCookWindow::on_goBackStackButton_clicked() @@ -471,3 +516,18 @@ void ManualCookWindow::on_backButton_clicked() stop(); close(); } + +void ManualCookWindow::addFavorite() +{ + ManualCookSetting s; + s.mode = oven->mode(); + s.humidity = oven->humidity(); + s.temp = oven->temp(); + s.time = oven->time(); + s.fan = oven->fan(); + s.coreTempEnabled = oven->interTempEnabled(); + s.coreTemp = oven->interTemp(); + + FavoriteNamePopup *p = new FavoriteNamePopup(this, s); + p->showFullScreen(); +} diff --git a/app/gui/oven_control/manualcookwindow.h b/app/gui/oven_control/manualcookwindow.h index f487173..cdd3578 100644 --- a/app/gui/oven_control/manualcookwindow.h +++ b/app/gui/oven_control/manualcookwindow.h @@ -5,6 +5,7 @@ #include "oven.h" #include "udphandler.h" +#include "cookhistory.h" namespace Ui { class ManualCookWindow; @@ -16,6 +17,7 @@ class ManualCookWindow : public QMainWindow public: explicit ManualCookWindow(QWidget *parent, Define::Mode mode); + explicit ManualCookWindow(QWidget *parent, ManualCookSetting setting); ~ManualCookWindow(); signals: @@ -63,6 +65,7 @@ private slots: void on_backButton_clicked(); + void addFavorite(); private: Ui::ManualCookWindow *ui; diff --git a/app/gui/oven_control/oven_control.pro b/app/gui/oven_control/oven_control.pro index 207cef5..26bf5d6 100644 --- a/app/gui/oven_control/oven_control.pro +++ b/app/gui/oven_control/oven_control.pro @@ -80,7 +80,11 @@ SOURCES += main.cpp\ configtimeformatdlg.cpp \ configresttimeformatdlg.cpp \ configmastervolumedlg.cpp \ - configsoundselelectdlg.cpp + configsoundselelectdlg.cpp \ + manualcooksettingwidget.cpp \ + autocooksettingwidget.cpp \ + favoritenamepopup.cpp \ + confirmpopup.cpp HEADERS += mainwindow.h \ cook.h \ @@ -150,7 +154,11 @@ HEADERS += mainwindow.h \ configtimeformatdlg.h \ configresttimeformatdlg.h \ configmastervolumedlg.h \ - configsoundselelectdlg.h + configsoundselelectdlg.h \ + manualcooksettingwidget.h \ + autocooksettingwidget.h \ + favoritenamepopup.h \ + confirmpopup.h FORMS += mainwindow.ui \ manualcookwindow.ui \ @@ -196,7 +204,11 @@ FORMS += mainwindow.ui \ configtimeformatdlg.ui \ configresttimeformatdlg.ui \ configmastervolumedlg.ui \ - configsoundselelectdlg.ui + configsoundselelectdlg.ui \ + manualcooksettingwidget.ui \ + autocooksettingwidget.ui \ + favoritenamepopup.ui \ + confirmpopup.ui RESOURCES += \ resources.qrc diff --git a/app/gui/oven_control/primewindow.cpp b/app/gui/oven_control/primewindow.cpp index 8aba297..76f1d69 100644 --- a/app/gui/oven_control/primewindow.cpp +++ b/app/gui/oven_control/primewindow.cpp @@ -1,7 +1,12 @@ #include "primewindow.h" #include "ui_primewindow.h" -#include "cookpanelbutton.h" +#include +#include +#include + +#include "manualcooksettingwidget.h" +#include "cookhistory.h" PrimeWindow::PrimeWindow(QWidget *parent) : QMainWindow(parent), @@ -13,6 +18,8 @@ PrimeWindow::PrimeWindow(QWidget *parent) : setAttribute(Qt::WA_DeleteOnClose); ui->verticalScrollLayout->setAlignment(Qt::AlignTop); + + lastInfoDisplayed = NULL; } PrimeWindow::~PrimeWindow() @@ -20,6 +27,157 @@ PrimeWindow::~PrimeWindow() delete ui; } +void PrimeWindow::listMostCooked() +{ + if (!ui->mostCookedButton->isChecked()) + { + ui->mostCookedButton->blockSignals(true); + ui->mostCookedButton->setChecked(true); + ui->mostCookedButton->blockSignals(false); + } + + listButtons(CookHistory::listMostCooked()); +} + +void PrimeWindow::listRecents() +{ + if (!ui->recentsButton->isChecked()) + { + ui->recentsButton->blockSignals(true); + ui->recentsButton->setChecked(true); + ui->recentsButton->blockSignals(false); + } + + listButtons(CookHistory::listRecents()); +} + +void PrimeWindow::listFavorites() +{ + if (!ui->favoritesButton->isChecked()) + { + ui->favoritesButton->blockSignals(true); + ui->favoritesButton->setChecked(true); + ui->favoritesButton->blockSignals(false); + } + + listButtons(CookHistory::listFavorites()); +} + +void PrimeWindow::focusFavorite(int id) +{ + foreach (CookPanelButton *b, list) + { + qDebug() << "Favorite ID" << b->record.id; + if (b->record.id == id) + { +// b->setFocus(); + b->focusBar(); + break; + } + } +} + +void PrimeWindow::on_mostCookedButton_toggled(bool checked) +{ + if (!checked) + return; + + listButtons(CookHistory::listMostCooked()); +} + +void PrimeWindow::on_recentsButton_toggled(bool checked) +{ + if (!checked) + return; + + listButtons(CookHistory::listRecents()); +} + +void PrimeWindow::on_favoritesButton_toggled(bool checked) +{ + if (!checked) + return; + + listButtons(CookHistory::listFavorites()); +} + +void PrimeWindow::listButtons(QList records) +{ + clear(); + + foreach(CookRecord r, records) + newButton(r); + + ui->scrollAreaWidgetContents->adjustSize(); +} + +void PrimeWindow::clear() +{ + lastInfoDisplayed = NULL; + while (!list.isEmpty()) + list.takeFirst()->deleteLater(); +} + +CookPanelButton *PrimeWindow::newButton(CookRecord record) +{ + CookPanelButton *button = new CookPanelButton(record, this); + connect(button, SIGNAL(infoClicked(CookPanelButton*)), SLOT(onInfoButtonClicked(CookPanelButton*))); + connect(button, SIGNAL(deleteClicked(CookPanelButton*)), SLOT(onDeleteButtonClicked(CookPanelButton*))); + + ui->verticalScrollLayout->addWidget(button); + list.append(button); + + return button; +} + +void PrimeWindow::onInfoButtonClicked(CookPanelButton *panelButton) +{ + if (lastInfoDisplayed) + { + if (panelButton == lastInfoDisplayed) + { + lastInfoDisplayed->hideInfo(); + lastInfoDisplayed = NULL; + + ui->scrollAreaWidgetContents->adjustSize(); + } + else + { + lastInfoDisplayed->hideInfo(); + lastInfoDisplayed = panelButton; + lastInfoDisplayed->showInfo(); + + ui->scrollAreaWidgetContents->adjustSize(); + ui->scrollArea->ensureWidgetVisible(lastInfoDisplayed); + } + } + else + { + lastInfoDisplayed = panelButton; + lastInfoDisplayed->showInfo(); + + ui->scrollAreaWidgetContents->adjustSize(); + ui->scrollArea->ensureWidgetVisible(lastInfoDisplayed); + } +} + +void PrimeWindow::onDeleteButtonClicked(CookPanelButton *panelButton) +{ + if (panelButton == lastInfoDisplayed) + lastInfoDisplayed = NULL; + + if (ui->mostCookedButton->isChecked()) + CookHistory::removeMostCooked(panelButton->record); + else if (ui->recentsButton->isChecked()) + CookHistory::removeRecent(panelButton->record); + else if (ui->favoritesButton->isChecked()) + CookHistory::removeFavorite(panelButton->record); + + list.removeAll(panelButton); + panelButton->deleteLater(); +} + + void PrimeWindow::on_backButton_clicked() { close(); diff --git a/app/gui/oven_control/primewindow.h b/app/gui/oven_control/primewindow.h index b8968a1..acb26dc 100644 --- a/app/gui/oven_control/primewindow.h +++ b/app/gui/oven_control/primewindow.h @@ -3,8 +3,11 @@ #include +#include #include +#include "cookpanelbutton.h" + namespace Ui { class PrimeWindow; } @@ -17,21 +20,32 @@ public: explicit PrimeWindow(QWidget *parent = 0); ~PrimeWindow(); + void listMostCooked(); + void listRecents(); + void listFavorites(); + void focusFavorite(int id); + private slots: -// void showMostCooked(); -// void showRecents(); -// void showFavorites(); -// void array(); + void on_mostCookedButton_toggled(bool checked); + void on_recentsButton_toggled(bool checked); + void on_favoritesButton_toggled(bool checked); + + void listButtons(QList records); + void clear(); + CookPanelButton *newButton(CookRecord record); -// void onInfoButtonClicked(QWidget *entry); -// void onDeleteButtonClicked(QWidget *entry); + void onInfoButtonClicked(CookPanelButton *panelButton); + void onDeleteButtonClicked(CookPanelButton *panelButton); void on_backButton_clicked(); + + private: Ui::PrimeWindow *ui; - QList list; + QList list; + CookPanelButton *lastInfoDisplayed; }; #endif // PRIMEWINDOW_H diff --git a/app/gui/oven_control/primewindow.ui b/app/gui/oven_control/primewindow.ui index 461109c..da0b3fa 100644 --- a/app/gui/oven_control/primewindow.ui +++ b/app/gui/oven_control/primewindow.ui @@ -76,7 +76,7 @@ background: none; 0
- + 0 @@ -102,7 +102,7 @@ QPushButton:pressed { background-image: url(:/images/etc/main_btn_04_ov.png); }< - + 0 @@ -128,7 +128,7 @@ QPushButton:pressed { background-image: url(:/images/etc/main_btn_03_ov.png); }< - + 0 @@ -269,9 +269,9 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); } 0 - 645 + 647 900 - 805 + 803 @@ -283,7 +283,7 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); }0 0 898 - 803 + 801 @@ -294,10 +294,10 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); }20 - 30 + 28 - 30 + 28 diff --git a/app/gui/oven_control/programmingwindow.cpp b/app/gui/oven_control/programmingwindow.cpp index 7666c45..456edcd 100644 --- a/app/gui/oven_control/programmingwindow.cpp +++ b/app/gui/oven_control/programmingwindow.cpp @@ -6,9 +6,17 @@ ProgrammingWindow::ProgrammingWindow(QWidget *parent) : ui(new Ui::ProgrammingWindow) { ui->setupUi(this); + + ui->clockContainer->setParent(ui->upperStack); + setAttribute(Qt::WA_DeleteOnClose); } ProgrammingWindow::~ProgrammingWindow() { delete ui; } + +void ProgrammingWindow::on_backButton_clicked() +{ + close(); +} diff --git a/app/gui/oven_control/programmingwindow.h b/app/gui/oven_control/programmingwindow.h index 1134550..ff8d118 100644 --- a/app/gui/oven_control/programmingwindow.h +++ b/app/gui/oven_control/programmingwindow.h @@ -15,6 +15,9 @@ public: explicit ProgrammingWindow(QWidget *parent = 0); ~ProgrammingWindow(); +private slots: + void on_backButton_clicked(); + private: Ui::ProgrammingWindow *ui; }; diff --git a/app/gui/oven_control/programmingwindow.ui b/app/gui/oven_control/programmingwindow.ui index a7abe39..d5be026 100644 --- a/app/gui/oven_control/programmingwindow.ui +++ b/app/gui/oven_control/programmingwindow.ui @@ -101,7 +101,7 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/back_ov.png); } QPushButton { border-image: url(:/images/bottom_bar/006_sys_icon_15.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/006_sys_icon_15.png); } +QPushButton:pressed { border-image: url(:/images/bottom_bar/006_sys_icon_15_ov.png); }
-- 2.1.4