diff --git a/app/gui/oven_control/configpanelbutton.cpp b/app/gui/oven_control/configpanelbutton.cpp index bbf780c..bffaf1d 100644 --- a/app/gui/oven_control/configpanelbutton.cpp +++ b/app/gui/oven_control/configpanelbutton.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "soundplayer.h" @@ -35,6 +36,11 @@ ConfigPanelButton::~ConfigPanelButton() delete ui; } +bool ConfigPanelButton::isFavoriteFocused() +{ + return (focusWidget() == ui->favoriteButton); +} + void ConfigPanelButton::setText(const QString &text) { if (text_ == text) @@ -107,6 +113,19 @@ void ConfigPanelButton::setFavoriteCheck(bool checked){ ui->favoriteButton->setChecked(checked); } +void ConfigPanelButton::focusInEvent(QFocusEvent *event) +{ + switch (event->reason()) + { + case Qt::TabFocusReason: + ui->pushButton->setFocus(); + break; + case Qt::BacktabFocusReason: + ui->favoriteButton->setFocus(); + break; + } +} + void ConfigPanelButton::on_favoriteButton_clicked(bool checked) { emit checkButtonClicked(btnid,checked); diff --git a/app/gui/oven_control/configpanelbutton.h b/app/gui/oven_control/configpanelbutton.h index 554654a..699abec 100644 --- a/app/gui/oven_control/configpanelbutton.h +++ b/app/gui/oven_control/configpanelbutton.h @@ -18,6 +18,8 @@ public: const QString &text() { return text_; } const QString &value() { return value_; } + bool isFavoriteFocused(); + public slots: void setText(const QString &text); void setValue(const QString &value); @@ -26,6 +28,9 @@ public slots: bool isFavoriteChecked(); void setFavoriteCheck(bool checked); +protected: + void focusInEvent(QFocusEvent *event); + private: Ui::ConfigPanelButton *ui; diff --git a/app/gui/oven_control/configpanelbutton.ui b/app/gui/oven_control/configpanelbutton.ui index 14ee294..7ab59a5 100644 --- a/app/gui/oven_control/configpanelbutton.ui +++ b/app/gui/oven_control/configpanelbutton.ui @@ -81,11 +81,11 @@ QPushButton:focus { background-image: url(:/images/config/pannel_ov.png); } - Qt::NoFocus + Qt::TabFocus QPushButton { background-image: url(:/images/config/088_fava_02.png); } -QPushButton:checked { background-image: url(:/images/config/088_fava_01.png); } +QPushButton:checked, QPushButton:focus { background-image: url(:/images/config/088_fava_01.png); } diff --git a/app/gui/oven_control/configwindow.cpp b/app/gui/oven_control/configwindow.cpp index 93dc392..53ecc05 100644 --- a/app/gui/oven_control/configwindow.cpp +++ b/app/gui/oven_control/configwindow.cpp @@ -59,6 +59,137 @@ void ConfigWindow::on_pushButton_clicked() } } +void ConfigWindow::prevFocus(){ + if(focusWidget() == ui->helpButton) { + qDebug() << "help"; + ui->washButton->setFocus(); + } + else if(focusWidget() == ui->washButton){ + ui->backButton->setFocus(); + } + else if(focusWidget() == ui->backButton){ + m_vectorMenuList[m_vectorMenuList.size()-1]->setFocus(); + nextFocus(); + nextFocus(); + //prevFocus(); + //focusPreviousChild(); + //qDebug << focusWidget()->wind + } + else if(focusWidget() == ui->scrollArea){ + ui->pushButton_3->setFocus(); + } + else if(focusWidget() == ui->pushButton){ + ui->helpButton->setFocus(); + } + else if(focusWidget() == ui->pushButton_8){ + ui->pushButton->setFocus(); + } + else if(focusWidget() == ui->pushButton_7){ + ui->pushButton_8->setFocus(); + } + else if(focusWidget() == ui->pushButton_2){ + ui->pushButton_7->setFocus(); + } + else if(focusWidget() == ui->pushButton_4){ + ui->pushButton_2->setFocus(); + } + else if(focusWidget() == ui->pushButton_5){ + ui->pushButton_4->setFocus(); + } + else if(focusWidget() == ui->pushButton_6){ + ui->pushButton_5->setFocus(); + } + else if(focusWidget() == ui->pushButton_3){ + ui->pushButton_6->setFocus(); + } + else focusPreviousChild(); +} + +void ConfigWindow::nextFocus(){ + if(focusWidget() == ui->helpButton) { + qDebug() << "help"; + ui->pushButton->setFocus(); + } + else if(focusWidget() == ui->backButton){ + ui->washButton->setFocus(); + } + else if(focusWidget() == ui->washButton){ + ui->helpButton->setFocus(); + } + else if(focusWidget() == ui->pushButton){ + ui->pushButton_8->setFocus(); + } + else if(focusWidget() == ui->pushButton_8){ + ui->pushButton_7->setFocus(); + } + else if(focusWidget() == ui->pushButton_7){ + ui->pushButton_2->setFocus(); + } + else if(focusWidget() == ui->pushButton_2){ + ui->pushButton_4->setFocus(); + } + else if(focusWidget() == ui->pushButton_4){ + ui->pushButton_5->setFocus(); + } + else if(focusWidget() == ui->pushButton_5){ + ui->pushButton_6->setFocus(); + } + else if(focusWidget() == ui->pushButton_6){ + ui->pushButton_3->setFocus(); + } + else if(focusWidget() == ui->pushButton_3){ + ui->scrollArea->setFocus(); + } + else if(m_vectorMenuList[m_vectorMenuList.size() -1]->isFavoriteFocused()){ + qDebug() << "last Favorite Focused"; + ui->backButton->setFocus(); + } + else focusNextChild(); +} + +void ConfigWindow::keyReleaseEvent(QKeyEvent *event){ + switch (event->key()) + { + case 0x01000030: // Turn left + //focusPreviousChild(); + prevFocus(); + qDebug() << "turn left"; + break; + case 0x01000031: // Push + { + QPushButton *btn = qobject_cast(focusWidget()); + if(btn != NULL){ + btn->click(); + } + qDebug() << "pushed "; + break; + } + case 0x01000032: // Turn right + nextFocus(); + qDebug() << "Turn Right"; + break; + } +} + +void ConfigWindow::keyPressEvent(QKeyEvent *event){ + switch (event->key()) + { + case 0x01000030: // Turn left + //focusPreviousChild(); + prevFocus(); + qDebug() << "turn left"; + break; + case 0x01000031: // Push + + qDebug() << "pushed "; + break; + case 0x01000032: // Turn right + nextFocus(); + qDebug() << "Turn Right"; + break; + } +} + void ConfigWindow::on_backButton_clicked() { Config* cfg = Config::getInstance(); @@ -187,6 +318,8 @@ void ConfigWindow::reloadUi(void){ } m_vectorFavorMenuList.clear(); + + if(m_nCurConfigPos != config_menu_favorite){ for(i=0 ; i < m_arrMaxMenuCount[m_nCurConfigPos] ;i++){ pcb = new ConfigPanelButton(this,m_arrConfigListInfos[m_nCurConfigPos][i]); diff --git a/app/gui/oven_control/configwindow.h b/app/gui/oven_control/configwindow.h index 8a6fd2e..bb2ce9b 100644 --- a/app/gui/oven_control/configwindow.h +++ b/app/gui/oven_control/configwindow.h @@ -44,6 +44,9 @@ private: {config_software_info,config_hotline_chef,config_hotline_service,config_steam_wash,config_demo_mode,config_enter_engineer_mode} }; + void nextFocus(); + void prevFocus(); + public: explicit ConfigWindow(QWidget *parent = 0); ~ConfigWindow(); @@ -77,11 +80,16 @@ public slots: void onConfigCheckBtnClicked(uint16_t id, bool checked); void onDeleteFavoriteBtnClicked(uint16_t id); +protected: + void keyReleaseEvent(QKeyEvent* event); + void keyPressEvent(QKeyEvent* event); + private: Ui::ConfigWindow *ui; QVector m_vectorMenuList; QVector m_vectorFavorMenuList; CONFIG_MENU_POS m_nCurConfigPos; + }; #endif // CONFIGWINDOW_H diff --git a/app/gui/oven_control/configwindow.ui b/app/gui/oven_control/configwindow.ui index 49ec6f9..378ef39 100644 --- a/app/gui/oven_control/configwindow.ui +++ b/app/gui/oven_control/configwindow.ui @@ -441,7 +441,7 @@ QPushButton:pressed, QPushButton:focus ,QPushButton:checked{ background-image: u 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); } @@ -458,7 +458,7 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/back_ov.png); } 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); } @@ -475,7 +475,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); } @@ -491,6 +491,9 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/help_ov.png); }600 + + Qt::TabFocus + background-color : transparent; @@ -558,6 +561,19 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/help_ov.png); }washwarnicon.h + + pushButton + backButton + pushButton_8 + washButton + pushButton_7 + helpButton + pushButton_2 + pushButton_4 + pushButton_5 + pushButton_6 + pushButton_3 + diff --git a/app/gui/oven_control/electricmodelsettingwindow.cpp b/app/gui/oven_control/electricmodelsettingwindow.cpp index 0681350..9cb7e5b 100644 --- a/app/gui/oven_control/electricmodelsettingwindow.cpp +++ b/app/gui/oven_control/electricmodelsettingwindow.cpp @@ -34,7 +34,6 @@ ElectricModelSettingWindow::ElectricModelSettingWindow(QWidget *parent) : ui->e40Button->setChecked(true); break; } - } ElectricModelSettingWindow::~ElectricModelSettingWindow()