FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
appstream/meterwidget.cpp at master · napcode/appstream · GitHub
napcode
/
appstream
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
appstream
/
meterwidget.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
73 lines (67 loc) · 1.59 KB
Breadcrumbs
appstream
/
meterwidget.cpp
Copy path
File metadata and controls
73 lines (67 loc) · 1.59 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
"
meterwidget.h
"
#
include
<
QPainter
>
#
include
<
QPaintEvent
>
#
include
<
QAction
>
#
include
<
QMenu
>
#
include
<
iostream
>
#
include
<
cmath
>
MeterWidget::MeterWidget
(QWidget* parent,
uint8_t
channels)
: QLabel(parent),
_isActive(
true
)
{
_colorspan =
120
.
0f
/
360
.
0f
;
setNumChannels
(channels);
QAction* act_p =
new
QAction
(
"
Toggle Metering
"
,
this
);
act_p->
setCheckable
(
true
);
connect
(act_p,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
toggleActive
(
bool
)));
this
->
addAction
(act_p);
}
MeterWidget::~MeterWidget
()
{
}
void
MeterWidget::setNumChannels
(
uint8_t
channels)
{
_numChannels = channels;
_v.
resize
(channels);
_width =
width
() / channels;
reset
();
}
void
MeterWidget::reset
()
{
for
(
uint8_t
i =
0
; i < _v.
size
(); ++i) {
_v[i] =
0
;
}
update
();
}
void
MeterWidget::paintEvent
(QPaintEvent* event)
{
QPainter
painter
(
this
);
QRect r = event->
rect
();
QColor color;
color.
setRgb
(
0
,
0
,
0
);
int
w = r.
width
() / _v.
size
();
int
h = r.
height
();
//
draw outer frame
QBrush
b
(color);
QRect
border
(
0
,
0
, r.
width
() -
1
, r.
height
() -
1
);
painter.
setBrush
(b);
painter.
drawRect
(border);
if
(!_isActive)
return
;
QRect rect;
for
(
uint8_t
i =
0
; i < _v.
size
(); ++i) {
rect.
setRect
(i * w, h - h * _v[i], w -
1
, h * _v[i]);
float
col = _colorspan - (_colorspan * _v[i]);
color.
setHsvF
(col,
1
.
0f
,
1
.
0f
);
QBrush
b
(color);
painter.
setBrush
(b);
painter.
drawRect
(rect);
}
}
void
MeterWidget::setValues
(MeterValues m)
{
if
(_isActive) {
_v = m;
update
();
}
}
Back
|
FazBrowse Home
|
New Git URL