Blame view

app/gui/oven_control/autocooksettingwidget.cpp 4.29 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
  
  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;
  }
  
  void AutoCookSettingWidget::setupUi(Cook cook)
  {
      ui->cookTypeIcon->setPixmap(Define::icon(cook.type));
      ui->selectCookButton->setText(cook.name);
  
      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
          {
              cw.button->setStyleSheet(
                          QString("QPushButton { image: url(%1); } QPushButton:pressed { image: url(%2); }")
                          .arg(Define::icon(config.type))
                          .arg(Define::iconOverlay(config.type)));
  
              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   김태훈   환경 설정 대응
119
                  cw.current->setText(Stringer::remainingTime(cook.time() * 1000, Stringer::fontSize14));
f588aa273   김태훈   부가 기능 로직 추가
120
                  break;
f588aa273   김태훈   부가 기능 로직 추가
121
              case Define::BurnDegree:
2bfd3a050   김태훈   환경 설정 대응
122
                  cw.current->setText(Stringer::temperature(cook.coreTemp(), Stringer::fontSize14));
f588aa273   김태훈   부가 기능 로직 추가
123
124
125
126
127
128
129
130
131
132
133
                  break;
              default:
                  cw.current->setText(QString().sprintf(
                          "%d"
                          "<span style=\"font-size:11pt;\">/%d</span>",
                          config.current, config.maximum));
                  break;
              }
          }
      }
  }