#include #include #include #include "configinfodlg.h" #include "ui_configinfodlg.h" #include "soundplayer.h" #include "config.h" static const char* g_strModelTypeName[] ={ QT_TRANSLATE_NOOP("ConfigInfoDlg", "전기식 10단"), QT_TRANSLATE_NOOP("ConfigInfoDlg", "전기식 20단"), QT_TRANSLATE_NOOP("ConfigInfoDlg", "전기식 24단"), QT_TRANSLATE_NOOP("ConfigInfoDlg", "전기식 40단"), QT_TRANSLATE_NOOP("ConfigInfoDlg", "가스식 10단 LPG"), QT_TRANSLATE_NOOP("ConfigInfoDlg", "가스식 20단 LPG"), QT_TRANSLATE_NOOP("ConfigInfoDlg", "가스식 24단 LPG"), QT_TRANSLATE_NOOP("ConfigInfoDlg", "가스식 40단 LPG"), QT_TRANSLATE_NOOP("ConfigInfoDlg", "가스식 10단 LNG"), QT_TRANSLATE_NOOP("ConfigInfoDlg", "가스식 20단 LNG"), QT_TRANSLATE_NOOP("ConfigInfoDlg", "가스식 24단 LNG"), QT_TRANSLATE_NOOP("ConfigInfoDlg", "가스식 40단 LNG") }; 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()) 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(); } bool ConfigInfoDlg::readFromInfoFile(QMap &info_map, const QString &filename){ QFile file(filename); QString label,value; qDebug() << "orgin size " << info_map.size(); if(file.open(QIODevice::ReadOnly | QIODevice::Text)){ while(!file.atEnd()){ QString line = QString::fromUtf8(file.readLine()); info_map[line.section(',',0,0)] = line.section(',',1,1); } qDebug() << file.fileName() << "read OK!"; qDebug() << "final size " << info_map.size(); return true; } else { qDebug() << file.fileName() + " file not found"; } return false; } void ConfigInfoDlg::loadSoftwareInfo(){ Config* cfg = Config::getInstance(); QString strTemp; QMap mapInfos; QLabel* label; //Default Value; mapInfos[tr("모 델 명")] = "PRIME ST-01"; mapInfos[tr("제조일자")] = "2017-06"; mapInfos[tr("제조국")] = "Korea"; mapInfos[tr("제조사")] = "프라임"; mapInfos[tr("제품번호")] = "01"; mapInfos[tr("소프트웨어 버전")] ="0.1 BETA"; mapInfos[tr("현재모델")] = tr(g_strModelTypeName[cfg->getConfigValue(Define::config_model).d32]); readFromInfoFile(mapInfos, QString(MODEL_INFO_FILE_NAME)); for(int i =0;isetText(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); } } void ConfigInfoDlg::loadHotlineChefInfo(){ QString strTemp; QMap mapInfos; QLabel* label; //Default Value; mapInfos[tr("연 락 처")] = "010-3004-6517"; mapInfos[tr("이 름")] = "김성우"; mapInfos[tr("위치정보")] ="인천광역시 남동구 남동동로 34번길 56"; readFromInfoFile(mapInfos, QString(CHEF_INFO_FILE_NAME)); for(int i =0;isetText(tr(hotline_chef_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); } } void ConfigInfoDlg::loadHotlineServiceInfo(){ QString strTemp; QMap mapInfos; QLabel* label; //Default Value mapInfos[tr("연 락 처")] = "1644-9533"; mapInfos[tr("위치정보")] ="인천광역시 남동구 남동동로 34번길 56"; readFromInfoFile(mapInfos, SERVICE_INFO_FILE_NAME); for(int i =0;isetText(tr(hotline_service_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); } } void ConfigInfoDlg::keyPressEvent(QKeyEvent */*event*/){ } void ConfigInfoDlg::keyReleaseEvent(QKeyEvent *event){ switch (event->key()) { case 0x01000031: // Push { QPushButton *btn = qobject_cast(focusWidget()); if(btn != NULL){ btn->click(); } break; } } }