diff --git a/app/gui/oven_control/define.cpp b/app/gui/oven_control/define.cpp index ae151e4..42edc7e 100644 --- a/app/gui/oven_control/define.cpp +++ b/app/gui/oven_control/define.cpp @@ -528,3 +528,41 @@ QString Define::name(Define::Process type) return ""; } } + +QString Define::name(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::name(Define::Mode mode) +{ + switch (mode) + { + case Define::SteamMode: + return "steam"; + case Define::CombiMode: + return "combi"; + case Define::DryMode: + return "dry"; + default: + return ""; + } +} diff --git a/app/gui/oven_control/define.h b/app/gui/oven_control/define.h index ab48cb3..7dfd4a9 100644 --- a/app/gui/oven_control/define.h +++ b/app/gui/oven_control/define.h @@ -3,10 +3,14 @@ #include -#define MAJOR_VER 1 +#define MAJOR_VER 1 #define MINOR_VER 0 #define HOTFIX_VER 5 +// 0 for normal +// 1 for premium +#define MODEL_GRADE 1 + namespace Define { enum CookType @@ -22,6 +26,7 @@ namespace Define }; QString icon(CookType type); + QString name(CookType type); enum CookConfigType { @@ -105,6 +110,7 @@ namespace Define }; Mode identifyMode(QString mode); + QString name(Mode mode); enum Process { diff --git a/app/gui/oven_control/interruptibletime.cpp b/app/gui/oven_control/interruptibletime.cpp new file mode 100644 index 0000000..9e687d9 --- /dev/null +++ b/app/gui/oven_control/interruptibletime.cpp @@ -0,0 +1,61 @@ +#include "interruptibletime.h" + +InterruptibleTime::InterruptibleTime(QObject *parent) : QObject(parent) +{ + elapsed_ = -1; +} + +int InterruptibleTime::elapsed() +{ + if (isNull()) + return -1; + + if (time.isValid()) + return elapsed_ + time.elapsed(); + + return elapsed_; +} + +bool InterruptibleTime::isValid() +{ + return elapsed_ != -1; +} + +bool InterruptibleTime::isNull() +{ + return elapsed_ == -1; +} + +void InterruptibleTime::start() +{ + elapsed_ = 0; + time.start(); +} + +void InterruptibleTime::pause() +{ + if (isNull()) + return; + + elapsed_ += time.elapsed(); + time = QTime(); +} + +void InterruptibleTime::resume() +{ + if (isNull()) + return; + + time.start(); +} + +int InterruptibleTime::restart() +{ + if (isNull()) + return -1; + + int t = elapsed(); + elapsed_ = 0; + time.start(); + return t; +} diff --git a/app/gui/oven_control/interruptibletime.h b/app/gui/oven_control/interruptibletime.h new file mode 100644 index 0000000..681ec52 --- /dev/null +++ b/app/gui/oven_control/interruptibletime.h @@ -0,0 +1,30 @@ +#ifndef INTERRUPTIBLETIME_H +#define INTERRUPTIBLETIME_H + +#include +#include + +class InterruptibleTime : public QObject +{ + Q_OBJECT +public: + explicit InterruptibleTime(QObject *parent = 0); + + int elapsed(); + bool isValid(); + bool isNull(); + +signals: + +public slots: + void start(); + void pause(); + void resume(); + int restart(); + +private: + QTime time; + int elapsed_; +}; + +#endif // INTERRUPTIBLETIME_H diff --git a/app/gui/oven_control/main.cpp b/app/gui/oven_control/main.cpp index 6461226..ff1e423 100644 --- a/app/gui/oven_control/main.cpp +++ b/app/gui/oven_control/main.cpp @@ -26,11 +26,11 @@ int main(int argc, char *argv[]) OvenStatistics::getInstance(oven); - - -// QTranslator* trans = new QTranslator(); -// qDebug() << trans->load(":/lang_en.qm"); -// QApplication::installTranslator(trans); + // Removing etching effect + QPalette pal = QApplication::palette(); + pal.setColor(QPalette::Disabled, QPalette::Text, QColor(80, 80, 80)); + pal.setColor(QPalette::Disabled, QPalette::Light, QColor(0, 0, 0, 0)); + QApplication::setPalette(pal); MainWindow w; w.showFullScreen(); diff --git a/app/gui/oven_control/mainwindow.cpp b/app/gui/oven_control/mainwindow.cpp index bde7591..e27fc66 100644 --- a/app/gui/oven_control/mainwindow.cpp +++ b/app/gui/oven_control/mainwindow.cpp @@ -13,6 +13,7 @@ #include "configwindow.h" #include "ovenstatics.h" #include "notipopupdlg.h" +#include "multicookwindow.h" MainWindow *MainWindow::instance = NULL; @@ -22,6 +23,13 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); +#if MODEL_GRADE > 0 + ui->logo->hide(); +#else + ui->multiButton->hide(); + ui->programmingButton->hide(); +#endif + instance = this; child = NULL; @@ -227,17 +235,22 @@ void MainWindow::on_primeButton_clicked() void MainWindow::on_multiButton_clicked() { + MultiCookWindow *w = new MultiCookWindow(this); + w->setWindowModality(Qt::WindowModal); + w->showFullScreen(); + w->raise(); + newChild(w); } 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(); -// newChild(w); + newChild(w); } void MainWindow::on_washButton_clicked() diff --git a/app/gui/oven_control/mainwindow.ui b/app/gui/oven_control/mainwindow.ui index e1ecd9b..b3faf3e 100644 --- a/app/gui/oven_control/mainwindow.ui +++ b/app/gui/oven_control/mainwindow.ui @@ -152,12 +152,12 @@ QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/h - false + true 0 - 1700 + 1164 300 286 @@ -180,13 +180,10 @@ QPushButton:pressed, QPushButton:focus { background-image: url(:/images/main_but - - false - 300 - 1700 + 1164 300 286 @@ -659,7 +656,10 @@ QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_typ Qt::Horizontal - + + + true + 0 @@ -675,6 +675,30 @@ QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_typ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + logo + bottomBar + multiButton + programmingButton + washButton + line + line_2 + line_3 + line_4 + line_5 + line_6 + dryheatButton + combiButton + steamButton + meatButton + dessertButton + etcButton + grainButton + poultryButton + fishButton + breadButton + primeButton + clockContainer + line_7 diff --git a/app/gui/oven_control/multiautocook.cpp b/app/gui/oven_control/multiautocook.cpp new file mode 100644 index 0000000..2170be2 --- /dev/null +++ b/app/gui/oven_control/multiautocook.cpp @@ -0,0 +1,277 @@ +#include "multiautocook.h" + +#include "oven.h" + +MultiAutoCook::MultiAutoCook(QObject *parent) : MultiCook(parent) +{ + name_ = ""; + mode_ = Define::InvalidMode; + state = Idle; + isModifying = false; + increasedTimeCount = 6; + decreasedTimeCount = 6; + + checkTimer.setInterval(100); + connect(&checkTimer, SIGNAL(timeout()), SLOT(check())); +} + +QString MultiAutoCook::name() +{ + return name_; +} + +Define::Mode MultiAutoCook::mode() +{ + return mode_; +} + +int MultiAutoCook::temperature() +{ + if (steps.isEmpty()) + return 30; + + return steps.first().temperature; +} + +int MultiAutoCook::humidity() +{ + if (steps.isEmpty()) + return 0; + + return steps.first().humidity; +} + +int MultiAutoCook::remainingTime() +{ + if (steps.isEmpty()) + return 0; + + if (isModifying) + { + int t = 0; + foreach (const Step &s, modifiedSteps) + t += s.time; + + return t; + } + + if (state == Running) + updateTime(); + + int t = 0; + foreach (const Step &s, steps) + t += s.time; + + return t; +} + +void MultiAutoCook::increaseTime() +{ + if (state == Finished) + return; + + if (!isModifying) + { + isModifying = true; + updateTime(); + modifiedSteps = steps; + } + + modifiedSteps.last().time += 60 * 1000; +} + +void MultiAutoCook::decreaseTime() +{ + if (state == Finished) + return; + + if (!isModifying) + { + isModifying = true; + updateTime(); + modifiedSteps = steps; + } + + Step &s = modifiedSteps.last(); + s.time = qMax(30 * 1000, s.time - 60 * 1000); +} + +void MultiAutoCook::setTime() +{ + if (state == Finished) + return; + + if (!isModifying) + return; + + isModifying = false; + elapsed.start(); + steps = modifiedSteps; +} + +void MultiAutoCook::start() +{ + state = Running; + elapsed.start(); + decreasedTime.start(); + + checkTimer.start(); +} + +void MultiAutoCook::stop() +{ + state = Finished; + checkTimer.stop(); +} + +void MultiAutoCook::pause() +{ + if (state != Running) + return; + + state = Paused; + decreasedTime.pause(); + if (increasedTime.isValid()) + increasedTime.pause(); + + updateTime(); + + checkTimer.stop(); +} + +void MultiAutoCook::resume() +{ + if (state != Paused) + return; + + state = Running; + steps.last().time += 30 * 1000; + elapsed.start(); + decreasedTime.resume(); + if (increasedTime.isValid()) + increasedTime.resume(); +} + +MultiCook *MultiAutoCook::clone(QObject *parent) +{ + MultiAutoCook *c = new MultiAutoCook(parent); + c->name_ = name_; + c->mode_ = mode_; + c->steps = steps; + + return (MultiCook *) c; +} + +bool MultiAutoCook::equals(MultiCook *other) +{ + MultiAutoCook *o = qobject_cast(other); + if (o == Q_NULLPTR) + return false; + + if (o->name_ != name_) + return false; + + if (o->mode_ != mode_) + return false; + + if (o->steps != steps) + return false; + + return true; +} + +void MultiAutoCook::setName(QString name) +{ + name_ = name; +} + +void MultiAutoCook::setMode(Define::Mode mode) +{ + mode_ = mode; +} + +void MultiAutoCook::append(int temperature, int humidity, int time) +{ + if (temperature < 30 || temperature > 300) + return; + + if (humidity < 0 || humidity > 100) + return; + + if (time < 0 || time > 24 * 60 * 60) + return; + + steps.append(Step{temperature, humidity, time * 1000}); +} + +void MultiAutoCook::updateTime() +{ + int e = elapsed.restart(); + + while (steps.size() > 0) + { + Step &s = steps.first(); + if (s.time > e) + { + s.time -= e; + break; + } + + e -= s.time; + steps.removeFirst(); + } +} + +void MultiAutoCook::check() +{ + if (state != Running) + return; + + int dt = Oven::getInstance()->currentTemp() - temperature(); + + // checking under temperature + if ((remainingTime() < 10 * 60 * 1000 && increasedTime.isNull()) + || (increasedTime.isValid() && increasedTime.elapsed() > 3 * 60 * 1000)) + { + increasedTime.start(); + if (dt < -20 && increasedTimeCount > 0) + { + increasedTimeCount--; + + steps.last().time += remainingTime() * 0.1; + } + } + + // checking over temperature + if (decreasedTime.elapsed() > 2 * 60 * 1000) + { + decreasedTime.start(); + if (dt > 20 && decreasedTimeCount > 0) + { + decreasedTimeCount--; + + Step &s = steps.last(); + if (s.time > 30 * 1000) + { + s.time -= remainingTime() * 0.2; + if (s.time < 30 * 1000) + s.time = 30 * 1000; + } + } + } + + if (remainingTime() <= 0) + stop(); +} + +bool MultiAutoCook::Step::operator==(const MultiAutoCook::Step &other) +{ + if (other.temperature != temperature) + return false; + if (other.humidity != humidity) + return false; + if (other.time != time) + return false; + + return true; +} diff --git a/app/gui/oven_control/multiautocook.h b/app/gui/oven_control/multiautocook.h new file mode 100644 index 0000000..1a545bb --- /dev/null +++ b/app/gui/oven_control/multiautocook.h @@ -0,0 +1,74 @@ +#ifndef MULTIAUTOCOOK_H +#define MULTIAUTOCOOK_H + +#include "multicook.h" +#include "interruptibletime.h" + +class MultiAutoCook : public MultiCook +{ + Q_OBJECT +public: + explicit MultiAutoCook(QObject *parent = 0); + + virtual QString name(); + virtual Define::Mode mode(); + virtual int temperature(); + virtual int humidity(); + virtual int remainingTime(); + + virtual void increaseTime(); + virtual void decreaseTime(); + virtual void setTime(); + + virtual void start(); + virtual void stop(); + virtual void pause(); + virtual void resume(); + + virtual MultiCook *clone(QObject *parent); + virtual bool equals(MultiCook *other); + + void setName(QString name); + void setMode(Define::Mode mode); + void append(int temperature, int humidity, int time); + +signals: + +public slots: + +private: + void updateTime(); + + QString name_; + Define::Mode mode_; + + struct Step { + int temperature; + int humidity; + int time; + + bool operator==(const Step &other); + }; + + QList steps; + + enum State { + Idle, Running, Paused, Finished + } state; + + QTime elapsed; + int decreasedTimeCount; + int increasedTimeCount; + InterruptibleTime decreasedTime; + InterruptibleTime increasedTime; + + QTimer checkTimer; + + bool isModifying; + QList modifiedSteps; + +private slots: + void check(); +}; + +#endif // MULTIAUTOCOOK_H diff --git a/app/gui/oven_control/multicook.cpp b/app/gui/oven_control/multicook.cpp new file mode 100644 index 0000000..0dce840 --- /dev/null +++ b/app/gui/oven_control/multicook.cpp @@ -0,0 +1,7 @@ +#include "multicook.h" + +#include + +MultiCook::MultiCook(QObject *parent) : QObject(parent) +{ +} diff --git a/app/gui/oven_control/multicook.h b/app/gui/oven_control/multicook.h new file mode 100644 index 0000000..b842dad --- /dev/null +++ b/app/gui/oven_control/multicook.h @@ -0,0 +1,34 @@ +#ifndef MULTICOOK_H +#define MULTICOOK_H + +#include +#include + +#include "define.h" + +class MultiCook : public QObject +{ + Q_OBJECT +public: + explicit MultiCook(QObject *parent = 0); + + virtual QString name() = 0; + virtual Define::Mode mode() = 0; + virtual int temperature() = 0; + virtual int humidity() = 0; + virtual int remainingTime() = 0; + + virtual void increaseTime() = 0; + virtual void decreaseTime() = 0; + virtual void setTime() = 0; + + virtual void start() = 0; + virtual void stop() = 0; + virtual void pause() = 0; + virtual void resume() = 0; + + virtual MultiCook *clone(QObject *parent = 0) = 0; + virtual bool equals(MultiCook *other) = 0; +}; + +#endif // MULTICOOK_H diff --git a/app/gui/oven_control/multicookautowindow.cpp b/app/gui/oven_control/multicookautowindow.cpp new file mode 100644 index 0000000..6329b34 --- /dev/null +++ b/app/gui/oven_control/multicookautowindow.cpp @@ -0,0 +1,162 @@ +#include "multicookautowindow.h" +#include "ui_multicookautowindow.h" + +#include + +#include "soundplayer.h" +#include "confirmpopup.h" + +MultiCookAutoWindow::MultiCookAutoWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MultiCookAutoWindow) +{ + ui->setupUi(this); + + ui->clockContainer->setParent(ui->upperStack); + setAttribute(Qt::WA_DeleteOnClose); + + book = Q_NULLPTR; + + setFocus(); +} + +MultiCookAutoWindow::~MultiCookAutoWindow() +{ + delete ui; +} + +void MultiCookAutoWindow::setType(Define::CookType type) +{ + ui->cookTypeIcon->setPixmap(Define::icon(type)); +} + +void MultiCookAutoWindow::setBook(MultiCookBook *book) +{ + this->book = book; + + QSignalMapper *sm = new QSignalMapper(this); + connect(sm, SIGNAL(mapped(int)), SLOT(select(int))); + + QFont font = this->font(); + font.setPointSize(10); + font.setBold(true); + font.setWeight(75); + + QLatin1String stylesheet("QPushButton {\n" + "border-image: url(:/images/button/288.png);\n" + "}\n" + "QPushButton::pressed, QPushButton:focus {\n" + "border-image: url(:/images/button/288_ov.png);\n" + "}"); + + QList list = book->names(); + + QWidget *last = this; + for (int idx = 0; idx < list.size(); idx++) + { + int x = 12 + (idx % 3) * 294; + int y = 615 + (idx / 3) * 80; + + QPushButton *pb = new QPushButton(this); + pb->setGeometry(QRect(x, y, 288, 70)); + pb->setFont(font); + pb->setStyleSheet(stylesheet); + pb->setText(list.at(idx)); + + sm->setMapping(pb, idx); + connect(pb, SIGNAL(clicked()), sm, SLOT(map())); + + setTabOrder(last, pb); + + last = pb; + } + + setTabOrder(last, ui->backButton); + setTabOrder(ui->backButton, ui->helpButton); + + foreach (QPushButton *button, findChildren()) + connect(button, &QPushButton::pressed, SoundPlayer::playClick); +} + +void MultiCookAutoWindow::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000032: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + pushed = focusWidget(); + break; + case 0x01000030: // Turn right + onEncoderRight(); + break; + } +} + +void MultiCookAutoWindow::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000032: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + if (focusWidget() == pushed) + onEncoderClicked(pushed); + + pushed = NULL; + break; + case 0x01000030: // Turn right + onEncoderRight(); + break; + } +} + +void MultiCookAutoWindow::onEncoderLeft() +{ + focusPreviousChild(); +} + +void MultiCookAutoWindow::onEncoderRight() +{ + focusNextChild(); +} + +void MultiCookAutoWindow::onEncoderClicked(QWidget *clicked) +{ + QPushButton *b = qobject_cast(clicked); + if (b) + b->click(); +} + +void MultiCookAutoWindow::select(int idx) +{ + selectedIndex = idx; + + setFocus(); + + ConfirmPopup *p = new ConfirmPopup(this, tr("다중 요리 목록에 추가하시겠습니까?")); + p->showFullScreen(); + + connect(p, SIGNAL(accepted()), SLOT(confirm())); +} + +void MultiCookAutoWindow::confirm() +{ + MultiAutoCook *cook = book->cook(selectedIndex); + if (cook == Q_NULLPTR) + return; + + emit selected(cook); +} + +void MultiCookAutoWindow::on_backButton_clicked() +{ + close(); +} + +void MultiCookAutoWindow::on_helpButton_clicked() +{ + +} diff --git a/app/gui/oven_control/multicookautowindow.h b/app/gui/oven_control/multicookautowindow.h new file mode 100644 index 0000000..cd1077b --- /dev/null +++ b/app/gui/oven_control/multicookautowindow.h @@ -0,0 +1,50 @@ +#ifndef MULTICOOKAUTOWINDOW_H +#define MULTICOOKAUTOWINDOW_H + +#include + +#include "multicookbook.h" + +namespace Ui { +class MultiCookAutoWindow; +} + +class MultiCookAutoWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MultiCookAutoWindow(QWidget *parent = 0); + ~MultiCookAutoWindow(); + + void setType(Define::CookType type); + void setBook(MultiCookBook *book); + +signals: + void selected(MultiCook *); + +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + +private: + Ui::MultiCookAutoWindow *ui; + + MultiCookBook *book; + int selectedIndex; + + QWidget *pushed = NULL; + + void onEncoderLeft(); + void onEncoderRight(); + void onEncoderClicked(QWidget *clicked); + +private slots: + void select(int idx); + void confirm(); + + void on_backButton_clicked(); + void on_helpButton_clicked(); +}; + +#endif // MULTICOOKAUTOWINDOW_H diff --git a/app/gui/oven_control/multicookautowindow.ui b/app/gui/oven_control/multicookautowindow.ui new file mode 100644 index 0000000..07ce606 --- /dev/null +++ b/app/gui/oven_control/multicookautowindow.ui @@ -0,0 +1,194 @@ + + + MultiCookAutoWindow + + + + 0 + 0 + 900 + 1600 + + + + #centralwidget { background-image: url(:/images/background/auto.png); } +#bottomBar { background-image: url(:/images/bottom_bar/background.png); } + + + + + + 0 + 0 + 900 + 426 + + + + + #clockContainer { background-image: url(:/images/clock/background.png); } + + + + + 272 + 36 + 356 + 355 + + + + + + + 800 + 320 + 80 + 84 + + + + + + + 780 + 230 + 101 + 90 + + + + + + + 780 + 160 + 108 + 67 + + + + + + + 20 + 310 + 600 + 100 + + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + + + 0 + 430 + 900 + 150 + + + + + + + :/images/images/auto/005_auto_icon_01_ov.png + + + Qt::AlignCenter + + + + + + 0 + 1450 + 900 + 150 + + + + + + 345 + 26 + 97 + 97 + + + + + 0 + 0 + + + + QPushButton { border-image: url(:/images/bottom_bar/back.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/back_ov.png); } + + + + + + + + + 458 + 26 + 97 + 97 + + + + + 0 + 0 + + + + QPushButton { border-image: url(:/images/bottom_bar/help.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/help_ov.png); } + + + + + + + + + + + Clock + QWidget +
clock.h
+ 1 +
+ + WashWarnIcon + QLabel +
washwarnicon.h
+
+ + DemoIcon + QLabel +
demoicon.h
+
+ + HalfEnergyIcon + QLabel +
halfenergyicon.h
+
+ + DigitalClock + QLabel +
digitalclock.h
+
+
+ + +
diff --git a/app/gui/oven_control/multicookbook.cpp b/app/gui/oven_control/multicookbook.cpp new file mode 100644 index 0000000..32e9828 --- /dev/null +++ b/app/gui/oven_control/multicookbook.cpp @@ -0,0 +1,171 @@ +#include "multicookbook.h" + +namespace +{ + +void showError(QString message) +{ + +} + +} + +MultiCookBook::MultiCookBook(QObject *parent) : QObject(parent) +{ + mode = Define::InvalidMode; + type = Define::InvalidCookType; +} + +void MultiCookBook::setMode(Define::Mode mode) +{ + this->mode = mode; + + loadTypes(); +} + +void MultiCookBook::setType(Define::CookType type) +{ + this->type = type; + + loadCooks(); + book = CookBook(type); +} + +bool MultiCookBook::checkType(Define::CookType type) +{ + return availables.contains(type); +} + +QList MultiCookBook::names() +{ + QList list; + foreach (QString root, roots) + list.append(book.name(root)); + + return list; +} + +MultiAutoCook *MultiCookBook::cook(int index) +{ + QString type = Define::name(this->type); + if (type.isEmpty()) + { + showError("Invalid cook type"); + return Q_NULLPTR; + } + + QString root = QString("/prime/cookbook/%1/%2").arg(type).arg(roots.at(index)); + QString name = book.name(root); + + Cook cook(this->type, root, name); + cook.load(); + + if (!cook.isLoaded()) + { + showError("Invalid cook data"); + return Q_NULLPTR; + } + + MultiAutoCook *c = new MultiAutoCook; + c->setName(name); + c->setMode(mode); + + foreach (CookStep s, cook.steps) + c->append(s.temp, s.humidity, s.time); + + return c; +} + +void MultiCookBook::loadTypes() +{ + QString mode = Define::name(this->mode); + if (mode.isEmpty()) + { + showError("Invalid cook mode"); + return; + } + + QString filename = QString("/prime/multi/types.%1").arg(mode); + + QFile file(filename); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + showError("File not found: " + filename); + return; + } + + availables.clear(); + + int lineCount = 0; + while (!file.atEnd()) + { + lineCount++; + + QString line = QString::fromUtf8(file.readLine().trimmed()); + if (line.isEmpty()) + continue; + + Define::CookType type; + if (line == "poultry") + type = Define::Poultry; + else if (line == "meat") + type = Define::Meat; + else if (line == "fish") + type = Define::Fish; + else if (line == "desert") + type = Define::Desert; + else if (line == "vegetable") + type = Define::Vegetable; + else if (line == "bread") + type = Define::Bread; + else if (line == "etc") + type = Define::Etc; + else + { + showError("Invalid cook type"); + return; + } + + availables.append(type); + } +} + +void MultiCookBook::loadCooks() +{ + QString type = Define::name(this->type); + if (type.isEmpty()) + { + showError("Invalid cook type"); + return; + } + + QString mode = Define::name(this->mode); + if (mode.isEmpty()) + { + showError("Invalid cook mode"); + return; + } + + QString filename = QString("/prime/multi/%1.%2").arg(type).arg(mode); + + QFile file(filename); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + showError("File not found: " + filename); + return; + } + + roots.clear(); + + int lineCount = 0; + while (!file.atEnd()) + { + lineCount++; + + QString line = QString::fromUtf8(file.readLine().trimmed()); + if (line.isEmpty()) + continue; + + roots.append(line); + } +} diff --git a/app/gui/oven_control/multicookbook.h b/app/gui/oven_control/multicookbook.h new file mode 100644 index 0000000..6aa6aff --- /dev/null +++ b/app/gui/oven_control/multicookbook.h @@ -0,0 +1,38 @@ +#ifndef MULTICOOKBOOK_H +#define MULTICOOKBOOK_H + +#include + +#include "define.h" +#include "multiautocook.h" +#include "cookbook.h" + +class MultiCookBook : public QObject +{ + Q_OBJECT +public: + explicit MultiCookBook(QObject *parent = 0); + + void setMode(Define::Mode mode); + void setType(Define::CookType type); + + bool checkType(Define::CookType type); + QList names(); + MultiAutoCook *cook(int index); + +signals: + +public slots: + +private: + Define::Mode mode; + Define::CookType type; + CookBook book; + QList availables; + QList roots; + + void loadTypes(); + void loadCooks(); +}; + +#endif // MULTICOOKBOOK_H diff --git a/app/gui/oven_control/multicookcontainer.cpp b/app/gui/oven_control/multicookcontainer.cpp new file mode 100644 index 0000000..63cc94a --- /dev/null +++ b/app/gui/oven_control/multicookcontainer.cpp @@ -0,0 +1,175 @@ +#include "multicookcontainer.h" + +MultiCookContainer::MultiCookContainer(QObject *parent) : QObject(parent) +{ + for (int i = 0; i < 10; i++) + list.append(Q_NULLPTR); + + isEmpty_ = true; + state = Idle; +} + +void MultiCookContainer::add(int slot, MultiCook *cook) +{ + list.replace(slot, cook); + if (isEmpty_) + { + mode_ = cook->mode(); + isEmpty_ = false; + } + + switch (state) + { + case Idle: + // Do nothing + break; + case Running: + cook->start(); + break; + case Paused: + cook->start(); + cook->pause(); + break; + } +} + +void MultiCookContainer::remove(int slot) +{ + MultiCook *cook = list.at(slot); + if (cook == Q_NULLPTR) + return; + + cook->stop(); + + list.replace(slot, Q_NULLPTR); + + isEmpty_ = true; + foreach (MultiCook *c, list) + if (c != Q_NULLPTR) + { + isEmpty_ = false; + break; + } + + if (isEmpty_) + { + mode_ = Define::InvalidMode; + state = Idle; + } +} + +MultiCook *MultiCookContainer::at(int slot) +{ + return list.at(slot); +} + +bool MultiCookContainer::isEmpty() +{ + return isEmpty_; +} + +bool MultiCookContainer::isFinished() +{ + foreach (MultiCook *c, list) + if (c != Q_NULLPTR && c->remainingTime() > 0) + return false; + + return true; +} + +Define::Mode MultiCookContainer::mode() +{ + return mode_; +} + +int MultiCookContainer::temperature() +{ + int count = 0; + int temp = 0; + foreach (MultiCook *c, list) + if (c != Q_NULLPTR && c->remainingTime() > 0) + { + temp += c->temperature(); + count++; + } + + if (count == 0) + return -1; + + return temp / count; +} + +int MultiCookContainer::humidity() +{ + int count = 0; + int hum = 0; + foreach (MultiCook *c, list) + if (c != Q_NULLPTR && c->remainingTime() > 0) + { + hum += c->humidity(); + count++; + } + + if (count == 0) + return -1; + + return hum / count; +} + +int MultiCookContainer::remainingTime() +{ + int max = 0; + foreach (MultiCook *c, list) + if (c != Q_NULLPTR) + max = qMax(max, c->remainingTime()); + + return max; +} + +void MultiCookContainer::start() +{ + if (isEmpty_ || state != Idle) + return; + + state = Running; + + foreach (MultiCook *c, list) + if (c != Q_NULLPTR) + c->start(); +} + +void MultiCookContainer::stop() +{ + if (isEmpty_ || state != Running) + return; + + state = Idle; + + foreach (MultiCook *c, list) + if (c != Q_NULLPTR) + c->stop(); +} + +void MultiCookContainer::pause() +{ + if (isEmpty_ || state != Running) + return; + + state = Paused; + + foreach (MultiCook *c, list) + if (c != Q_NULLPTR) + c->pause(); +} + +void MultiCookContainer::resume() +{ + if (isEmpty_ || state != Paused) + return; + + state = Running; + + foreach (MultiCook *c, list) + if (c != Q_NULLPTR) + c->resume(); +} diff --git a/app/gui/oven_control/multicookcontainer.h b/app/gui/oven_control/multicookcontainer.h new file mode 100644 index 0000000..2549296 --- /dev/null +++ b/app/gui/oven_control/multicookcontainer.h @@ -0,0 +1,45 @@ +#ifndef MULTICOOKCONTAINER_H +#define MULTICOOKCONTAINER_H + +#include + +#include "multicook.h" + +class MultiCookContainer : public QObject +{ + Q_OBJECT +public: + explicit MultiCookContainer(QObject *parent = 0); + + void add(int slot, MultiCook *cook); + void remove(int slot); + + MultiCook *at(int slot); + bool isEmpty(); + bool isFinished(); + + Define::Mode mode(); + int temperature(); + int humidity(); + int remainingTime(); + + void start(); + void stop(); + void pause(); + void resume(); + +signals: + +public slots: + +private: + QList list; + bool isEmpty_; + Define::Mode mode_; + + enum State { + Idle, Running, Paused + } state; +}; + +#endif // MULTICOOKCONTAINER_H diff --git a/app/gui/oven_control/multicookcontroller.cpp b/app/gui/oven_control/multicookcontroller.cpp new file mode 100644 index 0000000..ff38fa7 --- /dev/null +++ b/app/gui/oven_control/multicookcontroller.cpp @@ -0,0 +1,202 @@ +#include "multicookcontroller.h" + +#include "oven.h" + +MultiCookController::MultiCookController(QObject *parent) : QObject(parent) +{ + state = Idle; + + connect(&checkTimer, SIGNAL(timeout()), SLOT(check())); +} + +void MultiCookController::setContainer(MultiCookContainer *container) +{ + this->container = container; + checkTimer.start(100); +} + +bool MultiCookController::requireOpen() +{ + if (state == OpenDoor || state == Finished) + return true; + + if (state != Running) + return false; + + for (int i = 0; i < 10; i++) + { + MultiCook *cook = container->at(i); + if (cook != Q_NULLPTR && cook->remainingTime() <= 0) + return true; + } + + return false; +} + +bool MultiCookController::requireClose() +{ + if (state == Idle || state == OpenDoor) + return false; + + return true; +} + +void MultiCookController::check() +{ + switch (state) + { + case Idle: + if (!container->isEmpty()) + state = Preheating; + break; + case Preheating: + checkPreheating(); + break; + case OpenDoor: + if (Oven::getInstance()->door()) + state = CloseDoor; + break; + case CloseDoor: + if (!Oven::getInstance()->door()) + { + state = Running; + container->start(); + } + break; + case Running: + checkRunning(); + break; + case Paused: + checkPaused(); + break; + case Finished: + checkFinished(); + break; + } +} + +void MultiCookController::checkPreheating() +{ + Oven *oven = Oven::getInstance(); + if (container->isEmpty()) + { + state = Idle; + oven->stop(); + return; + } + + int temp = container->temperature(); + if (temp <= oven->currentTemp()) + { + state = OpenDoor; + oven->stop(); + return; + } + + if (temp != oven->temp()) + oven->setTemp(temp); + + int hum = container->humidity(); + if (hum != oven->humidity()) + oven->setHumidity(hum); + + if (!oven->preheating()) + oven->startPreheating(); +} + +void MultiCookController::checkRunning() +{ + Oven *oven = Oven::getInstance(); + if (container->isEmpty()) + { + state = Idle; + oven->stop(); + return; + } + + if (container->isFinished()) + { + state = Finished; + oven->stop(); + container->stop(); + return; + } + + if (oven->door()) + { + state = Paused; + oven->stopCooking(); + container->pause(); + return; + } + +// Define::Mode mode = container->mode(); +// switch (mode) +// { +// case Define::Invalid: +// // Do nothing +// break; +// case Define::SteamMode: +// case Define::CombiMode: +// case Define::DryMode: +// oven->setMode(mode); +// break; +// } + +// int temp = container->temperature(); +// if (temp != oven->temp()) +// oven->setTemp(temp); + +// int hum = container->humidity(); +// if (hum != oven->humidity()) +// oven->setHumidity(hum); + + oven->setMode(container->mode()); + oven->setTemp(container->temperature()); + oven->setHumidity(container->humidity()); + + if (!oven->cooking()) + { + oven->setTime(12 * 60 * 60); + oven->startCooking(); + } +} + +void MultiCookController::checkPaused() +{ + Oven *oven = Oven::getInstance(); + if (oven->door()) + return; + + for (int i = 0; i < 10; i++) + { + MultiCook *cook = container->at(i); + if (cook != Q_NULLPTR && cook->remainingTime() <= 0) + { + container->remove(i); + cook->deleteLater(); + } + } + + state = Running; + container->resume(); +} + +void MultiCookController::checkFinished() +{ + Oven *oven = Oven::getInstance(); + if (oven->door()) + { + state = Idle; + + for (int i = 0; i < 10; i++) + { + MultiCook *cook = container->at(i); + if (cook != Q_NULLPTR) + { + container->remove(i); + cook->deleteLater(); + } + } + } +} diff --git a/app/gui/oven_control/multicookcontroller.h b/app/gui/oven_control/multicookcontroller.h new file mode 100644 index 0000000..7813b27 --- /dev/null +++ b/app/gui/oven_control/multicookcontroller.h @@ -0,0 +1,41 @@ +#ifndef MULTICOOKCONTROLLER_H +#define MULTICOOKCONTROLLER_H + +#include +#include + +#include "multicookcontainer.h" + +class MultiCookController : public QObject +{ + Q_OBJECT +public: + explicit MultiCookController(QObject *parent = 0); + + void setContainer(MultiCookContainer *container); + bool requireOpen(); + bool requireClose(); + +signals: + +public slots: + +private: + MultiCookContainer *container; + QTimer checkTimer; + + enum State { + Idle, Preheating, OpenDoor, CloseDoor, Running, Paused, Finished + } state; + +private slots: + void check(); + + void checkPreheating(); + void checkRunning(); + void checkPaused(); + void checkFinished(); + +}; + +#endif // MULTICOOKCONTROLLER_H diff --git a/app/gui/oven_control/multicookmanualwindow.cpp b/app/gui/oven_control/multicookmanualwindow.cpp new file mode 100644 index 0000000..23dc291 --- /dev/null +++ b/app/gui/oven_control/multicookmanualwindow.cpp @@ -0,0 +1,282 @@ +#include "multicookmanualwindow.h" +#include "ui_multicookmanualwindow.h" + +#include + +#include "stringer.h" +#include "multimanualcook.h" +#include "mainwindow.h" +#include "configwindow.h" +#include "soundplayer.h" + +MultiCookManualWindow::MultiCookManualWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MultiCookManualWindow) +{ + ui->setupUi(this); + + ui->clockContainer->setParent(ui->upperStack); + setAttribute(Qt::WA_DeleteOnClose); + + ui->humiditySlider->setSubPixmap(":/images/slider/humidity.png"); + ui->humiditySlider->setRange(0, 100); + ui->humiditySlider->bigTickInterval = 50; + ui->humiditySlider->tickInterval = 10; + + ui->tempSlider->setSubPixmap(":/images/slider/temp.png"); + ui->tempSlider->bigTickInterval = 50; + ui->tempSlider->tickInterval = 10; + + ui->timeSlider->setSubPixmap(":/images/slider/time.png"); + ui->timeSlider->setRange(0, 342); + ui->timeSlider->bigTicks.append(0); + ui->timeSlider->bigTicks.append(180); + ui->timeSlider->bigTicks.append(270); + ui->timeSlider->bigTicks.append(342); + ui->timeSlider->ticks.append(60); + ui->timeSlider->ticks.append(120); + ui->timeSlider->ticks.append(180 + 30); + ui->timeSlider->ticks.append(180 + 60); + ui->timeSlider->ticks.append(270 + 4 * 6); + ui->timeSlider->ticks.append(270 + 4 * 12); + + connect(ui->humiditySlider, SIGNAL(sliderMoved(int)), SLOT(updateView())); + connect(ui->tempSlider, SIGNAL(sliderMoved(int)), SLOT(updateView())); + connect(ui->timeSlider, SIGNAL(sliderMoved(int)), SLOT(updateView())); + + connect(ui->humiditySlider, SIGNAL(sliderPressed()), SLOT(updateView())); + connect(ui->tempSlider, SIGNAL(sliderPressed()), SLOT(updateView())); + connect(ui->timeSlider, SIGNAL(sliderPressed()), SLOT(updateView())); + + foreach (QPushButton *button, findChildren()) + connect(button, &QPushButton::pressed, SoundPlayer::playClick); + + setFocus(); + + afterThreeSecsTimer.setSingleShot(true); + afterThreeSecsTimer.setInterval(3000); + connect(&afterThreeSecsTimer, SIGNAL(timeout()), SLOT(afterThreeSecs())); + + foreach (QWidget *w, findChildren()) + w->installEventFilter(this); + + installEventFilter(this); + + pushed = NULL; +} + +MultiCookManualWindow::~MultiCookManualWindow() +{ + delete ui; +} + +void MultiCookManualWindow::setMode(Define::Mode mode) +{ + switch (mode) + { + case Define::SteamMode: + ui->steamButton->setChecked(true); + ui->combiButton->setChecked(false); + ui->dryheatButton->setChecked(false); + ui->humidityButton->setEnabled(false); + ui->humiditySlider->setEnabled(false); + ui->humiditySlider->setValue(100); + ui->tempSlider->setRange(30, 130); + ui->tempSlider->setValue(100); + ui->timeSlider->setValue(0); + updateView(); + this->mode = mode; + break; + case Define::CombiMode: + ui->steamButton->setChecked(false); + ui->combiButton->setChecked(true); + ui->dryheatButton->setChecked(false); + ui->humidityButton->setEnabled(true); + ui->humiditySlider->setEnabled(true); + ui->humiditySlider->setValue(50); + ui->tempSlider->setRange(30, 300); + ui->tempSlider->setValue(100); + ui->timeSlider->setValue(0); + updateView(); + this->mode = mode; + break; + case Define::DryMode: + ui->steamButton->setChecked(false); + ui->combiButton->setChecked(false); + ui->dryheatButton->setChecked(true); + ui->humidityButton->setEnabled(false); + ui->humiditySlider->setEnabled(false); + ui->humiditySlider->setValue(0); + ui->tempSlider->setRange(30, 300); + ui->tempSlider->setValue(160); + ui->timeSlider->setValue(0); + updateView(); + this->mode = mode; + break; + default: + return; + } +} + +bool MultiCookManualWindow::eventFilter(QObject */*watched*/, QEvent *event) +{ + switch (event->type()) + { + case QEvent::KeyPress: + case QEvent::KeyRelease: + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + afterThreeSecsTimer.start(); + break; + default: + break; + } + + return false; +} + +void MultiCookManualWindow::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000032: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + pushed = focusWidget(); + break; + case 0x01000030: // Turn right + onEncoderRight(); + break; + } +} + +void MultiCookManualWindow::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000032: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + if (focusWidget() == pushed) + onEncoderClicked(pushed); + + pushed = NULL; + break; + case 0x01000030: // Turn right + onEncoderRight(); + break; + } +} + +int MultiCookManualWindow::sliderToTime(int value) +{ + if (value <= 180) + return value * 60; + if (value <= 270) + return 180 * 60 + (value - 180) * 2 * 60; + return 360 * 60 + (value - 270) * 15 * 60; +} + +void MultiCookManualWindow::onEncoderLeft() +{ + focusPreviousChild(); +} + +void MultiCookManualWindow::onEncoderRight() +{ + focusNextChild(); +} + +void MultiCookManualWindow::onEncoderClicked(QWidget *clicked) +{ + if (clicked == NULL) + return; + + QPushButton *b = qobject_cast(clicked); + if (b) + b->click(); + + Slider *slider = qobject_cast(clicked); + if (slider) + { + if (slider == ui->humiditySlider) + ui->humidityButton->setFocus(); + else if (slider == ui->tempSlider) + ui->tempButton->setFocus(); + else if (slider == ui->timeSlider) + ui->timeButton->setFocus(); + + updateView(); + } +} + +void MultiCookManualWindow::updateView() +{ + ui->humidityLabel->setText(QString("%1%").arg(ui->humiditySlider->sliderPosition())); + ui->tempLabel->setText(Stringer::temperature(ui->tempSlider->sliderPosition(), Stringer::fontSize14)); + ui->timeLabel->setText(Stringer::remainingTime(sliderToTime(ui->timeSlider->sliderPosition()) * 1000, Stringer::fontSize14)); + + QWidget *focused = focusWidget(); + ui->humidityButton->setChecked(focused == ui->humiditySlider); + ui->tempButton->setChecked(focused == ui->tempSlider); + ui->timeButton->setChecked(focused == ui->timeSlider); +} + +void MultiCookManualWindow::afterThreeSecs() +{ + Slider *slider = qobject_cast(focusWidget()); + if (slider) + { + if (slider == ui->humiditySlider) + ui->humidityButton->setFocus(); + else if (slider == ui->tempSlider) + ui->tempButton->setFocus(); + else if (slider == ui->timeSlider) + ui->timeButton->setFocus(); + + updateView(); + } +} + +void MultiCookManualWindow::on_humidityButton_clicked() +{ + ui->humiditySlider->setFocus(); + updateView(); +} + +void MultiCookManualWindow::on_tempButton_clicked() +{ + ui->tempSlider->setFocus(); + updateView(); +} + +void MultiCookManualWindow::on_timeButton_clicked() +{ + ui->timeSlider->setFocus(); + updateView(); +} + +void MultiCookManualWindow::on_backButton_clicked() +{ + close(); +} + +void MultiCookManualWindow::on_helpButton_clicked() +{ + +} + +void MultiCookManualWindow::on_okButton_clicked() +{ + MultiManualCook *c = new MultiManualCook; + c->setMode(mode); + c->setHumidity(ui->humiditySlider->value()); + c->setTemperature(ui->tempSlider->value()); + c->setTime(sliderToTime(ui->timeSlider->value())); + + emit selected(c); + close(); +} diff --git a/app/gui/oven_control/multicookmanualwindow.h b/app/gui/oven_control/multicookmanualwindow.h new file mode 100644 index 0000000..69197ae --- /dev/null +++ b/app/gui/oven_control/multicookmanualwindow.h @@ -0,0 +1,59 @@ +#ifndef MULTICOOKMANUALWINDOW_H +#define MULTICOOKMANUALWINDOW_H + +#include + +#include "multicook.h" + +namespace Ui { +class MultiCookManualWindow; +} + +class MultiCookManualWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MultiCookManualWindow(QWidget *parent = 0); + ~MultiCookManualWindow(); + + void setMode(Define::Mode mode); + + bool eventFilter(QObject *watched, QEvent *event); + +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + +signals: + void selected(MultiCook*); + +private: + Ui::MultiCookManualWindow *ui; + + Define::Mode mode; + + int sliderToTime(int value); + + QTimer afterThreeSecsTimer; + QWidget *pushed = NULL; + + void onEncoderLeft(); + void onEncoderRight(); + void onEncoderClicked(QWidget *clicked); + +private slots: + void updateView(); + void afterThreeSecs(); + + void on_humidityButton_clicked(); + void on_tempButton_clicked(); + void on_timeButton_clicked(); + + void on_backButton_clicked(); + void on_helpButton_clicked(); + void on_okButton_clicked(); + +}; + +#endif // MULTICOOKMANUALWINDOW_H diff --git a/app/gui/oven_control/multicookmanualwindow.ui b/app/gui/oven_control/multicookmanualwindow.ui new file mode 100644 index 0000000..92fdffa --- /dev/null +++ b/app/gui/oven_control/multicookmanualwindow.ui @@ -0,0 +1,902 @@ + + + MultiCookManualWindow + + + + 0 + 0 + 900 + 1600 + + + + #bottomBar { background-image: url(:/images/bottom_bar/background.png); } +#centralwidget { background-image: url(:/images/background/manual.png); } + +QPushButton { +background-repeat: no-repeat; +background-position: center; +border: none; +} + +QPushButton[style="mode"] { +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); +} + +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; +} + + + + + false + + + + 600 + 426 + 300 + 293 + + + + QPushButton { background-image: url(:/images/cook_mode/big_dryheat_hide.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_mode/big_dryheat_ov.png); } +QPushButton:checked { background-image: url(:/images/cook_mode/big_dryheat.png); } + + + 건열 + + + true + + + mode + + + + + + 27 + 1025 + 140 + 140 + + + + QPushButton { image: url(:/images/slider_icon/time.png); } +QPushButton:pressed, +QPushButton:focus { image: url(:/images/slider_icon/011_icon_03_active.png); } +QPushButton:checked { image: url(:/images/slider_icon/time_ov.png); } + + + true + + + icon + + + + + true + + + + 690 + 810 + 150 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 0% + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + true + + + + 160 + 740 + 91 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 감소 + + + Qt::AlignCenter + + + + + true + + + + 780 + 740 + 91 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 증가 + + + Qt::AlignCenter + + + + + + 27 + 725 + 140 + 140 + + + + QPushButton { image: url(:/images/slider_icon/humidity.png); } +QPushButton:pressed, +QPushButton:focus { image: url(:/images/slider_icon/011_icon_01_active.png); } +QPushButton:checked { image: url(:/images/slider_icon/humidity_ov.png); } + + + true + + + icon + + + + + true + + + + 160 + 890 + 91 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 감소 + + + Qt::AlignCenter + + + + + + 0 + 1450 + 900 + 150 + + + + + + 288 + 26 + 97 + 97 + + + + QPushButton { border-image: url(:/images/bottom_bar/back.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/back_ov.png); } + + + + + + + + + 514 + 26 + 97 + 97 + + + + QPushButton { border-image: url(:/images/bottom_bar/006_sys_icon_16.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/006_sys_icon_16_ov.png); } + + + + + + + + + 401 + 26 + 97 + 97 + + + + QPushButton { border-image: url(:/images/bottom_bar/help.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/help_ov.png); } + + + + + + + + + true + + + + 539 + 1110 + 301 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 0<span style="font-size:11pt;">초</span> + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + false + + + + 300 + 426 + 300 + 293 + + + + QPushButton { background-image: url(:/images/cook_mode/big_combi_hide.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_mode/big_combi_ov.png); } +QPushButton:checked { background-image: url(:/images/cook_mode/big_combi.png); } + + + 콤비 + + + true + + + mode + + + + + + 185 + 1065 + 666 + 60 + + + + Qt::ClickFocus + + + + + + 185 + 765 + 666 + 60 + + + + Qt::ClickFocus + + + + + false + + + + 0 + 426 + 300 + 293 + + + + QPushButton { background-image: url(:/images/cook_mode/big_steam_hide.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_mode/big_steam_ov.png); } +QPushButton:checked { background-image: url(:/images/cook_mode/big_steam.png); } + + + 스팀 + + + true + + + mode + + + + + true + + + + 690 + 960 + 150 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 30<span style="font-size:11pt;">℃</span> + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + true + + + + 780 + 890 + 91 + 51 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 9 + + + + 증가 + + + Qt::AlignCenter + + + + + + 0 + 0 + 900 + 426 + + + + + #clockContainer { background-image: url(:/images/clock/background.png); } + + + + + 272 + 36 + 356 + 355 + + + + + + + 800 + 320 + 80 + 84 + + + + + + + 780 + 230 + 101 + 90 + + + + + + + 780 + 160 + 108 + 67 + + + + + + + 20 + 310 + 600 + 100 + + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + #closeDoorWidget { background-image: url(:/images/clock/background.png); } + + + + + 366 + 20 + 251 + 292 + + + + + + + 430 + 170 + 85 + 24 + + + + :/images/animation/close_door_arrow.png + + + + + + + + 185 + 915 + 666 + 60 + + + + Qt::ClickFocus + + + + + + 27 + 875 + 140 + 140 + + + + QPushButton { image: url(:/images/slider_icon/temp.png); } +QPushButton:pressed, +QPushButton:focus { image: url(:/images/slider_icon/011_icon_02_active.png); } +QPushButton:checked { image: url(:/images/slider_icon/temp_ov.png); } + + + true + + + icon + + + + + + + Clock + QWidget +
clock.h
+ 1 +
+ + WashWarnIcon + QLabel +
washwarnicon.h
+
+ + DemoIcon + QLabel +
demoicon.h
+
+ + HalfEnergyIcon + QLabel +
halfenergyicon.h
+
+ + DigitalClock + QLabel +
digitalclock.h
+
+ + AnimatedImageBox + QLabel +
animatedimagebox.h
+
+ + Slider + QWidget +
slider.h
+ 1 +
+
+ + steamButton + combiButton + dryheatButton + humidityButton + tempButton + timeButton + backButton + helpButton + okButton + + + + + +
diff --git a/app/gui/oven_control/multicookrecorder.cpp b/app/gui/oven_control/multicookrecorder.cpp new file mode 100644 index 0000000..5aa72ba --- /dev/null +++ b/app/gui/oven_control/multicookrecorder.cpp @@ -0,0 +1,75 @@ +#include "multicookrecorder.h" + +namespace +{ + +Define::Mode mode = Define::InvalidMode; + +struct Entry +{ + MultiCook *cook; + int count; +}; + +QList sortedList; + +void sort() +{ + // Insertion sort + int size = sortedList.size(); + for (int i = 1; i < size; i++) + { + for (int j = i; j > 0; j--) + { + Entry c = sortedList.at(j); + Entry t = sortedList.at(j - 1); + + if (c.count > t.count) + { + // Swap + sortedList.replace(j, t); + sortedList.replace(j - 1, c); + } + else + break; + } + } +} + +} + +namespace MultiCookRecorder +{ + +void record(MultiCook *cook) +{ + if (mode != cook->mode()) + { + mode = cook->mode(); + sortedList.clear(); + } + + for (int i = 0; i < sortedList.size(); i++) + { + Entry &e = sortedList[i]; + if (e.cook->equals(cook)) + { + e.count++; + sort(); + return; + } + } + + sortedList.append(Entry{cook->clone(), 1}); +} + +QList list() +{ + QList l; + foreach (Entry e, sortedList) + l.append(e.cook); + + return l; +} + +} diff --git a/app/gui/oven_control/multicookrecorder.h b/app/gui/oven_control/multicookrecorder.h new file mode 100644 index 0000000..769a9eb --- /dev/null +++ b/app/gui/oven_control/multicookrecorder.h @@ -0,0 +1,14 @@ +#ifndef MULTICOOKRECORDER_H +#define MULTICOOKRECORDER_H + +#include "multicook.h" + +namespace MultiCookRecorder +{ + +void record(MultiCook *cook); +QList list(); + +} + +#endif // MULTICOOKRECORDER_H diff --git a/app/gui/oven_control/multicookselectionwindow.cpp b/app/gui/oven_control/multicookselectionwindow.cpp new file mode 100644 index 0000000..a5a7113 --- /dev/null +++ b/app/gui/oven_control/multicookselectionwindow.cpp @@ -0,0 +1,236 @@ +#include "multicookselectionwindow.h" +#include "ui_multicookselectionwindow.h" + +#include + +#include "mainwindow.h" +#include "configwindow.h" +#include "multicookmanualwindow.h" +#include "multicookautowindow.h" +#include "soundplayer.h" + +MultiCookSelectionWindow::MultiCookSelectionWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MultiCookSelectionWindow) +{ + ui->setupUi(this); + + ui->clockContainer->setParent(ui->upperStack); + setAttribute(Qt::WA_DeleteOnClose); + + mode = Define::InvalidMode; + + updateView(); + + setFocus(); + + foreach (QPushButton *button, findChildren()) + connect(button, &QPushButton::pressed, SoundPlayer::playClick); +} + +MultiCookSelectionWindow::~MultiCookSelectionWindow() +{ + delete ui; +} + +void MultiCookSelectionWindow::setMode(Define::Mode mode) +{ + this->mode = mode; + book.setMode(mode); + updateView(); +} + +void MultiCookSelectionWindow::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000032: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + pushed = focusWidget(); + break; + case 0x01000030: // Turn right + onEncoderRight(); + break; + } +} + +void MultiCookSelectionWindow::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000032: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + if (focusWidget() == pushed) + onEncoderClicked(pushed); + + pushed = NULL; + break; + case 0x01000030: // Turn right + onEncoderRight(); + break; + } +} + +void MultiCookSelectionWindow::updateView() +{ + if (mode == Define::InvalidMode) + { + ui->steamButton->setEnabled(true); + ui->combiButton->setEnabled(true); + ui->dryheatButton->setEnabled(true); + + ui->poultryButton->setEnabled(false); + ui->meatButton->setEnabled(false); + ui->fishButton->setEnabled(false); + ui->dessertButton->setEnabled(false); + ui->grainButton->setEnabled(false); + ui->breadButton->setEnabled(false); + ui->etcButton->setEnabled(false); + } + else + { + ui->steamButton->setEnabled(mode == Define::SteamMode); + ui->combiButton->setEnabled(mode == Define::CombiMode); + ui->dryheatButton->setEnabled(mode == Define::DryMode); + + ui->poultryButton->setEnabled(book.checkType(Define::Poultry)); + ui->meatButton->setEnabled(book.checkType(Define::Meat)); + ui->fishButton->setEnabled(book.checkType(Define::Fish)); + ui->dessertButton->setEnabled(book.checkType(Define::Desert)); + ui->grainButton->setEnabled(book.checkType(Define::Vegetable)); + ui->breadButton->setEnabled(book.checkType(Define::Bread)); + ui->etcButton->setEnabled(book.checkType(Define::Etc)); + } + + ui->primeButton->setEnabled(false); + + ui->multiButton->setEnabled(false); + ui->programmingButton->setEnabled(false); + ui->washButton->setEnabled(false); +} + +void MultiCookSelectionWindow::handleModeClick(Define::Mode mode) +{ + setFocus(); + + if (this->mode == Define::InvalidMode) + { + setMode(mode); + } + else + { + MultiCookManualWindow *w = new MultiCookManualWindow(this); + w->setMode(mode); + w->setWindowModality(Qt::WindowModal); + w->showFullScreen(); + w->raise(); + + connect(w, SIGNAL(selected(MultiCook*)), SIGNAL(selected(MultiCook*))); + connect(w, SIGNAL(selected(MultiCook*)), SLOT(hide())); + connect(w, SIGNAL(selected(MultiCook*)), SLOT(close())); + } +} + +void MultiCookSelectionWindow::handleTypeClick(Define::CookType type) +{ + setFocus(); + + book.setType(type); + + MultiCookAutoWindow *w = new MultiCookAutoWindow(this); + w->setType(type); + w->setBook(&book); + w->setWindowModality(Qt::WindowModal); + w->showFullScreen(); + w->raise(); + + connect(w, SIGNAL(selected(MultiCook*)), SIGNAL(selected(MultiCook*))); + connect(w, SIGNAL(selected(MultiCook*)), SLOT(hide())); + connect(w, SIGNAL(selected(MultiCook*)), SLOT(close())); +} + +void MultiCookSelectionWindow::on_steamButton_clicked() +{ + handleModeClick(Define::SteamMode); +} + +void MultiCookSelectionWindow::on_combiButton_clicked() +{ + handleModeClick(Define::CombiMode); +} + +void MultiCookSelectionWindow::on_dryheatButton_clicked() +{ + handleModeClick(Define::DryMode); +} + +void MultiCookSelectionWindow::on_poultryButton_clicked() +{ + handleTypeClick(Define::Poultry); +} + +void MultiCookSelectionWindow::on_meatButton_clicked() +{ + handleTypeClick(Define::Meat); +} + +void MultiCookSelectionWindow::on_fishButton_clicked() +{ + handleTypeClick(Define::Fish); +} + +void MultiCookSelectionWindow::on_dessertButton_clicked() +{ + handleTypeClick(Define::Desert); +} + +void MultiCookSelectionWindow::on_grainButton_clicked() +{ + handleTypeClick(Define::Vegetable); +} + +void MultiCookSelectionWindow::on_breadButton_clicked() +{ + handleTypeClick(Define::Bread); +} + +void MultiCookSelectionWindow::on_etcButton_clicked() +{ + handleTypeClick(Define::Etc); +} + +void MultiCookSelectionWindow::on_backButton_clicked() +{ + close(); +} + +void MultiCookSelectionWindow::on_helpButton_clicked() +{ + +} + +void MultiCookSelectionWindow::on_okButton_clicked() +{ + +} + +void MultiCookSelectionWindow::onEncoderLeft() +{ + focusPreviousChild(); +} + +void MultiCookSelectionWindow::onEncoderRight() +{ + focusNextChild(); +} + +void MultiCookSelectionWindow::onEncoderClicked(QWidget *clicked) +{ + QPushButton *b = qobject_cast(clicked); + if (b) + b->click(); +} diff --git a/app/gui/oven_control/multicookselectionwindow.h b/app/gui/oven_control/multicookselectionwindow.h new file mode 100644 index 0000000..cd34f86 --- /dev/null +++ b/app/gui/oven_control/multicookselectionwindow.h @@ -0,0 +1,64 @@ +#ifndef MULTICOOKSELECTIONWINDOW_H +#define MULTICOOKSELECTIONWINDOW_H + +#include + +#include "multicook.h" +#include "multicookbook.h" + +namespace Ui { +class MultiCookSelectionWindow; +} + +class MultiCookSelectionWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MultiCookSelectionWindow(QWidget *parent = 0); + ~MultiCookSelectionWindow(); + + void setMode(Define::Mode mode); + +signals: + void selected(MultiCook*); + +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + +private slots: + void updateView(); + + void handleModeClick(Define::Mode mode); + void handleTypeClick(Define::CookType type); + + void on_steamButton_clicked(); + void on_combiButton_clicked(); + void on_dryheatButton_clicked(); + + void on_poultryButton_clicked(); + void on_meatButton_clicked(); + void on_fishButton_clicked(); + void on_dessertButton_clicked(); + void on_grainButton_clicked(); + void on_breadButton_clicked(); + void on_etcButton_clicked(); + + void on_backButton_clicked(); + void on_helpButton_clicked(); + void on_okButton_clicked(); + +private: + Ui::MultiCookSelectionWindow *ui; + Define::Mode mode; + MultiCookBook book; + + QWidget *pushed = NULL; + + void onEncoderLeft(); + void onEncoderRight(); + void onEncoderClicked(QWidget *clicked); +}; + +#endif // MULTICOOKSELECTIONWINDOW_H diff --git a/app/gui/oven_control/multicookselectionwindow.ui b/app/gui/oven_control/multicookselectionwindow.ui new file mode 100644 index 0000000..9076753 --- /dev/null +++ b/app/gui/oven_control/multicookselectionwindow.ui @@ -0,0 +1,767 @@ + + + MultiCookSelectionWindow + + + + 0 + 0 + 900 + 1600 + + + + #centralwidget { background-image: url(:/images/background/main.png); } +#bottomBar { background-image: url(:/images/bottom_bar/background.png); } + +QWidget { outline: 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: white; +font-size: 40px; +} + +QPushButton[style="type"] { +background-repeat: no-repeat; +background-position: center; +background-clip: border; +background-origin: border; + +border-top: 165px; +border-style: hidden; +color: white; +font-size: 30px; +} + +QPushButton[style="function"] { +background-repeat: no-repeat; +background-position: center; +background-clip: border; +background-origin: border; + +border-top: 206px; +border-style: hidden; +color: white; +font-size: 30px; +} + +QPushButton:disabled { color: #7B7B7B; } + + + + + false + + + + 600 + 426 + 300 + 293 + + + + QPushButton { background-image: url(:/images/cook_mode/big_dryheat.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_mode/big_dryheat_ov.png); } +QPushButton:disabled { background-image: url(:/images/cook_mode/big_dryheat_hide.png); } + + + 건열 + + + mode + + + + + + 450 + 771 + 1 + 120 + + + + Qt::Vertical + + + + + false + + + + 0 + 942 + 225 + 222 + + + + + 0 + 0 + + + + QPushButton { background-image: url(:/images/cook_type/vegetable.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_type/vegetable_ov.png); } +QPushButton:disabled { background-image: url(:/images/cook_type/vegetable_hide.png); } + + + 채소및곡류 + + + type + + + + + + 450 + 993 + 1 + 120 + + + + Qt::Vertical + + + + + false + + + + 225 + 942 + 225 + 222 + + + + + 0 + 0 + + + + QPushButton { background-image: url(:/images/cook_type/bread.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_type/bread_ov.png); } +QPushButton:disabled { background-image: url(:/images/cook_type/bread_hide.png); } + + + 제과제빵류 + + + type + + + + + + 675 + 771 + 1 + 120 + + + + Qt::Vertical + + + + + false + + + + 225 + 720 + 225 + 222 + + + + + 0 + 0 + + + + QPushButton { background-image: url(:/images/cook_type/meat.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_type/meat_ov.png); } +QPushButton:disabled { background-image: url(:/images/cook_type/meat_hide.png); } + + + 육류 + + + type + + + + + + 225 + 771 + 1 + 120 + + + + Qt::Vertical + + + + + false + + + + 675 + 720 + 225 + 222 + + + + + 0 + 0 + + + + QPushButton { background-image: url(:/images/cook_type/desert.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_type/desert_ov.png); } +QPushButton:disabled { background-image: url(:/images/cook_type/desert_hide.png); } + + + 디저트류 + + + type + + + + + false + + + + 0 + 720 + 225 + 222 + + + + + 0 + 0 + + + + QPushButton { background-image: url(:/images/cook_type/poultry.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_type/poultry_ov.png); } +QPushButton:disabled { background-image: url(:/images/cook_type/poultry_hide.png); } + + + 가금류 + + + type + + + + + false + + + + 300 + 426 + 300 + 293 + + + + QPushButton { background-image: url(:/images/cook_mode/big_combi.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_mode/big_combi_ov.png); } +QPushButton:disabled { background-image: url(:/images/cook_mode/big_combi_hide.png); } + + + 콤비 + + + mode + + + + + false + + + + 0 + 1164 + 300 + 286 + + + + + 0 + 0 + + + + Qt::NoFocus + + + QPushButton { background-image: url(:/images/main_button/multi.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/main_button/multi_ov.png); } +QPushButton:disabled { background-image: url(:/images/main_button/multi_hide.png); } + + + 다중요리 + + + function + + + + + false + + + + 300 + 1164 + 300 + 286 + + + + + 0 + 0 + + + + Qt::NoFocus + + + QPushButton { background-image: url(:/images/main_button/custom.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/main_button/custom_ov.png); } +QPushButton:disabled { background-image: url(:/images/main_button/custom_hide.png); } + + + 프로그래밍모드 + + + function + + + + + + 18 + 942 + 863 + 1 + + + + Qt::Horizontal + + + + + false + + + + 450 + 942 + 225 + 222 + + + + + 0 + 0 + + + + QPushButton { background-image: url(:/images/cook_type/etc.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_type/etc_ov.png); } +QPushButton:disabled { background-image: url(:/images/cook_type/etc_hide.png); } + + + 기타요리 + + + type + + + + + + 225 + 993 + 1 + 120 + + + + Qt::Vertical + + + + + false + + + + 600 + 1164 + 300 + 286 + + + + + 0 + 0 + + + + Qt::NoFocus + + + QPushButton { background-image: url(:/images/main_button/wash.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/main_button/wash_ov.png); } +QPushButton:disabled { background-image: url(:/images/main_button/wash_hide.png); } + + + 세척모드 + + + function + + + + + false + + + + 675 + 942 + 225 + 222 + + + + + 0 + 0 + + + + QPushButton { background-image: url(:/images/cook_type/additional.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_type/additional_ov.png); } +QPushButton:disabled { background-image: url(:/images/cook_type/additional_hide.png); } + + + 부가기능 + + + type + + + + + + 675 + 993 + 1 + 120 + + + + Qt::Vertical + + + + + + 0 + 1450 + 900 + 150 + + + + + 900 + 150 + + + + + 900 + 150 + + + + + + 401 + 26 + 97 + 97 + + + + + 0 + 0 + + + + + 62 + 71 + + + + QPushButton { border-image: url(:/images/bottom_bar/help.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/help_ov.png); } + + + + + + + + + 288 + 26 + 97 + 97 + + + + QPushButton { border-image: url(:/images/bottom_bar/back.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/back_ov.png); } + + + + + + + + + 514 + 26 + 97 + 97 + + + + QPushButton { border-image: url(:/images/bottom_bar/006_sys_icon_16.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/006_sys_icon_16_ov.png); } + + + + + + + + + false + + + + 0 + 426 + 300 + 293 + + + + QPushButton { background-image: url(:/images/cook_mode/big_steam.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_mode/big_steam_ov.png); } +QPushButton:disabled { background-image: url(:/images/cook_mode/big_steam_hide.png); } + + + 스팀 + + + mode + + + + + false + + + + 450 + 720 + 225 + 222 + + + + + 0 + 0 + + + + QPushButton { background-image: url(:/images/cook_type/fish.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_type/fish_ov.png); } +QPushButton:disabled { background-image: url(:/images/cook_type/fish_hide.png); } + + + 생선류 + + + type + + + + + + 0 + 0 + 900 + 426 + + + + 0 + + + + #clockContainer { background-image: url(:/images/clock/background.png); } + + + + + 272 + 36 + 356 + 355 + + + + + + + 800 + 320 + 80 + 84 + + + + + + + 780 + 230 + 101 + 90 + + + + + + + 780 + 160 + 108 + 67 + + + + + + + 20 + 310 + 600 + 100 + + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + + + + Clock + QWidget +
clock.h
+ 1 +
+ + WashWarnIcon + QLabel +
washwarnicon.h
+
+ + DemoIcon + QLabel +
demoicon.h
+
+ + HalfEnergyIcon + QLabel +
halfenergyicon.h
+
+ + DigitalClock + QLabel +
digitalclock.h
+
+
+ + steamButton + combiButton + dryheatButton + poultryButton + meatButton + fishButton + dessertButton + grainButton + breadButton + etcButton + primeButton + backButton + helpButton + okButton + + + +
diff --git a/app/gui/oven_control/multicooktimebar.cpp b/app/gui/oven_control/multicooktimebar.cpp new file mode 100644 index 0000000..1f5c799 --- /dev/null +++ b/app/gui/oven_control/multicooktimebar.cpp @@ -0,0 +1,77 @@ +#include "multicooktimebar.h" + +#include +#include +#include + +MultiCookTimeBar::MultiCookTimeBar(QWidget *parent) : QWidget(parent) +{ + format = "hh:mm"; + timePosition = 0; + + checkTimer.start(100); + connect(&checkTimer, SIGNAL(timeout()), SLOT(check())); +} + +void MultiCookTimeBar::showNow() +{ + timePosition = 0; + update(); +} + +void MultiCookTimeBar::showPrev() +{ + timePosition--; + update(); +} + +void MultiCookTimeBar::showNext() +{ + timePosition++; + update(); +} + +void MultiCookTimeBar::paintEvent(QPaintEvent */*event*/) +{ + int w = width(); + int h = height(); + int y = h / 2; + + QPoint c1(w * 2 / 10, y); + QPoint c2(w * 5 / 10, y); + QPoint c3(w * 8 / 10, y); + +// QFont font = this->font(); +// font.setBold(true); + + QRect rect(0, 0, w, h); + + QTime t = QTime::currentTime(); + + QString s1 = t.addSecs(200 * (timePosition + 0)).toString(format); + QString s2 = t.addSecs(200 * (timePosition + 3)).toString(format); + QString s3 = t.addSecs(200 * (timePosition + 6)).toString(format); + + QPainter painter(this); + painter.setPen(Qt::white); +// painter.setFont(font); + + rect.moveCenter(c1); + painter.drawText(rect, Qt::AlignCenter, s1); + + rect.moveCenter(c2); + painter.drawText(rect, Qt::AlignCenter, s2); + + rect.moveCenter(c3); + painter.drawText(rect, Qt::AlignCenter, s3); +} + +void MultiCookTimeBar::check() +{ + QString s = QTime::currentTime().toString(format); + if (lastDraw.isNull() || s != lastDraw) + { + update(); + lastDraw = s; + } +} diff --git a/app/gui/oven_control/multicooktimebar.h b/app/gui/oven_control/multicooktimebar.h new file mode 100644 index 0000000..65c9d2a --- /dev/null +++ b/app/gui/oven_control/multicooktimebar.h @@ -0,0 +1,33 @@ +#ifndef MULTICOOKTIMEBAR_H +#define MULTICOOKTIMEBAR_H + +#include +#include + +class MultiCookTimeBar : public QWidget +{ + Q_OBJECT +public: + explicit MultiCookTimeBar(QWidget *parent = 0); + +signals: + +public slots: + void showNow(); + void showPrev(); + void showNext(); + +protected: + virtual void paintEvent(QPaintEvent *event); + +private: + int timePosition; + QString lastDraw; + QTimer checkTimer; + QString format; + +private slots: + void check(); +}; + +#endif // MULTICOOKTIMEBAR_H diff --git a/app/gui/oven_control/multicookview.cpp b/app/gui/oven_control/multicookview.cpp new file mode 100644 index 0000000..197f58d --- /dev/null +++ b/app/gui/oven_control/multicookview.cpp @@ -0,0 +1,282 @@ +#include "multicookview.h" + +#include +#include +#include + +MultiCookView::MultiCookView(QWidget *parent) + : QWidget(parent), + timePosition(0) +{ + barPixmap.load(":/images/multi/bar.png"); + + connect(&checkTimer, SIGNAL(timeout()), SLOT(check())); +} + +void MultiCookView::setContainer(MultiCookContainer *container) +{ + this->container = container; + rects = calcRects(); + checkTimer.start(33); +} + +void MultiCookView::setTimeBar(MultiCookTimeBar *bar) +{ + this->bar = bar; +} + +void MultiCookView::showNow() +{ + timePosition = 0; + updateView(); + + bar->showNow(); +} + +void MultiCookView::showNext() +{ + if (timePosition < 0 || !nothingOnRight()) + { + timePosition++; + updateView(); + + bar->showNext(); + } +} + +void MultiCookView::showPrev() +{ + if (timePosition > 0) + { + timePosition--; + updateView(); + + bar->showPrev(); + } +} + +void MultiCookView::updateView() +{ + rects = calcRects(); + update(); +} + +void MultiCookView::mousePressEvent(QMouseEvent *event) +{ + int x = event->x(); + int y = event->y(); + + pressedSlot = calcSlot(x, y); +} + +void MultiCookView::mouseReleaseEvent(QMouseEvent *event) +{ + if (pressedSlot == -1) + return; + + int x = event->x(); + int y = event->y(); + + if (calcSlot(x, y) == pressedSlot) + emit clicked(pressedSlot); +} + +void MultiCookView::paintEvent(QPaintEvent */*event*/) +{ + QPainter painter(this); + paintGrids(painter); + paintBars(painter); + paintCurrentTime(painter); +} + +void MultiCookView::resizeEvent(QResizeEvent *event) +{ + rects = calcRects(); + + QWidget::resizeEvent(event); +} + +void MultiCookView::check() +{ + bool needUpdate = false; + + QList rects = calcRects(); + for (int i = 0; i < 10; i++) + { + if (rects.at(i) != this->rects.at(i)) + { + needUpdate = true; + break; + } + } + + if (needUpdate) + { + this->rects = rects; + update(); + } +} + +QList MultiCookView::calcRects() +{ + int w = width(); + int h = height(); + int x = w * (2-timePosition) / 10 + 1; + int y = (h / 10 - 56) / 2; + + QList list; + for (int i = 0; i < 10; i++) + { + MultiCook *cook = container->at(i); + if (cook == Q_NULLPTR) + { + list.append(QRect()); + continue; + } + + int barY = y + h * i / 10; + int barW = 0; + + // bar width = remaining time(ms) / 200s * width of a grid + int remainingTime = cook->remainingTime(); + if (remainingTime > 0) + barW = qCeil(remainingTime / 2000000.0 * w); + + list.append(QRect(x, barY, barW, 56)); + } + + return list; +} + +int MultiCookView::calcSlot(int x, int y) +{ + for (int i = 0; i < 10; i++) + { + const QRect &r = rects.at(i); + if (r.isNull()) + continue; + + if (r.contains(x, y)) + return i; + } + + return -1; +} + +void MultiCookView::paintGrids(QPainter &painter) +{ + static const int padding = 10; + + int w = width(); + int h = height(); + + painter.setBrush(Qt::NoBrush); + painter.setPen(QColor(70,70,70)); + + for (int i = 1; i < 10; i++) + painter.drawLine(0, h * i / 10, w, h * i / 10); + + for (int i = 1; i < 10; i++) + painter.drawLine(w * i / 10, padding, w * i / 10, h - padding); +} + +void MultiCookView::paintBars(QPainter &painter) +{ + for (int i = 0; i < 10; i++) + { + MultiCook *cook = container->at(i); + if (cook == Q_NULLPTR) + continue; + + QRect r = rects.at(i); + if (!r.isNull()) + paintBar(painter, r); + + r.translate(10, 0); + + if (r.left() < 10) + r.moveLeft(10); + + painter.setBrush(Qt::NoBrush); + painter.setPen(Qt::white); + painter.drawText(r, Qt::AlignVCenter | Qt::TextDontClip, cook->name()); + } +} + +void MultiCookView::paintCurrentTime(QPainter &painter) +{ + static const int padding = 10; + + int w = width(); + int h = height(); + int x = w * (2-timePosition) / 10; + + QPen pen(Qt::yellow); + pen.setWidth(3); + painter.setPen(pen); + painter.setBrush(Qt::NoBrush); + painter.drawLine(x, padding, x, h - padding); +} + +void MultiCookView::paintBar(QPainter &painter, QRect r) +{ + static const int fullWidth = 281; + static const int headWidth = 7; + static const int tailWidth = fullWidth - 255; + static const int bodyWidth = fullWidth - headWidth - tailWidth; + static const int height = 56; + + static const int bodyOffset = headWidth; + static const int tailOffset = fullWidth - tailWidth; + + int w = r.width(); + if (w < tailWidth) + { + // Clip tail + QRect sourceRect(tailWidth - w + tailOffset, 0, w, height); + painter.drawPixmap(r, barPixmap, sourceRect); + } + else if (w < headWidth + tailWidth) + { + // Full tail + QRect sourceRect(tailOffset, 0, tailWidth, height); + QRect targetRect(r.x() + w - tailWidth, r.y(), tailWidth, height); + painter.drawPixmap(targetRect, barPixmap, sourceRect); + + // Clip head +// sourceRect = QRect(0, 0, w - tailWidth, height); +// targetRect = QRect(r.x(), r.y(), w - tailWidth, height); +// painter.drawPixmap(targetRect, barPixmap, sourceRect); + sourceRect = QRect(headWidth - (w - tailWidth), 0, w - tailWidth, height); + targetRect = QRect(r.x(), r.y(), w - tailWidth, height); + painter.drawPixmap(targetRect, barPixmap, sourceRect); + } + else + { + // Full tail + QRect sourceRect(tailOffset, 0, tailWidth, height); + QRect targetRect(r.x() + w - tailWidth, r.y(), tailWidth, height); + painter.drawPixmap(targetRect, barPixmap, sourceRect); + + // Full head + sourceRect = QRect(0, 0, headWidth, height); + targetRect = QRect(r.x(), r.y(), headWidth, height); + painter.drawPixmap(targetRect, barPixmap, sourceRect); + + // Stretch body + sourceRect = QRect(bodyOffset, 0, bodyWidth, 0); + targetRect = QRect(r.x() + bodyOffset, r.y(), w - headWidth - tailWidth, height); + painter.drawPixmap(targetRect, barPixmap, sourceRect); + } +} + +bool MultiCookView::nothingOnRight() +{ + int rightMost = width() * 2 / 3; + + foreach (QRect r, rects) + if (r.right() > rightMost) + return false; + + return true; +} diff --git a/app/gui/oven_control/multicookview.h b/app/gui/oven_control/multicookview.h new file mode 100644 index 0000000..e26276b --- /dev/null +++ b/app/gui/oven_control/multicookview.h @@ -0,0 +1,64 @@ +#ifndef MULTICOOKVIEW_H +#define MULTICOOKVIEW_H + +#include +#include +#include + +#include "multicookcontainer.h" +#include "multicooktimebar.h" + +class MultiCookView : public QWidget +{ + Q_OBJECT +public: + explicit MultiCookView(QWidget *parent = 0); + + void setContainer(MultiCookContainer *container); + void setTimeBar(MultiCookTimeBar *bar); + +signals: + void clicked(int); + +public slots: + void showNow(); + void showNext(); + void showPrev(); + void updateView(); + +protected: + virtual void mousePressEvent(QMouseEvent *event); + virtual void mouseReleaseEvent(QMouseEvent *event); + virtual void paintEvent(QPaintEvent *event); + virtual void resizeEvent(QResizeEvent *event); + +private: + // helper methods + QList calcRects(); + int calcSlot(int x, int y); + void paintGrids(QPainter &painter); + void paintBars(QPainter &painter); + void paintCurrentTime(QPainter &painter); + void paintBar(QPainter &painter, QRect r); + int currentTimePosition(); + bool nothingOnRight(); + + MultiCookContainer *container; + MultiCookTimeBar *bar; + QList rects; + int timePosition; + + // for click signal + int pressedSlot; + + QPixmap barPixmap; + + QTimer checkTimer; + +private slots: + void check(); + +}; + + +#endif // MULTICOOKVIEW_H diff --git a/app/gui/oven_control/multicookwindow.cpp b/app/gui/oven_control/multicookwindow.cpp new file mode 100644 index 0000000..b15d186 --- /dev/null +++ b/app/gui/oven_control/multicookwindow.cpp @@ -0,0 +1,538 @@ +#include "multicookwindow.h" +#include "ui_multicookwindow.h" + +#include +#include + +#include "multimanualcook.h" +#include "multiautocook.h" +#include "multicookrecorder.h" +#include "multicookselectionwindow.h" +#include "oven.h" +#include "stringer.h" +#include "confirmpopup.h" +#include "configwindow.h" +#include "washwindow.h" +#include "mainwindow.h" + +MultiCookWindow::MultiCookWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MultiCookWindow) +{ + ui->setupUi(this); + setAttribute(Qt::WA_DeleteOnClose); + + controller = new MultiCookController(this); + container = new MultiCookContainer(this); + controller->setContainer(container); + ui->view->setContainer(container); + ui->view->setTimeBar(ui->bar); + + + buttons.append(ui->selectButton_1); + buttons.append(ui->selectButton_2); + buttons.append(ui->selectButton_3); + buttons.append(ui->selectButton_4); + buttons.append(ui->selectButton_5); + buttons.append(ui->selectButton_6); + buttons.append(ui->selectButton_7); + buttons.append(ui->selectButton_8); + buttons.append(ui->selectButton_9); + buttons.append(ui->selectButton_10); + + cookButtons.append(ui->cookButton_1); + cookButtons.append(ui->cookButton_2); + cookButtons.append(ui->cookButton_3); + cookButtons.append(ui->cookButton_4); + cookButtons.append(ui->cookButton_5); + cookButtons.append(ui->cookButton_6); + cookButtons.append(ui->cookButton_7); + cookButtons.append(ui->cookButton_8); + cookButtons.append(ui->cookButton_9); + cookButtons.append(ui->cookButton_10); + cookButtons.append(ui->cookButton_11); + cookButtons.append(ui->cookButton_12); + + mode = Define::InvalidMode; + + lastClickedButton = -1; + lastClickedCookButton = -1; + trashClicked = false; + + updateViewTimer.start(100); + connect(&updateViewTimer, SIGNAL(timeout()), SLOT(updateView())); + + setFocus(); + + ui->closeDoorAnimationArea->hide(); + ui->closeDoorAnimation->load(":/images/animation/door_big_09.png"); + ui->closeDoorAnimation->load(":/images/animation/door_big_08.png"); + ui->closeDoorAnimation->load(":/images/animation/door_big_07.png"); + ui->closeDoorAnimation->load(":/images/animation/door_big_06.png"); + ui->closeDoorAnimation->load(":/images/animation/door_big_05.png"); + ui->closeDoorAnimation->load(":/images/animation/door_big_04.png"); + ui->closeDoorAnimation->load(":/images/animation/door_big_03.png"); + ui->closeDoorAnimation->load(":/images/animation/door_big_02.png"); + ui->closeDoorAnimation->load(":/images/animation/door_big_01.png"); + ui->closeDoorAnimation->start(300); + + ui->openDoorAnimationArea->hide(); + ui->openDoorAnimation->load(":/images/animation/door_big_01.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_02.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_03.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_04.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_05.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_06.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_07.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_08.png"); + ui->openDoorAnimation->load(":/images/animation/door_big_09.png"); + ui->openDoorAnimation->start(300); + +} + +MultiCookWindow::~MultiCookWindow() +{ + delete ui; + + Oven::getInstance()->stop(); +} + +void MultiCookWindow::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000032: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + if (focusWidget() != this) + pushed = focusWidget(); + break; + case 0x01000030: // Turn right + onEncoderRight(); + break; + } +} + +void MultiCookWindow::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000032: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + if (focusWidget() == pushed) + onEncoderClicked(pushed); + + pushed = NULL; + break; + case 0x01000030: // Turn right + onEncoderRight(); + break; + } +} + +void MultiCookWindow::updateView() +{ + Oven *oven = Oven::getInstance(); + if (controller->requireOpen() && !oven->door()) + { + ui->blockingArea->setEnabled(false); + ui->closeDoorAnimationArea->hide(); + ui->openDoorAnimationArea->show(); + } + else if (controller->requireClose() && oven->door()) + { + ui->blockingArea->setEnabled(false); + ui->closeDoorAnimationArea->show(); + ui->openDoorAnimationArea->hide(); + } + else + { + ui->blockingArea->setEnabled(true); + ui->closeDoorAnimationArea->hide(); + ui->openDoorAnimationArea->hide(); + } + + + QTime currentTime = QTime::currentTime(); + ui->showNowButton->setText(QString("%1:%2") + .arg(currentTime.hour(), 2, 10, QLatin1Char('0')) + .arg(currentTime.minute(), 2, 10, QLatin1Char('0'))); + + for (int i = 0; i < 10; i++) + { + QPushButton *button = buttons.at(i); + + MultiCook *cook = container->at(i); + if (cook == Q_NULLPTR) + button->setText("-"); + else + button->setText(Stringer::time(cook->remainingTime())); + } +} + +void MultiCookWindow::handleButtonClick(int button) +{ + MultiCook *cook = container->at(button); + if (cook) + { + if (trashClicked) + { + trashClicked = false; + container->remove(button); + cook->deleteLater(); + } + else + { + if (lastClickedButton == -1) + lastClickedButton = button; + else + cook->setTime(); + } + } + else + { + if (lastClickedCookButton != -1) + { + MultiCook *c = favorites.at(lastClickedCookButton)->clone(this); + addCook(button, c); + + lastClickedCookButton = -1; + } + else + { + lastClickedButton = button; + + ui->upperStack->setCurrentIndex(0); + setFocus(); + + selectCook(); + } + } +} + +void MultiCookWindow::handleFavoriteButtonClick(int button) +{ + lastClickedCookButton = button; +} + +void MultiCookWindow::selectCook() +{ + MultiCookSelectionWindow *w = new MultiCookSelectionWindow(this); + + if (mode != Define::InvalidMode) + w->setMode(mode); + + w->setWindowModality(Qt::WindowModal); + w->showFullScreen(); + w->raise(); + + connect(w, SIGNAL(selected(MultiCook*)), SLOT(onCookSelected(MultiCook*))); +} + +void MultiCookWindow::onCookSelected(MultiCook *cook) +{ + cook->setParent(this); + + if (lastClickedButton != -1) + { + addCook(lastClickedButton, cook); + lastClickedButton = -1; + } +} + +void MultiCookWindow::showFavorites() +{ + favorites = MultiCookRecorder::list(); + + int max = qMin(12, favorites.size()); + for (int i = 0; i < max; i++) + { + cookButtons.at(i)->show(); + cookButtons.at(i)->setText(favorites.at(i)->name()); + } + + for (int i = max; i < 12; i++) + cookButtons.at(i)->hide(); + + ui->upperStack->setCurrentIndex(1); +} + +void MultiCookWindow::showClock() +{ + ui->upperStack->setCurrentIndex(0); +} + +void MultiCookWindow::addCook(int slot, MultiCook *cook) +{ + mode = cook->mode(); + MultiCookRecorder::record(cook); + container->add(slot, cook); +} + +void MultiCookWindow::jumpConfig() +{ + ConfigWindow *w = new ConfigWindow(MainWindow::getInstance()); + w->setWindowModality(Qt::WindowModal); + w->showFullScreen(); + w->raise(); + + MainWindow::jump(w); +} + +void MultiCookWindow::jumpWash() +{ + WashWindow *w = new WashWindow(MainWindow::getInstance()); + w->setWindowModality(Qt::WindowModal); + w->showFullScreen(); + w->raise(); + + MainWindow::jump(w); +} + +void MultiCookWindow::on_showPrevButton_clicked() +{ + ui->view->showPrev(); +} + +void MultiCookWindow::on_showNowButton_clicked() +{ + ui->view->showNow(); +} + +void MultiCookWindow::on_showNextButton_clicked() +{ + ui->view->showNext(); +} + +void MultiCookWindow::on_showFavoritesButton_clicked() +{ + if (ui->upperStack->currentIndex() == 0) + showFavorites(); + else + showClock(); +} + +void MultiCookWindow::on_backButton_clicked() +{ + if (container->isEmpty() || container->isFinished()) + { + close(); + } + else + { + ConfirmPopup *p = new ConfirmPopup(this, tr("요리를 취소하시겠습니까?")); + p->showFullScreen(); + + connect(p, SIGNAL(accepted()), SLOT(close())); + } +} + +void MultiCookWindow::on_configButton_clicked() +{ + if (container->isEmpty() || container->isFinished()) + { + jumpConfig(); + } + else + { + ConfirmPopup *p = new ConfirmPopup(this, tr("요리를 취소하시겠습니까?")); + p->showFullScreen(); + + connect(p, SIGNAL(accepted()), SLOT(jumpConfig())); + } +} + +void MultiCookWindow::on_washButton_clicked() +{ + if (container->isEmpty() || container->isFinished()) + { + jumpConfig(); + } + else + { + ConfirmPopup *p = new ConfirmPopup(this, tr("요리를 취소하시겠습니까?")); + p->showFullScreen(); + + connect(p, SIGNAL(accepted()), SLOT(jumpWash())); + } +} + +void MultiCookWindow::on_deleteButton_clicked() +{ + trashClicked = true; +} + +void MultiCookWindow::on_helpButton_clicked() +{ + +} + +void MultiCookWindow::onEncoderLeft() +{ + MultiCook *c = Q_NULLPTR; + + if (lastClickedButton != -1) + { + QPushButton *b = buttons.at(lastClickedButton); + if (b == focusWidget()) + c = container->at(lastClickedButton); + } + + if (c) + c->decreaseTime(); + else + focusPreviousChild(); +} + +void MultiCookWindow::onEncoderRight() +{ + MultiCook *c = Q_NULLPTR; + + if (lastClickedButton != -1) + { + QPushButton *b = buttons.at(lastClickedButton); + if (b == focusWidget()) + c = container->at(lastClickedButton); + } + + if (c) + c->increaseTime(); + else + focusNextChild(); +} + +void MultiCookWindow::onEncoderClicked(QWidget *clicked) +{ + MultiCook *c = Q_NULLPTR; + + if (lastClickedButton != -1) + { + QPushButton *b = buttons.at(lastClickedButton); + if (b == focusWidget()) + c = container->at(lastClickedButton); + + lastClickedButton = -1; + } + + if (c) + c->setTime(); + else + { + QPushButton *b = qobject_cast(clicked); + if (b) + b->click(); + } +} + +void MultiCookWindow::on_selectButton_1_clicked() +{ + handleButtonClick(0); +} + +void MultiCookWindow::on_selectButton_2_clicked() +{ + handleButtonClick(1); +} + +void MultiCookWindow::on_selectButton_3_clicked() +{ + handleButtonClick(2); +} + +void MultiCookWindow::on_selectButton_4_clicked() +{ + handleButtonClick(3); +} + +void MultiCookWindow::on_selectButton_5_clicked() +{ + handleButtonClick(4); +} + +void MultiCookWindow::on_selectButton_6_clicked() +{ + handleButtonClick(5); +} + +void MultiCookWindow::on_selectButton_7_clicked() +{ + handleButtonClick(6); +} + +void MultiCookWindow::on_selectButton_8_clicked() +{ + handleButtonClick(7); +} + +void MultiCookWindow::on_selectButton_9_clicked() +{ + handleButtonClick(8); +} + +void MultiCookWindow::on_selectButton_10_clicked() +{ + handleButtonClick(9); +} + +void MultiCookWindow::on_cookButton_1_clicked() +{ + handleFavoriteButtonClick(0); +} + +void MultiCookWindow::on_cookButton_2_clicked() +{ + handleFavoriteButtonClick(1); +} + +void MultiCookWindow::on_cookButton_3_clicked() +{ + handleFavoriteButtonClick(2); +} + +void MultiCookWindow::on_cookButton_4_clicked() +{ + handleFavoriteButtonClick(3); +} + +void MultiCookWindow::on_cookButton_5_clicked() +{ + handleFavoriteButtonClick(4); +} + +void MultiCookWindow::on_cookButton_6_clicked() +{ + handleFavoriteButtonClick(5); +} + +void MultiCookWindow::on_cookButton_7_clicked() +{ + handleFavoriteButtonClick(6); +} + +void MultiCookWindow::on_cookButton_8_clicked() +{ + handleFavoriteButtonClick(7); +} + +void MultiCookWindow::on_cookButton_9_clicked() +{ + handleFavoriteButtonClick(8); +} + +void MultiCookWindow::on_cookButton_10_clicked() +{ + handleFavoriteButtonClick(9); +} + +void MultiCookWindow::on_cookButton_11_clicked() +{ + handleFavoriteButtonClick(10); +} + +void MultiCookWindow::on_cookButton_12_clicked() +{ + handleFavoriteButtonClick(11); +} diff --git a/app/gui/oven_control/multicookwindow.h b/app/gui/oven_control/multicookwindow.h new file mode 100644 index 0000000..9ab4152 --- /dev/null +++ b/app/gui/oven_control/multicookwindow.h @@ -0,0 +1,96 @@ +#ifndef MULTICOOKWINDOW_H +#define MULTICOOKWINDOW_H + +#include +#include + +#include "multicookview.h" +#include "multicookcontroller.h" + +namespace Ui { +class MultiCookWindow; +} + +class MultiCookWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MultiCookWindow(QWidget *parent = 0); + ~MultiCookWindow(); + +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + +private slots: + void updateView(); + void handleButtonClick(int button); + void handleFavoriteButtonClick(int button); + void selectCook(); + void onCookSelected(MultiCook *cook); + void showFavorites(); + void showClock(); + void addCook(int slot, MultiCook *cook); + void jumpConfig(); + void jumpWash(); + + void on_showPrevButton_clicked(); + void on_showNowButton_clicked(); + void on_showNextButton_clicked(); + void on_showFavoritesButton_clicked(); + + void on_backButton_clicked(); + void on_configButton_clicked(); + void on_washButton_clicked(); + void on_deleteButton_clicked(); + void on_helpButton_clicked(); + + void onEncoderLeft(); + void onEncoderRight(); + void onEncoderClicked(QWidget *clicked); + + void on_selectButton_1_clicked(); + void on_selectButton_2_clicked(); + void on_selectButton_3_clicked(); + void on_selectButton_4_clicked(); + void on_selectButton_5_clicked(); + void on_selectButton_6_clicked(); + void on_selectButton_7_clicked(); + void on_selectButton_8_clicked(); + void on_selectButton_9_clicked(); + void on_selectButton_10_clicked(); + + void on_cookButton_1_clicked(); + void on_cookButton_2_clicked(); + void on_cookButton_3_clicked(); + void on_cookButton_4_clicked(); + void on_cookButton_5_clicked(); + void on_cookButton_6_clicked(); + void on_cookButton_7_clicked(); + void on_cookButton_8_clicked(); + void on_cookButton_9_clicked(); + void on_cookButton_10_clicked(); + void on_cookButton_11_clicked(); + void on_cookButton_12_clicked(); + +private: + Ui::MultiCookWindow *ui; + + MultiCookContainer *container; + MultiCookController *controller; + + QList buttons; + QList cookButtons; + QList favorites; + QTimer updateViewTimer; + + int lastClickedButton; + int lastClickedCookButton; + bool trashClicked; + + Define::Mode mode; + QWidget *pushed = NULL; +}; + +#endif // MULTICOOKWINDOW_H diff --git a/app/gui/oven_control/multicookwindow.ui b/app/gui/oven_control/multicookwindow.ui new file mode 100644 index 0000000..68af0bf --- /dev/null +++ b/app/gui/oven_control/multicookwindow.ui @@ -0,0 +1,1283 @@ + + + MultiCookWindow + + + + 0 + 0 + 900 + 1600 + + + + MainWindow + + + #centralwidget { background-image: url(:/images/background/original.png); } +#bottomBar { background-image: url(:/images/bottom_bar/background.png); } + +QWidget { etch-disabled-text: 0; } +QPushButton { +background-position: center; +background-repeat: no-repeat; +border: none; +} + +QPushButton[style="select"] +{ background-image: url(:/images/button/154.png); } +QPushButton[style="select"]:pressed, +QPushButton[style="select"]:focus +{ background-image: url(:/images/button/154_ov.png); } + +QPushButton[style="favorite"] +{ background-image: url(:/images/button/288.png); } +QPushButton[style="favorite"]:pressed, +QPushButton[style="favorite"]:focus +{ background-image: url(:/images/button/288_ov.png); } + +QLabel[style="slotLabel"] { color: #C4C4C4; font-size: 24px; font-style: bold; } + + + + + + 0 + 426 + 900 + 1024 + + + + + + 366 + 366 + 251 + 292 + + + + + + + 440 + 520 + 85 + 24 + + + + :/images/animation/close_door_arrow.png + + + + + + + 0 + 426 + 900 + 1024 + + + + + + 366 + 366 + 251 + 292 + + + + + + + 440 + 520 + 85 + 24 + + + + :/images/animation/open_door_arrow.png + + + + + + + 0 + 0 + 900 + 1450 + + + + + + 0 + 1314 + 70 + 136 + + + + QPushButton +{ background-image: url(:/images/auto_button/prev_step.png); } +QPushButton:pressed, +QPushButton:focus +{ background-image: url(:/images/auto_button/prev_step_ov.png); } + + + + + + 830 + 1314 + 70 + 136 + + + + QPushButton +{ background-image: url(:/images/auto_button/next_step.png); } +QPushButton:pressed, +QPushButton:focus +{ background-image: url(:/images/auto_button/next_step_ov.png); } + + + + + + 70 + 1314 + 85 + 136 + + + + + -1 + 75 + true + + + + QPushButton +{ background-image: url(:/images/multi/button.png); font-size: 24px; font-weight: bold; } +QPushButton:pressed, +QPushButton:focus +{ background-image: url(:/images/multi/button_ov.png); } + + + + + + 160 + 1314 + 85 + 136 + + + + QPushButton +{ background-image: url(:/images/multi/button.png); } +QPushButton:pressed, +QPushButton:focus +{ background-image: url(:/images/multi/button_ov.png); } + + + + :/images/multi/icon_prime.png:/images/multi/icon_prime.png + + + + 50 + 57 + + + + + + + 215 + 554 + 685 + 760 + + + + + + + 200 + 1314 + 700 + 136 + + + + + 75 + true + + + + + + + 0 + 554 + 200 + 76 + + + + select + + + + + + 0 + 630 + 200 + 76 + + + + select + + + + + + 0 + 706 + 200 + 76 + + + + select + + + + + + 0 + 782 + 200 + 76 + + + + select + + + + + + 0 + 858 + 200 + 76 + + + + select + + + + + + 0 + 934 + 200 + 76 + + + + select + + + + + + 0 + 1010 + 200 + 76 + + + + select + + + + + + 0 + 1086 + 200 + 76 + + + + select + + + + + + 0 + 1162 + 200 + 76 + + + + select + + + + + + 0 + 1238 + 200 + 76 + + + + select + + + + + + 0 + 0 + 900 + 426 + + + + + #clockContainer { background-image: url(:/images/clock/background.png); } + + + + + 272 + 36 + 356 + 355 + + + + + + + 800 + 320 + 80 + 84 + + + + + + + 780 + 230 + 101 + 90 + + + + + + + 780 + 160 + 108 + 67 + + + + + + + 20 + 310 + 600 + 100 + + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + #progressContainer { background-image: url(:/images/clock/background.png); } + + + + true + + + + 0 + 0 + 900 + 88 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 13 + 75 + true + + + + 다중 요리 즐겨찾기 목록입니다 + + + Qt::AlignCenter + + + + + + 0 + 88 + 900 + 1 + + + + Qt::Horizontal + + + + + + 0 + 102 + 300 + 70 + + + + + 75 + true + + + + favorite + + + + + + 300 + 102 + 300 + 70 + + + + + 75 + true + + + + favorite + + + + + + 600 + 102 + 300 + 70 + + + + + 75 + true + + + + favorite + + + + + + 0 + 182 + 300 + 70 + + + + + 75 + true + + + + favorite + + + + + + 600 + 182 + 300 + 70 + + + + + 75 + true + + + + favorite + + + + + + 300 + 182 + 300 + 70 + + + + + 75 + true + + + + favorite + + + + + + 600 + 262 + 300 + 70 + + + + + 75 + true + + + + favorite + + + + + + 0 + 262 + 300 + 70 + + + + + 75 + true + + + + favorite + + + + + + 300 + 262 + 300 + 70 + + + + + 75 + true + + + + favorite + + + + + + 0 + 342 + 300 + 70 + + + + + 75 + true + + + + favorite + + + + + + 300 + 342 + 300 + 70 + + + + + 75 + true + + + + favorite + + + + + + 600 + 342 + 300 + 70 + + + + + 75 + true + + + + favorite + + + + + + + + 170 + 554 + 50 + 76 + + + + + -1 + + + + 01 + + + Qt::AlignCenter + + + slotLabel + + + + + + 170 + 630 + 50 + 76 + + + + + -1 + + + + 02 + + + Qt::AlignCenter + + + slotLabel + + + + + + 170 + 706 + 50 + 76 + + + + + -1 + + + + 03 + + + Qt::AlignCenter + + + slotLabel + + + + + + 170 + 782 + 50 + 76 + + + + + -1 + + + + 04 + + + Qt::AlignCenter + + + slotLabel + + + + + + 170 + 858 + 50 + 76 + + + + + -1 + + + + 05 + + + Qt::AlignCenter + + + slotLabel + + + + + + 170 + 934 + 50 + 76 + + + + + -1 + + + + 06 + + + Qt::AlignCenter + + + slotLabel + + + + + + 170 + 1010 + 50 + 76 + + + + + -1 + + + + 07 + + + Qt::AlignCenter + + + slotLabel + + + + + + 170 + 1086 + 50 + 76 + + + + + -1 + + + + 08 + + + Qt::AlignCenter + + + slotLabel + + + + + + 170 + 1162 + 50 + 76 + + + + + -1 + + + + 09 + + + Qt::AlignCenter + + + slotLabel + + + + + + 170 + 1238 + 50 + 76 + + + + + -1 + + + + 10 + + + Qt::AlignCenter + + + slotLabel + + + + + + 0 + 426 + 125 + 128 + + + + :/images/symbol/symbol_01.png + + + Qt::AlignCenter + + + + + + 750 + 426 + 150 + 128 + + + + QPushButton { background-image: url(:/images/button/100.png); } +QPushButton::pressed, QPushButton:focus { background-image: url(:/images/button/100_ov.png); } + + + + + + + :/images/auto_button/btn_icon_02.png:/images/auto_button/btn_icon_02.png + + + + 40 + 51 + + + + + + + 0 + 426 + 900 + 128 + + + + 1. 해당 조리 칸 버튼을 눌러 메뉴를 선택해주세요. +2. 메뉴가 선택되면, 해당 작업 시간이 적용됩니다. + + + 125 + + + slotLabel + + + label_6 + slotLabel_10 + slotLabel_9 + slotLabel_8 + slotLabel_7 + slotLabel_6 + slotLabel_5 + slotLabel_4 + slotLabel_3 + slotLabel_2 + slotLabel_1 + bar + showPrevButton + showNextButton + showNowButton + showFavoritesButton + view + selectButton_1 + selectButton_2 + selectButton_3 + selectButton_4 + selectButton_5 + selectButton_6 + selectButton_7 + selectButton_8 + selectButton_9 + selectButton_10 + upperStack + label + homeButton + + + + + 0 + 1450 + 900 + 150 + + + + + + 175 + 26 + 97 + 97 + + + + + 0 + 0 + + + + QPushButton { border-image: url(:/images/bottom_bar/back.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/back_ov.png); } + + + + + + + + + 401 + 26 + 97 + 97 + + + + + 0 + 0 + + + + QPushButton { border-image: url(:/images/bottom_bar/wash.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/wash_ov.png); } + + + + + + + + + 288 + 26 + 97 + 97 + + + + + 0 + 0 + + + + QPushButton { border-image: url(:/images/bottom_bar/config.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/config_ov.png); } + + + + + + + + + 627 + 26 + 97 + 97 + + + + + 0 + 0 + + + + QPushButton { border-image: url(:/images/bottom_bar/help.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/help_ov.png); } + + + + + + + + + 514 + 26 + 97 + 97 + + + + + 0 + 0 + + + + QPushButton { border-image: url(:/images/bottom_bar/006_sys_icon_19.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/006_sys_icon_19_ov.png); } + + + + + + + blockingArea + bottomBar + closeDoorAnimationArea + openDoorAnimationArea + + + + + Clock + QWidget +
clock.h
+ 1 +
+ + WashWarnIcon + QLabel +
washwarnicon.h
+
+ + DemoIcon + QLabel +
demoicon.h
+
+ + HalfEnergyIcon + QLabel +
halfenergyicon.h
+
+ + DigitalClock + QLabel +
digitalclock.h
+
+ + AnimatedImageBox + QLabel +
animatedimagebox.h
+
+ + MultiCookView + QWidget +
multicookview.h
+ 1 +
+ + MultiCookTimeBar + QWidget +
multicooktimebar.h
+ 1 +
+
+ + selectButton_1 + selectButton_2 + selectButton_3 + selectButton_4 + selectButton_5 + selectButton_6 + selectButton_7 + selectButton_8 + selectButton_9 + selectButton_10 + showPrevButton + showNowButton + showFavoritesButton + showNextButton + backButton + configButton + washButton + deleteButton + helpButton + cookButton_1 + cookButton_2 + cookButton_3 + cookButton_4 + cookButton_5 + cookButton_6 + cookButton_7 + cookButton_8 + cookButton_9 + cookButton_10 + cookButton_11 + cookButton_12 + + + + + +
diff --git a/app/gui/oven_control/multimanualcook.cpp b/app/gui/oven_control/multimanualcook.cpp new file mode 100644 index 0000000..99de1ac --- /dev/null +++ b/app/gui/oven_control/multimanualcook.cpp @@ -0,0 +1,247 @@ +#include "multimanualcook.h" + +#include "oven.h" + +MultiManualCook::MultiManualCook(QObject *parent) : MultiCook(parent) +{ + mode_ = Define::InvalidMode; + temp = 30; + hum = 0; + time = 0; + modifiedTime = -1; + state = Idle; + + checkTimer.setInterval(100); + connect(&checkTimer, SIGNAL(timeout()), SLOT(check())); +} + +QString MultiManualCook::name() +{ + QString n("%1, %2, %3"); + QString m; + switch (mode_) + { + case Define::InvalidMode: + m = "Invalid"; + break; + case Define::SteamMode: + m = "Steam"; + break; + case Define::CombiMode: + m = "Combi"; + break; + case Define::DryMode: + m = "Dry"; + break; + } + + return n.arg(m).arg(temp).arg(hum); +} + +Define::Mode MultiManualCook::mode() +{ + return mode_; +} + +int MultiManualCook::temperature() +{ + return temp; +} + +int MultiManualCook::humidity() +{ + return hum; +} + +int MultiManualCook::remainingTime() +{ + if (modifiedTime != -1) + return modifiedTime; + + switch (state) + { + case Idle: + return time; + case Running: + return time -= elapsed.restart(); + case Paused: + return time; + case Finished: + return 0; + } + + return 0; +} + +void MultiManualCook::increaseTime() +{ + if (state == Finished) + return; + + if (modifiedTime == -1) + modifiedTime = remainingTime() + 60 * 1000; + else + modifiedTime += 60 * 1000; +} + +void MultiManualCook::decreaseTime() +{ + if (state == Finished) + return; + + if (modifiedTime == -1) + modifiedTime = remainingTime() - 60 * 1000; + else + modifiedTime -= 60 * 1000; + + if (modifiedTime < 60 * 1000) + modifiedTime = 60 * 1000; +} + +void MultiManualCook::setTime() +{ + if (state == Finished) + return; + + if (modifiedTime == -1) + return; + + time = modifiedTime; + elapsed.start(); + modifiedTime = -1; + + qDebug() << QTime::currentTime() << "setTime to" << time; +} + +void MultiManualCook::start() +{ + state = Running; + elapsed.start(); + decreasedTime.start(); + + checkTimer.start(); +} + +void MultiManualCook::stop() +{ + state = Finished; + checkTimer.stop(); +} + +void MultiManualCook::pause() +{ + if (state != Running) + return; + + state = Paused; + time -= elapsed.elapsed(); + decreasedTime.pause(); + if (increasedTime.isValid()) + increasedTime.pause(); + + checkTimer.stop(); +} + +void MultiManualCook::resume() +{ + if (state != Paused) + return; + + state = Running; + time += 30 * 1000; + elapsed.start(); + decreasedTime.resume(); + if (increasedTime.isValid()) + increasedTime.resume(); + + checkTimer.start(); +} + +MultiCook *MultiManualCook::clone(QObject *parent) +{ + MultiManualCook *c = new MultiManualCook(parent); + c->mode_ = mode_; + c->temp = temp; + c->hum = hum; + c->time = time; + + return (MultiCook *) c; +} + +bool MultiManualCook::equals(MultiCook *other) +{ + MultiManualCook *o = qobject_cast(other); + if (o == Q_NULLPTR) + return false; + + if (o->mode_ != mode_) + return false; + + if (o->temp != temp) + return false; + + if (o->hum != hum) + return false; + + if (o->time != time) + return false; + + return true; +} + +void MultiManualCook::setMode(Define::Mode mode) +{ + mode_ = mode; +} + +void MultiManualCook::setTemperature(int temperature) +{ + temp = temperature; + checkTimer.start(); +} + +void MultiManualCook::setHumidity(int humidity) +{ + hum = humidity; +} + +void MultiManualCook::setTime(int secs) +{ + time = secs * 1000; +} + +void MultiManualCook::check() +{ + if (state != Running) + return; + + int dt = Oven::getInstance()->currentTemp() - temp; + + // checking under temperature + if ((remainingTime() < 10 * 60 * 1000 && increasedTime.isNull()) + || (increasedTime.isValid() && increasedTime.elapsed() > 3 * 60 * 1000)) + { + increasedTime.start(); + if (dt < -20) + { + int t = remainingTime(); + time = remainingTime() * 1.1; + qDebug() << QTime::currentTime() << "Increase from" << t << "to" << remainingTime(); + } + } + + // checking over temperature + if (decreasedTime.elapsed() > 2 * 60 * 1000) + { + decreasedTime.start(); + if (dt > 20) + { + int t = remainingTime(); + time = remainingTime() * 0.8; + qDebug() << QTime::currentTime() << "Reduce from" << t << "to" << remainingTime(); + } + } + + if (remainingTime() <= 0) + stop(); +} diff --git a/app/gui/oven_control/multimanualcook.h b/app/gui/oven_control/multimanualcook.h new file mode 100644 index 0000000..34794e3 --- /dev/null +++ b/app/gui/oven_control/multimanualcook.h @@ -0,0 +1,61 @@ +#ifndef MULTIMANUALCOOK_H +#define MULTIMANUALCOOK_H + +#include "multicook.h" +#include "interruptibletime.h" + +class MultiManualCook : public MultiCook +{ + Q_OBJECT +public: + explicit MultiManualCook(QObject *parent = 0); + + virtual QString name(); + virtual Define::Mode mode(); + virtual int temperature(); + virtual int humidity(); + virtual int remainingTime(); + + virtual void increaseTime(); + virtual void decreaseTime(); + virtual void setTime(); + + virtual void start(); + virtual void stop(); + virtual void pause(); + virtual void resume(); + + virtual MultiCook *clone(QObject *parent); + virtual bool equals(MultiCook *other); + + void setMode(Define::Mode mode); + void setTemperature(int temperature); + void setHumidity(int humidity); + void setTime(int secs); + +signals: + +public slots: + +private: + Define::Mode mode_; + int temp; + int hum; + int time; + int modifiedTime; + + QTimer checkTimer; + QTime elapsed; + + enum State { + Idle, Running, Paused, Finished + } state; + + InterruptibleTime decreasedTime; + InterruptibleTime increasedTime; + +private slots: + void check(); +}; + +#endif // MULTIMANUALCOOK_H diff --git a/app/gui/oven_control/oven_control.pro b/app/gui/oven_control/oven_control.pro index 3b28813..283a3dd 100644 --- a/app/gui/oven_control/oven_control.pro +++ b/app/gui/oven_control/oven_control.pro @@ -122,14 +122,28 @@ SOURCES += main.cpp\ autocookselectionpopup.cpp \ autocookcheckwindow.cpp \ autocookcheckconfigwindow.cpp \ - programmedcookpanelbutton.cpp \ + #programmedcookpanelbutton.cpp \ configdemomodedlg.cpp \ demoicon.cpp \ halfenergyicon.cpp \ notipopupdlg.cpp \ configsteamwashdlg.cpp \ digitalclock.cpp \ - manualviewerdlg.cpp + manualviewerdlg.cpp \ + multicookwindow.cpp \ + multicookview.cpp \ + multicook.cpp \ + multicookcontainer.cpp \ + multicookcontroller.cpp \ + multicooktimebar.cpp \ + multimanualcook.cpp \ + interruptibletime.cpp \ + multiautocook.cpp \ + multicookrecorder.cpp \ + multicookselectionwindow.cpp \ + multicookmanualwindow.cpp \ + multicookautowindow.cpp \ + multicookbook.cpp HEADERS += mainwindow.h \ @@ -242,14 +256,28 @@ HEADERS += mainwindow.h \ autocookselectionpopup.h \ autocookcheckwindow.h \ autocookcheckconfigwindow.h \ - programmedcookpanelbutton.h \ + #programmedcookpanelbutton.h \ configdemomodedlg.h \ demoicon.h \ halfenergyicon.h \ notipopupdlg.h \ configsteamwashdlg.h \ digitalclock.h \ - manualviewerdlg.h + manualviewerdlg.h \ + multicookwindow.h \ + multicookview.h \ + multicook.h \ + multicookcontainer.h \ + multicookcontroller.h \ + multicooktimebar.h \ + multimanualcook.h \ + interruptibletime.h \ + multiautocook.h \ + multicookrecorder.h \ + multicookselectionwindow.h \ + multicookmanualwindow.h \ + multicookautowindow.h \ + multicookbook.h FORMS += mainwindow.ui \ manualcookwindow.ui \ @@ -327,11 +355,15 @@ FORMS += mainwindow.ui \ autocookselectionpopup.ui \ autocookcheckwindow.ui \ autocookcheckconfigwindow.ui \ - programmedcookpanelbutton.ui \ + #programmedcookpanelbutton.ui \ configdemomodedlg.ui \ notipopupdlg.ui \ configsteamwashdlg.ui \ - manualviewerdlg.ui + manualviewerdlg.ui \ + multicookwindow.ui \ + multicookselectionwindow.ui \ + multicookmanualwindow.ui \ + multicookautowindow.ui RESOURCES += \ resources.qrc diff --git a/app/gui/oven_control/programmingselectionwindow.cpp b/app/gui/oven_control/programmingselectionwindow.cpp index 1a77962..d722ba8 100644 --- a/app/gui/oven_control/programmingselectionwindow.cpp +++ b/app/gui/oven_control/programmingselectionwindow.cpp @@ -15,7 +15,7 @@ ProgrammingSelectionWindow::ProgrammingSelectionWindow(QWidget *parent) : { ui->setupUi(this); -// ui->clockContainer->setParent(ui->upperStack); + ui->clockContainer->setParent(ui->upperStack); setAttribute(Qt::WA_DeleteOnClose); setFocus(); diff --git a/app/gui/oven_control/programmingselectionwindow.ui b/app/gui/oven_control/programmingselectionwindow.ui index bdecc44..a14605c 100644 --- a/app/gui/oven_control/programmingselectionwindow.ui +++ b/app/gui/oven_control/programmingselectionwindow.ui @@ -643,72 +643,6 @@ QPushButton:disabled { background-image: url(:/images/cook_type/additional_hide. type - - - - 0 - 0 - 900 - 426 - - - - #clockContainer { background-image: url(:/images/clock/background.png); } - - - - - 272 - 36 - 356 - 355 - - - - - - - 800 - 320 - 80 - 84 - - - - - - - 780 - 230 - 101 - 90 - - - - - - - 780 - 160 - 108 - 67 - - - - - - - 20 - 310 - 600 - 100 - - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - false @@ -739,6 +673,78 @@ QPushButton:disabled { background-image: url(:/images/cook_type/bread_hide.png); type + + + + 0 + 0 + 900 + 426 + + + + 0 + + + + #clockContainer { background-image: url(:/images/clock/background.png); } + + + + + 272 + 36 + 356 + 355 + + + + + + + 800 + 320 + 80 + 84 + + + + + + + 780 + 230 + 101 + 90 + + + + + + + 780 + 160 + 108 + 67 + + + + + + + 20 + 310 + 600 + 100 + + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + diff --git a/app/gui/oven_control/stringer.cpp b/app/gui/oven_control/stringer.cpp index e952d18..d43fef4 100644 --- a/app/gui/oven_control/stringer.cpp +++ b/app/gui/oven_control/stringer.cpp @@ -234,3 +234,17 @@ QString Stringer::dateTime(const QDateTime &dateTime, DateTimeType type) return dateTime.toString("yy-MM-dd\nHH:mm"); } } + +QString Stringer::time(int msecs) +{ + int t = qCeil(msecs / 1000.0); + + int h = t / (60*60); + int m = (t/60) % 60; + int s = t % 60; + + return QString("%1:%2:%3") + .arg(h, 2, 10, QLatin1Char('0')) + .arg(m, 2, 10, QLatin1Char('0')) + .arg(s, 2, 10, QLatin1Char('0')); +} diff --git a/app/gui/oven_control/stringer.h b/app/gui/oven_control/stringer.h index f4abc69..af51716 100644 --- a/app/gui/oven_control/stringer.h +++ b/app/gui/oven_control/stringer.h @@ -27,6 +27,7 @@ QString temperature(int current, int target, QString style); QString unusedTemperature(); QString unusedTemperature(QString style); QString dateTime(const QDateTime &dateTime, DateTimeType type = TwoLine); +QString time(int msecs); }