{
QRect rect
= this
->rect
();
// define fundo do display
if( m_currentMsg.message().isNull() ) {
// sem fundo
}
else if(m_currentMsg.priority() == Monitoring::HIGH_PRIORITY) {
// cor de fundo vermelha - frequência 1.5Hz duty cycle = 50%
qDebug("checkAlarmDutyCycle:HIGH_PRIORITY");
if(m_alarmDutyOn) {
// Alterna a cor da fonte para melhorar visibilidade
setPalette(palette);
if(m_currentMsg.state() != SILENCED) {
painter.
setBrush(QBrush(QColor("#ff0000"), Qt
::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
}
else {
painter.
setBrush(QBrush(QColor("#880000"), Qt
::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
}
}
else {
// não preenche o fundo
// Alterna a cor da fonte para melhorar visibilidade
setPalette(palette);
}
}
else if(m_currentMsg.priority() == Monitoring::MEDIUM_PRIORITY) {
// cor de fundo amarela - frequência 0.5Hz duty cycle = 50%
if(m_alarmDutyOn) {
// alterna cor da fonte para melhorar visibilidade
setPalette(palette);
if(m_currentMsg.state() != SILENCED) {
painter.
setBrush(QBrush(QColor("#dddd00"), Qt
::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
}
else {
painter.
setBrush(QBrush(QColor("#888800"), Qt
::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
}
}
else {
// não preenche o fundo
// Alterna a cor da fonte para melhorar visibilidade
setPalette(palette);
}
}
else if(m_currentMsg.priority() == Monitoring::LOW_PRIORITY) {
if(m_currentMsg.state() != SILENCED) {
// cor de fundo ciano - constante
painter.
setBrush(QBrush(QColor("#00ffff"), Qt
::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
}
else {
// cor de fundo ciano - constante
painter.
setBrush(QBrush(QColor("#008888"), Qt
::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
}
}
// executa o método da classe base
// QWidget::paintEvent(e);
}
void CMessageLabel::paintEvent(QPaintEvent* e)
{
QPainter painter(this);
QRect rect = this->rect();
// define fundo do display
if( m_currentMsg.message().isNull() ) {
// sem fundo
}
else if(m_currentMsg.priority() == Monitoring::HIGH_PRIORITY) {
// cor de fundo vermelha - frequência 1.5Hz duty cycle = 50%
qDebug("checkAlarmDutyCycle:HIGH_PRIORITY");
if(m_alarmDutyOn) {
// Alterna a cor da fonte para melhorar visibilidade
QPalette palette = this->palette();
palette.setColor(QPalette::WindowText,QColor(0,0,0));
setPalette(palette);
if(m_currentMsg.state() != SILENCED) {
painter.setBrush(QBrush(QColor("#ff0000"), Qt::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
}
else {
painter.setBrush(QBrush(QColor("#880000"), Qt::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
}
}
else {
// não preenche o fundo
// Alterna a cor da fonte para melhorar visibilidade
QPalette palette = this->palette();
palette.setColor(QPalette::WindowText,QColor(255,255,255));
setPalette(palette);
}
}
else if(m_currentMsg.priority() == Monitoring::MEDIUM_PRIORITY) {
// cor de fundo amarela - frequência 0.5Hz duty cycle = 50%
if(m_alarmDutyOn) {
// alterna cor da fonte para melhorar visibilidade
QPalette palette = this->palette();
palette.setColor(QPalette::WindowText,QColor(0,0,0));
setPalette(palette);
if(m_currentMsg.state() != SILENCED) {
painter.setBrush(QBrush(QColor("#dddd00"), Qt::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
}
else {
painter.setBrush(QBrush(QColor("#888800"), Qt::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
}
}
else {
// não preenche o fundo
// Alterna a cor da fonte para melhorar visibilidade
QPalette palette = this->palette();
palette.setColor(QPalette::WindowText,QColor(255,255,255));
setPalette(palette);
}
}
else if(m_currentMsg.priority() == Monitoring::LOW_PRIORITY) {
if(m_currentMsg.state() != SILENCED) {
// cor de fundo ciano - constante
painter.setBrush(QBrush(QColor("#00ffff"), Qt::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
}
else {
// cor de fundo ciano - constante
painter.setBrush(QBrush(QColor("#008888"), Qt::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
}
}
// executa o método da classe base
QLabel::paintEvent(e);
// QWidget::paintEvent(e);
}
To copy to clipboard, switch view to plain text mode
Bookmarks