configwindow.cpp
11 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
#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"
#include "configdatetimedlg.h"
#include "servicepassinputdlg.h"
#include "fileprocessor.h"
#include "soundplayer.h"
#include "washwindow.h"
#include "mainwindow.h"
#include "configdoormonitoring.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);
foreach (QPushButton *button, findChildren<QPushButton *>())
connect(button, &QPushButton::pressed, SoundPlayer::playClick);
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::prevFocus(){
int i = 0;
for(i = 0; i < m_vectorTabOrder.size();i++){
if(focusWidget() == m_vectorTabOrder[i]) break;
}
if(i==0){
i = m_vectorTabOrder.size()-1;
m_vectorTabOrder[i]->setFocus();
}
else if(i < m_vectorTabOrder.size()) {
i = i - 1;
m_vectorTabOrder[i]->setFocus();
}
else{
i=0;
m_vectorTabOrder[i]->setFocus();
}
}
void ConfigWindow::nextFocus(){
int i = 0;
for(i = 0; i < m_vectorTabOrder.size();i++){
if(focusWidget() == m_vectorTabOrder[i]) break;
}
if(i<m_vectorTabOrder.size()-1){
i+=1;
m_vectorTabOrder[i]->setFocus();
}
else if(i== (m_vectorTabOrder.size()-1)){
i=0;
m_vectorTabOrder[i]->setFocus();
}
else{
i=0;
m_vectorTabOrder[i]->setFocus();
}
return;
}
void ConfigWindow::keyReleaseEvent(QKeyEvent *event){
switch (event->key())
{
case 0x01000030: // Turn left
prevFocus();
ui->scrollArea->ensureWidgetVisible(m_vectorTabOrder[m_nTabIndex]);
break;
case 0x01000031: // Push
{
QPushButton *btn = qobject_cast<QPushButton*>(focusWidget());
if(btn != NULL){
btn->click();
}
qDebug() << "pushed ";
break;
}
case 0x01000032: // Turn right
nextFocus();
ui->scrollArea->ensureWidgetVisible(focusWidget());
qDebug() << "Turn Right";
break;
}
}
void ConfigWindow::keyPressEvent(QKeyEvent *event){
switch (event->key())
{
case 0x01000030: // Turn left
prevFocus();
ui->scrollArea->ensureWidgetVisible(focusWidget());
qDebug() << "turn left";
break;
case 0x01000031: // Push
qDebug() << "pushed ";
break;
case 0x01000032: // Turn right
nextFocus();
ui->scrollArea->ensureWidgetVisible(focusWidget());
qDebug() << "Turn Right";
break;
}
}
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();
}
cfg->applyConfig();
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;
QWidget *focusedWidget = focusWidget();
switch(id){
case config_loading_door_monitoring:
case config_cooking_door_monitoring:
ConfigDoorMonitoring* wnd;
wnd = new ConfigDoorMonitoring(this,(ConfigType) id);
connect(wnd,SIGNAL(destroyed(QObject*)),this,SLOT(reloadValue()));
wnd->setWindowModality(Qt::WindowModal);
wnd->showFullScreen();
qDebug() << "closed window";
break;
case config_datetime:
dlg = new ConfigDateTimeDlg(this);
dlg->exec();
if(m_nCurConfigPos != config_menu_favorite) reloadValue();
break;
case config_enter_engineer_mode:
{
dlg = new ServicePassInputDlg(this);
dlg->exec();
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;
}
focusedWidget->setFocus();
}
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();
m_vectorTabOrder.clear();
m_vectorTabOrder.append(this);
m_vectorTabOrder.append(ui->pushButton);
m_vectorTabOrder.append(ui->pushButton_8);
m_vectorTabOrder.append(ui->pushButton_7);
m_vectorTabOrder.append(ui->pushButton_2);
m_vectorTabOrder.append(ui->pushButton_4);
m_vectorTabOrder.append(ui->pushButton_5);
m_vectorTabOrder.append(ui->pushButton_6);
m_vectorTabOrder.append(ui->pushButton_3);
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]));
m_vectorTabOrder.append(pcb->getFavoriteBtn());
m_vectorTabOrder.append(pcb->getBtn());
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);
m_vectorTabOrder.append(fpcb->getBtn());
m_vectorTabOrder.append(fpcb->getDelBtn());
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)));
}
}
m_vectorTabOrder.append(ui->backButton);
m_vectorTabOrder.append(ui->washButton);
m_vectorTabOrder.append(ui->helpButton);
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);
}
}
}
void ConfigWindow::on_washButton_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();
}
cfg->applyConfig();
WashWindow *w = new WashWindow(MainWindow::getInstance());
w->setWindowModality(Qt::WindowModal);
w->showFullScreen();
w->raise();
MainWindow::jump(w);
}
void ConfigWindow::on_helpButton_clicked()
{
}