diff --git a/app/gui/oven_control/confirmpopup.cpp b/app/gui/oven_control/confirmpopup.cpp index 5c4f4c8..5b8f513 100644 --- a/app/gui/oven_control/confirmpopup.cpp +++ b/app/gui/oven_control/confirmpopup.cpp @@ -1,6 +1,8 @@ #include "confirmpopup.h" #include "ui_confirmpopup.h" +#include + #include "soundplayer.h" ConfirmPopup::ConfirmPopup(QWidget *parent, QString text) : @@ -12,6 +14,8 @@ ConfirmPopup::ConfirmPopup(QWidget *parent, QString text) : foreach (QPushButton *button, findChildren()) connect(button, &QPushButton::pressed, SoundPlayer::playClick); + + setFocus(); } ConfirmPopup::~ConfirmPopup() @@ -19,6 +23,41 @@ ConfirmPopup::~ConfirmPopup() delete ui; } +void ConfirmPopup::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + pushed = focusWidget(); + break; + case 0x01000032: // Turn right + onEncoderRight(); + break; + } +} + +void ConfirmPopup::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + if (focusWidget() == pushed) + onEncoderClicked(pushed); + + pushed = NULL; + break; + case 0x01000032: // Turn right + onEncoderRight(); + break; + } +} + void ConfirmPopup::on_okButton_clicked() { deleteLater(); @@ -30,3 +69,28 @@ void ConfirmPopup::on_cancelButton_clicked() deleteLater(); emit rejected(); } + +void ConfirmPopup::onEncoderLeft() +{ + QWidget *focused = focusWidget(); + if (focused == this || focused == ui->okButton) + ui->cancelButton->setFocus(); + else + focusPreviousChild(); +} + +void ConfirmPopup::onEncoderRight() +{ + QWidget *focused = focusWidget(); + if (focused == this || focused == ui->cancelButton) + ui->okButton->setFocus(); + else + focusNextChild(); +} + +void ConfirmPopup::onEncoderClicked(QWidget *clicked) +{ + QPushButton *b = qobject_cast(clicked); + if (b) + b->click(); +} diff --git a/app/gui/oven_control/confirmpopup.h b/app/gui/oven_control/confirmpopup.h index 92aee5e..059f8ee 100644 --- a/app/gui/oven_control/confirmpopup.h +++ b/app/gui/oven_control/confirmpopup.h @@ -19,6 +19,10 @@ public: explicit ConfirmPopup(QWidget *parent, QString text); ~ConfirmPopup(); +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + private slots: void on_okButton_clicked(); @@ -26,6 +30,12 @@ private slots: private: Ui::ConfirmPopup *ui; + + QWidget *pushed = NULL; + + void onEncoderLeft(); + void onEncoderRight(); + void onEncoderClicked(QWidget *clicked); }; #endif // CONFIRMPOPUP_H diff --git a/app/gui/oven_control/cooldownpopup.cpp b/app/gui/oven_control/cooldownpopup.cpp index 3ef86a1..b08ca7a 100644 --- a/app/gui/oven_control/cooldownpopup.cpp +++ b/app/gui/oven_control/cooldownpopup.cpp @@ -1,6 +1,8 @@ #include "cooldownpopup.h" #include "ui_cooldownpopup.h" +#include + #include "soundplayer.h" #include "stringer.h" @@ -57,6 +59,14 @@ CooldownPopup::CooldownPopup(QWidget *parent, Oven *oven) : foreach (QPushButton *button, findChildren()) connect(button, &QPushButton::pressed, SoundPlayer::playClick); + + focusTempButtonTimer.setSingleShot(true); + focusTempButtonTimer.setInterval(3000); + connect(&focusTempButtonTimer, SIGNAL(timeout()), SLOT(focusTempButton())); + + connect(ui->tempSlider, SIGNAL(sliderMoved(int)), &focusTempButtonTimer, SLOT(start())); + + ui->background->setFocus(); } CooldownPopup::~CooldownPopup() @@ -64,6 +74,41 @@ CooldownPopup::~CooldownPopup() delete ui; } +void CooldownPopup::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + pushed = focusWidget(); + break; + case 0x01000032: // Turn right + onEncoderRight(); + break; + } +} + +void CooldownPopup::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + if (focusWidget() == pushed) + onEncoderClicked(pushed); + + pushed = NULL; + break; + case 0x01000032: // Turn right + onEncoderRight(); + break; + } +} + void CooldownPopup::start() { started = true; @@ -95,10 +140,8 @@ void CooldownPopup::updateView() int temp; if (showingCurrentTemp) temp = oven->currentTemp(); - else if (ui->tempSlider->isSliderDown()) - temp = ui->tempSlider->sliderPosition(); else - temp = ui->tempSlider->value(); + temp = ui->tempSlider->sliderPosition(); ui->tempCurrentLabel->setText(Stringer::temperature(temp, Stringer::fontSize14)); @@ -129,11 +172,7 @@ void CooldownPopup::updateView() if (lastDisplayedHumidification != oven->humidification()) { lastDisplayedHumidification = oven->humidification(); - - if (oven->humidification()) - ui->humidificationButton->setStyleSheet("background-image: url(:/images/cooldown/side_nozzle_ov.png);"); - else - ui->humidificationButton->setStyleSheet("background-image: url(:/images/cooldown/side_nozzle.png);"); + ui->humidificationButton->setChecked(oven->humidification()); } if (started && !oven->door()) @@ -227,3 +266,50 @@ void CooldownPopup::on_humidificationButton_clicked() else oven->startHumidification(); } + +void CooldownPopup::on_tempButton_clicked() +{ + ui->tempSlider->setFocus(); + focusTempButtonTimer.start(); +} + +void CooldownPopup::focusTempButton() +{ + if (focusWidget() == ui->tempSlider) + ui->tempButton->setFocus(); +} + +void CooldownPopup::onEncoderLeft() +{ + QWidget *focused = focusWidget(); + if (focused == ui->background) + ui->humidificationButton->setFocus(); + else + focusPreviousChild(); +} + +void CooldownPopup::onEncoderRight() +{ + if (focusWidget() == ui->humidificationButton) + ui->background->setFocus(); + else + focusNextChild(); +} + +void CooldownPopup::onEncoderClicked(QWidget *clicked) +{ + if (clicked == ui->background) + close(); + else if (clicked->inherits("QPushButton")) + { + QPushButton *b = qobject_cast(clicked); + if (b) + b->click(); + } + else if (clicked->inherits("Slider")) + { + Slider *slider = qobject_cast(clicked); + if (slider == ui->tempSlider) + ui->tempButton->setFocus(); + } +} diff --git a/app/gui/oven_control/cooldownpopup.h b/app/gui/oven_control/cooldownpopup.h index 75eddcc..01ce4e9 100644 --- a/app/gui/oven_control/cooldownpopup.h +++ b/app/gui/oven_control/cooldownpopup.h @@ -18,6 +18,10 @@ public: explicit CooldownPopup(QWidget *parent = 0, Oven *oven = 0); ~CooldownPopup(); +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + private slots: void start(); void stop(); @@ -39,6 +43,10 @@ private slots: void on_humidificationButton_clicked(); + void on_tempButton_clicked(); + + void focusTempButton(); + private: Ui::CooldownPopup *ui; Oven *oven; @@ -56,6 +64,13 @@ private: int lastDisplayedFanLevel; bool lastDisplayedHumidification; + + QTimer focusTempButtonTimer; + QWidget *pushed = NULL; + + void onEncoderLeft(); + void onEncoderRight(); + void onEncoderClicked(QWidget *clicked); }; #endif // COOLDOWNPOPUP_H diff --git a/app/gui/oven_control/cooldownpopup.ui b/app/gui/oven_control/cooldownpopup.ui index cecf6bc..8672879 100644 --- a/app/gui/oven_control/cooldownpopup.ui +++ b/app/gui/oven_control/cooldownpopup.ui @@ -14,6 +14,7 @@ #closeButton { border: none; } #closeButton_2 { border: none; } #background { background-image: url(:/images/background/popup/373.png); } +#background:focus { border: 4px solid gray; } QPushButton { background-position: center; @@ -85,6 +86,9 @@ height: 33px; 373 + + Qt::TabFocus + @@ -96,7 +100,7 @@ height: 33px; QPushButton { image: url(:/images/slider_icon/cooldown.png); } -QPushButton::pressed { image: url(:/images/slider_icon/cooldown_ov.png); } +QPushButton::pressed, QPushButton:focus { image: url(:/images/slider_icon/cooldown_ov.png); } @@ -116,7 +120,7 @@ QPushButton::pressed { image: url(:/images/slider_icon/cooldown_ov.png); } QPushButton { background-image: url(:/images/cooldown/run.png); } -QPushButton:pressed { background-image: url(:/images/cooldown/run_ov.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cooldown/run_ov.png); } @@ -149,11 +153,15 @@ QPushButton:pressed { background-image: url(:/images/cooldown/run_ov.png); } QPushButton { background-image: url(:/images/cooldown/side_nozzle.png); } -QPushButton:pressed { background-image: url(:/images/cooldown/side_nozzle_ov.png); } +QPushButton:checked { background-image: url(:/images/cooldown/side_nozzle_ov.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cooldown/side_nozzle_ov.png); } + + true + diff --git a/app/gui/oven_control/coretempsettingpopup.cpp b/app/gui/oven_control/coretempsettingpopup.cpp index 1b4558d..e6848cc 100644 --- a/app/gui/oven_control/coretempsettingpopup.cpp +++ b/app/gui/oven_control/coretempsettingpopup.cpp @@ -1,6 +1,8 @@ #include "coretempsettingpopup.h" #include "ui_coretempsettingpopup.h" +#include + #include "config.h" #include "soundplayer.h" #include "stringer.h" @@ -77,6 +79,14 @@ CoreTempSettingPopup::CoreTempSettingPopup(QWidget *parent) : connect(button, &QPushButton::pressed, SoundPlayer::playClick); updateView(); + + ui->background->setFocus(); + + focusCoreTempButtonTimer.setSingleShot(true); + focusCoreTempButtonTimer.setInterval(3000); + connect(&focusCoreTempButtonTimer, SIGNAL(timeout()), SLOT(focusCoreTempButton())); + + connect(ui->coreTempSlider, SIGNAL(sliderMoved(int)), &focusCoreTempButtonTimer, SLOT(start())); } CoreTempSettingPopup::~CoreTempSettingPopup() @@ -84,6 +94,90 @@ CoreTempSettingPopup::~CoreTempSettingPopup() delete ui; } +void CoreTempSettingPopup::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + pushed = focusWidget(); + break; + case 0x01000032: // Turn right + onEncoderRight(); + break; + } +} + +void CoreTempSettingPopup::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + if (focusWidget() == pushed) + onEncoderClicked(pushed); + + pushed = NULL; + break; + case 0x01000032: // Turn right + onEncoderRight(); + break; + } +} + +void CoreTempSettingPopup::onEncoderLeft() +{ + QWidget *focused = focusWidget(); + if (focused == ui->background) + ui->applyButton->setFocus(); + else if (focused->inherits("QPushButton")) + focusPreviousChild(); +} + +void CoreTempSettingPopup::onEncoderRight() +{ + QWidget *focused = focusWidget(); + if (focused == ui->applyButton) + ui->background->setFocus(); + else if (focused == ui->background || focused->inherits("QPushButton")) + focusNextChild(); +} + +void CoreTempSettingPopup::onEncoderClicked(QWidget *clicked) +{ + QWidget *focused = clicked; + if (focused == ui->background) + close(); + else if (focused->inherits("QPushButton")) + { + QPushButton *pb = qobject_cast(focused); + if (pb) + pb->click(); + } + else if (focused->inherits("Slider")) + { + Slider *slider = qobject_cast(focused); + if (slider) + { + if (slider->value() != slider->sliderPosition()) + slider->setValue(slider->sliderPosition()); + + if (slider == ui->coreTempSlider) + ui->coreTempButton->setFocus(); + } + } +} + +void CoreTempSettingPopup::focusCoreTempButton() +{ + if (focusWidget() == ui->coreTempSlider) + ui->coreTempButton->setFocus(); +} + void CoreTempSettingPopup::updateView() { int coreTemp = ui->coreTempSlider->sliderPosition(); @@ -117,3 +211,9 @@ void CoreTempSettingPopup::on_applyButton_clicked() oven->setInterTempEnabled(true); close(); } + +void CoreTempSettingPopup::on_coreTempButton_clicked() +{ + ui->coreTempSlider->setFocus(); + focusCoreTempButtonTimer.start(); +} diff --git a/app/gui/oven_control/coretempsettingpopup.h b/app/gui/oven_control/coretempsettingpopup.h index 2d0673e..267c762 100644 --- a/app/gui/oven_control/coretempsettingpopup.h +++ b/app/gui/oven_control/coretempsettingpopup.h @@ -2,6 +2,7 @@ #define CORETEMPSETTINGPOPUP_H #include +#include #include "oven.h" @@ -17,14 +18,28 @@ public: explicit CoreTempSettingPopup(QWidget *parent = 0); ~CoreTempSettingPopup(); +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + private: Ui::CoreTempSettingPopup *ui; Oven *oven; + QTimer focusCoreTempButtonTimer; + QWidget *pushed = NULL; + + void onEncoderLeft(); + void onEncoderRight(); + void onEncoderClicked(QWidget *clicked); + + private slots: void updateView(); void on_cancelButton_clicked(); void on_applyButton_clicked(); + void on_coreTempButton_clicked(); + void focusCoreTempButton(); }; #endif // CORETEMPSETTINGPOPUP_H diff --git a/app/gui/oven_control/coretempsettingpopup.ui b/app/gui/oven_control/coretempsettingpopup.ui index 3bfaab1..d783bdb 100644 --- a/app/gui/oven_control/coretempsettingpopup.ui +++ b/app/gui/oven_control/coretempsettingpopup.ui @@ -13,9 +13,15 @@ #background { background-image: url(:/images/background/manual_core.png); +background-origin: border; margin-top: -720px; } +#background:focus { +border: 4px solid gray; +border-top: 724px solid gray; +} + QPushButton[style="icon"] { background-image: url(:/images/slider_icon/background.png); background-repeat: no-repeat; @@ -61,6 +67,9 @@ height: 33px; 730 + + Qt::TabFocus + @@ -150,7 +159,7 @@ height: 33px; QPushButton { background-image: url(:/images/manual_button/ok.png); } -QPushButton:pressed { background-image: url(:/images/manual_button/ok_ov.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/manual_button/ok_ov.png); } 확인/적용하기 @@ -437,7 +446,8 @@ QPushButton:pressed { background-image: url(:/images/manual_button/ok_ov.png); } QPushButton { image: url(:/images/slider_icon/core_temp_enabled.png); } -QPushButton:pressed { image: url(:/images/slider_icon/core_temp_ov.png); } +QPushButton:checked { image: url(:/images/slider_icon/core_temp_ov.png); } +QPushButton:pressed, QPushButton:focus { image: url(:/images/slider_icon/core_temp_ov.png); } icon @@ -657,7 +667,7 @@ QPushButton:pressed { image: url(:/images/slider_icon/core_temp_ov.png); } QPushButton { background-image: url(:/images/manual_button/back.png); } -QPushButton:pressed { background-image: url(:/images/manual_button/back_ov.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/manual_button/back_ov.png); } 이전으로 @@ -1004,6 +1014,9 @@ QPushButton:pressed { background-image: url(:/images/manual_button/back_ov.png); 140 + + Qt::ClickFocus + @@ -1014,6 +1027,12 @@ QPushButton:pressed { background-image: url(:/images/manual_button/back_ov.png); 1 + + background + coreTempButton + cancelButton + applyButton + diff --git a/app/gui/oven_control/manualcookwindow.cpp b/app/gui/oven_control/manualcookwindow.cpp index 8600482..bb0927f 100644 --- a/app/gui/oven_control/manualcookwindow.cpp +++ b/app/gui/oven_control/manualcookwindow.cpp @@ -125,6 +125,27 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) : showCurrentTempTimer.setInterval(1000); connect(&showCurrentTempTimer, SIGNAL(timeout()), SLOT(showCurrentTemp())); + focusHumidityButtonTimer.setSingleShot(true); + focusHumidityButtonTimer.setInterval(3000); + connect(&focusHumidityButtonTimer, SIGNAL(timeout()), SLOT(focusHumidityButton())); + + focusTempButtonTimer.setSingleShot(true); + focusTempButtonTimer.setInterval(3000); + connect(&focusTempButtonTimer, SIGNAL(timeout()), SLOT(focusTempButton())); + + focusTimeButtonTimer.setSingleShot(true); + focusTimeButtonTimer.setInterval(3000); + connect(&focusTimeButtonTimer, SIGNAL(timeout()), SLOT(focusTimeButton())); + + focusInterTempButtonTimer.setSingleShot(true); + focusInterTempButtonTimer.setInterval(3000); + connect(&focusInterTempButtonTimer, SIGNAL(timeout()), SLOT(focusInterTempButton())); + + connect(ui->humiditySlider, SIGNAL(sliderMoved(int)), &focusHumidityButtonTimer, SLOT(start())); + connect(ui->tempSlider, SIGNAL(sliderMoved(int)), &focusTempButtonTimer, SLOT(start())); + connect(ui->timeSlider, SIGNAL(sliderMoved(int)), &focusTimeButtonTimer, SLOT(start())); + connect(ui->interTempSlider, SIGNAL(sliderMoved(int)), &focusInterTempButtonTimer, SLOT(start())); + connect(oven, SIGNAL(changed(Oven*)), this, SLOT(onOvenUpdated(Oven*))); oven->setDefault(mode); @@ -135,6 +156,8 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) : connect(button, &QPushButton::pressed, SoundPlayer::playClick); QTimer::singleShot(0, this, SLOT(setupAnimation())); + + setFocus(); } ManualCookWindow::ManualCookWindow(QWidget *parent, ManualCookSetting setting) @@ -159,6 +182,55 @@ ManualCookWindow::~ManualCookWindow() delete ui; } +void ManualCookWindow::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + if (focusWidget() != this) + { + pushed = focusWidget(); + + if (pushed == ui->humidityButton) + on_humidityButton_pressed(); + else if (pushed == ui->tempButton) + on_tempButton_pressed(); + + } + break; + case 0x01000032: // Turn right + onEncoderRight(); + break; + } +} + +void ManualCookWindow::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + if (focusWidget() == ui->humidityButton) + on_humidityButton_released(); + else if (focusWidget() == ui->tempButton) + on_tempButton_released(); + + if (focusWidget() == pushed) + onEncoderClicked(pushed); + + pushed = NULL; + break; + case 0x01000032: // Turn right + onEncoderRight(); + break; + } +} + void ManualCookWindow::setupAnimation() { ui->openDoorAnimation->load(":/images/animation/door_big_09.png"); @@ -178,16 +250,28 @@ void ManualCookWindow::updateView() switch (oven->mode()) { case Define::DryMode: + if (ui->steamButton->isChecked()) + ui->steamButton->setChecked(false); + if (ui->combiButton->isChecked()) + ui->combiButton->setChecked(false); if (!ui->dryheatButton->isChecked()) ui->dryheatButton->setChecked(true); break; case Define::SteamMode: if (!ui->steamButton->isChecked()) ui->steamButton->setChecked(true); + if (ui->combiButton->isChecked()) + ui->combiButton->setChecked(false); + if (ui->dryheatButton->isChecked()) + ui->dryheatButton->setChecked(false); break; case Define::CombiMode: + if (ui->steamButton->isChecked()) + ui->steamButton->setChecked(false); if (!ui->combiButton->isChecked()) ui->combiButton->setChecked(true); + if (ui->dryheatButton->isChecked()) + ui->dryheatButton->setChecked(false); break; default: break; @@ -196,7 +280,7 @@ void ManualCookWindow::updateView() int humidity; if (showCurrentHumidity_) humidity = oven->currentHumidity(); - else if (ui->humiditySlider->isSliderDown()) + else if (ui->humiditySlider->isSliderDown() || focusWidget() == ui->humiditySlider) humidity = ui->humiditySlider->sliderPosition(); else humidity = oven->humidity(); @@ -217,7 +301,7 @@ void ManualCookWindow::updateView() int temp; if (showCurrentTemp_) temp = oven->currentTemp(); - else if (ui->tempSlider->isSliderDown()) + else if (ui->tempSlider->isSliderDown() || focusWidget() == ui->tempSlider) temp = ui->tempSlider->sliderPosition(); else temp = oven->temp(); @@ -235,25 +319,21 @@ void ManualCookWindow::updateView() ui->tempSlider->setValue(temp); ui->tempSlider->blockSignals(old); - int msecs; - if (ui->timeSlider->isSliderDown()) - msecs = sliderToTime(ui->timeSlider->sliderPosition()) * 1000; + int msecs = oven->msecs(); + if (ui->timeSlider->isSliderMoved()) + ui->timeLabel->setText(Stringer::remainingTime(sliderToTime(ui->timeSlider->sliderPosition()) * 1000, Stringer::fontSize14)); else - msecs = oven->msecs(); + ui->timeLabel->setText(Stringer::remainingTime(msecs, Stringer::fontSize14)); - if (msecs != lastViewTime) + if (focusWidget() != ui->timeSlider) { - lastViewTime = msecs; - bool old = ui->timeSlider->blockSignals(true); ui->timeSlider->setSliderPosition(timeToSlider(msecs / 1000)); ui->timeSlider->blockSignals(old); - - ui->timeLabel->setText(Stringer::remainingTime(msecs, Stringer::fontSize14)); } int interTemp; - if (ui->interTempSlider->isSliderDown()) + if (ui->interTempSlider->isSliderDown() || focusWidget() == ui->interTempSlider) interTemp = ui->interTempSlider->sliderPosition(); else interTemp = oven->interTemp(); @@ -264,23 +344,7 @@ void ManualCookWindow::updateView() if (interTempEnabled != lastViewInterTempEnabled) { lastViewInterTempEnabled = oven->interTempEnabled(); - - if (interTempEnabled) - ui->interTempButton->setStyleSheet("\ -QPushButton {\ - image: url(:/images/slider_icon/core_temp_enabled.png);\ -}\ -QPushButton:pressed {\ - image: url(:/images/slider_icon/core_temp_ov.png);\ -}"); - else - ui->interTempButton->setStyleSheet("\ -QPushButton {\ - image: url(:/images/slider_icon/core_temp.png);\ -}\ -QPushButton:pressed {\ - image: url(:/images/slider_icon/core_temp_ov.png);\ -}"); + ui->interTempButton->setChecked(interTempEnabled); } lastViewInterTemp = interTemp; @@ -312,32 +376,70 @@ QPushButton:pressed {\ "border-image: url(:/images/manual_button/run.png)"); } - bool damper = oven->damper(); - if (damper != lastViewDamper) + if (showFrontButtons) { - lastViewDamper = damper; - - if (damper) - ui->damperButton->setStyleSheet( - "background-image: url(:/images/manual_button/damper_open.png)"); + ui->preheatButton->show(); + ui->damperButton->show(); + ui->humidificationButton->show(); + if (oven->cooking()) + ui->repeatButton->show(); else - ui->damperButton->setStyleSheet( - "background-image: url(:/images/manual_button/damper_close.png)"); - } + ui->repeatButton->hide(); - bool humidification = oven->humidification(); - if (humidification != lastViewHumidification) + ui->cooldownButton->hide(); + ui->fanButton->hide(); + ui->reserveButton->hide(); + ui->favoriteButton->hide(); + } + else { - lastViewHumidification = humidification; + ui->preheatButton->hide(); + ui->damperButton->hide(); + ui->humidificationButton->hide(); + ui->repeatButton->hide(); - if (humidification) - ui->humidificationButton->setStyleSheet( - "background-image: url(:/images/manual_button/side_nozzle_open.png)"); + ui->cooldownButton->show(); + ui->fanButton->show(); + if (oven->cooking()) + { + ui->reserveButton->hide(); + ui->favoriteButton->hide(); + } else - ui->humidificationButton->setStyleSheet( - "background-image: url(:/images/manual_button/side_nozzle_close.png)"); + { + ui->reserveButton->show(); + ui->favoriteButton->show(); + } } + bool damper = oven->damper(); + ui->damperButton->setChecked(damper); +// if (damper != lastViewDamper) +// { +// lastViewDamper = damper; + +// if (damper) +// ui->damperButton->setStyleSheet( +// "background-image: url(:/images/manual_button/damper_open.png)"); +// else +// ui->damperButton->setStyleSheet( +// "background-image: url(:/images/manual_button/damper_close.png)"); +// } + + bool humidification = oven->humidification(); + ui->humidificationButton->setChecked(humidification); +// if (humidification != lastViewHumidification) +// { +// lastViewHumidification = humidification; + +// if (humidification) +// ui->humidificationButton->setStyleSheet( +// "background-image: url(:/images/manual_button/side_nozzle_open.png)"); +// else +// ui->humidificationButton->setStyleSheet( +// "background-image: url(:/images/manual_button/side_nozzle_close.png)"); +// } + int fan = oven->fan(); if (fan != lastViewFan) { @@ -376,20 +478,6 @@ QPushButton:pressed {\ ui->upperStack->setCurrentIndex(1); else ui->upperStack->setCurrentIndex(0); - - if (oven->cooking()) - { - ui->reserveButton->hide(); - ui->favoriteButton->hide(); - ui->repeatButton->show(); - } - else - { - ui->reserveButton->show(); - ui->favoriteButton->show(); - ui->repeatButton->hide(); - } - } void ManualCookWindow::showCurrentHumidity() @@ -588,6 +676,159 @@ void ManualCookWindow::onMonitor3Timeout() close(); } +void ManualCookWindow::onEncoderLeft() +{ + QWidget *focused = focusWidget(); + if (focused == NULL) + focusPreviousChild(); + else if (focused == this || focused->inherits("QPushButton")) + { + focusPreviousChild(); + focused = focusWidget(); + + if (focused == ui->steamButton) + { + if (oven->mode() == Define::SteamMode) + focusPreviousChild(); + } + else if (focused == ui->combiButton) + { + if (oven->mode() == Define::CombiMode) + focusPreviousChild(); + } + else if (focused == ui->dryheatButton) + { + if (oven->mode() == Define::DryMode) + focusPreviousChild(); + } + } +} + +void ManualCookWindow::onEncoderRight() +{ + QWidget *focused = focusWidget(); + if (focused == NULL) + focusNextChild(); + else if (focused == this) + { + switch (oven->mode()) + { + case Define::DryMode: + case Define::SteamMode: + ui->tempButton->setFocus(); + break; + default: + ui->humidityButton->setFocus(); + } + } + else if (focused->inherits("QPushButton")) + { + focusNextChild(); + focused = focusWidget(); + + if (focused == ui->steamButton) + { + if (oven->mode() == Define::SteamMode) + focusNextChild(); + } + else if (focused == ui->combiButton) + { + if (oven->mode() == Define::CombiMode) + focusNextChild(); + } + else if (focused == ui->dryheatButton) + { + if (oven->mode() == Define::DryMode) + focusNextChild(); + } + } +} + +void ManualCookWindow::onEncoderClicked(QWidget *clicked) +{ + QWidget *focused = clicked; + if (focused == NULL) + return; + + if (focused->inherits("QPushButton")) + { + QPushButton *pb = qobject_cast(focused); + if (pb) + { + pb->click(); + + if (pb == ui->steamButton || pb == ui->dryheatButton) + ui->tempButton->setFocus(); + else if (pb == ui->combiButton) + ui->humidityButton->setFocus(); + } + } + else if (focused->inherits("Slider")) + { + Slider *slider = qobject_cast(focused); + if (slider) + { + if (slider->value() != slider->sliderPosition()) + slider->setValue(slider->sliderPosition()); + + if (slider == ui->humiditySlider) + ui->humidityButton->setFocus(); + else if (slider == ui->tempSlider) + ui->tempButton->setFocus(); + else if (slider == ui->timeSlider) + ui->timeButton->setFocus(); + else if (slider == ui->interTempSlider) + ui->interTempButton->setFocus(); + } + } +} + +void ManualCookWindow::focusHumidityButton() +{ + if (focusWidget() == ui->humiditySlider) + { + oven->setHumidity(ui->humiditySlider->value()); + ui->humidityButton->setFocus(); + } +} + +void ManualCookWindow::focusTempButton() +{ + if (focusWidget() == ui->tempSlider) + { + oven->setTemp(ui->tempSlider->value()); + ui->tempButton->setFocus(); + } +} + +void ManualCookWindow::focusTimeButton() +{ + if (focusWidget() == ui->timeSlider) + { + if (ui->timeSlider->isSliderMoved()) + oven->setTime(sliderToTime(ui->timeSlider->value())); + ui->timeButton->setFocus(); + } +} + +void ManualCookWindow::focusInterTempButton() +{ + if (focusWidget() == ui->interTempSlider) + { + oven->setInterTemp(ui->interTempSlider->value()); + ui->interTempButton->setFocus(); + } +} + +void ManualCookWindow::focusAgain() +{ + if (focused) + { + focused->setFocus(); + focused = NULL; + } +} + void ManualCookWindow::on_steamButton_clicked() { setOvenDefault(Define::SteamMode); @@ -629,6 +870,27 @@ void ManualCookWindow::on_tempButton_released() hideCurrentTemp(); } +void ManualCookWindow::on_humidityButton_clicked() +{ + ui->humiditySlider->setFocus(); + + focusHumidityButtonTimer.start(); +} + +void ManualCookWindow::on_tempButton_clicked() +{ + ui->tempSlider->setFocus(); + + focusTempButtonTimer.start(); +} + +void ManualCookWindow::on_timeButton_clicked() +{ + ui->timeSlider->setFocus(); + + focusTimeButtonTimer.start(); +} + void ManualCookWindow::on_interTempButton_clicked() { if (oven->interTempEnabled()) @@ -637,6 +899,9 @@ void ManualCookWindow::on_interTempButton_clicked() { CoreTempSettingPopup *p = new CoreTempSettingPopup(this); p->show(); + + focused = ui->interTempButton; + connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain())); } } @@ -664,6 +929,9 @@ void ManualCookWindow::on_preheatButton_clicked() PreheatPopup *p = new PreheatPopup(this, oven); p->setWindowModality(Qt::WindowModal); p->showFullScreen(); + + focused = ui->preheatButton; + connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain())); } void ManualCookWindow::on_damperButton_clicked() @@ -713,6 +981,9 @@ void ManualCookWindow::on_cooldownButton_clicked() CooldownPopup *p = new CooldownPopup(this, oven); p->setWindowModality(Qt::WindowModal); p->showFullScreen(); + + focused = ui->cooldownButton; + connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain())); } void ManualCookWindow::on_reserveButton_clicked() @@ -725,6 +996,9 @@ void ManualCookWindow::on_reserveButton_clicked() connect(p, SIGNAL(timeout()), SLOT(start())); connect(p, SIGNAL(canceled()), &startCookingTimer, SLOT(start())); p->showFullScreen(); + + focused = ui->reserveButton; + connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain())); } } @@ -736,6 +1010,8 @@ void ManualCookWindow::on_favoriteButton_clicked() ConfirmPopup *p = new ConfirmPopup(this, tr("즐겨찾기 항목에 추가하시겠습니까?")); p->showFullScreen(); + focused = ui->favoriteButton; + connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain())); connect(p, SIGNAL(accepted()), SLOT(addFavorite())); if (startCookingTimer.isActive()) @@ -745,14 +1021,11 @@ void ManualCookWindow::on_favoriteButton_clicked() } } -void ManualCookWindow::on_goBackStackButton_clicked() -{ - ui->buttonStack->setCurrentIndex(1); -} - void ManualCookWindow::on_goFrontStackButton_clicked() { - ui->buttonStack->setCurrentIndex(0); + showFrontButtons = !showFrontButtons; + + updateView(); } void ManualCookWindow::on_backButton_clicked() @@ -769,6 +1042,9 @@ void ManualCookWindow::on_configButton_clicked() p->showFullScreen(); connect(p, SIGNAL(accepted()), SLOT(jumpConfig())); + + focused = ui->configButton; + connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain())); } else { @@ -789,6 +1065,9 @@ void ManualCookWindow::on_favoritesButton_clicked() p->showFullScreen(); connect(p, SIGNAL(accepted()), SLOT(jumpFavorites())); + + focused = ui->favoritesButton; + connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain())); } else { @@ -810,6 +1089,9 @@ void ManualCookWindow::on_washButton_clicked() p->showFullScreen(); connect(p, SIGNAL(accepted()), SLOT(jumpWash())); + + focused = ui->washButton; + connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain())); } else { @@ -844,8 +1126,8 @@ int ManualCookWindow::sliderToTime(int value) int ManualCookWindow::timeToSlider(int secs) { if (secs <= 180 * 60) - return secs / 60; + return qCeil((qreal) secs / 60); if (secs <= 360 * 60) - return 180 + (secs - 180 * 60) / 2 / 60; - return 270 + (secs - 360 * 60) / 15 / 60; + return 180 + qCeil((qreal) (secs - 180 * 60) / 2 / 60); + return 270 + qCeil((qreal) (secs - 360 * 60) / 15 / 60); } diff --git a/app/gui/oven_control/manualcookwindow.h b/app/gui/oven_control/manualcookwindow.h index e40d206..a7f9230 100644 --- a/app/gui/oven_control/manualcookwindow.h +++ b/app/gui/oven_control/manualcookwindow.h @@ -2,6 +2,7 @@ #define MANUALCOOKWINDOW_H #include +#include #include "oven.h" #include "udphandler.h" @@ -20,6 +21,10 @@ public: explicit ManualCookWindow(QWidget *parent, ManualCookSetting setting); ~ManualCookWindow(); +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + signals: void cookStopRequested(); @@ -47,6 +52,16 @@ private slots: void onMonitor2Timeout(); void onMonitor3Timeout(); + void onEncoderLeft(); + void onEncoderRight(); + void onEncoderClicked(QWidget *clicked); + + void focusHumidityButton(); + void focusTempButton(); + void focusTimeButton(); + void focusInterTempButton(); + void focusAgain(); + void on_steamButton_clicked(); void on_combiButton_clicked(); void on_dryheatButton_clicked(); @@ -55,6 +70,10 @@ private slots: void on_humidityButton_released(); void on_tempButton_pressed(); void on_tempButton_released(); + + void on_humidityButton_clicked(); + void on_tempButton_clicked(); + void on_timeButton_clicked(); void on_interTempButton_clicked(); void on_runStopButton_clicked(); @@ -66,7 +85,6 @@ private slots: void on_cooldownButton_clicked(); void on_reserveButton_clicked(); void on_favoriteButton_clicked(); - void on_goBackStackButton_clicked(); void on_goFrontStackButton_clicked(); void on_backButton_clicked(); @@ -77,6 +95,8 @@ private slots: void on_timeSlider_valueChanged(); + + private: Ui::ManualCookWindow *ui; Oven *oven; @@ -105,6 +125,8 @@ private: bool lastViewHumidification; int lastViewFan; + bool showFrontButtons = true; + int monitorLevel; QTimer monitor1; QTimer monitor2; @@ -117,6 +139,14 @@ private: int sliderToTime(int value); int timeToSlider(int secs); + + QWidget *pushed = NULL; + QWidget *focused = NULL; + + QTimer focusHumidityButtonTimer; + QTimer focusTempButtonTimer; + QTimer focusTimeButtonTimer; + QTimer focusInterTempButtonTimer; }; #endif // MANUALCOOKWINDOW_H diff --git a/app/gui/oven_control/manualcookwindow.ui b/app/gui/oven_control/manualcookwindow.ui index f395998..8943716 100644 --- a/app/gui/oven_control/manualcookwindow.ui +++ b/app/gui/oven_control/manualcookwindow.ui @@ -41,6 +41,12 @@ background-position: center; border: none; } +QPushButton[style="tool"] { +border: none; +background-repeat: no-repeat; +background-position: center; +} + QSlider::groove { background-image: url(:/images/slider/groove_ticks.png); background-repeat: no-repeat; @@ -133,8 +139,8 @@ height: 33px; QPushButton { background-image: url(:/images/cook_mode/big_combi_hide.png); } -QPushButton:pressed { background-image: url(:/images/cook_mode/big_combi_ov.png); } -QPushButton:checked { background-image: url(:/images/cook_mode/big_combi.png); } +QPushButton:checked { background-image: url(:/images/cook_mode/big_combi.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_mode/big_combi_ov.png); } 콤비 @@ -143,7 +149,7 @@ QPushButton:checked { background-image: url(:/images/cook_mode/big_combi.png); } true - true + false mode @@ -160,8 +166,8 @@ QPushButton:checked { background-image: url(:/images/cook_mode/big_combi.png); } QPushButton { background-image: url(:/images/cook_mode/big_steam_hide.png); } -QPushButton:pressed { background-image: url(:/images/cook_mode/big_steam_ov.png); } -QPushButton:checked { background-image: url(:/images/cook_mode/big_steam.png); } +QPushButton:checked { background-image: url(:/images/cook_mode/big_steam.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_mode/big_steam_ov.png); } 스팀 @@ -170,7 +176,7 @@ QPushButton:checked { background-image: url(:/images/cook_mode/big_steam.png); } true - true + false mode @@ -187,8 +193,8 @@ QPushButton:checked { background-image: url(:/images/cook_mode/big_steam.png); } QPushButton { background-image: url(:/images/cook_mode/big_dryheat_hide.png); } -QPushButton:pressed { background-image: url(:/images/cook_mode/big_dryheat_ov.png); } -QPushButton:checked { background-image: url(:/images/cook_mode/big_dryheat.png); } +QPushButton:checked { background-image: url(:/images/cook_mode/big_dryheat.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/cook_mode/big_dryheat_ov.png); } 건열 @@ -197,7 +203,7 @@ QPushButton:checked { background-image: url(:/images/cook_mode/big_dryheat.png); true - true + false mode @@ -223,7 +229,7 @@ QPushButton:checked { background-image: url(:/images/cook_mode/big_dryheat.png); QPushButton { border-image: url(:/images/bottom_bar/back.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/back_ov.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/back_ov.png); } @@ -240,7 +246,7 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/back_ov.png); } QPushButton { border-image: url(:/images/bottom_bar/config.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/config_ov.png); } @@ -257,7 +263,7 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); } QPushButton { border-image: url(:/images/bottom_bar/favorites_manual.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/favorites_manual_ov.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/favorites_manual_ov.png); } @@ -274,7 +280,7 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/favorites_manual_ov. QPushButton { border-image: url(:/images/bottom_bar/wash.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/wash_ov.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/wash_ov.png); } @@ -291,7 +297,7 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/wash_ov.png); } QPushButton { border-image: url(:/images/bottom_bar/help.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/help_ov.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/help_ov.png); } @@ -497,7 +503,7 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/help_ov.png); } QPushButton { image: url(:/images/slider_icon/temp.png); } -QPushButton:pressed { image: url(:/images/slider_icon/temp_ov.png); } +QPushButton:pressed, QPushButton:focus { image: url(:/images/slider_icon/temp_ov.png); } icon @@ -631,248 +637,6 @@ QPushButton:pressed { image: url(:/images/slider_icon/temp_ov.png); } Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - 337 - 1319 - 563 - 131 - - - - QPushButton { -background-repeat: no-repeat; -background-position: center; -border: none; -} - - - 0 - - - - - - 448 - 0 - 112 - 131 - - - - QPushButton { background-image: url(:/images/manual_button/next.png); } -QPushButton:pressed { background-image: url(:/images/manual_button/next_ov.png); } - - - - - - 336 - 36 - 2 - 58 - - - - background-image: url(:/images/line/manual_button.png); - - - - - - 224 - 0 - 112 - 131 - - - - QPushButton { background-image: url(:/images/manual_button/side_nozzle_close.png); } - - - - - - 224 - 36 - 2 - 58 - - - - background-image: url(:/images/line/manual_button.png); - - - - - - 0 - 0 - 112 - 131 - - - - QPushButton { background-image: url(:/images/manual_button/preheat.png); } -QPushButton:pressed { background-image: url(:/images/manual_button/preheat_ov.png); } - - - - - - 336 - 0 - 112 - 131 - - - - QPushButton { background-image: url(:/images/manual_button/repeat.png); } -QPushButton:pressed { background-image: url(:/images/manual_button/repeat_ov.png); } - - - - - - 112 - 36 - 2 - 58 - - - - background-image: url(:/images/line/manual_button.png); - - - - - - 112 - 0 - 112 - 131 - - - - QPushButton { background-image: url(:/images/manual_button/damper_close.png); } - - - - - - - - 448 - 0 - 112 - 131 - - - - QPushButton { background-image: url(:/images/manual_button/next.png); } -QPushButton:pressed { background-image: url(:/images/manual_button/next_ov.png); } - - - - - - 112 - 36 - 2 - 58 - - - - background-image: url(:/images/line/manual_button.png); - - - - - - 224 - 0 - 112 - 131 - - - - QPushButton { background-image: url(:/images/manual_button/reserve.png); } -QPushButton:pressed { background-image: url(:/images/manual_button/reserve_ov.png); } - - - - - - 224 - 36 - 2 - 58 - - - - background-image: url(:/images/line/manual_button.png); - - - - - - 0 - 0 - 112 - 131 - - - - QPushButton { background-image: url(:/images/manual_button/cooldown.png); } -QPushButton:pressed { background-image: url(:/images/manual_button/cooldown_ov.png); } - - - true - - - - - - 336 - 0 - 112 - 131 - - - - QPushButton { background-image: url(:/images/manual_button/favorites.png); } -QPushButton:pressed { background-image: url(:/images/manual_button/favorites_ov.png); } - - - - - - 336 - 36 - 2 - 58 - - - - background-image: url(:/images/line/manual_button.png); - - - - - - 112 - 0 - 112 - 131 - - - - QPushButton { background-image: url(:/images/manual_button/fan_4.png); } - - - - true @@ -946,7 +710,11 @@ QPushButton:pressed { background-image: url(:/images/manual_button/favorites_ov. QPushButton { image: url(:/images/slider_icon/humidity.png); } -QPushButton:pressed { image: url(:/images/slider_icon/humidity_ov.png); } +QPushButton:checked { image: url(:/images/slider_icon/humidity_ov.png); } +QPushButton:pressed, QPushButton:focus { border: 2px dotted white; border-radius: 70px; } + + + true icon @@ -963,7 +731,11 @@ QPushButton:pressed { image: url(:/images/slider_icon/humidity_ov.png); } QPushButton { image: url(:/images/slider_icon/core_temp.png); } -QPushButton:pressed { image: url(:/images/slider_icon/core_temp_ov.png); } +QPushButton:checked { image: url(:/images/slider_icon/core_temp_enabled.png); } +QPushButton:pressed, QPushButton:focus { image: url(:/images/slider_icon/core_temp_ov.png); } + + + true icon @@ -980,7 +752,7 @@ QPushButton:pressed { image: url(:/images/slider_icon/core_temp_ov.png); } QPushButton { image: url(:/images/slider_icon/time.png); } -QPushButton:pressed { image: url(:/images/slider_icon/time_ov.png); } +QPushButton:pressed, QPushButton:focus { image: url(:/images/slider_icon/time_ov.png); } icon @@ -1132,42 +904,288 @@ QPushButton:pressed { image: url(:/images/slider_icon/time_ov.png); } 185 - 875 + 915 666 - 140 + 60 + + Qt::ClickFocus + 185 - 725 + 765 666 - 140 + 60 + + Qt::ClickFocus + 185 - 1025 + 1065 666 - 140 + 60 + + Qt::ClickFocus + 185 - 1175 + 1215 666 - 140 + 60 + + + + Qt::ClickFocus + + + + + + 337 + 1319 + 112 + 131 + + + + QPushButton { background-image: url(:/images/manual_button/cooldown.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/manual_button/cooldown_ov.png); } + + + true + + + tool + + + + + + 785 + 1319 + 112 + 131 + + + + QPushButton { background-image: url(:/images/manual_button/next.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/manual_button/next_ov.png); } + + + tool + + + + + + 673 + 1319 + 112 + 131 + + + + QPushButton { background-image: url(:/images/manual_button/favorites.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/manual_button/favorites_ov.png); } + + + tool + + + + + + 561 + 1319 + 112 + 131 + + QPushButton { background-image: url(:/images/manual_button/reserve.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/manual_button/reserve_ov.png); } + + + tool + + + + + + 449 + 1319 + 112 + 131 + + + + QPushButton { background-image: url(:/images/manual_button/fan_4.png); } + + + tool + + + + + + 561 + 1355 + 2 + 58 + + + + background-image: url(:/images/line/manual_button.png); + + + + + + 673 + 1355 + 2 + 58 + + + + background-image: url(:/images/line/manual_button.png); + + + + + + 449 + 1319 + 112 + 131 + + + + QPushButton { background-image: url(:/images/manual_button/damper_close.png); } +QPushButton:checked, QPushButton:focus { background-image: url(:/images/manual_button/damper_open.png); } + + + true + + + tool + + + + + + 673 + 1319 + 112 + 131 + + + + QPushButton { background-image: url(:/images/manual_button/repeat.png); } +QPushButton:pressed { background-image: url(:/images/manual_button/repeat_ov.png); } + + + tool + + + + + + 337 + 1319 + 112 + 131 + + + + QPushButton { background-image: url(:/images/manual_button/preheat.png); } +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/manual_button/preheat_ov.png); } + + + tool + + + + + + 561 + 1319 + 112 + 131 + + + + QPushButton, QPushButton:checked:pressed { background-image: url(:/images/manual_button/side_nozzle_close.png); } +QPushButton:checked, QPushButton:focus, QPushButton:pressed { background-image: url(:/images/manual_button/side_nozzle_open.png); } + + + true + + + tool + + + + + + 449 + 1355 + 2 + 58 + + + + background-image: url(:/images/line/manual_button.png); + + goFrontStackButton + fanButton + reserveButton + favoriteButton + cooldownButton + preheatButton + damperButton + repeatButton + humidificationButton + upperStack + combiButton + steamButton + dryheatButton + bottomBar + steamLabel_3 + steamLabel_2 + timeLabel + tempButton + tempLabel + humidityLabel + steamLabel_4 + humidityButton + interTempButton + timeButton + interTempLabel + steamLabel_5 + runStopButton + tempSlider + humiditySlider + timeSlider + interTempSlider + sysLine_8 + sysLine_7 + sysLine_9 @@ -1194,6 +1212,30 @@ QPushButton:pressed { image: url(:/images/slider_icon/time_ov.png); } 1 + + steamButton + combiButton + dryheatButton + humidityButton + tempButton + timeButton + interTempButton + runStopButton + preheatButton + cooldownButton + damperButton + fanButton + humidificationButton + reserveButton + repeatButton + favoriteButton + goFrontStackButton + backButton + configButton + favoritesButton + washButton + helpButton + diff --git a/app/gui/oven_control/preheatpopup.cpp b/app/gui/oven_control/preheatpopup.cpp index 0b84759..ded25aa 100644 --- a/app/gui/oven_control/preheatpopup.cpp +++ b/app/gui/oven_control/preheatpopup.cpp @@ -1,6 +1,8 @@ #include "preheatpopup.h" #include "ui_preheatpopup.h" +#include + #include "stringer.h" PreheatPopup::PreheatPopup(QWidget *parent, Oven *oven) : @@ -28,9 +30,13 @@ PreheatPopup::PreheatPopup(QWidget *parent, Oven *oven) : ui->preheatGauge->setMinimum(oven->currentTemp()); ui->preheatGauge->setValue(oven->currentTemp()); + ui->infoButton->hide(); + updateView(); start(); + + ui->background->setFocus(); } PreheatPopup::~PreheatPopup() @@ -38,6 +44,21 @@ PreheatPopup::~PreheatPopup() delete ui; } +void PreheatPopup::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + break; + case 0x01000031: // Push + stop(); + close(); + break; + case 0x01000032: // Turn right + break; + } +} + void PreheatPopup::updateView() { ui->timeLabel->setText(Stringer::remainingTime(oven->msecs(), Stringer::fontSize14)); diff --git a/app/gui/oven_control/preheatpopup.h b/app/gui/oven_control/preheatpopup.h index 6ef43c8..0f66edc 100644 --- a/app/gui/oven_control/preheatpopup.h +++ b/app/gui/oven_control/preheatpopup.h @@ -18,6 +18,9 @@ public: explicit PreheatPopup(QWidget *parent = 0, Oven *oven = 0); ~PreheatPopup(); +protected: + void keyReleaseEvent(QKeyEvent *event); + private slots: void updateView(); void start(); diff --git a/app/gui/oven_control/preheatpopup.ui b/app/gui/oven_control/preheatpopup.ui index 1c0997d..21d82b9 100644 --- a/app/gui/oven_control/preheatpopup.ui +++ b/app/gui/oven_control/preheatpopup.ui @@ -13,7 +13,10 @@ #closeButton { border: none; } #closeButton_2 { border: none; } -#background { background-image: url(:/images/background/popup/696.png); } +#background { background-image: url(:/images/background/popup/696.png); } + + +QWidget#background:focus { border: 4px solid gray; } @@ -24,6 +27,9 @@ 426 + + Qt::NoFocus + @@ -37,6 +43,9 @@ 696 + + Qt::TabFocus + @@ -378,6 +387,9 @@ 290 + + Qt::NoFocus + border: #000000 @@ -659,6 +671,9 @@ border-image: url(:/images/images/auto/btn_01_ov.png); 290 + + Qt::NoFocus + border: #000000 @@ -789,6 +804,9 @@ border-image: url(:/images/images/auto/btn_01_ov.png); 478 + + Qt::NoFocus + @@ -814,6 +832,13 @@ border-image: url(:/images/images/auto/btn_01_ov.png); 1 + + background + infoButton + humidityGaugeButton + selectCookButton_2 + heatGaugeButton + diff --git a/app/gui/oven_control/slider.cpp b/app/gui/oven_control/slider.cpp index 06d9875..befdcf3 100644 --- a/app/gui/oven_control/slider.cpp +++ b/app/gui/oven_control/slider.cpp @@ -8,6 +8,7 @@ Slider::Slider(QWidget *parent) : QWidget(parent), isSliderDown_(false), sliderPosition_(0), value_(0), minimum_(0), maximum_(1), subVisible_(true), + focused(false), isSliderMoved_(false), tickInterval(0), bigTickInterval(0) { groove.load(":/images/slider/groove.png"); @@ -95,16 +96,76 @@ int Slider::sliderPosition() void Slider::setSliderPosition(int value) { + value = qBound(minimum_, value, maximum_); + if (sliderPosition_ == value) return; sliderPosition_ = value; + if (focused) + isSliderMoved_ = true; emit sliderMoved(value); update(); } +bool Slider::isSliderMoved() +{ + return isSliderMoved_; +} + +void Slider::focusInEvent(QFocusEvent */*event*/) +{ + focused = true; +} + +void Slider::focusOutEvent(QFocusEvent *event) +{ + QWidget::focusOutEvent(event); + + focused = false; + + if (isSliderMoved_) + { + isSliderMoved_ = false; + value_ = sliderPosition_; + emit valueChanged(value_); + } +} + +void Slider::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + decrease(); + break; + case 0x01000031: // Push + event->ignore(); + break; + case 0x01000032: // Turn right + increase(); + break; + } +} + +void Slider::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + decrease(); + break; + case 0x01000031: // Push + event->ignore(); + break; + case 0x01000032: // Turn right + increase(); + break; + } +} + void Slider::mouseMoveEvent(QMouseEvent *event) { if (!isSliderDown_) @@ -124,12 +185,7 @@ void Slider::mouseReleaseEvent(QMouseEvent */*event*/) { isSliderDown_ = false; - if (sliderPosition_ == value_) - return; - emit sliderReleased(); - - setValue(sliderPosition_); } void Slider::paintEvent(QPaintEvent */*event*/) @@ -206,6 +262,7 @@ void Slider::updatePixmapPosition() void Slider::setValue(int value) { + value = qBound(minimum_, value, maximum_); if (value == value_) return; @@ -215,3 +272,13 @@ void Slider::setValue(int value) emit valueChanged(value); } + +void Slider::increase() +{ + setSliderPosition(sliderPosition_ + 1); +} + +void Slider::decrease() +{ + setSliderPosition(sliderPosition_ - 1); +} diff --git a/app/gui/oven_control/slider.h b/app/gui/oven_control/slider.h index 2d61775..14c6a88 100644 --- a/app/gui/oven_control/slider.h +++ b/app/gui/oven_control/slider.h @@ -25,6 +25,8 @@ class Slider : public QWidget QPoint subPoint; bool subVisible_; + bool focused; + bool isSliderMoved_; public: explicit Slider(QWidget *parent = 0); @@ -44,6 +46,7 @@ public: bool isSliderDown(); int sliderPosition(); void setSliderPosition(int value); + bool isSliderMoved(); QList ticks; QList bigTicks; @@ -52,6 +55,10 @@ public: int bigTickInterval; protected: + virtual void focusInEvent(QFocusEvent *event); + virtual void focusOutEvent(QFocusEvent *event); + virtual void keyPressEvent(QKeyEvent *event); + virtual void keyReleaseEvent(QKeyEvent *event); virtual void mouseMoveEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event); @@ -71,7 +78,8 @@ signals: public slots: void setValue(int value); - + void increase(); + void decrease(); }; #endif // SLIDER_H diff --git a/app/gui/oven_control/washwindow.cpp b/app/gui/oven_control/washwindow.cpp index 0553bfe..8505a5a 100644 --- a/app/gui/oven_control/washwindow.cpp +++ b/app/gui/oven_control/washwindow.cpp @@ -2,6 +2,7 @@ #include "ui_washwindow.h" #include +#include #include "soundplayer.h" #include "dirtylevel.h" @@ -53,6 +54,8 @@ WashWindow::WashWindow(QWidget *parent) : connect(button, &QPushButton::pressed, SoundPlayer::playClick); updateGauge(); + + setFocus(); } WashWindow::~WashWindow() @@ -60,6 +63,41 @@ WashWindow::~WashWindow() delete ui; } +void WashWindow::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + pushed = focusWidget(); + break; + case 0x01000032: // Turn right + onEncoderRight(); + break; + } +} + +void WashWindow::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case 0x01000030: // Turn left + onEncoderLeft(); + break; + case 0x01000031: // Push + if (focusWidget() == pushed) + onEncoderClicked(pushed); + + pushed = NULL; + break; + case 0x01000032: // Turn right + onEncoderRight(); + break; + } +} + void WashWindow::start(int type) { if (selected) @@ -273,3 +311,20 @@ void WashWindow::on_helpButton_clicked() { } + +void WashWindow::onEncoderLeft() +{ + focusPreviousChild(); +} + +void WashWindow::onEncoderRight() +{ + focusNextChild(); +} + +void WashWindow::onEncoderClicked(QWidget *clicked) +{ + QPushButton *b = qobject_cast(clicked); + if (b) + b->click(); +} diff --git a/app/gui/oven_control/washwindow.h b/app/gui/oven_control/washwindow.h index 5913929..d9154ad 100644 --- a/app/gui/oven_control/washwindow.h +++ b/app/gui/oven_control/washwindow.h @@ -18,16 +18,20 @@ public: explicit WashWindow(QWidget *parent = 0); ~WashWindow(); +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + private slots: void start(int type); void stop(); void returnToClock(); void updateGauge(); + void onChanged(); - void on_backButton_clicked(); + void on_backButton_clicked(); void on_configButton_clicked(); - void on_helpButton_clicked(); private: @@ -42,6 +46,12 @@ private: int type; QTimer returnToClockTimer; + + QWidget *pushed = NULL; + + void onEncoderLeft(); + void onEncoderRight(); + void onEncoderClicked(QWidget *clicked); }; #endif // WASHWINDOW_H diff --git a/app/gui/oven_control/washwindow.ui b/app/gui/oven_control/washwindow.ui index e7fc06f..3a66aab 100644 --- a/app/gui/oven_control/washwindow.ui +++ b/app/gui/oven_control/washwindow.ui @@ -482,7 +482,7 @@ border: none; QPushButton { border-image: url(:/images/bottom_bar/back.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/back_ov.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/back_ov.png); } @@ -505,7 +505,7 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/back_ov.png); } QPushButton { border-image: url(:/images/bottom_bar/config.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/config_ov.png); } @@ -528,7 +528,7 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); } QPushButton { border-image: url(:/images/bottom_bar/help.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/help_ov.png); } +QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/help_ov.png); } @@ -545,11 +545,11 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/help_ov.png); } - Qt::NoFocus + Qt::StrongFocus QPushButton { background-image: url(:/images/wash/button_1.png); } -QPushButton::pressed { background-image: url(:/images/wash/button_1_ov.png); } +QPushButton::pressed, QPushButton:focus { background-image: url(:/images/wash/button_1_ov.png); } 세제 없이 헹굼 @@ -568,11 +568,11 @@ QPushButton::pressed { background-image: url(:/images/wash/button_1_ov.png); } - Qt::NoFocus + Qt::StrongFocus QPushButton { background-image: url(:/images/wash/button_2.png); } -QPushButton::pressed { background-image: url(:/images/wash/button_2_ov.png); } +QPushButton::pressed, QPushButton:focus { background-image: url(:/images/wash/button_2_ov.png); } 간이 세척 @@ -591,11 +591,11 @@ QPushButton::pressed { background-image: url(:/images/wash/button_2_ov.png); } - Qt::NoFocus + Qt::StrongFocus QPushButton { background-image: url(:/images/wash/button_3.png); } -QPushButton::pressed { background-image: url(:/images/wash/button_3_ov.png); } +QPushButton::pressed, QPushButton:focus { background-image: url(:/images/wash/button_3_ov.png); } 표준 세척 @@ -614,11 +614,11 @@ QPushButton::pressed { background-image: url(:/images/wash/button_3_ov.png); } - Qt::NoFocus + Qt::StrongFocus QPushButton { background-image: url(:/images/wash/button_4.png); } -QPushButton::pressed { background-image: url(:/images/wash/button_4_ov.png); } +QPushButton::pressed, QPushButton:focus { background-image: url(:/images/wash/button_4_ov.png); } 강 세척 @@ -637,11 +637,11 @@ QPushButton::pressed { background-image: url(:/images/wash/button_4_ov.png); } - Qt::NoFocus + Qt::StrongFocus QPushButton { background-image: url(:/images/wash/button_5.png); } -QPushButton::pressed { background-image: url(:/images/wash/button_5_ov.png); } +QPushButton::pressed, QPushButton:focus { background-image: url(:/images/wash/button_5_ov.png); } 고속 세척 @@ -721,6 +721,9 @@ QPushButton::pressed { background-image: url(:/images/wash/button_5_ov.png); }140 + + Qt::NoFocus + QPushButton { image: url(:/images/slider_icon/management.png); } QPushButton:pressed { image: url(:/images/slider_icon/management_ov.png); } @@ -870,6 +873,9 @@ QPushButton:pressed { image: url(:/images/slider_icon/management_ov.png); }33 + + Qt::NoFocus + 5 @@ -960,6 +966,9 @@ QPushButton:pressed { image: url(:/images/slider_icon/management_ov.png); }140 + + Qt::NoFocus + QPushButton { image: url(:/images/slider_icon/clean.png); } QPushButton:pressed { image: url(:/images/slider_icon/clean_ov.png); } @@ -1109,6 +1118,9 @@ QPushButton:pressed { image: url(:/images/slider_icon/clean_ov.png); } 33 + + Qt::NoFocus + 5 @@ -1180,6 +1192,16 @@ QPushButton:pressed { image: url(:/images/slider_icon/clean_ov.png); } 1 + + washButton_1 + washButton_2 + washButton_3 + washButton_4 + washButton_5 + backButton + configButton + helpButton +