Blame view

app/gui/oven_control/mainwindow.cpp 5.61 KB
8c2952457   김태훈   응용 프로그램 추가
1
2
3
4
  #include "mainwindow.h"
  #include "ui_mainwindow.h"
  
  #include <QtDebug>
0ce283850   김태훈   로터리 엔코더 임시 구현
5
  #include <QKeyEvent>
8c2952457   김태훈   응용 프로그램 추가
6
ac60b5cec   김태훈   음향 효과 일부 적용 및 소스 ...
7
  #include "soundplayer.h"
8c2952457   김태훈   응용 프로그램 추가
8
  #include "manualcookwindow.h"
99b8066f4   김태훈   V0.1.1
9
  #include "autocookselectionwindow.h"
b85726132   김태훈   부가 기능 UI 추가
10
  #include "primewindow.h"
8a1db78e6   김태훈   소스 코드 정리
11
12
13
  #include "programmingwindow.h"
  #include "washwindow.h"
  #include "configwindow.h"
569d7a56c   김태훈   기능 구현
14
15
  #include "ovenstatics.h"
  #include "notipopupdlg.h"
2f6b55128   김태훈   다중 요리 구현
16
  #include "multicookwindow.h"
8c2952457   김태훈   응용 프로그램 추가
17
e00c6a2a9   김태훈   기능 추가 구현
18
  MainWindow *MainWindow::instance = NULL;
8c2952457   김태훈   응용 프로그램 추가
19
20
21
22
23
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui->setupUi(this);
0ce283850   김태훈   로터리 엔코더 임시 구현
24
2f6b55128   김태훈   다중 요리 구현
25
26
27
28
29
30
  #if MODEL_GRADE > 0
      ui->logo->hide();
  #else
      ui->multiButton->hide();
      ui->programmingButton->hide();
  #endif
e00c6a2a9   김태훈   기능 추가 구현
31
32
      instance = this;
      child = NULL;
0ce283850   김태훈   로터리 엔코더 임시 구현
33
      setFocus();
ac60b5cec   김태훈   음향 효과 일부 적용 및 소스 ...
34
35
36
37
38
39
40
  
      QList<QPushButton *> buttons = findChildren<QPushButton *>();
      foreach (QPushButton *button, buttons)
      {
          connect(button, &QPushButton::pressed, SoundPlayer::playClick);
          connect(button, SIGNAL(clicked()), SLOT(setFocus()));
      }
569d7a56c   김태훈   기능 구현
41
42
  
      QTimer::singleShot(0, this, SLOT(checkPrevWash()));
8c2952457   김태훈   응용 프로그램 추가
43
44
45
46
47
48
  }
  
  MainWindow::~MainWindow()
  {
      delete ui;
  }
e00c6a2a9   김태훈   기능 추가 구현
49
50
51
52
  void MainWindow::jump(QMainWindow *newChild)
  {
      if (instance->child)
          instance->child->deleteLater();
f97672f51   김태훈   현재 자식 창이 환경 설정 창이...
53
      instance->newChild(newChild);
e00c6a2a9   김태훈   기능 추가 구현
54
  }
7d0288172   김태훈   기능 추가 구현
55
56
57
58
  void MainWindow::killChild()
  {
      if (instance->child)
          instance->child->deleteLater();
f97672f51   김태훈   현재 자식 창이 환경 설정 창이...
59
  }
7d0288172   김태훈   기능 추가 구현
60
a7e8cc0aa   고영탁   버그 및 동작 개선
61
  bool MainWindow::killChildCook()
f97672f51   김태훈   현재 자식 창이 환경 설정 창이...
62
  {
a7e8cc0aa   고영탁   버그 및 동작 개선
63
f97672f51   김태훈   현재 자식 창이 환경 설정 창이...
64
      if (instance->child && !instance->child->inherits("ConfigWindow"))
a7e8cc0aa   고영탁   버그 및 동작 개선
65
66
67
      {
          qDebug() << "kill child";
          instance->child->hide();
f97672f51   김태훈   현재 자식 창이 환경 설정 창이...
68
          instance->child->deleteLater();
a7e8cc0aa   고영탁   버그 및 동작 개선
69
70
71
          return true;
      }
      else return false;
7d0288172   김태훈   기능 추가 구현
72
  }
