Blame view

app/gui/oven_control/configipdlg.cpp 6.34 KB
63a45681f   고영탁   엔코더 기능 구현
1
  #include <QKeyEvent>
776411ce5   고영탁   설정 기능 5월 개발 범위 UI...
2
3
  #include "configipdlg.h"
  #include "ui_configipdlg.h"
3130d4416   고영탁   IP설정 추가
4
  #include "config.h"
66e60ceb5   김태훈   모든 버튼에 음향 효과 추가
5
  #include "soundplayer.h"
3130d4416   고영탁   IP설정 추가
6
7
  
  using namespace Define;
776411ce5   고영탁   설정 기능 5월 개발 범위 UI...
8
9
10
11
12
13
14
15
16
  
  ConfigIpDlg::ConfigIpDlg(QWidget *parent) :
      QDialog(parent),
      ui(new Ui::ConfigIpDlg)
  {
      ui->setupUi(this);
      setWindowFlags(Qt::FramelessWindowHint);
      setAttribute(Qt::WA_NoSystemBackground);
      setAttribute(Qt::WA_TranslucentBackground);
63a45681f   고영탁   엔코더 기능 구현
17
18
      qApp->setActiveWindow(this);
      this->setFocus();
66e60ceb5   김태훈   모든 버튼에 음향 효과 추가
19
20
21
  
      foreach (QPushButton *button, findChildren<QPushButton *>())
          connect(button, &QPushButton::pressed, SoundPlayer::playClick);
776411ce5   고영탁   설정 기능 5월 개발 범위 UI...
22
23
24
25
26
27
28
29
30
31
32
33
      ui->ctrGw_0->setFormatterWidth(3);
      ui->ctrGw_1->setFormatterWidth(3);
      ui->ctrGw_2->setFormatterWidth(3);
      ui->ctrGw_3->setFormatterWidth(3);
      ui->ctrIp_0->setFormatterWidth(3);
      ui->ctrIp_1->setFormatterWidth(3);
      ui->ctrIp_2->setFormatterWidth(3);
      ui->ctrIp_3->setFormatterWidth(3);
      ui->ctrNetmask_0->setFormatterWidth(3);
      ui->ctrNetmask_1->setFormatterWidth(3);
      ui->ctrNetmask_2->setFormatterWidth(3);
      ui->ctrNetmask_3->setFormatterWidth(3);
3130d4416   고영탁   IP설정 추가
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  
      Config* cfg = Config::getInstance();
  
      config_item temp;
      temp = cfg->getConfigValue(config_ip);
      ui->ctrIp_0->setValue(temp.d8.d8_0);
      ui->ctrIp_1->setValue(temp.d8.d8_1);
      ui->ctrIp_2->setValue(temp.d8.d8_2);
      ui->ctrIp_3->setValue(temp.d8.d8_3);
  
      temp = cfg->getConfigValue(config_gateway);
      ui->ctrGw_0->setValue(temp.d8.d8_0);
      ui->ctrGw_1->setValue(temp.d8.d8_1);
      ui->ctrGw_2->setValue(temp.d8.d8_2);
      ui->ctrGw_3->setValue(temp.d8.d8_3);
  
      temp = cfg->getConfigValue(config_netmask);
      ui->ctrNetmask_0->setValue(temp.d8.d8_0);
      ui->ctrNetmask_1->setValue(temp.d8.d8_1);
      ui->ctrNetmask_2->setValue(temp.d8.d8_2);
      ui->ctrNetmask_3->setValue(temp.d8.d8_3);
63a45681f   고영탁   엔코더 기능 구현
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
      connect(ui->keyboardwidget, SIGNAL(onOkKeyClicked()), this, SLOT(keyEnter_clicked()));
      connect(ui->keyboardwidget, SIGNAL(onCancelKeyClicked()), this, SLOT(keyCancel_clicked()));
  
      m_pSignalMapper = new QSignalMapper(this);
  
      m_pSignalMapper->setMapping(ui->ctrIp_0,ui->ctrIp_0);
      m_pSignalMapper->setMapping(ui->ctrIp_1,ui->ctrIp_1);
      m_pSignalMapper->setMapping(ui->ctrIp_2,ui->ctrIp_2);
      m_pSignalMapper->setMapping(ui->ctrIp_3,ui->ctrIp_3);
      m_pSignalMapper->setMapping(ui->ctrGw_0,ui->ctrGw_0);
      m_pSignalMapper->setMapping(ui->ctrGw_1,ui->ctrGw_1);
      m_pSignalMapper->setMapping(ui->ctrGw_2,ui->ctrGw_2);
      m_pSignalMapper->setMapping(ui->ctrGw_3,ui->ctrGw_3);
      m_pSignalMapper->setMapping(ui->ctrNetmask_0,ui->ctrNetmask_0);
      m_pSignalMapper->setMapping(ui->ctrNetmask_1,ui->ctrNetmask_1);
      m_pSignalMapper->setMapping(ui->ctrNetmask_2,ui->ctrNetmask_2);
      m_pSignalMapper->setMapping(ui->ctrNetmask_3,ui->ctrNetmask_3);
  
      connect(ui->ctrGw_0,SIGNAL(focusInEdit()),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrGw_1,SIGNAL(focusInEdit()),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrGw_2,SIGNAL(focusInEdit()),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrGw_3,SIGNAL(focusInEdit()),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrIp_0,SIGNAL(focusInEdit()),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrIp_1,SIGNAL(focusInEdit()),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrIp_2,SIGNAL(focusInEdit()),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrIp_3,SIGNAL(focusInEdit()),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrNetmask_0,SIGNAL(focusInEdit()),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrNetmask_1,SIGNAL(focusInEdit()),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrNetmask_2,SIGNAL(focusInEdit()),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrNetmask_3,SIGNAL(focusInEdit()),m_pSignalMapper, SLOT(map()));
  
      connect(m_pSignalMapper, SIGNAL(mapped(QWidget*)), this, SLOT(focusInSpinBox(QWidget*)));
776411ce5   고영탁   설정 기능 5월 개발 범위 UI...
87
88
89
90
91
92
93
94
95
  }
  
  ConfigIpDlg::~ConfigIpDlg()
  {
      delete ui;
  }
  
  void ConfigIpDlg::on_ctrBtnOk_clicked()
  {
3130d4416   고영탁   IP설정 추가
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
      Config* cfg = Config::getInstance();
      config_item temp;
  
      temp.d8.d8_0 = (uint8_t)ui->ctrIp_0->value();
      temp.d8.d8_1 = (uint8_t)ui->ctrIp_1->value();
      temp.d8.d8_2 = (uint8_t)ui->ctrIp_2->value();
      temp.d8.d8_3 = (uint8_t)ui->ctrIp_3->value();
      cfg->setConfigValue(config_ip, temp);
  
      temp.d8.d8_0 = (uint8_t)ui->ctrGw_0->value();
      temp.d8.d8_1 = (uint8_t)ui->ctrGw_1->value();
      temp.d8.d8_2 = (uint8_t)ui->ctrGw_2->value();
      temp.d8.d8_3 = (uint8_t)ui->ctrGw_3->value();
      cfg->setConfigValue(config_gateway, temp);
  
      temp.d8.d8_0 = (uint8_t)ui->ctrNetmask_0->value();
      temp.d8.d8_1 = (uint8_t)ui->ctrNetmask_1->value();
      temp.d8.d8_2 = (uint8_t)ui->ctrNetmask_2->value();
      temp.d8.d8_3 = (uint8_t)ui->ctrNetmask_3->value();
      cfg->setConfigValue(config_netmask, temp);
776411ce5   고영탁   설정 기능 5월 개발 범위 UI...
116
117
118
119
120
121
122
      accept();
  }
  
  void ConfigIpDlg::on_ctrBtnCancel_clicked()
  {
      reject();
  }
