configinfodlg.cpp
5.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#include <QMap>
#include <QLabel>
#include <QDebug>
#include "configinfodlg.h"
#include "ui_configinfodlg.h"
#include "soundplayer.h"
#include "config.h"
#include "define.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<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();
}
bool ConfigInfoDlg::readFromInfoFile(QMap<QString, QString> &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())).remove(QChar('\n'));
info_map[line.section(',',0,0)] = line.section(',',1,1);
}
qDebug() << file.fileName() << "read OK!";
qDebug() << "final size " << info_map.size();
QList<QString> list = info_map.keys();
for(int i=0; i< info_map.size() ;i++){
qDebug() << list[i] << info_map[list[i]];
}
return true;
}
else {
qDebug() << file.fileName() + " file not found";
}
return false;
}
QString ConfigInfoDlg::getSoftwareVerString()
{
if(MAJOR_VER == 0)
return QString("V%1.%2.%3 BETA").arg(MAJOR_VER).arg(MINOR_VER).arg(HOTFIX_VER);
else return QString("V%1.%2.%3").arg(MAJOR_VER).arg(MINOR_VER).arg(HOTFIX_VER);
}
void ConfigInfoDlg::loadSoftwareInfo(){
Config* cfg = Config::getInstance();
QString strTemp;
QMap<QString , QString> mapInfos;
QLabel* label;
//Default Value;
mapInfos[tr("모 델 명")] = "PRIME ST-01";
mapInfos[tr("제조일자")] = "2017-06";
mapInfos[tr("제조국")] = "Korea";
mapInfos[tr("제조사")] = "프라임";
mapInfos[tr("제품번호")] = "01";
mapInfos[tr("소프트웨어 버전")] = getSoftwareVerString();
mapInfos[tr("현재모델")] = tr(g_strModelTypeName[cfg->getConfigValue(Define::config_model).d32]);
readFromInfoFile(mapInfos, QString(MODEL_INFO_FILE_NAME));
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);
}
}
void ConfigInfoDlg::loadHotlineChefInfo(){
QString strTemp;
QMap<QString , QString> 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;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";
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;
}
}
}