Blame view

app/gui/oven_control/configbacklightdlg.cpp 4.51 KB
92fef6124   고영탁   환경 설정 - 설정 UI 완료
1
2
3
  #include "configbacklightdlg.h"
  #include "ui_configbacklightdlg.h"
  #include "config.h"
66e60ceb5   김태훈   모든 버튼에 음향 효과 추가
4
  #include "soundplayer.h"
92fef6124   고영탁   환경 설정 - 설정 UI 완료
5
a9841cd3c   김태훈   밝기 조절 설정 중에도 화면 밝...
6
  #include "backlight.h"
92fef6124   고영탁   환경 설정 - 설정 UI 완료
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  using namespace Define;
  
  #define MAX_LIGHT 7
  #define MIN_LIGHT 0
  
  ConfigBackLightDlg::ConfigBackLightDlg(QWidget *parent) :
      QDialog(parent),
      ui(new Ui::ConfigBackLightDlg)
  {
      Config* cfg = Config::getInstance();
      Define::config_item item;
      ui->setupUi(this);
      this->setWindowFlags( Qt::FramelessWindowHint);
      this->setAttribute( Qt::WA_DeleteOnClose);
40f5d047f   고영탁   엔코더 작업 진행 중
21
22
      qApp->setActiveWindow(this);
      this->setFocus();
66e60ceb5   김태훈   모든 버튼에 음향 효과 추가
23
24
25
  
      foreach (QPushButton *button, findChildren<QPushButton *>())
          connect(button, &QPushButton::pressed, SoundPlayer::playClick);
92fef6124   고영탁   환경 설정 - 설정 UI 완료
26
27
28
29
30
      showFullScreen();
      item = cfg->getConfigValue(config_backlight);
      m_nSelBackLight = item.d32;
      ui->ctrProgressLight->setMaxProgress(0,MAX_LIGHT);
      ui->ctrProgressLight->setCurrentProgress(m_nSelBackLight);
40f5d047f   고영탁   엔코더 작업 진행 중
31
32
33
34
35
      m_vectorTabOrder.append(this);
      m_vectorTabOrder.append(ui->ctrBtnPlus);
      m_vectorTabOrder.append(ui->ctrBtnMinus);
      m_vectorTabOrder.append(ui->ctrBtnOk);
      m_vectorTabOrder.append(ui->ctrBtnCancel);
92fef6124   고영탁   환경 설정 - 설정 UI 완료
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  }
  
  ConfigBackLightDlg::~ConfigBackLightDlg()
  {
      delete ui;
  }
  
  void ConfigBackLightDlg::on_ctrBtnOk_clicked()
  {
      Config* cfg = Config::getInstance();
      config_item item;
      item.d32 = m_nSelBackLight;
      cfg->setConfigValue(config_backlight,item);
      accept();
  }
  
  
  
  void ConfigBackLightDlg::on_ctrBtnCancel_clicked()
  {
a9841cd3c   김태훈   밝기 조절 설정 중에도 화면 밝...
56
57
58
59
      Config* cfg = Config::getInstance();
      config_item item;
      item = cfg->getConfigValue(config_backlight);
      Backlight::set(item.d32);
92fef6124   고영탁   환경 설정 - 설정 UI 완료
60
61
62
63
64
65
66
67
68
69
70
71
72
      reject();
  }
  
  void ConfigBackLightDlg::on_pushButton_clicked()
  {
  
  }
  
  void ConfigBackLightDlg::on_ctrBtnPlus_clicked()
  {
      //minus button;
      m_nSelBackLight = m_nSelBackLight>0?m_nSelBackLight-1:0;
      ui->ctrProgressLight->setCurrentProgress(m_nSelBackLight);
a9841cd3c   김태훈   밝기 조절 설정 중에도 화면 밝...
73
74
  
      Backlight::set(m_nSelBackLight);
92fef6124   고영탁   환경 설정 - 설정 UI 완료
75
76
77
78
79
80
81
82
  }
  
  
  
  void ConfigBackLightDlg::on_ctrBtnMinus_clicked()
  {
      m_nSelBackLight = m_nSelBackLight<7?m_nSelBackLight+1:7;
      ui->ctrProgressLight->setCurrentProgress(m_nSelBackLight);
a9841cd3c   김태훈   밝기 조절 설정 중에도 화면 밝...
83
84
  
      Backlight::set(m_nSelBackLight);
92fef6124   고영탁   환경 설정 - 설정 UI 완료
85
  }
40f5d047f   고영탁   엔코더 작업 진행 중
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
  
  void ConfigBackLightDlg::keyPressEvent(QKeyEvent *event){
      int i = 0;
      switch (event->key())
      {
      case 0x01000030:    // Turn left
          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;
      case 0x01000032:    // Turn right
          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 ConfigBackLightDlg::keyReleaseEvent(QKeyEvent *event){
      int i = 0;
      switch (event->key())
      {
      case 0x01000030:    // Turn left
          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;
      }
      case 0x01000032:    // Turn right
          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;
      }
  }