0ce283850   김태훈   로터리 엔코더 임시 구현
73
74
75
76
  void MainWindow::keyPressEvent(QKeyEvent *event)
  {
      switch (event->key())
      {
01249f413   김태훈   엔코더 방향 반전. 하드웨어가 변경됨
77
      case 0x01000032:    // Turn left
8a1db78e6   김태훈   소스 코드 정리
78
          onEncoderLeft();
0ce283850   김태훈   로터리 엔코더 임시 구현
79
80
          break;
      case 0x01000031:    // Push
8a1db78e6   김태훈   소스 코드 정리
81
          pushed = focusWidget();
0ce283850   김태훈   로터리 엔코더 임시 구현
82
          break;
01249f413   김태훈   엔코더 방향 반전. 하드웨어가 변경됨
83
      case 0x01000030:    // Turn right
8a1db78e6   김태훈   소스 코드 정리
84
          onEncoderRight();
0ce283850   김태훈   로터리 엔코더 임시 구현
85
86
87
88
89
90
91
92
          break;
      }
  }
  
  void MainWindow::keyReleaseEvent(QKeyEvent *event)
  {
      switch (event->key())
      {
01249f413   김태훈   엔코더 방향 반전. 하드웨어가 변경됨
93
      case 0x01000032:    // Turn left
8a1db78e6   김태훈   소스 코드 정리
94
          onEncoderLeft();
0ce283850   김태훈   로터리 엔코더 임시 구현
95
96
          break;
      case 0x01000031:    // Push
8a1db78e6   김태훈   소스 코드 정리
97
98
          if (focusWidget() == pushed)
              onEncoderClicked(pushed);
0ce283850   김태훈   로터리 엔코더 임시 구현
99
8a1db78e6   김태훈   소스 코드 정리
100
          pushed = NULL;
0ce283850   김태훈   로터리 엔코더 임시 구현
101
          break;
01249f413   김태훈   엔코더 방향 반전. 하드웨어가 변경됨
102
      case 0x01000030:    // Turn right
8a1db78e6   김태훈   소스 코드 정리
103
          onEncoderRight();
0ce283850   김태훈   로터리 엔코더 임시 구현
104
105
106
          break;
      }
  }
8a1db78e6   김태훈   소스 코드 정리
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
  void MainWindow::onEncoderLeft()
  {
      focusPreviousChild();
  }
  
  void MainWindow::onEncoderRight()
  {
      focusNextChild();
  }
  
  void MainWindow::onEncoderClicked(QWidget *clicked)
  {
      QPushButton *b = qobject_cast<QPushButton *>(clicked);
      if (b)
          b->click();
  }
