68c06e96f
김태훈
자동 요리 세부 사항 구현
|
1
2
3
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
|
#include "autocookcheckconfigwindow.h"
#include "ui_autocookcheckconfigwindow.h"
#include <QKeyEvent>
#include "soundplayer.h"
#include "stringer.h"
AutoCookCheckConfigWindow::AutoCookCheckConfigWindow(QWidget *parent, Cook cook) :
QMainWindow(parent),
ui(new Ui::AutoCookCheckConfigWindow),
cook(cook)
{
ui->setupUi(this);
if (!this->cook.isLoaded())
this->cook.load();
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();
afterThreeSecsTimer.setSingleShot(true);
afterThreeSecsTimer.setInterval(3000);
afterThreeSecsTimer.start();
connect(&afterThreeSecsTimer, SIGNAL(timeout()), SLOT(afterThreeSecs()));
foreach (QPushButton *button, findChildren<QPushButton *>())
connect(button, &QPushButton::pressed, SoundPlayer::playClick);
foreach (QWidget *w, findChildren<QWidget *>())
w->installEventFilter(this);
setFocus();
}
AutoCookCheckConfigWindow::~AutoCookCheckConfigWindow()
{
delete ui;
}
bool AutoCookCheckConfigWindow::eventFilter(QObject */*watched*/, QEvent *event)
{
switch (event->type())
{
case QEvent::KeyPress:
case QEvent::KeyRelease:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
afterThreeSecsTimer.start();
break;
default:
break;
}
return false;
}
void AutoCookCheckConfigWindow::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
|
01249f413
김태훈
엔코더 방향 반전. 하드웨어가 변경됨
|
103
|
case 0x01000032: // Turn left
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
104
105
106
107
108
|
onEncoderLeft();
break;
case 0x01000031: // Push
pushed = focusWidget();
break;
|
01249f413
김태훈
엔코더 방향 반전. 하드웨어가 변경됨
|
109
|
case 0x01000030: // Turn right
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
110
111
112
113
114
115
116
117
118
|
onEncoderRight();
break;
}
}
void AutoCookCheckConfigWindow::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
|
01249f413
김태훈
엔코더 방향 반전. 하드웨어가 변경됨
|
119
|
case 0x01000032: // Turn left
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
120
121
122
123
124
125
126
127
|
onEncoderLeft();
break;
case 0x01000031: // Push
if (focusWidget() == pushed)
onEncoderClicked(pushed);
pushed = NULL;
break;
|
01249f413
김태훈
엔코더 방향 반전. 하드웨어가 변경됨
|
128
|
case 0x01000030: // Turn right
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
129
130
131
132
133
134
135
136
137
|
onEncoderRight();
break;
}
}
void AutoCookCheckConfigWindow::setupUi()
{
ui->cookTypeIcon->setPixmap(Define::icon(cook.type));
ui->selectCookButton->setText(cook.name);
|
07441dbd3
김태훈
엔코더 관련 디자인 변경 대비
|
138
139
140
141
142
|
QString styleSheet("\
QPushButton { image: url(%1); }\
QPushButton:pressed,\
QPushButton:focus { image: url(%2); }\
QPushButton:checked { image: url(%3); }");
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
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
{
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
158
159
160
161
162
|
cw.button->show();
cw.minimum->show();
cw.maximum->show();
cw.current->show();
cw.slider->show();
|
07441dbd3
김태훈
엔코더 관련 디자인 변경 대비
|
163
164
165
166
|
cw.button->setStyleSheet(styleSheet
.arg(Define::icon(config.type))
.arg(Define::iconOverlay(config.type))
.arg(Define::iconActiveted(config.type)));
|
68c06e96f
김태훈
자동 요리 세부 사항 구현
|
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
cw.minimum->setText(Define::minimum(config.type));
cw.maximum->setText(Define::maximum(config.type));
switch (config.type)
{
case Define::Time:
cw.slider->setSubPixmap(":/images/slider/sub_white.png");
break;
case Define::BurnDegree:
cw.slider->setSubPixmap(":/images/slider/sub_yellow.png");
break;
case Define::Brightness:
cw.slider->setSubPixmap(":/images/slider/sub_red.png");
break;
default:
cw.slider->setSubPixmap(":/images/slider/sub_blue.png");
break;
}
cw.slider->blockSignals(true);
cw.slider->setMinimum(1);
cw.slider->setMaximum(config.maximum);
cw.slider->setValue(config.current);
cw.slider->blockSignals(false);
cw.slider->bigTickInterval = 1;
switch (config.type)
{
case Define::Time:
cw.current->setText(Stringer::remainingTime(cook.time() * 1000, Stringer::fontSize14));
break;
case Define::BurnDegree:
cw.current->setText(Stringer::temperature(cook.coreTemp(), Stringer::fontSize14));
break;
default:
cw.current->setText(QString().sprintf(
"%d"
"<span style=\"font-size:11pt;\">/%d</span>",
config.current, config.maximum));
break;
}
}
}
}
void AutoCookCheckConfigWindow::onEncoderLeft()
{
focusPreviousChild();
}
void AutoCookCheckConfigWindow::onEncoderRight()
{
focusNextChild();
}
void AutoCookCheckConfigWindow::onEncoderClicked(QWidget *clicked)
{
QPushButton *pb = qobject_cast<QPushButton *>(clicked);
if (pb)
pb->click();
}
void AutoCookCheckConfigWindow::afterThreeSecs()
{
close();
}
void AutoCookCheckConfigWindow::on_backButton_clicked()
{
close();
}
|