63a45681f   고영탁   엔코더 기능 구현
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
  
  void ConfigIpDlg::focusInSpinBox(QWidget *widget){
      QSpinBox *spbx = qobject_cast<QSpinBox*>(widget);
      if(spbx != NULL){
          m_nFocusValue = spbx->value();
      }
  }
  
  void ConfigIpDlg::keyPressEvent(QKeyEvent *event){
      switch (event->key())
      {
      case 0x01000030:    // Turn left
          if(focusWidget() == ui->ctrIp_0) ui->ctrBtnCancel->setFocus();
          else focusPreviousChild();
          break;
      case 0x01000031:    // Push
  
          break;
      case 0x01000032:    // Turn right
          if(focusWidget() == ui->ctrBtnCancel) ui->ctrIp_0->setFocus();
          else focusNextChild();
  
          break;
      }
  }
  
  void ConfigIpDlg::keyReleaseEvent(QKeyEvent *event){
      switch (event->key())
      {
      case 0x01000030:    // Turn left
          if(focusWidget() == ui->ctrIp_0) ui->ctrBtnCancel->setFocus();
          else focusPreviousChild();
          break;
      case 0x01000031:    // Push
      {
          QPushButton *btn = qobject_cast<QPushButton*>(focusWidget());
          if(btn != NULL){
              btn->click();
          }
          else{
              QSpinBox *spbx = qobject_cast<QSpinBox*>(focusWidget());
              if(spbx != NULL) ui->keyboardwidget->focusInKeyboard();
          }
          break;
      }
      case 0x01000032:    // Turn right
          if(focusWidget() == ui->ctrBtnCancel) ui->ctrIp_0->setFocus();
          else focusNextChild();
          break;
      }
  }
  
  void ConfigIpDlg::keyCancel_clicked(){
      QSpinBox *spbx = qobject_cast<QSpinBox*>(focusWidget());
      if(spbx != NULL){
          spbx->setValue(m_nFocusValue);
      }
      ui->keyboardwidget->focusOutKeyboard();
  }
  
  void ConfigIpDlg::keyEnter_clicked(){
       ui->keyboardwidget->focusOutKeyboard();
  }