-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstateindicatorwidget.cpp
More file actions
46 lines (39 loc) · 980 Bytes
/
stateindicatorwidget.cpp
File metadata and controls
46 lines (39 loc) · 980 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
41
42
43
44
45
46
#include "stateindicatorwidget.h"
#include "ui_stateindicatorwidget.h"
#include <QPainter>
#include <QPainterPath>
StateIndicatorWidget::StateIndicatorWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::StateIndicatorWidget)
{
ui->setupUi(this);
}
StateIndicatorWidget::~StateIndicatorWidget() {
delete ui;
}
QSize StateIndicatorWidget::minimumSizeHint() const {
return QSize(50, 50);
}
QSize StateIndicatorWidget::sizeHint() const {
return QSize(50, 50);
}
bool StateIndicatorWidget::state() const {
return m_state;
}
void StateIndicatorWidget::setState(bool arg) {
if (m_state != arg) {
m_state = arg;
emit stateChanged(m_state);
update();
}
}
void StateIndicatorWidget::paintEvent(QPaintEvent */* event */) {
QPainter painter(this);
QRect bb(0, 0, 50, 50);
if (m_state) {
painter.setBrush(Qt::green);
} else {
painter.setBrush(Qt::red);
}
painter.drawEllipse(bb);
}