Blame view

app/gui/oven_control/autocooksettingwidget.cpp 4.76 KB
f588aa273   김태훈   부가 기능 로직 추가
1
2
  #include "autocooksettingwidget.h"
  #include "ui_autocooksettingwidget.h"
2bfd3a050   김태훈   환경 설정 대응
3
  #include "stringer.h"
f588aa273   김태훈   부가 기능 로직 추가
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
  
  AutoCookSettingWidget::AutoCookSettingWidget(AutoCookSetting setting, QWidget *parent) :
      QWidget(parent),
      ui(new Ui::AutoCookSettingWidget)
  {
      ui->setupUi(this);
  
      Cook cook(setting.type, setting.root, setting.name);
      cook.setConfig(setting.configs[0],
                     setting.configs[1],
                     setting.configs[2],
                     setting.configs[3],
                     setting.configs[4]);
  
      configWidgets.append(
                  ConfigWidget {
                      ui->configButton_1,
                      ui->configMinLabel_1,
                      ui->configMaxLabel_1,
                      ui->configCurrentLabel_1,
                      ui->configSlider_1
                  });
      configWidgets.append(
                  ConfigWidget {
                      ui->configButton_2,
                      ui->configMinLabel_2,
                      ui->configMaxLabel_2,
                      ui->configCurrentLabel_2,
                      ui->configSlider_2
                  });
      configWidgets.append(
                  ConfigWidget {
                      ui->configButton_3,
                      ui->configMinLabel_3,
                      ui->configMaxLabel_3,
                      ui->configCurrentLabel_3,
                      ui->configSlider_3
                  });
      configWidgets.append(
                  ConfigWidget {
                      ui->configButton_4,
                      ui->configMinLabel_4,
                      ui->configMaxLabel_4,
                      ui->configCurrentLabel_4,
                      ui->configSlider_4
                  });
      configWidgets.append(
                  ConfigWidget {
                      ui->configButton_5,
                      ui->configMinLabel_5,
                      ui->configMaxLabel_5,
                      ui->configCurrentLabel_5,
                      ui->configSlider_5
                  });
  
      setupUi(cook);
  }
  
  AutoCookSettingWidget::~AutoCookSettingWidget()
  {
      delete ui;
  }
9e1f8d093   김태훈   엔코더 구현 대비 선행 수정
66
67
68
69
70
71
72
73
74
  void AutoCookSettingWidget::keyPressEvent(QKeyEvent *event)
  {
  
  }
  
  void AutoCookSettingWidget::keyReleaseEvent(QKeyEvent *event)
  {
  
  }
f588aa273   김태훈   부가 기능 로직 추가
75
76
77
78
  void AutoCookSettingWidget::setupUi(Cook cook)
  {
      ui->cookTypeIcon->setPixmap(Define::icon(cook.type));
      ui->selectCookButton->setText(cook.name);
07441dbd3   김태훈   엔코더 관련 디자인 변경 대비
79
80
81
82
83
      QString styleSheet("\
  QPushButton { image: url(%1); }\
  QPushButton:pressed,\
  QPushButton:focus { image: url(%2); }\
  QPushButton:checked { image: url(%3); }");
f588aa273   김태훈   부가 기능 로직 추가
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
      for (int idx = 0; idx < 5; idx++)
      {
          ConfigWidget cw = configWidgets.at(idx);
  
          CookConfig config = cook.configs[idx];
          if (config.type == Define::ConfigNotUsed)
          {
              cw.button->hide();
              cw.minimum->hide();
              cw.maximum->hide();
              cw.current->hide();
              cw.slider->hide();
          }
          else
          {
07441dbd3   김태훈   엔코더 관련 디자인 변경 대비
99
100
101
102
              cw.button->setStyleSheet(styleSheet
                                       .arg(Define::icon(config.type))
                                       .arg(Define::iconOverlay(config.type))
                                       .arg(Define::iconActiveted(config.type)));
f588aa273   김태훈   부가 기능 로직 추가
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
  
              cw.minimum->setText(Define::minimum(config.type));
              cw.maximum->setText(Define::maximum(config.type));
              cw.slider->blockSignals(true);
              cw.slider->setMinimum(1);
              cw.slider->setMaximum(config.maximum);
              cw.slider->setValue(config.current);
              cw.slider->blockSignals(false);
  
              switch (config.type)
              {
              case Define::Time:
                  cw.slider->setProperty("sliderColor", "white");
                  break;
              case Define::BurnDegree:
                  cw.slider->setProperty("sliderColor", "yellow");
                  break;
              case Define::Brightness:
                  cw.slider->setProperty("sliderColor", "red");
                  break;
              default:
                  cw.slider->setProperty("sliderColor", "blue");
                  break;
              }
  
              switch (config.type)
              {
              case Define::Time:
2bfd3a050   김태훈   환경 설정 대응
131
                  cw.current->setText(Stringer::remainingTime(cook.time() * 1000, Stringer::fontSize14));
f588aa273   김태훈   부가 기능 로직 추가
132
                  break;
f588aa273   김태훈   부가 기능 로직 추가
133
              case Define::BurnDegree:
2bfd3a050   김태훈   환경 설정 대응
134
                  cw.current->setText(Stringer::temperature(cook.coreTemp(), Stringer::fontSize14));
f588aa273   김태훈   부가 기능 로직 추가
135
136
137
138
139
140
141
142
143
144
145
                  break;
              default:
                  cw.current->setText(QString().sprintf(
                          "%d"
                          "<span style=\"font-size:11pt;\">/%d</span>",
                          config.current, config.maximum));
                  break;
              }
          }
      }
  }
9e1f8d093   김태훈   엔코더 구현 대비 선행 수정
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
  
  void AutoCookSettingWidget::onEncoderLeft()
  {
  
  }
  
  void AutoCookSettingWidget::onEncoderRight()
  {
  
  }
  
  void AutoCookSettingWidget::onEncoderClicked(QWidget *clicked)
  {
  
  }