#include #include "configwindow.h" #include "ui_configwindow.h" #include "configfavoritebutton.h" #include "functiontestwindow.h" #include "engineermenuwindow.h" #include "config.h" #include "configinfodlg.h" #include "yesnopopupdlg.h" #include "configdatetimedlg.h" #include "servicepassinputdlg.h" #include "fileprocessor.h" #include "soundplayer.h" #include "washwindow.h" #include "mainwindow.h" #include "configdoormonitoring.h" #include "servicepassinputdlg.h" #include "manualviewerdlg.h" ConfigWindow::ConfigWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::ConfigWindow) { ui->setupUi(this); ui->clockContainer->setParent(ui->upperStack); setAttribute(Qt::WA_DeleteOnClose); Config* cfg = Config::getInstance(); ui->scrollAreaMenuLayout->setAlignment(Qt::AlignTop); foreach (QPushButton *button, findChildren()) connect(button, &QPushButton::pressed, SoundPlayer::playClick); config_item item; m_nCurConfigPos = config_menu_favorite; reloadUi(); item = cfg->getConfigValue(config_demo_mode); if(item.d32!=0){ QDialog* dlg = new ServicePassInputDlg(this, DEMO_SERVICE_PASS_MODE); dlg->setModal(true); dlg->showFullScreen(); dlg->raise(); connect(dlg, SIGNAL(rejected()), SLOT(deleteLater())); } } void ConfigWindow::onLoadedWindow(){ QDialog* dlg = new ServicePassInputDlg(this); dlg->exec(); this->show(); } void ConfigWindow::showFullScreen(){ Config* cfg = Config::getInstance(); config_item item = cfg->getConfigValue(config_demo_mode); if(item.d32){ //QMainWindow::showFullScreen(); // QDialog* dlg = new ServicePassInputDlg(this->parentWidget()); // dlg->exec(); QMainWindow::showFullScreen(); } else{ QMainWindow::showFullScreen(); } } ConfigWindow::~ConfigWindow() { delete ui; } void ConfigWindow::on_pushButton_clicked() { if(m_nCurConfigPos != config_menu_favorite){ m_nCurConfigPos = config_menu_favorite; reloadUi(); } } void ConfigWindow::prevFocus(){ int i = 0; for(i = 0; i < m_vectorTabOrder.size();i++){ if(focusWidget() == m_vectorTabOrder[i]) break; } if(i==0){ i = m_vectorTabOrder.size()-1; m_vectorTabOrder[i]->setFocus(); } else if(i < m_vectorTabOrder.size()) { i = i - 1; m_vectorTabOrder[i]->setFocus(); } else{ i=0; m_vectorTabOrder[i]->setFocus(); } } void ConfigWindow::nextFocus(){ int i = 0; for(i = 0; i < m_vectorTabOrder.size();i++){ if(focusWidget() == m_vectorTabOrder[i]) break; } if(isetFocus(); } else if(i== (m_vectorTabOrder.size()-1)){ i=0; m_vectorTabOrder[i]->setFocus(); } else{ i=0; m_vectorTabOrder[i]->setFocus(); } return; } void ConfigWindow::keyReleaseEvent(QKeyEvent *event){ switch (event->key()) { case 0x01000032: // Turn left prevFocus(); ui->scrollArea->ensureWidgetVisible(m_vectorTabOrder[m_nTabIndex]); break; case 0x01000031: // Push { QPushButton *btn = qobject_cast(focusWidget()); if(btn != NULL){ btn->click(); } qDebug() << "pushed "; break; } case 0x01000030: // Turn right nextFocus(); ui->scrollArea->ensureWidgetVisible(focusWidget()); qDebug() << "Turn Right"; break; } } void ConfigWindow::keyPressEvent(QKeyEvent *event){ switch (event->key()) { case 0x01000032: // Turn left prevFocus(); ui->scrollArea->ensureWidgetVisible(focusWidget()); qDebug() << "turn left"; break; case 0x01000031: // Push qDebug() << "pushed "; break; case 0x01000030: // Turn right nextFocus(); ui->scrollArea->ensureWidgetVisible(focusWidget()); qDebug() << "Turn Right"; break; } } void ConfigWindow::on_backButton_clicked() { Config* cfg = Config::getInstance(); QDialog* dlg = new YesNoPopupDlg(this,tr("현재 설정을 적용하시겠습니까?")); dlg->setModal(true); dlg->exec(); if(dlg->result() == QDialog::Accepted){ cfg->saveConfig(); cfg->saveFavorite(); } else{ cfg->loadConfig(); cfg->loadFavorite(); } cfg->applyConfig(); close(); } void ConfigWindow::on_pushButton_3_clicked() { /*EngineerMenuWindow *w = new EngineerMenuWindow(this); w->setWindowModality(Qt::WindowModal); w->showFullScreen();*/ if(m_nCurConfigPos != config_menu_service){ m_nCurConfigPos = config_menu_service; reloadUi(); } } void ConfigWindow::on_pushButton_8_clicked() //설정 버튼 { if(m_nCurConfigPos != config_menu_setting){ m_nCurConfigPos = config_menu_setting; reloadUi(); } } void ConfigWindow::reloadValue(){ Config* cfg = Config::getInstance(); QString strtemp=""; for(int i=0;igetValueString(m_arrConfigListInfos[m_nCurConfigPos][i]); m_vectorMenuList[i]->setValue(strtemp); } } void ConfigWindow::onConfigBtnClicked(uint16_t id){ Config *cfg = Config::getInstance(); QDialog* dlg; QWidget *focusedWidget = focusWidget(); switch(id){ case config_loading_door_monitoring: case config_cooking_door_monitoring: ConfigDoorMonitoring* wnd; wnd = new ConfigDoorMonitoring(this,(ConfigType) id); connect(wnd,SIGNAL(destroyed(QObject*)),this,SLOT(reloadValue())); wnd->setWindowModality(Qt::WindowModal); wnd->showFullScreen(); qDebug() << "closed window"; break; case config_datetime: dlg = new ConfigDateTimeDlg(this); dlg->exec(); if(m_nCurConfigPos != config_menu_favorite) reloadValue(); break; case config_enter_engineer_mode: { dlg = new ServicePassInputDlg(this); dlg->exec(); break; } case config_software_info: case config_hotline_chef: case config_hotline_service: dlg = new ConfigInfoDlg(this,(ConfigType)id); dlg->exec(); break; default: cfg->execConfigWindow(this,(Define::ConfigType)id); if(m_nCurConfigPos != config_menu_favorite) reloadValue(); break; } focusedWidget->setFocus(); } void ConfigWindow::onConfigCheckBtnClicked(uint16_t id, bool checked){ Config* cfg = Config::getInstance(); qDebug()<<"favorite pressed " << id; if(checked){ cfg->insertFavorite((ConfigType)id); } else{ cfg->removeFavorite((ConfigType)id); } } void ConfigWindow::reloadUi(void){ ConfigPanelButton** pws = m_vectorMenuList.data(); ConfigFavoriteButton** fpws = m_vectorFavorMenuList.data(); ConfigPanelButton* pw; ConfigPanelButton *pcb; ConfigFavoriteButton* fpw; ConfigFavoriteButton* fpcb; uint32_t idx; int i = 0; Config* cfg = Config::getInstance(); QString strtemp=""; for(i = 0; i < m_vectorMenuList.count();i++){ pw = pws[i]; ui->scrollAreaMenuLayout->removeWidget(pw); pw->deleteLater(); } m_vectorMenuList.clear(); for(i=0;iscrollAreaMenuLayout->removeWidget(fpw); fpw->deleteLater(); } m_vectorFavorMenuList.clear(); m_vectorTabOrder.clear(); m_vectorTabOrder.append(this); m_vectorTabOrder.append(ui->pushButton); m_vectorTabOrder.append(ui->pushButton_8); m_vectorTabOrder.append(ui->pushButton_7); m_vectorTabOrder.append(ui->pushButton_2); m_vectorTabOrder.append(ui->pushButton_4); m_vectorTabOrder.append(ui->pushButton_5); m_vectorTabOrder.append(ui->pushButton_6); m_vectorTabOrder.append(ui->pushButton_3); if(m_nCurConfigPos != config_menu_favorite){ for(i=0 ; i < m_arrMaxMenuCount[m_nCurConfigPos] ;i++){ pcb = new ConfigPanelButton(this,m_arrConfigListInfos[m_nCurConfigPos][i]); qDebug() <getTitleString(m_arrConfigListInfos[m_nCurConfigPos][i]); strtemp = cfg->getTitleString(m_arrConfigListInfos[m_nCurConfigPos][i]); pcb->setText(strtemp); strtemp = cfg->getValueString(m_arrConfigListInfos[m_nCurConfigPos][i]); pcb->setValue(strtemp); pcb->showFavoriteButton(); pcb->setFavoriteCheck(cfg->isFavorite(m_arrConfigListInfos[m_nCurConfigPos][i])); m_vectorTabOrder.append(pcb->getFavoriteBtn()); m_vectorTabOrder.append(pcb->getBtn()); ui->scrollAreaMenuLayout->addWidget(pcb); m_vectorMenuList.append(pcb); connect(pcb ,SIGNAL(clicked(uint16_t)),SLOT(onConfigBtnClicked(uint16_t))); connect(pcb,SIGNAL(checkButtonClicked(uint16_t,bool)),SLOT(onConfigCheckBtnClicked(uint16_t,bool))); } } else{ QList list = cfg->getConstSortedFavorite(); for(i=0;i < list.count();i++){ idx = list[i]; fpcb = new ConfigFavoriteButton(this,idx); strtemp = cfg->getTitleString((ConfigType)idx); fpcb->setText(strtemp); m_vectorTabOrder.append(fpcb->getBtn()); m_vectorTabOrder.append(fpcb->getDelBtn()); ui->scrollAreaMenuLayout->addWidget(fpcb); m_vectorFavorMenuList.append(fpcb); connect(fpcb,SIGNAL(clicked(uint16_t)),SLOT(onConfigBtnClicked(uint16_t))); connect(fpcb,SIGNAL(delBtnClicked(uint16_t)),SLOT(onDeleteFavoriteBtnClicked(uint16_t))); } } m_vectorTabOrder.append(ui->backButton); m_vectorTabOrder.append(ui->washButton); m_vectorTabOrder.append(ui->helpButton); ui->scrollAreaMenu->adjustSize(); //Display 전 Contents 사이즈 수정 깜빡임 제거함. } void ConfigWindow::on_pushButton_7_clicked() //음향 관리 { if(m_nCurConfigPos != config_menu_sound){ m_nCurConfigPos = config_menu_sound; reloadUi(); } } void ConfigWindow::on_pushButton_2_clicked() { if(m_nCurConfigPos != config_menu_system){ m_nCurConfigPos = config_menu_system; reloadUi(); } } void ConfigWindow::on_pushButton_4_clicked() { if(m_nCurConfigPos != config_menu_energy){ m_nCurConfigPos = config_menu_energy; reloadUi(); } } void ConfigWindow::on_pushButton_5_clicked() { if(m_nCurConfigPos != config_menu_expert){ m_nCurConfigPos = config_menu_expert; reloadUi(); } } void ConfigWindow::onDeleteFavoriteBtnClicked(uint16_t id){ Config* cfg = Config::getInstance(); ConfigFavoriteButton* btn; m_vectorTabOrder.clear(); m_vectorTabOrder.append(this); m_vectorTabOrder.append(ui->pushButton); m_vectorTabOrder.append(ui->pushButton_8); m_vectorTabOrder.append(ui->pushButton_7); m_vectorTabOrder.append(ui->pushButton_2); m_vectorTabOrder.append(ui->pushButton_4); m_vectorTabOrder.append(ui->pushButton_5); m_vectorTabOrder.append(ui->pushButton_6); m_vectorTabOrder.append(ui->pushButton_3); for(int i = 0;igetBtnId() == id){ btn = m_vectorFavorMenuList[i]; ui->scrollAreaMenuLayout->removeWidget(btn); m_vectorFavorMenuList.remove(i); delete btn; cfg->removeFavorite((ConfigType)id); } else{ m_vectorTabOrder.append(m_vectorFavorMenuList[i]->getBtn()); m_vectorTabOrder.append(m_vectorFavorMenuList[i]->getDelBtn()); } } m_vectorTabOrder.append(ui->backButton); m_vectorTabOrder.append(ui->washButton); m_vectorTabOrder.append(ui->helpButton); } void ConfigWindow::on_washButton_clicked() { Config* cfg = Config::getInstance(); QDialog* dlg = new YesNoPopupDlg(this,tr("현재 설정을 적용하시겠습니까?")); dlg->setModal(true); dlg->exec(); if(dlg->result() == QDialog::Accepted){ cfg->saveConfig(); cfg->saveFavorite(); } else{ cfg->loadConfig(); cfg->loadFavorite(); } cfg->applyConfig(); WashWindow *w = new WashWindow(MainWindow::getInstance()); w->setWindowModality(Qt::WindowModal); w->showFullScreen(); w->raise(); MainWindow::jump(w); } void ConfigWindow::on_helpButton_clicked() { ManualViewerDlg* dlg = new ManualViewerDlg(this); dlg->showFullScreen(); dlg->raise(); }