2021-04-04 21:04:12 +01:00
|
|
|
#include <QPainter>
|
|
|
|
|
|
|
|
|
|
#include "BodyWidget.hpp"
|
|
|
|
|
#include "src/Logger/Logger.hpp"
|
|
|
|
|
|
2021-07-07 20:54:45 +01:00
|
|
|
using namespace Bloom::Widgets::InsightTargetWidgets::Qfp;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
void BodyWidget::paintEvent(QPaintEvent* event) {
|
|
|
|
|
auto painter = QPainter(this);
|
|
|
|
|
this->drawWidget(painter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BodyWidget::drawWidget(QPainter& painter) {
|
|
|
|
|
painter.setRenderHints(QPainter::RenderHint::Antialiasing | QPainter::RenderHint::SmoothPixmapTransform, true);
|
|
|
|
|
|
|
|
|
|
auto targetBodyColor = this->getBodyColor();
|
2021-09-21 23:13:28 +01:00
|
|
|
auto backgroundColor = QColor("#373835");
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
if (!this->isEnabled()) {
|
|
|
|
|
targetBodyColor.setAlpha(this->getDisableAlphaLevel());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
painter.setPen(Qt::PenStyle::NoPen);
|
|
|
|
|
painter.setBrush(targetBodyColor);
|
|
|
|
|
|
|
|
|
|
auto containerGeometry = this->geometry();
|
|
|
|
|
auto targetBodyWidth = containerGeometry.width() - 16;
|
|
|
|
|
auto targetBodyHeight = containerGeometry.height() - 16;
|
|
|
|
|
|
|
|
|
|
auto targetBodyPoint = QPoint(
|
|
|
|
|
(containerGeometry.width() / 2) - (targetBodyWidth / 2),
|
|
|
|
|
(containerGeometry.height() / 2) - (targetBodyHeight / 2)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
painter.drawRect(
|
|
|
|
|
targetBodyPoint.x(),
|
|
|
|
|
targetBodyPoint.y(),
|
|
|
|
|
targetBodyWidth,
|
|
|
|
|
targetBodyHeight
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
painter.setBrush(backgroundColor);
|
|
|
|
|
painter.drawEllipse(QRectF(
|
2021-09-17 21:49:37 +01:00
|
|
|
targetBodyPoint.x() + 13,
|
|
|
|
|
targetBodyPoint.y() + 13,
|
|
|
|
|
20,
|
|
|
|
|
20
|
2021-04-04 21:04:12 +01:00
|
|
|
));
|
|
|
|
|
}
|