configinfodlg.cpp 4.43 KB
#include <QMap>
#include <QLabel>
#include <QDebug>
#include "configinfodlg.h"
#include "ui_configinfodlg.h"
#include "soundplayer.h"
#include "config.h"
#include "define.h"
#include "fileprocessor.h"
#include "ovenstatics.h"





ConfigInfoDlg::ConfigInfoDlg(QWidget *parent, ConfigType type) :
    QDialog(parent),
    ui(new Ui::ConfigInfoDlg)
{
    Config* cfg = Config::getInstance();
    ui->setupUi(this);
    this->setWindowFlags( Qt::FramelessWindowHint);
    this->setAttribute( Qt::WA_DeleteOnClose);
    qApp->setActiveWindow(this);
    this->setFocus();

    foreach (QPushButton *button, findChildren<QPushButton *>())
        connect(button, &QPushButton::pressed, SoundPlayer::playClick);

    m_nType = type;

    ui->ctrTitle->setText(cfg->getTitleString(type));

    switch(type){
    case config_hotline_chef:
        loadHotlineChefInfo();
        break;
    case config_hotline_service:
        loadHotlineServiceInfo();
        break;
    case config_software_info:
    default:
        loadSoftwareInfo();
        break;
    }
    ui->ctrBtnOk->setFocus();
}

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

void ConfigInfoDlg::on_ctrBtnOk_clicked()
{
    deleteLater();
}

void ConfigInfoDlg::loadSoftwareInfo(){
    Config* cfg = Config::getInstance();
    QString strTemp;
    QMap<QString , QString> mapInfos;
    QLabel* label;
    float firmver =  (float)(OvenStatistics::getInstance()->getFrimwareVersion())/100.0;



//Default Value;
    mapInfos[tr("모  델  명")] = cfg->getProductModelName();
    mapInfos[tr("제조일자")] = cfg->getProductDateTime();
    mapInfos[tr("제조국")] = cfg->getProductCountry();
    mapInfos[tr("제조사")] = cfg->getProductCompany();
    mapInfos[tr("제품번호")] = cfg->getProductSerial();
    mapInfos[tr("소프트웨어 버전")] = cfg->getProductSWVersion();
    mapInfos[tr("현재모델")] =  cfg->getProductType();


    for(int i =0;i<MAX_SOFTWARE_INFO_CNT;i++){
        strTemp = mapInfos[tr(software_item_name[i])];

        label = new QLabel(this);
        label ->setText(tr(software_item_name[i]).append(" :"));
        ui->gridLayout_info->addWidget(label,i,0);
        label = new QLabel(this);
        label->setText(strTemp);
        ui->gridLayout_info->addWidget(label,i,1);
    }
    label = new QLabel(this);
    label ->setText("Firmware Version");
    ui->gridLayout_info->addWidget(label,MAX_SOFTWARE_INFO_CNT,0);
    label = new QLabel(this);
    strTemp.sprintf("%.2f",firmver);
    label->setText(strTemp);
    ui->gridLayout_info->addWidget(label,MAX_SOFTWARE_INFO_CNT,1);

}

void ConfigInfoDlg::loadHotlineChefInfo(){
    QString strTemp;
    QMap<QString , QString> mapInfos;
    QLabel* label;


//Default Value;
    mapInfos[tr("연 락 처")] = "010-3004-6517";
    mapInfos[tr("이       름")] = "김성우";
    mapInfos[tr("위치정보")] ="인천광역시 남동구 남동동로 34번길 56";

   FileProcessor::readFromInfoFile(mapInfos, QString(CHEF_INFO_FILE_NAME));

    for(int i =0;i<MAX_HOTLINE_CHEF_CNT;i++){
        strTemp = mapInfos[tr(hotline_chef_item_name[i])];
        label = new QLabel(this);
        label ->setText(tr(hotline_chef_item_name[i]).append(":"));
        ui->gridLayout_info->addWidget(label,i,0);
        label = new QLabel(this);
        label->setWordWrap(true);
        label->setText(strTemp);
        ui->gridLayout_info->addWidget(label,i,1);
    }
}

void ConfigInfoDlg::loadHotlineServiceInfo(){
    QString strTemp;
    QMap<QString , QString> mapInfos;
    QLabel* label;

//Default Value
    mapInfos[tr("연 락 처")] = "1644-9533";
    mapInfos[tr("위치정보")] ="인천광역시 남동구 남동동로 34번길 56";

    FileProcessor::readFromInfoFile(mapInfos, SERVICE_INFO_FILE_NAME);

    for(int i =0;i<MAX_HOTLINE_SERVICE_CNT;i++){
        strTemp = mapInfos[tr(hotline_service_item_name[i])];
        label = new QLabel(this);
        label ->setText(tr(hotline_service_item_name[i]).append(":"));
        ui->gridLayout_info->addWidget(label,i,0);
        label = new QLabel(this);
        label->setWordWrap(true);
        label->setText(strTemp);
        ui->gridLayout_info->addWidget(label,i,1);
    }
}

void ConfigInfoDlg::keyPressEvent(QKeyEvent */*event*/){

}

void ConfigInfoDlg::keyReleaseEvent(QKeyEvent *event){
    switch (event->key())
    {
    case 0x01000031:    // Push
    {
        QPushButton *btn = qobject_cast<QPushButton*>(focusWidget());
        if(btn != NULL){
            btn->click();
        }
        break;
    }
    }
}