logplus/Workflow/WFEngine/Component/WorkflowWidget/src/PaiJobSummaryWidgetBar.cpp
2026-01-16 17:18:41 +08:00

66 lines
1.6 KiB
C++

#include "PaiJobSummaryWidgetBar.h"
#include <QPainter>
#include <QLinearGradient>
namespace pai
{
namespace gui
{
PaiJobSummaryWidgetBar::PaiJobSummaryWidgetBar(QWidget *parent) : QWidget(parent)
{
this->resize(200,20);
}
PaiJobSummaryWidgetBar::~PaiJobSummaryWidgetBar()
{
}
void PaiJobSummaryWidgetBar::SetColor(const QColor& beforeColor, const QColor& afterColor)
{
m_BeforeColor = beforeColor;
m_AfterColor = afterColor;
}
void PaiJobSummaryWidgetBar::SetName(const QString& text, const QString& progress)
{
m_value = text;
m_progress = progress;
}
void PaiJobSummaryWidgetBar::paintEvent(QPaintEvent */*pEvent*/)
{
QPainter paint(this);
QPen pen;
pen.setWidth(15);
pen.setCapStyle(Qt::RoundCap);
paint.setRenderHint(QPainter::Antialiasing, true);
QLinearGradient linearGradient(0, this->height()/2, this->width() - 40, this->height()/2);
linearGradient.setColorAt(0.1, m_BeforeColor);
linearGradient.setColorAt(0.6, m_AfterColor);
pen.setBrush(linearGradient);
paint.setPen(pen);
paint.drawLine(0, this->height()/2, this->width() - 40, this->height()/2);
pen.setCapStyle(Qt::FlatCap);
pen.setColor(m_BeforeColor);
paint.setPen(pen);
paint.drawLine(0, this->height()/2, 5, this->height()/2);
pen.setColor(Qt::white);
paint.setPen(pen);
paint.drawText(2, this->height()/2 + 4, m_value);
pen.setColor("#666666");
paint.setPen(pen);
paint.drawText(this->width()-32 ,this->height()/2 + 4,m_progress);
}
}
}