36 lines
757 B
C++
36 lines
757 B
C++
#include "alarmbanner.h"
|
|
#include <QHBoxLayout>
|
|
#include <QLabel>
|
|
#include "global.h"
|
|
|
|
AlarmBanner::AlarmBanner(QWidget* parent)
|
|
: QWidget(parent)
|
|
{
|
|
setFixedHeight(54);
|
|
setStyleSheet("background: transparent;");
|
|
|
|
QHBoxLayout* lay = new QHBoxLayout(this);
|
|
lay->setContentsMargins(0, 0, 0, 0);
|
|
|
|
m_label = new QLabel(this);
|
|
m_label->setAlignment(Qt::AlignCenter);
|
|
m_label->setProperty("alert", true);
|
|
m_label->setStyleSheet("font-size:30px;font-weight:700;");
|
|
lay->addWidget(m_label);
|
|
|
|
hide(); // 默认隐藏
|
|
}
|
|
|
|
void AlarmBanner::showAlarm(const QString& text)
|
|
{
|
|
m_label->setText(text);
|
|
startBlink(m_label, "blink");
|
|
show();
|
|
}
|
|
|
|
void AlarmBanner::clear()
|
|
{
|
|
stopBlink(m_label, "blink");
|
|
hide();
|
|
}
|