2025-09-24 12:10:51 +08:00
|
|
|
|
#include "alarmEventRealTimeDock.h"
|
|
|
|
|
|
#include "./ui_alarmEventRealTimeDock.h"
|
2025-10-17 18:15:06 +08:00
|
|
|
|
#include "alarmEventDataView.h"
|
2025-09-24 12:10:51 +08:00
|
|
|
|
|
|
|
|
|
|
#include <QPropertyAnimation>
|
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
|
|
|
|
#define bottomMargin 0
|
|
|
|
|
|
AlarmEventRealTimeDock::AlarmEventRealTimeDock(QWidget* parent)
|
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
|
, ui(new Ui::alarmEventRealTimeDock)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
setAttribute(Qt::WA_TranslucentBackground);
|
|
|
|
|
|
|
2025-10-29 17:38:57 +08:00
|
|
|
|
m_isInAnimationExpand = false;
|
|
|
|
|
|
m_isInAnimationAlert = false;
|
2025-09-24 12:10:51 +08:00
|
|
|
|
m_curState = "collapse";
|
|
|
|
|
|
|
2025-10-28 16:39:23 +08:00
|
|
|
|
m_tableView = new AlarmEventDataView(RealTime, this);
|
2025-10-17 18:15:06 +08:00
|
|
|
|
ui->tableLayout->addWidget(m_tableView);
|
2025-10-29 17:38:57 +08:00
|
|
|
|
connect(m_tableView->model(), &AlarmEventDataModel::receivedNewAlarm, this, &AlarmEventRealTimeDock::onSIG_receivedNewAlarm);
|
2025-10-17 18:15:06 +08:00
|
|
|
|
|
2025-10-29 17:38:57 +08:00
|
|
|
|
m_animationExpand = new QPropertyAnimation(this, "geometry", this);
|
2025-10-28 18:50:59 +08:00
|
|
|
|
m_animationExpand->setDuration(120);
|
2025-10-29 17:38:57 +08:00
|
|
|
|
connect(m_animationExpand, &QPropertyAnimation::finished, this, [this]{m_isInAnimationExpand = false;});
|
|
|
|
|
|
|
|
|
|
|
|
m_animationAlert = new QPropertyAnimation(this, "alertWidgetBGColorAlpha", this);
|
|
|
|
|
|
m_animationAlert->setDuration(3000);
|
|
|
|
|
|
m_animationAlert->setStartValue(0.0);
|
|
|
|
|
|
m_animationAlert->setEndValue(1.0);
|
|
|
|
|
|
m_animationAlert->setLoopCount(-1);//无限循环
|
|
|
|
|
|
m_alertWidgetStyleSheet = QString(
|
|
|
|
|
|
"background-color: qradialgradient("
|
|
|
|
|
|
"spread:pad, "
|
|
|
|
|
|
"cx:0.5, cy:0.5, radius:0.5, "
|
|
|
|
|
|
"fx:0.5, fy:0.5, "
|
|
|
|
|
|
"stop:0 rgba(200, 0, 0, 0), "
|
|
|
|
|
|
"stop:1 rgba(255, 255, 255, 0));"
|
|
|
|
|
|
);
|
2025-09-24 12:10:51 +08:00
|
|
|
|
|
|
|
|
|
|
ui->btnClose->setVisible(false);
|
|
|
|
|
|
connect(ui->btnOpen, &QPushButton::clicked, this, &AlarmEventRealTimeDock::onBtnClicked_open);
|
|
|
|
|
|
connect(ui->btnClose, &QPushButton::clicked, this, &AlarmEventRealTimeDock::onBtnClicked_close);
|
|
|
|
|
|
connect(ui->btnConfirmAll, &QPushButton::clicked, this, &AlarmEventRealTimeDock::onBtnClicked_confirmAll);
|
|
|
|
|
|
connect(ui->btnCheckAll, &QPushButton::clicked, this, &AlarmEventRealTimeDock::onBtnClicked_checkAll);
|
|
|
|
|
|
|
|
|
|
|
|
/*if(parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
int parentWidth = parent->width();
|
|
|
|
|
|
int parentHeight = parent->height();
|
|
|
|
|
|
int selfWidth = parentWidth * 0.8;
|
|
|
|
|
|
int x = (parentWidth - selfWidth) * 0.5;
|
|
|
|
|
|
int y = parentHeight - ui->tobBar->height();
|
|
|
|
|
|
setGeometry(x, y, selfWidth, height());
|
|
|
|
|
|
}*/
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AlarmEventRealTimeDock::~AlarmEventRealTimeDock()
|
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void AlarmEventRealTimeDock::expand()
|
|
|
|
|
|
{
|
2025-10-29 17:38:57 +08:00
|
|
|
|
if(m_isInAnimationExpand || m_curState == "expand" )
|
2025-09-24 12:10:51 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
QWidget* parent = this->parentWidget();
|
|
|
|
|
|
if(parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
QRect startRect(x(), y(), width(), height());
|
|
|
|
|
|
QRect endRect(x(), parent->height() - height() - bottomMargin, width(), height());
|
2025-10-28 18:50:59 +08:00
|
|
|
|
m_animationExpand->setStartValue(startRect);
|
|
|
|
|
|
m_animationExpand->setEndValue(endRect);
|
|
|
|
|
|
m_animationExpand->start();
|
2025-09-24 12:10:51 +08:00
|
|
|
|
m_curState = "expand";
|
2025-10-29 17:38:57 +08:00
|
|
|
|
m_isInAnimationExpand = true;
|
|
|
|
|
|
|
|
|
|
|
|
stopAlarmAlert();
|
2025-09-24 12:10:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AlarmEventRealTimeDock::collapse()
|
|
|
|
|
|
{
|
2025-10-29 17:38:57 +08:00
|
|
|
|
if(m_isInAnimationExpand || m_curState == "collapse" )
|
2025-09-24 12:10:51 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
QWidget* parent = this->parentWidget();
|
|
|
|
|
|
if(parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
QRect startRect(x(), y(), width(), height());
|
2025-10-28 18:50:59 +08:00
|
|
|
|
QRect endRect(x(), parent->height() - ui->tobBar->height() - ui->alertWidget->height(), width(), height());
|
|
|
|
|
|
m_animationExpand->setStartValue(startRect);
|
|
|
|
|
|
m_animationExpand->setEndValue(endRect);
|
|
|
|
|
|
m_animationExpand->start();
|
2025-09-24 12:10:51 +08:00
|
|
|
|
m_curState = "collapse";
|
2025-10-29 17:38:57 +08:00
|
|
|
|
m_isInAnimationExpand = true;
|
2025-09-24 12:10:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AlarmEventRealTimeDock::updateGeometry()
|
|
|
|
|
|
{
|
|
|
|
|
|
QWidget* parent = this->parentWidget();
|
|
|
|
|
|
if(parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
int parentWidth = parent->width();
|
|
|
|
|
|
int parentHeight = parent->height();
|
|
|
|
|
|
int selfWidth = parentWidth * 0.8;
|
|
|
|
|
|
int x = (parentWidth - selfWidth) * 0.5;
|
2025-10-28 18:50:59 +08:00
|
|
|
|
int y = parentHeight - ui->tobBar->height() - ui->alertWidget->height();
|
2025-09-24 12:10:51 +08:00
|
|
|
|
if(m_curState == "expand")
|
|
|
|
|
|
y = parentHeight - this->height() - bottomMargin;
|
|
|
|
|
|
setGeometry(x, y, selfWidth, height());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-29 17:38:57 +08:00
|
|
|
|
void AlarmEventRealTimeDock::startAlarmAlert()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_isInAnimationAlert || m_curState == "expand")
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
m_animationAlert->start();
|
|
|
|
|
|
m_isInAnimationAlert = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AlarmEventRealTimeDock::stopAlarmAlert()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!m_isInAnimationAlert)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
m_animationAlert->stop();
|
|
|
|
|
|
m_isInAnimationAlert = false;
|
|
|
|
|
|
|
|
|
|
|
|
m_alertWidgetStyleSheet = QString(
|
|
|
|
|
|
"background-color: qradialgradient("
|
|
|
|
|
|
"spread:pad, "
|
|
|
|
|
|
"cx:0.5, cy:0.5, radius:0.5, "
|
|
|
|
|
|
"fx:0.5, fy:0.5, "
|
|
|
|
|
|
"stop:0 rgba(200, 0, 0, 0), "
|
|
|
|
|
|
"stop:1 rgba(255, 255, 255, 0));"
|
|
|
|
|
|
);
|
|
|
|
|
|
ui->alertWidget->setStyleSheet(m_alertWidgetStyleSheet);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AlarmEventRealTimeDock::setAlertWidgetBGColorAlpha(float value)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_alertWidgetBGColorAlpha = value;
|
|
|
|
|
|
updateAlertWidgetBGColorAlpha();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AlarmEventRealTimeDock::updateAlertWidgetBGColorAlpha()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 计算透明度 (从0到200再到0)
|
|
|
|
|
|
int alpha = 200 * (1 - qAbs(2 * m_alertWidgetBGColorAlpha - 1));
|
|
|
|
|
|
if(alpha == 1) //1表示不透,具体原因为探究,先舍弃该值
|
|
|
|
|
|
return;
|
|
|
|
|
|
QString styleSheet = QString(
|
|
|
|
|
|
"background-color: qradialgradient("
|
|
|
|
|
|
"spread:pad, "
|
|
|
|
|
|
"cx:0.5, cy:0.5, radius:0.5, "
|
|
|
|
|
|
"fx:0.5, fy:0.5, "
|
|
|
|
|
|
"stop:0 rgba(200, 0, 0, %1), "
|
|
|
|
|
|
"stop:1 rgba(255, 255, 255, 0));"
|
|
|
|
|
|
).arg(alpha);
|
|
|
|
|
|
|
|
|
|
|
|
if(m_alertWidgetStyleSheet != styleSheet)
|
|
|
|
|
|
{
|
|
|
|
|
|
//qDebug() << alpha;
|
|
|
|
|
|
ui->alertWidget->setStyleSheet(styleSheet);
|
|
|
|
|
|
m_alertWidgetStyleSheet = styleSheet;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-24 12:10:51 +08:00
|
|
|
|
void AlarmEventRealTimeDock::onBtnClicked_open()
|
|
|
|
|
|
{
|
|
|
|
|
|
expand();
|
|
|
|
|
|
ui->btnOpen->setVisible(false);
|
|
|
|
|
|
ui->btnClose->setVisible(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AlarmEventRealTimeDock::onBtnClicked_close()
|
|
|
|
|
|
{
|
|
|
|
|
|
collapse();
|
|
|
|
|
|
ui->btnOpen->setVisible(true);
|
|
|
|
|
|
ui->btnClose->setVisible(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AlarmEventRealTimeDock::onBtnClicked_confirmAll()
|
2025-10-29 17:38:57 +08:00
|
|
|
|
{
|
|
|
|
|
|
//stopAlarmAlert();
|
|
|
|
|
|
}
|
2025-09-24 12:10:51 +08:00
|
|
|
|
|
|
|
|
|
|
void AlarmEventRealTimeDock::onBtnClicked_checkAll()
|
2025-10-29 17:38:57 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
2025-09-24 12:10:51 +08:00
|
|
|
|
|
2025-10-29 17:38:57 +08:00
|
|
|
|
void AlarmEventRealTimeDock::onSIG_receivedNewAlarm(const EventData& event)
|
|
|
|
|
|
{
|
|
|
|
|
|
startAlarmAlert();
|
2025-10-29 17:53:43 +08:00
|
|
|
|
|
|
|
|
|
|
m_alarmDataStatics.allCount++;
|
|
|
|
|
|
ui->alarmCount->setText(QString::number(m_alarmDataStatics.allCount));
|
|
|
|
|
|
if(event.severity == "事故")
|
|
|
|
|
|
{
|
|
|
|
|
|
m_alarmDataStatics.accidentCount++;
|
|
|
|
|
|
ui->accidentCount->setText(QString::number(m_alarmDataStatics.accidentCount));
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(event.severity == "异常")
|
|
|
|
|
|
{
|
|
|
|
|
|
m_alarmDataStatics.abnormalCount++;
|
|
|
|
|
|
ui->abnormalCount->setText(QString::number(m_alarmDataStatics.abnormalCount));
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(event.severity == "预警")
|
|
|
|
|
|
{
|
|
|
|
|
|
m_alarmDataStatics.alertCount++;
|
|
|
|
|
|
ui->alertCount->setText(QString::number(m_alarmDataStatics.alertCount));
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(event.severity == "告知")
|
|
|
|
|
|
{
|
|
|
|
|
|
m_alarmDataStatics.informCount++;
|
|
|
|
|
|
ui->informCount->setText(QString::number(m_alarmDataStatics.informCount));
|
|
|
|
|
|
}
|
2025-10-29 17:38:57 +08:00
|
|
|
|
}
|
2025-09-24 12:10:51 +08:00
|
|
|
|
|