2021-12-17 09:18:13 +08:00
|
|
|
//
|
|
|
|
|
// Created by Krad on 2021/12/16.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "TopBarWidget.h"
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QHBoxLayout>
|
2021-12-23 10:09:35 +08:00
|
|
|
#include "components/RollingMessageWidget.h"
|
2021-12-17 09:18:13 +08:00
|
|
|
#include <QDateTime>
|
2021-12-17 10:24:05 +08:00
|
|
|
#include "event/EventCenter.h"
|
2021-12-20 13:25:31 +08:00
|
|
|
#include "errorhandle/GUIErrorLW.h"
|
2022-01-12 17:06:08 +08:00
|
|
|
#include "json/jsonobject.h"
|
2021-12-17 09:18:13 +08:00
|
|
|
|
|
|
|
|
TopBarWidget::TopBarWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) {
|
|
|
|
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
2021-12-17 10:24:05 +08:00
|
|
|
layout->setMargin(0);
|
2021-12-17 09:18:13 +08:00
|
|
|
QLabel * logo = new QLabel(this);
|
2021-12-17 10:24:05 +08:00
|
|
|
QPixmap img(":/icons/logo.png");
|
|
|
|
|
logo->setPixmap(img.scaledToHeight(33, Qt::SmoothTransformation));
|
2021-12-17 09:18:13 +08:00
|
|
|
logo->setObjectName("logo");
|
|
|
|
|
layout->addWidget(logo);
|
|
|
|
|
QLabel * company = new QLabel(this);
|
|
|
|
|
company->setObjectName("company");
|
|
|
|
|
layout->addWidget(company);
|
2021-12-17 10:24:05 +08:00
|
|
|
company->setText(tr("浙江衡玖医疗科技"));
|
|
|
|
|
QWidget* spacerLine0 = new QWidget(this);
|
|
|
|
|
spacerLine0->setFixedWidth(2);
|
|
|
|
|
spacerLine0->setObjectName("spacer_2");
|
|
|
|
|
layout->addWidget(spacerLine0);
|
2021-12-17 09:18:13 +08:00
|
|
|
QLabel * lbl_msglogo = new QLabel(this);
|
|
|
|
|
lbl_msglogo->setObjectName("lbl_msglogo");
|
2021-12-17 10:24:05 +08:00
|
|
|
lbl_msglogo->setPixmap(QPixmap(":/icons/msg.png").scaledToHeight(26, Qt::SmoothTransformation));
|
2021-12-17 09:18:13 +08:00
|
|
|
layout->addWidget(lbl_msglogo);
|
2021-12-17 10:24:05 +08:00
|
|
|
|
|
|
|
|
QWidget* widgetMsg = new QWidget(this);
|
2022-01-12 17:06:08 +08:00
|
|
|
layout->addWidget(widgetMsg,1);
|
|
|
|
|
// widgetMsg->setObjectName("need_border");
|
|
|
|
|
widgetMsg->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
|
|
|
|
|
layout->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Expanding));
|
2021-12-17 09:18:13 +08:00
|
|
|
QWidget* statusBarWidget = new QWidget(this);
|
|
|
|
|
layout->addWidget(statusBarWidget);
|
|
|
|
|
QLabel* hosp = new QLabel(this);
|
2022-01-12 17:06:08 +08:00
|
|
|
hosp->setText(JsonObject::Instance()->institutionName());
|
2021-12-17 09:18:13 +08:00
|
|
|
QLabel* nowDate = new QLabel(this);
|
|
|
|
|
nowDate->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
|
|
|
|
|
QLabel* linkIcon = new QLabel(this);
|
|
|
|
|
linkIcon->setPixmap(QPixmap(":/icons/link_g.png").scaledToHeight(22, Qt::SmoothTransformation));
|
|
|
|
|
QLabel* readyIcon = new QLabel(this);
|
|
|
|
|
readyIcon->setPixmap(QPixmap(":/icons/ready.png").scaledToHeight(22, Qt::SmoothTransformation));
|
|
|
|
|
QLabel* lockIcon = new QLabel(this);
|
|
|
|
|
lockIcon->setText("");
|
|
|
|
|
// lockIcon->setPixmap(QPixmap(":/icons/lock.png").scaledToHeight(22,Qt::SmoothTransformation));
|
|
|
|
|
QHBoxLayout* status_layout = new QHBoxLayout(statusBarWidget);
|
|
|
|
|
status_layout->setMargin(0);
|
2022-01-12 17:06:08 +08:00
|
|
|
|
2021-12-17 09:18:13 +08:00
|
|
|
status_layout->addWidget(hosp);
|
|
|
|
|
status_layout->addWidget(nowDate);
|
|
|
|
|
QWidget* spacerLine = new QWidget(this);
|
|
|
|
|
spacerLine->setFixedWidth(2);
|
|
|
|
|
spacerLine->setObjectName("spacer_2");
|
|
|
|
|
|
|
|
|
|
layout->addWidget(spacerLine);
|
|
|
|
|
layout->addWidget(linkIcon);
|
|
|
|
|
layout->addWidget(readyIcon);
|
|
|
|
|
layout->addWidget(lockIcon);
|
2021-12-17 10:24:05 +08:00
|
|
|
|
2021-12-17 09:18:13 +08:00
|
|
|
QVBoxLayout* l = new QVBoxLayout(widgetMsg);
|
|
|
|
|
l->setMargin(0);
|
|
|
|
|
auto w = new RollingMessageWidget(this);
|
2021-12-20 13:25:31 +08:00
|
|
|
|
|
|
|
|
w->setMessageList(GUIErrorLW::getWARNMessages());
|
2021-12-17 09:18:13 +08:00
|
|
|
w->setObjectName("need_border");
|
|
|
|
|
l->addWidget(w);
|
2021-12-17 10:24:05 +08:00
|
|
|
connect(EventCenter::Default(), &EventCenter::ResponseDeviceTemperature, [=](QObject*, QObject* msg) {
|
|
|
|
|
nowDate->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
|
|
|
|
|
if (!msg) return;
|
|
|
|
|
QString* s = (QString*)msg;
|
|
|
|
|
lockIcon->setText(QString("%1%2").arg(*s).arg(tr("°C")));
|
|
|
|
|
});
|
2021-12-20 13:25:31 +08:00
|
|
|
connect(EventCenter::Default(), &EventCenter::WarnStateFlagChange, [=](QObject*, QObject* msg) {
|
|
|
|
|
QVariant* var = (QVariant*)msg;
|
|
|
|
|
int v = var->toInt();
|
|
|
|
|
int f = 0x00000001;
|
|
|
|
|
for (int i = 0; i < 32; ++i) {
|
|
|
|
|
int d = (f<<i);
|
|
|
|
|
if (d & v){
|
|
|
|
|
printf("warn %d, val:%d\r\n", i, v);
|
2022-01-14 14:20:52 +08:00
|
|
|
if (w)w->updateMessagePriority(i,1);
|
2021-12-20 13:25:31 +08:00
|
|
|
} else{
|
2022-01-14 14:20:52 +08:00
|
|
|
if (w)w->updateMessagePriority(i,-1);
|
2021-12-20 13:25:31 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-12-17 09:18:13 +08:00
|
|
|
}
|