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" + "<span style=\"font-size:11pt;\">시간</span>" + " %02d" + "<span style=\"font-size:11pt;\">분</span>", + time / 3600, + (time % 3600) / 60)); + else if (time >= 60) + cw.current->setText(QString().sprintf( + "%d" + "<span style=\"font-size:11pt;\">분</span>" + " %02d" + "<span style=\"font-size:11pt;\">초</span>", + time / 60, + time % 60)); + else + cw.current->setText(QString().sprintf( + "%d" + "<span style=\"font-size:11pt;\">초</span>", + time)); + break; + } + case Define::BurnDegree: + cw.current->setText(QString().sprintf( + "%d" + "<span style=\"font-size:11pt;\">℃</span>", + cook.coreTemp())); + break; + default: + cw.current->setText(QString().sprintf( + "%d" + "<span style=\"font-size:11pt;\">/%d</span>", + 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 <QWidget> +#include <QPushButton> +#include <QLabel> +#include <QSlider> + +#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<ConfigWidget> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>AutoCookSettingWidget</class> + <widget class="QWidget" name="AutoCookSettingWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>900</width> + <height>1024</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <property name="styleSheet"> + <string notr="true">#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; +}</string> + </property> + <widget class="QLabel" name="configMaxLabel_2"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>700</x> + <y>354</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="QPushButton" name="configButton_4"> + <property name="geometry"> + <rect> + <x>27</x> + <y>689</y> + <width>140</width> + <height>140</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + <property name="style" stdset="0"> + <string notr="true">icon</string> + </property> + </widget> + <widget class="QPushButton" name="configButton_3"> + <property name="geometry"> + <rect> + <x>27</x> + <y>509</y> + <width>140</width> + <height>140</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + <property name="style" stdset="0"> + <string notr="true">icon</string> + </property> + </widget> + <widget class="QLabel" name="configMaxLabel_5"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>700</x> + <y>874</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="configCurrentLabel_1"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>199</x> + <y>264</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 class="QLabel" name="configMinLabel_5"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>185</x> + <y>874</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="QPushButton" name="configButton_2"> + <property name="geometry"> + <rect> + <x>27</x> + <y>339</y> + <width>140</width> + <height>140</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + <property name="style" stdset="0"> + <string notr="true">icon</string> + </property> + </widget> + <widget class="QSlider" name="configSlider_5"> + <property name="geometry"> + <rect> + <x>185</x> + <y>917</y> + <width>666</width> + <height>33</height> + </rect> + </property> + <property name="maximum"> + <number>100</number> + </property> + <property name="pageStep"> + <number>1</number> + </property> + <property name="value"> + <number>0</number> + </property> + <property name="tracking"> + <bool>true</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + <widget class="QLabel" name="configCurrentLabel_2"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>199</x> + <y>424</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 class="QLabel" name="configCurrentLabel_5"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>189</x> + <y>944</y> + <width>651</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 class="QSlider" name="configSlider_3"> + <property name="geometry"> + <rect> + <x>185</x> + <y>567</y> + <width>666</width> + <height>33</height> + </rect> + </property> + <property name="maximum"> + <number>100</number> + </property> + <property name="pageStep"> + <number>1</number> + </property> + <property name="value"> + <number>0</number> + </property> + <property name="tracking"> + <bool>true</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + <widget class="QSlider" name="configSlider_2"> + <property name="geometry"> + <rect> + <x>185</x> + <y>397</y> + <width>666</width> + <height>33</height> + </rect> + </property> + <property name="maximum"> + <number>100</number> + </property> + <property name="pageStep"> + <number>1</number> + </property> + <property name="value"> + <number>10</number> + </property> + <property name="tracking"> + <bool>true</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + <widget class="QLabel" name="configCurrentLabel_3"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>199</x> + <y>594</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 class="QLabel" name="cookTypeIcon"> + <property name="geometry"> + <rect> + <x>0</x> + <y>4</y> + <width>250</width> + <height>150</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap>:/images/images/auto/005_auto_icon_01_ov.png</pixmap> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + <widget class="QLabel" name="configMaxLabel_4"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>700</x> + <y>704</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="QPushButton" name="configButton_5"> + <property name="geometry"> + <rect> + <x>27</x> + <y>859</y> + <width>140</width> + <height>140</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + <property name="style" stdset="0"> + <string notr="true">icon</string> + </property> + </widget> + <widget class="QLabel" name="configMinLabel_1"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>185</x> + <y>194</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="QPushButton" name="pushButton_4"> + <property name="geometry"> + <rect> + <x>720</x> + <y>54</y> + <width>152</width> + <height>70</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton { +border-image: url(:/images/button/152.png); +} +QPushButton::pressed { +border-image: url(:/images/button/152_ov.png); +}</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="resources.qrc"> + <normaloff>:/images/auto_button/btn_icon_01.png</normaloff>:/images/auto_button/btn_icon_01.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>40</width> + <height>51</height> + </size> + </property> + </widget> + <widget class="QPushButton" name="configButton_1"> + <property name="geometry"> + <rect> + <x>27</x> + <y>179</y> + <width>140</width> + <height>140</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + <property name="style" stdset="0"> + <string notr="true">icon</string> + </property> + </widget> + <widget class="QLabel" name="configMinLabel_2"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>185</x> + <y>354</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="configSlider_4"> + <property name="geometry"> + <rect> + <x>185</x> + <y>747</y> + <width>666</width> + <height>33</height> + </rect> + </property> + <property name="maximum"> + <number>100</number> + </property> + <property name="pageStep"> + <number>1</number> + </property> + <property name="value"> + <number>0</number> + </property> + <property name="tracking"> + <bool>true</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + <widget class="QLabel" name="configCurrentLabel_4"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>199</x> + <y>774</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 class="QLabel" name="configMaxLabel_1"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>700</x> + <y>194</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="configMinLabel_3"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>185</x> + <y>524</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="QLabel" name="configMinLabel_4"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>185</x> + <y>704</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="configSlider_1"> + <property name="geometry"> + <rect> + <x>185</x> + <y>237</y> + <width>666</width> + <height>33</height> + </rect> + </property> + <property name="maximum"> + <number>100</number> + </property> + <property name="pageStep"> + <number>1</number> + </property> + <property name="value"> + <number>39</number> + </property> + <property name="tracking"> + <bool>true</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksBelow</enum> + </property> + <property name="tickInterval"> + <number>1</number> + </property> + </widget> + <widget class="QLabel" name="configMaxLabel_3"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>700</x> + <y>524</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="QPushButton" name="selectCookButton"> + <property name="geometry"> + <rect> + <x>420</x> + <y>54</y> + <width>288</width> + <height>70</height> + </rect> + </property> + <property name="font"> + <font> + <family>Roboto</family> + <pointsize>10</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton { +border-image: url(:/images/button/288.png); +} +QPushButton::pressed { +border-image: url(:/images/button/288_ov.png); +}</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + <widget class="QLabel" name="background"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>900</width> + <height>1024</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + </widget> + <zorder>background</zorder> + <zorder>configMaxLabel_2</zorder> + <zorder>configButton_4</zorder> + <zorder>configButton_3</zorder> + <zorder>configMaxLabel_5</zorder> + <zorder>configCurrentLabel_1</zorder> + <zorder>configMinLabel_5</zorder> + <zorder>configButton_2</zorder> + <zorder>configSlider_5</zorder> + <zorder>configCurrentLabel_2</zorder> + <zorder>configCurrentLabel_5</zorder> + <zorder>configSlider_3</zorder> + <zorder>configSlider_2</zorder> + <zorder>configCurrentLabel_3</zorder> + <zorder>cookTypeIcon</zorder> + <zorder>configMaxLabel_4</zorder> + <zorder>configButton_5</zorder> + <zorder>configMinLabel_1</zorder> + <zorder>pushButton_4</zorder> + <zorder>configButton_1</zorder> + <zorder>configMinLabel_2</zorder> + <zorder>configSlider_4</zorder> + <zorder>configCurrentLabel_4</zorder> + <zorder>configMaxLabel_1</zorder> + <zorder>configMinLabel_3</zorder> + <zorder>configMinLabel_4</zorder> + <zorder>configSlider_1</zorder> + <zorder>configMaxLabel_3</zorder> + <zorder>selectCookButton</zorder> + </widget> + <resources> + <include location="resources.qrc"/> + </resources> + <connections/> +</ui> 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 <QWidget> + +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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ConfirmPopup</class> + <widget class="QWidget" name="ConfirmPopup"> + <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">#text { color: white; } +QPushButton { color: white; border: none; } +QPushButton:pressed, QPushButton:focus { color: yellow; }</string> + </property> + <widget class="QLabel" name="label"> + <property name="geometry"> + <rect> + <x>0</x> + <y>426</y> + <width>900</width> + <height>150</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap resource="resources.qrc">:/images/symbol/warning_big.png</pixmap> + </property> + <property name="alignment"> + <set>Qt::AlignBottom|Qt::AlignHCenter</set> + </property> + </widget> + <widget class="QLabel" name="text"> + <property name="geometry"> + <rect> + <x>0</x> + <y>576</y> + <width>900</width> + <height>200</height> + </rect> + </property> + <property name="font"> + <font> + <pointsize>14</pointsize> + </font> + </property> + <property name="text"> + <string>즐겨찾기 항목에 추가하시겠습니까?</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + <widget class="QWidget" name="horizontalLayoutWidget"> + <property name="geometry"> + <rect> + <x>430</x> + <y>776</y> + <width>261</width> + <height>100</height> + </rect> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QPushButton" name="okButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + <underline>true</underline> + </font> + </property> + <property name="text"> + <string>예</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + <underline>true</underline> + </font> + </property> + <property name="text"> + <string>아니오</string> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QLabel" name="background"> + <property name="geometry"> + <rect> + <x>0</x> + <y>426</y> + <width>900</width> + <height>503</height> + </rect> + </property> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap resource="resources.qrc">:/images/background/popup/503.png</pixmap> + </property> + </widget> + <zorder>background</zorder> + <zorder>label</zorder> + <zorder>text</zorder> + <zorder>horizontalLayoutWidget</zorder> + </widget> + <resources> + <include location="resources.qrc"/> + </resources> + <connections/> +</ui> 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<QString> 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<QString, CountsEntry> countMap; +QList<CountsEntry> countList; +QList<RecentsEntry> recentList; +QList<FavoritesEntry> 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<CookRecord> CookHistory::listMostCooked() +{ + checkInitialized(); + + QList<CookRecord> 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<CookRecord> CookHistory::listRecents() +{ + checkInitialized(); + + QList<CookRecord> 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<CookRecord> CookHistory::listFavorites() +{ + checkInitialized(); + + QList<CookRecord> 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 <QList> + +#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<CookRecord> listMostCooked(); +QList<CookRecord> listRecents(); +QList<CookRecord> 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 <QWidget> +#include <QLabel> +#include <QButtonGroup> + +#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); }</s <property name="text"> <string/> </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> </widget> <widget class="QPushButton" name="deleteButton"> <property name="geometry"> 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 <QWidget> + +#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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>FavoriteNamePopup</class> + <widget class="QWidget" name="FavoriteNamePopup"> + <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">#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; }</string> + </property> + <widget class="QWidget" name="background" native="true"> + <property name="geometry"> + <rect> + <x>0</x> + <y>426</y> + <width>900</width> + <height>1024</height> + </rect> + </property> + <widget class="Line" name="line"> + <property name="geometry"> + <rect> + <x>0</x> + <y>95</y> + <width>900</width> + <height>3</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">color: rgb(255, 255, 255);</string> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + <widget class="QWidget" name="horizontalLayoutWidget"> + <property name="geometry"> + <rect> + <x>460</x> + <y>320</y> + <width>371</width> + <height>101</height> + </rect> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QPushButton" name="okButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <family>나눔고딕</family> + <pointsize>12</pointsize> + <underline>true</underline> + </font> + </property> + <property name="text"> + <string>확인</string> + </property> + <property name="flat"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <family>나눔고딕</family> + <pointsize>12</pointsize> + <underline>true</underline> + </font> + </property> + <property name="text"> + <string>취소</string> + </property> + <property name="flat"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QLabel" name="titleLabel"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>900</width> + <height>95</height> + </rect> + </property> + <property name="font"> + <font> + <pointsize>14</pointsize> + </font> + </property> + <property name="text"> + <string>즐겨찾기 추가</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + <widget class="QLineEdit" name="lineEdit"> + <property name="geometry"> + <rect> + <x>0</x> + <y>100</y> + <width>900</width> + <height>200</height> + </rect> + </property> + <property name="font"> + <font> + <pointsize>12</pointsize> + <underline>true</underline> + </font> + </property> + <property name="text"> + <string>즐겨찾기 이름</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + <zorder>line</zorder> + <zorder>horizontalLayoutWidget</zorder> + <zorder>titleLabel</zorder> + <zorder>lineEdit</zorder> + <zorder>keyboard</zorder> + </widget> + <widget class="KeyboardWidget" name="keyboard" native="true"> + <property name="geometry"> + <rect> + <x>0</x> + <y>850</y> + <width>900</width> + <height>600</height> + </rect> + </property> + </widget> + </widget> + <customwidgets> + <customwidget> + <class>KeyboardWidget</class> + <extends>QWidget</extends> + <header>keyboardwidget.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> 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<span style=\"font-size:11pt;\">℃</span>").arg(celsius)); +} + +void ManualCookSettingWidget::setTime(int secs) +{ + ui->timeSlider->setValue(secs); + + if (secs >= 3600) + ui->timeLabel->setText( + QString("%1<span style=\"font-size:11pt;\">시간</span> %2<span style=\"font-size:11pt;\">분</span>") + .arg(secs / 3600) + .arg((secs % 3600) / 60, 2, 10, QLatin1Char('0'))); + else if (secs >= 60) + ui->timeLabel->setText( + QString("%1<span style=\"font-size:11pt;\">분</span> %2<span style=\"font-size:11pt;\">초</span>") + .arg(secs / 60) + .arg(secs % 60, 2, 10, QLatin1Char('0'))); + else + ui->timeLabel->setText(QString("%1<span style=\"font-size:11pt;\">초</span>").arg(secs)); +} + +void ManualCookSettingWidget::setCoreTempEnabled(bool enabled) +{ + ui->coreTempButton->setEnabled(enabled); + ui->coreTempSlider->setEnabled(enabled); + + if (enabled) + ui->coreTempLabel->setText(QString("%1<span style=\"font-size:11pt;\">℃</span>").arg(ui->coreTempSlider->value())); + else + ui->coreTempLabel->setText("<span style=\"font-size:11pt;\">℃</span>"); +} + +void ManualCookSettingWidget::setCoreTemp(int celsius) +{ + ui->coreTempSlider->setValue(celsius); + if (ui->coreTempSlider->isEnabled()) + ui->coreTempLabel->setText(QString("%1<span style=\"font-size:11pt;\">℃</span>").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 <QWidget> + +#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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ManualCookSettingWidget</class> + <widget class="QWidget" name="ManualCookSettingWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>900</width> + <height>1024</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <property name="styleSheet"> + <string notr="true">#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; +}</string> + </property> + <widget class="QPushButton" name="dryheatButton"> + <property name="geometry"> + <rect> + <x>600</x> + <y>0</y> + <width>300</width> + <height>293</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">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); }</string> + </property> + <property name="text"> + <string>건열</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="style" stdset="0"> + <string notr="true">mode</string> + </property> + </widget> + <widget class="QPushButton" name="steamButton"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>300</width> + <height>293</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">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); }</string> + </property> + <property name="text"> + <string>스팀</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="style" stdset="0"> + <string notr="true">mode</string> + </property> + </widget> + <widget class="QPushButton" name="combiButton"> + <property name="geometry"> + <rect> + <x>300</x> + <y>0</y> + <width>300</width> + <height>293</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">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); }</string> + </property> + <property name="text"> + <string>콤비</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="style" stdset="0"> + <string notr="true">mode</string> + </property> + </widget> + <widget class="QLabel" name="humidityLabel"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>690</x> + <y>384</y> + <width>150</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>100%</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QSlider" name="humiditySlider"> + <property name="geometry"> + <rect> + <x>185</x> + <y>357</y> + <width>666</width> + <height>33</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QSlider::sub-page { background-image: url(:/images/slider/humidity.png); }</string> + </property> + <property name="maximum"> + <number>100</number> + </property> + <property name="tracking"> + <bool>false</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + <widget class="QLabel" name="steamLabel_2"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>160</x> + <y>314</y> + <width>91</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::AlignCenter</set> + </property> + </widget> + <widget class="QSlider" name="coreTempSlider"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="geometry"> + <rect> + <x>185</x> + <y>807</y> + <width>666</width> + <height>33</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QSlider::sub-page { background-image: url(:/images/slider/core.png); } +QSlider::sub-page:disabled { background: #00000000; } +QSlider::handle:disabled { background: #00000000; }</string> + </property> + <property name="minimum"> + <number>30</number> + </property> + <property name="maximum"> + <number>99</number> + </property> + <property name="value"> + <number>30</number> + </property> + <property name="tracking"> + <bool>false</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + <widget class="QPushButton" name="timeButton"> + <property name="geometry"> + <rect> + <x>27</x> + <y>599</y> + <width>140</width> + <height>140</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton { image: url(:/images/slider_icon/time.png); } +QPushButton:pressed { image: url(:/images/slider_icon/time_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="humidityButton"> + <property name="geometry"> + <rect> + <x>27</x> + <y>299</y> + <width>140</width> + <height>140</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton { image: url(:/images/slider_icon/humidity.png); } +QPushButton:pressed { image: url(:/images/slider_icon/humidity_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="QSlider" name="tempSlider"> + <property name="geometry"> + <rect> + <x>185</x> + <y>507</y> + <width>666</width> + <height>33</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QSlider::sub-page { background-image: url(:/images/slider/temp.png); }</string> + </property> + <property name="minimum"> + <number>30</number> + </property> + <property name="maximum"> + <number>130</number> + </property> + <property name="tracking"> + <bool>false</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + <widget class="QLabel" name="tempLabel"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>690</x> + <y>534</y> + <width>150</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>30<span style="font-size:11pt;">℃</span></string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="steamLabel_4"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>160</x> + <y>464</y> + <width>91</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::AlignCenter</set> + </property> + </widget> + <widget class="QLabel" name="coreTempLabel"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>690</x> + <y>834</y> + <width>150</width> + <height>50</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><span style="font-size:11pt;">℃</span></string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="steamLabel_5"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>780</x> + <y>464</y> + <width>91</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::AlignCenter</set> + </property> + </widget> + <widget class="QPushButton" name="coreTempButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="geometry"> + <rect> + <x>27</x> + <y>749</y> + <width>140</width> + <height>140</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton:disabled { image: url(:/images/slider_icon/core_temp.png); } +QPushButton:enabled { image: url(:/images/slider_icon/core_temp_enabled.png); }</string> + </property> + <property name="text"> + <string notr="true"/> + </property> + <property name="style" stdset="0"> + <string notr="true">icon</string> + </property> + </widget> + <widget class="QLabel" name="timeLabel"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>539</x> + <y>684</y> + <width>301</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>0<span style="font-size:11pt;">초</span></string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QSlider" name="timeSlider"> + <property name="geometry"> + <rect> + <x>185</x> + <y>657</y> + <width>666</width> + <height>33</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QSlider::sub-page { background-image: url(:/images/slider/time.png); }</string> + </property> + <property name="maximum"> + <number>86400</number> + </property> + <property name="singleStep"> + <number>60</number> + </property> + <property name="pageStep"> + <number>3600</number> + </property> + <property name="tracking"> + <bool>false</bool> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + <widget class="QPushButton" name="tempButton"> + <property name="geometry"> + <rect> + <x>27</x> + <y>449</y> + <width>140</width> + <height>140</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton { image: url(:/images/slider_icon/temp.png); } +QPushButton:pressed { image: url(:/images/slider_icon/temp_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="QLabel" name="steamLabel_3"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>780</x> + <y>314</y> + <width>91</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::AlignCenter</set> + </property> + </widget> + <widget class="QPushButton" name="fanButton"> + <property name="geometry"> + <rect> + <x>449</x> + <y>893</y> + <width>112</width> + <height>131</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton { background-image: url(:/images/manual_button/fan_4.png); }</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + <widget class="QLabel" name="background"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>900</width> + <height>1024</height> + </rect> + </property> + <property name="text"> + <string notr="true"/> + </property> + </widget> + <zorder>background</zorder> + <zorder>dryheatButton</zorder> + <zorder>steamButton</zorder> + <zorder>combiButton</zorder> + <zorder>humidityLabel</zorder> + <zorder>humiditySlider</zorder> + <zorder>steamLabel_2</zorder> + <zorder>coreTempSlider</zorder> + <zorder>timeButton</zorder> + <zorder>humidityButton</zorder> + <zorder>tempSlider</zorder> + <zorder>tempLabel</zorder> + <zorder>steamLabel_4</zorder> + <zorder>coreTempLabel</zorder> + <zorder>steamLabel_5</zorder> + <zorder>coreTempButton</zorder> + <zorder>timeLabel</zorder> + <zorder>timeSlider</zorder> + <zorder>tempButton</zorder> + <zorder>steamLabel_3</zorder> + <zorder>fanButton</zorder> + </widget> + <resources/> + <connections/> +</ui> 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 <QTime> @@ -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 <QtDebug> +#include <QLabel> +#include <QPainter> + +#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<CookRecord> 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 <QMainWindow> +#include <QTimer> #include <QList> +#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<CookRecord> 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<QWidget *> list; + QList<CookPanelButton *> 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; <number>0</number> </property> <item> - <widget class="QPushButton" name="steamButton"> + <widget class="QPushButton" name="mostCookedButton"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> <horstretch>0</horstretch> @@ -102,7 +102,7 @@ QPushButton:pressed { background-image: url(:/images/etc/main_btn_04_ov.png); }< </widget> </item> <item> - <widget class="QPushButton" name="steamButton_2"> + <widget class="QPushButton" name="recentsButton"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> <horstretch>0</horstretch> @@ -128,7 +128,7 @@ QPushButton:pressed { background-image: url(:/images/etc/main_btn_03_ov.png); }< </widget> </item> <item> - <widget class="QPushButton" name="steamButton_3"> + <widget class="QPushButton" name="favoritesButton"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> <horstretch>0</horstretch> @@ -269,9 +269,9 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); }</s <property name="geometry"> <rect> <x>0</x> - <y>645</y> + <y>647</y> <width>900</width> - <height>805</height> + <height>803</height> </rect> </property> <property name="widgetResizable"> @@ -283,7 +283,7 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); }</s <x>0</x> <y>0</y> <width>898</width> - <height>803</height> + <height>801</height> </rect> </property> <layout class="QVBoxLayout" name="verticalScrollLayout"> @@ -294,10 +294,10 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); }</s <number>20</number> </property> <property name="topMargin"> - <number>30</number> + <number>28</number> </property> <property name="bottomMargin"> - <number>30</number> + <number>28</number> </property> </layout> </widget> 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); }</str </property> <property name="styleSheet"> <string notr="true">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); }</string> +QPushButton:pressed { border-image: url(:/images/bottom_bar/006_sys_icon_15_ov.png); }</string> </property> <property name="text"> <string/>