569d7a56c   김태훈   기능 구현
123
124
125
126
127
128
129
130
131
132
133
134
135
  void MainWindow::checkPrevWash()
  {
      if (OvenStatistics::getInstance()->loadWashState())
      {
          NotiPopupDlg *d = new NotiPopupDlg(this, tr("세척이 정상적으로 종료되지 않아
  반드시 세척통을 자동 세척해야 합니다.
  내부를 비워주세요"));
          d->setWindowModality(Qt::WindowModal);
          d->show();
  
          connect(d, SIGNAL(accepted()), SLOT(on_washButton_clicked()));
      }
  }
d0cfbd177   김태훈   GUI V0.1.10 (이 버전...
136
  void MainWindow::showManualCookWindow(Define::Mode mode)
538041ab9   김태훈   소스 코드 구조 개선
137
138
139
140
141
  {
      ManualCookWindow *w = new ManualCookWindow(this, mode);
      w->setWindowModality(Qt::WindowModal);
      w->showFullScreen();
      w->raise();
e00c6a2a9   김태훈   기능 추가 구현
142
f97672f51   김태훈   현재 자식 창이 환경 설정 창이...
143
      newChild(w);
538041ab9   김태훈   소스 코드 구조 개선
144
  }
3f52600cc   김태훈   소스 코드 구조 개선
145
146
147
148
149
150
  void MainWindow::showAutoCookSelectionWindow(Define::CookType type)
  {
      AutoCookSelectionWindow *w = new AutoCookSelectionWindow(this, type);
      w->setWindowModality(Qt::WindowModal);
      w->showFullScreen();
      w->raise();
e00c6a2a9   김태훈   기능 추가 구현
151
f97672f51   김태훈   현재 자식 창이 환경 설정 창이...
152
153
154
155
156
157
158
159
160
161
162
163
164
      newChild(w);
  }
  
  void MainWindow::newChild(QMainWindow *newChild)
  {
      child = newChild;
      connect(newChild, SIGNAL(destroyed(QObject*)), this, SLOT(onChildDestroyed(QObject*)));
  }
  
  void MainWindow::onChildDestroyed(QObject *destroyed)
  {
      if (destroyed == child)
          child = NULL;
3f52600cc   김태훈   소스 코드 구조 개선
165
  }
538041ab9   김태훈   소스 코드 구조 개선
166
  void MainWindow::on_steamButton_clicked()
8c2952457   김태훈   응용 프로그램 추가
167
  {
d0cfbd177   김태훈   GUI V0.1.10 (이 버전...
168
      showManualCookWindow(Define::SteamMode);
8c2952457   김태훈   응용 프로그램 추가
169
  }
538041ab9   김태훈   소스 코드 구조 개선
170
  void MainWindow::on_combiButton_clicked()
8c2952457   김태훈   응용 프로그램 추가
171
  {
d0cfbd177   김태훈   GUI V0.1.10 (이 버전...
172
      showManualCookWindow(Define::CombiMode);
538041ab9   김태훈   소스 코드 구조 개선
173
174
175
176
  }
  
  void MainWindow::on_dryheatButton_clicked()
  {
d0cfbd177   김태훈   GUI V0.1.10 (이 버전...
177
      showManualCookWindow(Define::DryMode);
8c2952457   김태훈   응용 프로그램 추가
178
  }
99b8066f4   김태훈   V0.1.1
179
180
181
  
  void MainWindow::on_poultryButton_clicked()
  {
3f52600cc   김태훈   소스 코드 구조 개선
182
      showAutoCookSelectionWindow(Define::Poultry);
99b8066f4   김태훈   V0.1.1
183
184
185
186
  }
  
  void MainWindow::on_meatButton_clicked()
  {
3f52600cc   김태훈   소스 코드 구조 개선
187
      showAutoCookSelectionWindow(Define::Meat);
99b8066f4   김태훈   V0.1.1
188
  }
538041ab9   김태훈   소스 코드 구조 개선
189
190
191
192
193
194
195
196
197
198
199
200
201
202
  void MainWindow::on_fishButton_clicked()
  {
      showAutoCookSelectionWindow(Define::Fish);
  }
  
  void MainWindow::on_dessertButton_clicked()
  {
      showAutoCookSelectionWindow(Define::Desert);
  }
  
  void MainWindow::on_grainButton_clicked()
  {
      showAutoCookSelectionWindow(Define::Vegetable);
  }
99b8066f4   김태훈   V0.1.1
203
204
  void MainWindow::on_breadButton_clicked()
  {
3f52600cc   김태훈   소스 코드 구조 개선
205
      showAutoCookSelectionWindow(Define::Bread);
99b8066f4   김태훈   V0.1.1
206
  }
05f2a7552   김태훈   image 관리 구조 변경
207
538041ab9   김태훈   소스 코드 구조 개선
208
209
210
211
  void MainWindow::on_etcButton_clicked()
  {
      showAutoCookSelectionWindow(Define::Etc);
  }
b85726132   김태훈   부가 기능 UI 추가
212
213
  void MainWindow::on_primeButton_clicked()
  {
599b9c350   고영탁   부가기능 복구
214
215
216
217
      PrimeWindow *w = new PrimeWindow(this);
      w->setWindowModality(Qt::WindowModal);
      w->showFullScreen();
      w->raise();
e00c6a2a9   김태훈   기능 추가 구현
218
599b9c350   고영탁   부가기능 복구
219
      newChild(w);
b85726132   김태훈   부가 기능 UI 추가
220
  }
ac60b5cec   김태훈   음향 효과 일부 적용 및 소스 ...
221
222
  void MainWindow::on_multiButton_clicked()
  {
2f6b55128   김태훈   다중 요리 구현
223
224
225
226
      MultiCookWindow *w = new MultiCookWindow(this);
      w->setWindowModality(Qt::WindowModal);
      w->showFullScreen();
      w->raise();
ac60b5cec   김태훈   음향 효과 일부 적용 및 소스 ...
227
2f6b55128   김태훈   다중 요리 구현
228
      newChild(w);
ac60b5cec   김태훈   음향 효과 일부 적용 및 소스 ...
229
230
231
232
  }
  
  void MainWindow::on_programmingButton_clicked()
  {
2f6b55128   김태훈   다중 요리 구현
233
234
235
236
      ProgrammingWindow *w = new ProgrammingWindow(this);
      w->setWindowModality(Qt::WindowModal);
      w->showFullScreen();
      w->raise();
e00c6a2a9   김태훈   기능 추가 구현
237
2f6b55128   김태훈   다중 요리 구현
238
      newChild(w);
ac60b5cec   김태훈   음향 효과 일부 적용 및 소스 ...
239
  }
05f2a7552   김태훈   image 관리 구조 변경
240
241
  void MainWindow::on_washButton_clicked()
  {
538041ab9   김태훈   소스 코드 구조 개선
242
243
244
245
      WashWindow *w = new WashWindow(this);
      w->setWindowModality(Qt::WindowModal);
      w->showFullScreen();
      w->raise();
e00c6a2a9   김태훈   기능 추가 구현
246
f97672f51   김태훈   현재 자식 창이 환경 설정 창이...
247
      newChild(w);
538041ab9   김태훈   소스 코드 구조 개선
248
249
250
251
  }
  
  void MainWindow::on_configButton_clicked()
  {
f588aa273   김태훈   부가 기능 로직 추가
252
      ConfigWindow *w = new ConfigWindow(this);
453d18662   김태훈   GUI 버전 0.1.11
253
254
255
      w->setWindowModality(Qt::WindowModal);
      w->showFullScreen();
      w->raise();
e00c6a2a9   김태훈   기능 추가 구현
256
f97672f51   김태훈   현재 자식 창이 환경 설정 창이...
257
      newChild(w);
05f2a7552   김태훈   image 관리 구조 변경
258
  }
6a965b9f1   고영탁   엔지니어 모드 2차 구현
259
260
261
  
  void MainWindow::on_helpButton_clicked()
  {
069c75507   고영탁   메인 설정 버튼 기능 변경
262
6a965b9f1   고영탁   엔지니어 모드 2차 구현
263
  }