configwindow.cpp
6.74 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#include <QList>
#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"
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()
{
if(m_nCurConfigPos != config_menu_favorite){
m_nCurConfigPos = config_menu_favorite;
reloadUi();
}
}
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();
}
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;i<m_vectorMenuList.count();i++){
strtemp = cfg->getValueString(m_arrConfigListInfos[m_nCurConfigPos][i]);
m_vectorMenuList[i]->setValue(strtemp);
}
}
void ConfigWindow::onConfigBtnClicked(uint16_t id){
Config *cfg = Config::getInstance();
QDialog* dlg;
switch(id){
case config_enter_engineer_mode:
{
EngineerMenuWindow *w = new EngineerMenuWindow(this);
w->setWindowModality(Qt::WindowModal);
w->showFullScreen();
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;
}
}
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);
delete pw;
}
m_vectorMenuList.clear();
for(i=0;i<m_vectorFavorMenuList.count();i++){
fpw = fpws[i];
ui->scrollAreaMenuLayout->removeWidget(fpw);
delete fpw;
}
m_vectorFavorMenuList.clear();
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() <<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)));
connect(pcb,SIGNAL(checkButtonClicked(uint16_t,bool)),SLOT(onConfigCheckBtnClicked(uint16_t,bool)));
}
}
else{
QList<uint32_t> 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);
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)));
}
}
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;
for(int i = 0;i<m_vectorFavorMenuList.count();i++){
if(m_vectorFavorMenuList[i]->getBtnId() == id){
btn = m_vectorFavorMenuList[i];
ui->scrollAreaMenuLayout->removeWidget(btn);
m_vectorFavorMenuList.remove(i);
delete btn;
cfg->removeFavorite((ConfigType)id);
}
}
}