Blame view

app/gui/oven_control/configsoundselelectdlg.cpp 7.12 KB
937409186   고영탁   config enum 설정 진행...
1
  #include <QDebug>
92fef6124   고영탁   환경 설정 - 설정 UI 완료
2
3
  #include "configsoundselelectdlg.h"
  #include "ui_configsoundselelectdlg.h"
66e60ceb5   김태훈   모든 버튼에 음향 효과 추가
4
  #include "soundplayer.h"
92fef6124   고영탁   환경 설정 - 설정 UI 완료
5
937409186   고영탁   config enum 설정 진행...
6
92fef6124   고영탁   환경 설정 - 설정 UI 완료
7
8
9
10
  ConfigSoundSelelectDlg::ConfigSoundSelelectDlg(QWidget *parent, ConfigType cfgtype) :
      QDialog(parent),
      ui(new Ui::ConfigSoundSelelectDlg)
  {
937409186   고영탁   config enum 설정 진행...
11
      QString strTemp;
92fef6124   고영탁   환경 설정 - 설정 UI 완료
12
13
14
      Config* cfg = Config::getInstance();
      config_item item;
      ui->setupUi(this);
937409186   고영탁   config enum 설정 진행...
15
16
17
      setWindowFlags(Qt::Widget | Qt::FramelessWindowHint);
      setAttribute(Qt::WA_NoSystemBackground);
      setAttribute(Qt::WA_TranslucentBackground);
40f5d047f   고영탁   엔코더 작업 진행 중
18
19
      qApp->setActiveWindow(this);
      this->setFocus();
92fef6124   고영탁   환경 설정 - 설정 UI 완료
20
66e60ceb5   김태훈   모든 버튼에 음향 효과 추가
21
22
      foreach (QPushButton *button, findChildren<QPushButton *>())
          connect(button, &QPushButton::pressed, SoundPlayer::playClick);
937409186   고영탁   config enum 설정 진행...
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
      this->setAttribute( Qt::WA_DeleteOnClose);
  
  
      m_nCfgType = cfgtype;
  
      ui->pushButton_1->setText(tr("Media 01"));
      ui->pushButton_2->setText(tr("Media 02"));
      ui->pushButton_3->setText(tr("Media 03"));
      ui->pushButton_4->setText(tr("Media 04"));
      ui->pushButton_5->setText(tr("Media 05"));
      ui->pushButton_6->setText(tr("Media 06"));
      ui->pushButton_7->setText(tr("Media 07"));
      ui->pushButton_8->setText(tr("Media 08"));
      ui->pushButton_9->setText(tr("Media 09"));
      ui->pushButton_10->setText(tr("Media 10"));
  
      strTemp = cfg->getTitleString(cfgtype);
  
      ui->ctrLbTitle->setText(strTemp);
  
  
      item = cfg->getConfigValue(cfgtype);
  
     m_nCurSel = item.d32;
     qDebug() << "m_nCurSel is " << m_nCurSel;
92fef6124   고영탁   환경 설정 - 설정 UI 완료
48
92fef6124   고영탁   환경 설정 - 설정 UI 완료
49
      reloadUi();
937409186   고영탁   config enum 설정 진행...
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
  
      m_pSignalMapper = new QSignalMapper(this);
      m_pSignalMapper->setMapping(ui->pushButton_1,0);
      m_pSignalMapper->setMapping(ui->pushButton_2,1);
      m_pSignalMapper->setMapping(ui->pushButton_3,2);
      m_pSignalMapper->setMapping(ui->pushButton_4,3);
      m_pSignalMapper->setMapping(ui->pushButton_5,4);
      m_pSignalMapper->setMapping(ui->pushButton_6,5);
      m_pSignalMapper->setMapping(ui->pushButton_7,6);
      m_pSignalMapper->setMapping(ui->pushButton_8,7);
      m_pSignalMapper->setMapping(ui->pushButton_9,8);
      m_pSignalMapper->setMapping(ui->pushButton_10,9);
  
  
      connect(ui->pushButton_1,SIGNAL(clicked(bool)),m_pSignalMapper,SLOT(map()));
      connect(ui->pushButton_2,SIGNAL(clicked(bool)),m_pSignalMapper,SLOT(map()));
      connect(ui->pushButton_3,SIGNAL(clicked(bool)),m_pSignalMapper,SLOT(map()));
      connect(ui->pushButton_4,SIGNAL(clicked(bool)),m_pSignalMapper,SLOT(map()));
      connect(ui->pushButton_5,SIGNAL(clicked(bool)),m_pSignalMapper,SLOT(map()));
      connect(ui->pushButton_6,SIGNAL(clicked(bool)),m_pSignalMapper,SLOT(map()));
      connect(ui->pushButton_7,SIGNAL(clicked(bool)),m_pSignalMapper,SLOT(map()));
      connect(ui->pushButton_8,SIGNAL(clicked(bool)),m_pSignalMapper,SLOT(map()));
      connect(ui->pushButton_9,SIGNAL(clicked(bool)),m_pSignalMapper,SLOT(map()));
      connect(ui->pushButton_10,SIGNAL(clicked(bool)),m_pSignalMapper,SLOT(map()));
  
      connect(m_pSignalMapper,SIGNAL(mapped(int)),this,SLOT(onConfigBtnClicked(int)));
40f5d047f   고영탁   엔코더 작업 진행 중
76
77
78
79
80
81
82
83
84
85
86
87
88
  
      m_vectorTabOrder.append(ui->pushButton_1);
      m_vectorTabOrder.append(ui->pushButton_2);
      m_vectorTabOrder.append(ui->pushButton_3);
      m_vectorTabOrder.append(ui->pushButton_4);
      m_vectorTabOrder.append(ui->pushButton_5);
      m_vectorTabOrder.append(ui->pushButton_6);
      m_vectorTabOrder.append(ui->pushButton_7);
      m_vectorTabOrder.append(ui->pushButton_8);
      m_vectorTabOrder.append(ui->pushButton_9);
      m_vectorTabOrder.append(ui->pushButton_10);
      m_vectorTabOrder.append(ui->ctrBtnOk);
      m_vectorTabOrder.append(ui->ctrBtnCancel);
92fef6124   고영탁   환경 설정 - 설정 UI 완료
89
90
91
92
93
94
95
96
97
  }
  
  ConfigSoundSelelectDlg::~ConfigSoundSelelectDlg()
  {
      delete ui;
  }
  
  void ConfigSoundSelelectDlg::on_ctrBtnOk_clicked()
  {
937409186   고영탁   config enum 설정 진행...
98
99
100
101
102
      Config* cfg = Config::getInstance();
      config_item item;
      item.d32 = m_nCurSel;
      qDebug() << item.d32 << "cur sel  " << m_nCurSel;
      cfg->setConfigValue(m_nCfgType,item);
92fef6124   고영탁   환경 설정 - 설정 UI 완료
103
104
105
106
107
108
109
110
111
112
      accept();
  }
  
  void ConfigSoundSelelectDlg::on_ctrBtnCancel_clicked()
  {
      reject();
  }
  
  void ConfigSoundSelelectDlg::reloadUi(){
      switch(m_nCurSel){
937409186   고영탁   config enum 설정 진행...
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
      case 1:
          ui->pushButton_2->setChecked(true);
          break;
      case 2:
          ui->pushButton_3->setChecked(true);
          break;
      case 3:
          ui->pushButton_4->setChecked(true);
          break;
      case 4:
          ui->pushButton_5->setChecked(true);
          break;
      case 5:
          ui->pushButton_6->setChecked(true);
          break;
      case 6:
          ui->pushButton_7->setChecked(true);
          break;
      case 7:
          ui->pushButton_8->setChecked(true);
          break;
      case 8:
          ui->pushButton_9->setChecked(true);
          break;
      case 9:
          ui->pushButton_10->setChecked(true);
          break;
92fef6124   고영탁   환경 설정 - 설정 UI 완료
140
      case 0:
937409186   고영탁   config enum 설정 진행...
141
142
      default:
          ui->pushButton_1->setChecked(true);
92fef6124   고영탁   환경 설정 - 설정 UI 완료
143
144
145
          break;
      }
  }
