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

180 lines
4.3 KiB
C++

/**
* @file PaiJobErrorInfoBar.cpp
* @brief 日志中错误信息函数
* @date: 2013-4-17
*/
#include "PaiJobErrorInfoBar.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPainter>
#include <QLinearGradient>
#include <QColor>
#include <QDebug>
namespace pai
{
namespace gui
{
PaiJobErrorInfoBar::PaiJobErrorInfoBar(QWidget *parent) :
QWidget(parent)
{
QPalette pal = palette();
pal.setColor(QPalette::Background, QColor("#ffeaea"));
setPalette(pal);
setWindowOpacity(0.7);
setWindowFlags(Qt::WindowStaysOnTopHint);
this->resize(505, 30);
m_pLabel = new QLabel(tr("Error Info"));
m_pbtn = new QPushButton(QIcon(":/log_close.png"), tr(""), this);
m_pbtn->resize(10, 10);
m_pbtn->setCheckable(true);
m_pbtn->setAutoDefault(false);
m_pbtn->setStyleSheet("QPushButton{border: 0px solid red;border-radius:10px}");
m_pIconBtn = new QPushButton(QIcon(":/log_error_downbutton.png"), tr(""), this);
m_pIconBtn->resize(10, 10);
m_pIconBtn->setStyleSheet("QPushButton{border: 0px solid red;border-radius:10px}");
QHBoxLayout *pHoxLayout = new QHBoxLayout();
pHoxLayout->setSpacing(60);
pHoxLayout->addWidget(m_pLabel);
pHoxLayout->addStretch(150);
pHoxLayout->addWidget(m_pIconBtn);
pHoxLayout->setSpacing(1);
pHoxLayout->addWidget(m_pbtn);
m_pDownWidget = new QWidget();
QVBoxLayout *pDownLayout = new QVBoxLayout;
m_pTextEdit = new QTextEdit();
m_pTextEdit->resize(500, 280);
m_pDownWidget->setFixedSize(500, 198);
pDownLayout->addWidget(m_pTextEdit);
pDownLayout->setContentsMargins(0, 0, 0, 0);
m_pDownWidget->setLayout(pDownLayout);
connect(m_pIconBtn, SIGNAL(clicked(bool)), this, SLOT(SetShow(bool)));
connect(m_pIconBtn, SIGNAL(toggled(bool)), m_pDownWidget, SLOT(setVisible(bool)));
connect(m_pbtn, SIGNAL(clicked(bool)), this, SLOT(CloseDialog(bool)));
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
mainLayout->addLayout(pHoxLayout);
mainLayout->addWidget(m_pDownWidget);
mainLayout->setContentsMargins(4, 1, 1, 1);
this->setLayout(mainLayout);
m_pDownWidget->hide();
}
PaiJobErrorInfoBar::~PaiJobErrorInfoBar()
{
}
QWidget* PaiJobErrorInfoBar::GetDownWidget() const
{
return m_pDownWidget;
}
QLabel* PaiJobErrorInfoBar::GetLabel() const
{
return m_pLabel;
}
QTextEdit* PaiJobErrorInfoBar::GetTextEdit() const
{
return m_pTextEdit;
}
void PaiJobErrorInfoBar::SetShow(bool /*show*/)
{
if(m_pDownWidget != NULL)
{
if (m_pDownWidget->isHidden())
{
emit ExpendDialog(true);
m_pDownWidget->show();
}
else
{
emit ExpendDialog(false);
m_pDownWidget->hide();
}
}
}
void PaiJobErrorInfoBar::CloseDialog(bool /*close*/)
{
emit CloseDialog();
}
void PaiJobErrorInfoBar::ErrorBarInfo(const QString& error)
{
if(m_pTextEdit != NULL)
{
m_pTextEdit->setHtml(error);
}
}
void PaiJobErrorInfoBar::enterEvent(QEvent */*pEvent*/)
{
m_x = this->x();
m_y = this->y();
}
void PaiJobErrorInfoBar::leaveEvent(QEvent */*pEvent*/)
{
//emit ExpendDialog(false);
//m_pDownWidget->hide();
//this->resize(280,20);
//this->move(m_x,m_y);
}
void PaiJobErrorInfoBar::mousePressEvent(QMouseEvent * pEvent)
{
if(pEvent->button() == Qt::LeftButton)
{
SetShow(true);
}
QWidget::mousePressEvent(pEvent);
}
void PaiJobErrorInfoBar::paintEvent(QPaintEvent */*pEvent*/)
{
QPainter paint(this);
QPen pen;
if ((m_pDownWidget != NULL) && (m_pDownWidget->isHidden()))
{
if(m_pIconBtn != NULL)
{
m_pIconBtn->setIcon(QIcon(":/log_error_downbutton.png"));
}
paint.drawPixmap(0, 0, this->width(), 30, QPixmap(":/log_error_shrink.png"));
}
else
{
paint.drawPixmap(0, 0, this->width(), this->height(), QPixmap(":/log_error_exten.png"));
paint.drawPixmap(0, 0, this->width(), 30, QPixmap(":/log_error_shrink.png"));
if(m_pIconBtn != NULL)
{
m_pIconBtn->setIcon(QIcon(":/log_error_upbutton.png"));
}
}
pen.setWidth(1);
pen.setColor(QColor("#dd1d1d"));
paint.setPen(pen);
paint.drawLine(450, 10, 450, 19);
}
}
}