a366f320c
김태훈
자동 요리 후속 공정 동작 개선
|
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
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
131
132
133
134
135
136
137
138
139
140
141
142
|
#include "bulletindicator.h"
BulletIndicator::BulletIndicator(QWidget *parent) : QWidget(parent)
{
max = 1;
cur = 0;
bulletPixmap.load(":/images/symbol/step_bullet.png");
currentBulletPixmap.load(":/images/symbol/selected_step_bullet.png");
padding = qMin(bulletPixmap.width(), currentBulletPixmap.width());
QRect defaultGeometry;
defaultGeometry.setSize(bulletPixmap.size());
QLabel *bullet;
bullet = new QLabel(this);
bullet->setPixmap(currentBulletPixmap);
bullet->setGeometry(defaultGeometry);
bullets.append(bullet);
bullet = new QLabel(this);
bullet->setPixmap(bulletPixmap);
bullet->setGeometry(defaultGeometry);
bullets.append(bullet);
updatePosition();
}
void BulletIndicator::setBulletPixmap(QPixmap &pixmap)
{
bulletPixmap = pixmap;
for (int i = 0; i <= max; i++)
if (i != cur)
bullets.at(i)->setPixmap(pixmap);
padding = qMin(pixmap.width(), padding);
updatePosition();
}
void BulletIndicator::setCurrentBulletPixmap(QPixmap &pixmap)
{
currentBulletPixmap = pixmap;
bullets.at(cur)->setPixmap(pixmap);
padding = qMin(pixmap.width(), padding);
updatePosition();
}
void BulletIndicator::setCurrentIndex(int index)
{
if (index == cur || index < 0 || index > max)
return;
bullets.at(cur)->setPixmap(bulletPixmap);
bullets.at(index)->setPixmap(currentBulletPixmap);
cur = index;
updatePosition();
}
void BulletIndicator::setMaximum(int maximum)
{
if (maximum == max || maximum < 1)
return;
if (bullets.size() <= maximum)
{
QRect defaultGeometry;
defaultGeometry.setSize(bulletPixmap.size());
for (int i = bullets.size(); i <= maximum; i++)
{
QLabel *l = new QLabel(this);
l->setPixmap(bulletPixmap);
l->setGeometry(defaultGeometry);
bullets.append(l);
}
}
if (maximum > max)
{
for (int i = max + 1; i <= maximum; i++)
{
QLabel *l = bullets.at(i);
if (l->isHidden())
l->show();
}
}
else if (maximum < max)
{
for (int i = maximum + 1; i <= max; i++)
{
QLabel *l = bullets.at(i);
if (l->isVisible())
l->hide();
}
}
max = maximum;
if (maximum < cur)
setCurrentIndex(maximum);
else
updatePosition();
}
void BulletIndicator::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
updatePosition();
}
void BulletIndicator::updatePosition()
{
int bulletWidth = bulletPixmap.width();
int bulletHeight = bulletPixmap.height();
int currentBulletWidth = currentBulletPixmap.width();
int currentBulletHeight = currentBulletPixmap.height();
int x = (width() - ((bulletWidth + padding) * max + currentBulletWidth)) / 2;
int bulletY = (height() - bulletHeight) / 2;
int currentBulletY = (height() - currentBulletHeight) / 2;
for (int i = 0; i <= max; i++)
{
if (i == cur)
{
bullets.at(i)->setGeometry(x, currentBulletY, currentBulletWidth, currentBulletHeight);
x += currentBulletWidth + padding;
}
else
{
bullets.at(i)->setGeometry(x, bulletY, bulletWidth, bulletHeight);
x += bulletWidth + padding;
}
}
}
|