diff --git a/app/gui/oven_control/autocookwindow.cpp b/app/gui/oven_control/autocookwindow.cpp index cb2c026..ffd8d30 100644 --- a/app/gui/oven_control/autocookwindow.cpp +++ b/app/gui/oven_control/autocookwindow.cpp @@ -46,8 +46,6 @@ AutoCookWindow::~AutoCookWindow() void AutoCookWindow::setupUi() { - bulletPixmap.load(":/images/symbol/step_bullet.png"); - selectedBulletPixmap.load(":/images/symbol/selected_step_bullet.png"); steamModeIcon.load(":/images/cook_mode/small_steam.png"); dryModeIcon.load(":/images/cook_mode/small_dryheat.png"); combiModeIcon.load(":/images/cook_mode/small_combi.png"); @@ -55,15 +53,7 @@ void AutoCookWindow::setupUi() ui->cookTypeIcon->setPixmap(Define::icon(cook.type)); ui->selectCookButton->setText(cook.name); - int offsetX = (900 - (cook.steps.size() * 19 * 2 - 19)) / 2; - int offsetY = 1150; - for (int idx = 0; idx < cook.steps.size(); idx++) - { - QLabel *bullet = new QLabel(this); - bullet->setPixmap(bulletPixmap); - bullet->setGeometry(offsetX + 19 * 2 * idx, offsetY, 19, 19); - bullets.append(bullet); - } + ui->stepIndicator->setMaximum(cook.steps.size() - 1); ui->cookStepAnimation->start(300); @@ -333,15 +323,7 @@ void AutoCookWindow::updateView() if (selectedStepIndex != lastViewStepIndex) { lastViewStepIndex = selectedStepIndex; - - for (int idx = 0; idx < bullets.length(); idx++) - { - QLabel *bullet = bullets.at(idx); - if (idx == selectedStepIndex) - bullet->setPixmap(selectedBulletPixmap); - else - bullet->setPixmap(bulletPixmap); - } + ui->stepIndicator->setCurrentIndex(selectedStepIndex); } CookStep showingStep = autocook.cook.steps[selectedStepIndex]; @@ -566,8 +548,20 @@ void AutoCookWindow::startProcess(int process) CookStep &step = autocook.cook.steps[autocook.cook.steps.size() - 1]; + CookStep newStep = step; + newStep.type = Define::MakeCrispy; + newStep.humidity = 0; + newStep.temp += 10; + newStep.time = 0; + newStep.humidification = 0; + newStep.dehumidification = 0; + autocook.cook.steps.append(newStep); + autocook.currentStepIndex = autocook.cook.steps.size() - 1; + ui->stepIndicator->setMaximum(autocook.cook.steps.size() - 1); + returnToCurrentStep(); + Oven *oven = Oven::getInstance(); - oven->setHumidity(step.humidity); + oven->setHumidity(0); oven->setTemp(step.temp + 10); oven->startCooking(); @@ -601,6 +595,7 @@ void AutoCookWindow::checkProcess() { oven->stopCooking(); checkProcessTimer.stop(); + processSelected = false; } break; } @@ -683,7 +678,7 @@ void AutoCookWindow::on_showPrevStepButton_clicked() void AutoCookWindow::on_showNextStepButton_clicked() { - if (selectedStepIndex + 1 < cook.steps.size()) + if (selectedStepIndex + 1 < autocook.cook.steps.size()) { selectedStepIndex++; updateView(); diff --git a/app/gui/oven_control/autocookwindow.h b/app/gui/oven_control/autocookwindow.h index a7d0f28..492b703 100644 --- a/app/gui/oven_control/autocookwindow.h +++ b/app/gui/oven_control/autocookwindow.h @@ -27,10 +27,6 @@ private: QTimer checkCookTimer; - QPixmap bulletPixmap; - QPixmap selectedBulletPixmap; - QList bullets; - QPixmap steamModeIcon; QPixmap dryModeIcon; QPixmap combiModeIcon; diff --git a/app/gui/oven_control/autocookwindow.ui b/app/gui/oven_control/autocookwindow.ui index 6eaab6d..0362416 100644 --- a/app/gui/oven_control/autocookwindow.ui +++ b/app/gui/oven_control/autocookwindow.ui @@ -1304,6 +1304,16 @@ QPushButton:pressed { border-image: url(:/images/button/152_ov.png); } + + + + 100 + 1130 + 700 + 50 + + + openDoorAnimation closeDoorAnimation upperStack @@ -1336,10 +1346,17 @@ QPushButton:pressed { border-image: url(:/images/button/152_ov.png); } openDoorArrow heatGaugeButton processContainer + stepIndicator + BulletIndicator + QWidget +
bulletindicator.h
+ 1 +
+ Clock QWidget
clock.h
diff --git a/app/gui/oven_control/bulletindicator.cpp b/app/gui/oven_control/bulletindicator.cpp new file mode 100644 index 0000000..115cd2f --- /dev/null +++ b/app/gui/oven_control/bulletindicator.cpp @@ -0,0 +1,142 @@ +#include "bulletindicator.h" + +BulletIndicator::BulletIndicator(QWidget *parent) : QWidget(parent) +{ + max = 1; + cur = 0; + bulletPixmap.load(":/images/symbol/step_bullet.png"); + currentBulletPixmap.load(":/images/symbol/selected_step_bullet.png"); + padding = qMin(bulletPixmap.width(), currentBulletPixmap.width()); + + QRect defaultGeometry; + defaultGeometry.setSize(bulletPixmap.size()); + + QLabel *bullet; + + bullet = new QLabel(this); + bullet->setPixmap(currentBulletPixmap); + bullet->setGeometry(defaultGeometry); + bullets.append(bullet); + + bullet = new QLabel(this); + bullet->setPixmap(bulletPixmap); + bullet->setGeometry(defaultGeometry); + bullets.append(bullet); + + updatePosition(); +} + +void BulletIndicator::setBulletPixmap(QPixmap &pixmap) +{ + bulletPixmap = pixmap; + + for (int i = 0; i <= max; i++) + if (i != cur) + bullets.at(i)->setPixmap(pixmap); + + padding = qMin(pixmap.width(), padding); + + updatePosition(); +} + +void BulletIndicator::setCurrentBulletPixmap(QPixmap &pixmap) +{ + currentBulletPixmap = pixmap; + + bullets.at(cur)->setPixmap(pixmap); + + padding = qMin(pixmap.width(), padding); + + updatePosition(); +} + +void BulletIndicator::setCurrentIndex(int index) +{ + if (index == cur || index < 0 || index > max) + return; + + bullets.at(cur)->setPixmap(bulletPixmap); + bullets.at(index)->setPixmap(currentBulletPixmap); + + cur = index; + + updatePosition(); +} + +void BulletIndicator::setMaximum(int maximum) +{ + if (maximum == max || maximum < 1) + return; + + if (bullets.size() <= maximum) + { + QRect defaultGeometry; + defaultGeometry.setSize(bulletPixmap.size()); + for (int i = bullets.size(); i <= maximum; i++) + { + QLabel *l = new QLabel(this); + l->setPixmap(bulletPixmap); + l->setGeometry(defaultGeometry); + bullets.append(l); + } + } + + if (maximum > max) + { + for (int i = max + 1; i <= maximum; i++) + { + QLabel *l = bullets.at(i); + if (l->isHidden()) + l->show(); + } + } + else if (maximum < max) + { + for (int i = maximum + 1; i <= max; i++) + { + QLabel *l = bullets.at(i); + if (l->isVisible()) + l->hide(); + } + } + + max = maximum; + + if (maximum < cur) + setCurrentIndex(maximum); + else + updatePosition(); +} + +void BulletIndicator::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + + updatePosition(); +} + +void BulletIndicator::updatePosition() +{ + int bulletWidth = bulletPixmap.width(); + int bulletHeight = bulletPixmap.height(); + int currentBulletWidth = currentBulletPixmap.width(); + int currentBulletHeight = currentBulletPixmap.height(); + + int x = (width() - ((bulletWidth + padding) * max + currentBulletWidth)) / 2; + int bulletY = (height() - bulletHeight) / 2; + int currentBulletY = (height() - currentBulletHeight) / 2; + + for (int i = 0; i <= max; i++) + { + if (i == cur) + { + bullets.at(i)->setGeometry(x, currentBulletY, currentBulletWidth, currentBulletHeight); + x += currentBulletWidth + padding; + } + else + { + bullets.at(i)->setGeometry(x, bulletY, bulletWidth, bulletHeight); + x += bulletWidth + padding; + } + } +} diff --git a/app/gui/oven_control/bulletindicator.h b/app/gui/oven_control/bulletindicator.h new file mode 100644 index 0000000..462785c --- /dev/null +++ b/app/gui/oven_control/bulletindicator.h @@ -0,0 +1,41 @@ +#ifndef BULLETINDICATOR_H +#define BULLETINDICATOR_H + +#include +#include + +class BulletIndicator : public QWidget +{ + Q_OBJECT +public: + explicit BulletIndicator(QWidget *parent = 0); + + void setBulletPixmap(QPixmap &pixmap); + void setCurrentBulletPixmap(QPixmap &pixmap); + + int maximum() { return max; } + int currentIndex() { return cur; } + +signals: + +public slots: + void setCurrentIndex(int index); + void setMaximum(int maximum); + +protected: + void resizeEvent(QResizeEvent *event); + +private: + int max; + int cur; + + int padding; + QPixmap bulletPixmap; + QPixmap currentBulletPixmap; + + QList bullets; + + void updatePosition(); +}; + +#endif // BULLETINDICATOR_H diff --git a/app/gui/oven_control/oven_control.pro b/app/gui/oven_control/oven_control.pro index 8491f70..20dfbc5 100644 --- a/app/gui/oven_control/oven_control.pro +++ b/app/gui/oven_control/oven_control.pro @@ -60,7 +60,8 @@ SOURCES += main.cpp\ operationtimeparts.cpp \ realtimemain.cpp \ realtimepartswindow.cpp \ - realtimesensorwindow.cpp + realtimesensorwindow.cpp \ + bulletindicator.cpp HEADERS += mainwindow.h \ cook.h \ @@ -109,7 +110,8 @@ HEADERS += mainwindow.h \ operationtimeparts.h \ realtimemain.h \ realtimepartswindow.h \ - realtimesensorwindow.h + realtimesensorwindow.h \ + bulletindicator.h FORMS += mainwindow.ui \ manualcookwindow.ui \