-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrecordinglight.cpp
More file actions
40 lines (34 loc) · 862 Bytes
/
recordinglight.cpp
File metadata and controls
40 lines (34 loc) · 862 Bytes
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
#include "recordinglight.h"
#include <QWidget>
#include <QTimer>
RecordingLight::RecordingLight(QWidget *parent)
: QWidget(parent) {
// Set the size of the recording light (small red dot)
setFixedSize(10, 10);
currentScale = 160;
pulseTimer = new QTimer(this);
connect(pulseTimer, &QTimer::timeout, this, &RecordingLight::updatePulse);
pulseTimer->start(35);
}
void RecordingLight::updatePulse(){
if (growing){
currentScale += 7;
}else{
currentScale -= 7;
}
if (currentScale < 70){
growing = true;
currentScale = 70;
}else if (currentScale > 255){
growing = false;
currentScale = 255;
}
update();
}
void RecordingLight::paintEvent(QPaintEvent *) {
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setBrush(QColor(currentScale, 0, 0));
painter.setPen(Qt::NoPen);
painter.drawEllipse(rect());
}