382b586e9
김태훈
프로그래밍 모드 임시 구현
|
1
2
3
4
5
6
|
#include "programmingautoconfigwindow.h"
#include "ui_programmingautoconfigwindow.h"
#include "soundplayer.h"
#include "stringer.h"
#include "cookprogram.h"
|
95a9aa99d
김태훈
기능 보충 구현
|
7
8
|
#include "configwindow.h"
#include "mainwindow.h"
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
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
|
ProgrammingAutoConfigWindow::ProgrammingAutoConfigWindow(QWidget *parent, Cook cook) :
QMainWindow(parent),
ui(new Ui::ProgrammingAutoConfigWindow),
cook(cook)
{
ui->setupUi(this);
ui->clockContainer->setParent(ui->upperStack);
setAttribute(Qt::WA_DeleteOnClose);
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();
foreach (QPushButton *button, findChildren<QPushButton *>())
connect(button, &QPushButton::pressed, SoundPlayer::playClick);
}
ProgrammingAutoConfigWindow::~ProgrammingAutoConfigWindow()
{
delete ui;
}
void ProgrammingAutoConfigWindow::setupUi()
{
ui->cookTypeIcon->setPixmap(Define::icon(cook.type));
ui->selectCookButton->setText(cook.name);
for (int idx = 0; idx < 5; idx++)
{
CookConfig config = cook.configs[idx];
if (config.type == Define::ConfigNotUsed)
{
ConfigWidget cw = configWidgets.at(idx);
cw.button->hide();
cw.minimum->hide();
cw.maximum->hide();
cw.current->hide();
cw.slider->hide();
}
else
{
ConfigWidget cw = configWidgets.at(idx);
cw.button->setStyleSheet(
"QPushButton { image: url("
+ Define::icon(config.type)
+ ") } QPushButton::pressed { image: url("
+ Define::iconOverlay(config.type)
+ ") }");
cw.minimum->setText(Define::minimum(config.type));
cw.maximum->setText(Define::maximum(config.type));
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
101
102
103
104
|
switch (config.type)
{
case Define::Time:
|
935b853a4
김태훈
새 슬라이더 적용
|
105
|
cw.slider->setSubPixmap(":/images/slider/sub_white.png");
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
106
107
|
break;
case Define::BurnDegree:
|
935b853a4
김태훈
새 슬라이더 적용
|
108
|
cw.slider->setSubPixmap(":/images/slider/sub_yellow.png");
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
109
110
|
break;
case Define::Brightness:
|
935b853a4
김태훈
새 슬라이더 적용
|
111
|
cw.slider->setSubPixmap(":/images/slider/sub_red.png");
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
112
113
|
break;
default:
|
935b853a4
김태훈
새 슬라이더 적용
|
114
|
cw.slider->setSubPixmap(":/images/slider/sub_blue.png");
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
115
116
|
break;
}
|
935b853a4
김태훈
새 슬라이더 적용
|
117
118
119
120
121
122
123
124
|
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;
connect(cw.slider, SIGNAL(sliderMoved(int)), SLOT(updateConfig()));
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
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
|
}
}
updateView();
}
void ProgrammingAutoConfigWindow::updateView()
{
for (int idx = 0; idx < 5; idx++)
{
CookConfig config = cook.configs[idx];
if (config.type == Define::ConfigNotUsed)
continue;
ConfigWidget cw = configWidgets.at(idx);
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 ProgrammingAutoConfigWindow::updateConfig()
{
|
935b853a4
김태훈
새 슬라이더 적용
|
161
162
163
164
165
|
cook.setConfig(ui->configSlider_1->sliderPosition(),
ui->configSlider_2->sliderPosition(),
ui->configSlider_3->sliderPosition(),
ui->configSlider_4->sliderPosition(),
ui->configSlider_5->sliderPosition());
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
166
167
168
169
170
171
172
173
174
175
176
|
updateView();
}
void ProgrammingAutoConfigWindow::on_backButton_clicked()
{
close();
}
void ProgrammingAutoConfigWindow::on_configButton_clicked()
{
|
95a9aa99d
김태훈
기능 보충 구현
|
177
178
179
180
|
ConfigWindow *w = new ConfigWindow(MainWindow::getInstance());
w->setWindowModality(Qt::WindowModal);
w->showFullScreen();
w->raise();
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
181
|
|
95a9aa99d
김태훈
기능 보충 구현
|
182
|
MainWindow::jump(w);
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
}
void ProgrammingAutoConfigWindow::on_helpButton_clicked()
{
}
void ProgrammingAutoConfigWindow::on_okButton_clicked()
{
if (!cook.isLoaded())
cook.load();
AutoCookSetting s;
s.type = cook.type;
s.name = cook.name;
s.root = cook.root;
for (int i = 0; i < 5; i++)
s.configs[i] = cook.configs[i].current;
CookProgram::add(s);
emit added();
close();
}
|