configwindow.cpp 3.54 KB
#include "configwindow.h"
#include "ui_configwindow.h"

#include "functiontestwindow.h"
#include "engineermenuwindow.h"
#include "config.h"




ConfigWindow::ConfigWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ConfigWindow)
{
    uint32_t idx;
    ui->setupUi(this);

    ui->clockContainer->setParent(ui->upperStack);
    setAttribute(Qt::WA_DeleteOnClose);

    ui->scrollAreaMenuLayout->setAlignment(Qt::AlignTop);

    Config* cfg = Config::getInstance();

    QSetIterator<uint32_t> itr = cfg->getConstBeginFavorite();
    while(itr.hasNext()) itr.next();

    while(itr.hasPrevious()){
        idx = itr.previous();
        //configbtn = new ConfigPanelButton(this,idx);
    }

    m_nCurConfigPos = config_menu_favorite;

    reloadUi();

}

ConfigWindow::~ConfigWindow()
{
    delete ui;
}

void ConfigWindow::on_pushButton_clicked()
{

}

void ConfigWindow::on_backButton_clicked()
{
    close();
}

void ConfigWindow::on_pushButton_3_clicked()
{
    EngineerMenuWindow *w = new EngineerMenuWindow(this);
    w->setWindowModality(Qt::WindowModal);
    w->showFullScreen();
}

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;i<m_vectorMenuList.count();i++){
        strtemp = cfg->getValueString(m_arrConfigListInfos[m_nCurConfigPos][i]);
        m_vectorMenuList[i]->setValue(strtemp);
    }
}

void ConfigWindow::onConfigBtnClicked(uint16_t id){
    qDebug() << "config id prsess : " << id;
    Config *cfg = Config::getInstance();
    cfg->execConfigWindow(this,(Define::ConfigType)id);
    reloadValue();
}


void ConfigWindow::onConfigCheckBtnClicked(uint16_t id, bool checked){

}

void ConfigWindow::reloadUi(void){
    ConfigPanelButton** pws = m_vectorMenuList.data();
    ConfigPanelButton* pw;
    ConfigPanelButton *pcb;
    Config* cfg = Config::getInstance();
    QString strtemp="";
    for(int i = 0; i < m_vectorMenuList.count();i++){
        pw = pws[i];
        ui->scrollAreaMenuLayout->removeWidget(pw);
        delete pw;
    }
    m_vectorMenuList.clear();

    if(m_nCurConfigPos != config_menu_favorite){
        for(int i=0 ; i < m_arrMaxMenuCount[m_nCurConfigPos] ;i++){
            pcb = new ConfigPanelButton(this,m_arrConfigListInfos[m_nCurConfigPos][i]);
            qDebug() <<m_arrConfigListInfos[m_nCurConfigPos][i] << cfg->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]));
            ui->scrollAreaMenuLayout->addWidget(pcb);
            m_vectorMenuList.append(pcb);
            connect(pcb ,SIGNAL(clicked(uint16_t)),SLOT(onConfigBtnClicked(uint16_t)));
        }
    }

    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();
    }
}