937409186   고영탁   config enum 설정 진행...
146
147
148
149
  
  void ConfigSoundSelelectDlg::onConfigBtnClicked(const int sel){
      m_nCurSel = sel;
  }
40f5d047f   고영탁   엔코더 작업 진행 중
150
151
152
153
154
155
  
  
  void ConfigSoundSelelectDlg::keyPressEvent(QKeyEvent *event){
      int i = 0;
      switch (event->key())
      {
01249f413   김태훈   엔코더 방향 반전. 하드웨어가 변경됨
156
      case 0x01000032:    // Turn left
40f5d047f   고영탁   엔코더 작업 진행 중
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
          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();
          }
          break;
      case 0x01000031:    // Push
  
          break;
01249f413   김태훈   엔코더 방향 반전. 하드웨어가 변경됨
177
      case 0x01000030:    // Turn right
40f5d047f   고영탁   엔코더 작업 진행 중
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
          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();
          }
          break;
      }
  }
  
  void ConfigSoundSelelectDlg::keyReleaseEvent(QKeyEvent *event){
      int i = 0;
      switch (event->key())
      {
01249f413   김태훈   엔코더 방향 반전. 하드웨어가 변경됨
202
      case 0x01000032:    // Turn left
40f5d047f   고영탁   엔코더 작업 진행 중
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
          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();
          }
          break;
      case 0x01000031:    // Push
      {
          QPushButton *btn = qobject_cast<QPushButton*>(focusWidget());
          if(btn != NULL){
              btn->click();
          }
          break;
      }
01249f413   김태훈   엔코더 방향 반전. 하드웨어가 변경됨
228
      case 0x01000030:    // Turn right
40f5d047f   고영탁   엔코더 작업 진행 중
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
          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();
          }
          break;
      }
  }