代码拉取完成,页面将自动刷新
#include "toolbar.h"
#include "ui_toolbar.h"
ToolBar* ToolBar::m_ToolBar = nullptr;
ToolBar::ToolBar(QWidget *parent) :
QWidget(parent),
ui(new Ui::ToolBar)
{
ui->setupUi(this);
m_LocalNetworkSta = new StatusPic(StatusPic::PIC_OK_SHOW,
"/image/LocalNetworkOk.png",
"/image/LocalNetworkFailed.png",
"/image/LocalNetworkFault.png");
m_BBNetworkSta = new StatusPic(StatusPic::PIC_OK_SHOW,
"/image/BBNetworkStatusOK.png",
"/image/BBNetworkStatusFailed.png",
"");
m_BlackBoxSta = new StatusPic(StatusPic::PIC_OK_SHOW,
"/image/BlackBoxStatusOk.png",
"/image/BlackBoxStatusFailed.png",
"");
m_SatellitePSta = new StatusPic(StatusPic::PIC_OK_SHOW,
"/image/SatellitePStatusOK.png",
"/image/SatellitePStatusFailed.png",
"");
m_MultiComSta = new StatusPic(StatusPic::PIC_OK_SHOW,
"/image/MultiComStatusOk.png",
"/image/MultiComStatusFailed.png",
"");
m_CtlBoardSta = new StatusPic(StatusPic::PIC_OK_SHOW,
"/image/CtlBoardStatusOk.png",
"/image/CtlBoardStatusFailed.png",
"");
m_SmartBoardSta = new StatusPic(StatusPic::PIC_OK_SHOW,
"/image/SmartBoardStatusOk.png",
"/image/SmartBoardStatusFailed.png",
"");
m_StaList.append(m_LocalNetworkSta);
m_StaList.append(m_BBNetworkSta);
m_StaList.append(m_BlackBoxSta);
m_StaList.append(m_SatellitePSta);
m_StaList.append(m_MultiComSta);
m_StaList.append(m_CtlBoardSta);
m_StaList.append(m_SmartBoardSta);
m_LabelList.append(new StatusLabel(true,ui->Sta1));
m_LabelList.append(new StatusLabel(true,ui->Sta2));
m_LabelList.append(new StatusLabel(true,ui->Sta3));
m_LabelList.append(new StatusLabel(true,ui->Sta4));
m_LabelList.append(new StatusLabel(true,ui->Sta5));
m_LabelList.append(new StatusLabel(true,ui->Sta6));
m_LabelList.append(new StatusLabel(true,ui->Sta7));
m_TimeUpdateTimer = new QTimer;
m_TimeUpdateTimer->setInterval(TIME_UPDATE_TIMER);
m_TimeUpdateTimer->start();
m_NetCheckTimer = new QTimer;
m_NetCheckTimer->setInterval(2*1000);
m_NetCheckTimer->start();
m_FaceIdSucess = false;
m_DataDictionary = DataDictionary::GetInstance();
int LockSta = m_DataDictionary->GetMisData(MIS_LOCK_SCREEN).toInt();
if( LockSta == 1)
{
m_ScreenSta = SCREEN_UNLOCK;
}
else if( LockSta == 0)
{
m_ScreenSta = SCREEN_LOCK;
}
SettingButtonPress5s();
SetFaceIdButton(false);
connect(m_NetCheckTimer,SIGNAL(timeout()), \
this,SLOT(CheckNetWork()));
connect(m_TimeUpdateTimer,SIGNAL(timeout()), \
this,SLOT(SysTimeDisplay()));
connect(m_DataDictionary,SIGNAL(MonitorRtDataChange(MonitorRtDataIndex_t)),\
this,SLOT(MonitorRtDataChange(MonitorRtDataIndex_t)));
connect(m_DataDictionary,SIGNAL(MisDataChange(MisDataIndex_t)),\
this,SLOT(MisDataChange(MisDataIndex_t)));
connect(m_DataDictionary,SIGNAL(DevParamDataChange(DevParamDataIndex_t)),\
this,SLOT(DevParamDataChange(DevParamDataIndex_t)));
connect(m_DataDictionary,SIGNAL(SystemDataChange(SystemDataIndex_t)),\
this,SLOT(SystemDataChange(SystemDataIndex_t)));
connect(ui->SettingButton,SIGNAL(Press2s()),\
this,SLOT(SettingButtonPress5s()));
connect(ui->SettingButton,SIGNAL(clicked()),\
this,SLOT(SettingButtonclicked()));
connect(&m_Process,SIGNAL(readyRead()),\
this,SLOT(NetStaCheck()));
}
ToolBar::~ToolBar()
{
delete ui;
}
ToolBar *ToolBar::GetInstance()
{
if(m_ToolBar == nullptr){
m_ToolBar = new ToolBar;
}
return m_ToolBar;
}
void ToolBar::Show(QWidget *parent)
{
MisDataChange(MIS_SERIAL_STA);
DevParamDataChange(D_CB_ENALBE);
DevParamDataChange(D_SENSOR_TYPE);
DevParamDataChange(D_TOWER_CTL_FUNC);
SystemDataChange(SYS_FACEID_ENABLE);
MonitorRtDataChange(M_NETWORK_STA);
MonitorRtDataChange(M_CB_CON_STA);
MonitorRtDataChange(M_SENSOR_STA);
this->setParent(parent);
if(isHidden())
this->show();
}
void ToolBar::SetFaceIdSuccess(QString Name,QImage Img)
{
QImage NewImg = Img.scaled(ui->FaceIdPic->width(), ui->FaceIdPic->height(),\
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
ui->FaceIdName->setText(Name);
ui->FaceIdPic->setPixmap(QPixmap::fromImage(NewImg));
SetFaceIdButton(true);
m_FaceIdSucess = true;
DataDictionary::GetInstance()->SetMisData(MIS_FACEID_STA,1);
}
void ToolBar::ShowStatusPic(void)
{
int i = 0,j = 0;
for(i = 0;i < m_LabelList.size();i++)
{
m_LabelList[i]->SetEnable(false);
}
for(i = 0,j = 0;i < m_StaList.size();i++)
{
switch (m_StaList[i]->GetStatus()) {
case StatusPic::PIC_OK_SHOW:
m_LabelList[j]->SetEnable(true);
m_LabelList[j++]->SetPic(m_StaList[i]->GetOkPic());
break;
case StatusPic::PIC_FAILED_SHOW:
m_LabelList[j]->SetEnable(true);
m_LabelList[j++]->SetPic(m_StaList[i]->GetFailedPic());
break;
case StatusPic::PIC_FAULT_SHOW:
m_LabelList[j]->SetEnable(true);
m_LabelList[j++]->SetPic(m_StaList[i]->GetFaultPic());
break;
case StatusPic::PIC_HIDE:
break;
default:
break;
}
}
for(i = 0;i < m_LabelList.size();i++)
{
m_LabelList[i]->Show();
}
}
void ToolBar::SetFaceIdButton(bool En)
{
if(En)
{
ui->FaceIdButton->setText("退出");
ui->FaceIdButton->setStyleSheet("QPushButton{background-color: rgba(255, 255, 255,0);\
border-image: url(:/image/Transparent.png);\
image: url(:/image/ButtonFaceIdQuite.png);\
font: 18pt 'Ubuntu';\
font:bold;\
color: rgb(255, 255, 255);\
text-align: right;\
image-position:left;\
border:0px solid;}");
}
else
{
ui->FaceIdButton->setText("开始");
ui->FaceIdButton->setStyleSheet("QPushButton{background-color: rgba(255, 255, 255,0);\
border-image: url(:/image/Transparent.png);\
image: url(:/image/ButtonFaceIdStart.png);\
font: 18pt 'Ubuntu';\
font:bold;\
color: rgb(255, 255, 255);\
text-align: right;\
image-position:left;\
border:0px solid;}");
}
}
void ToolBar::CheckNetWork()
{
QString Ip = getIPAddress();
QString V = m_DataDictionary->GetMisData(MIS_SERVICE_CON_STA);
// if(Ip == tr("127.0.0.1"))
// {
// m_LocalNetworkSta->SetStatus(StatusPic::PIC_FAULT_SHOW);
// }
// else if(Ip != tr("127.0.0.1") && V.toUInt() == MIS_OFFLINE)
// {
// m_LocalNetworkSta->SetStatus(StatusPic::PIC_FAILED_SHOW);
// }
// else if(Ip != tr("127.0.0.1") && V.toUInt() == MIS_ONLINE)
// {
// m_LocalNetworkSta->SetStatus(StatusPic::PIC_OK_SHOW);
// }
QString strArg = "ifconfig eth0";
m_Process.start(strArg);
// if(Ip == tr("127.0.0.1"))
// {
// m_LocalNetworkSta->SetStatus(StatusPic::PIC_FAILED_SHOW);
// }
// else if(Ip != tr("127.0.0.1"))
// {
// m_LocalNetworkSta->SetStatus(StatusPic::PIC_OK_SHOW);
// }
}
void ToolBar::SysTimeDisplay()
{
// QString Date = QDate::currentDate().toString(Qt::ISODate);
QString Time = QTime::currentTime().toString();
// QString Week = QDateTime::currentDateTime().toString("dddd");
ui->TimeShow->setText(Time);
//CheckNetWork();
ShowStatusPic();
update();
}
void ToolBar::MonitorRtDataChange(MonitorRtDataIndex_t Index)
{
QString V = m_DataDictionary->GetMonitorRtData(Index);
switch (Index) {
case M_NETWORK_STA:
if(V.toUInt() == 0)
m_BBNetworkSta->SetStatus(StatusPic::PIC_FAILED_SHOW);
else if(V.toUInt() == 1)
m_BBNetworkSta->SetStatus(StatusPic::PIC_OK_SHOW);
else if(V.toUInt() == 2)
m_BBNetworkSta->SetStatus(StatusPic::PIC_FAULT_SHOW);
break;
case M_SENSOR_STA:
if(m_DataDictionary->GetSensorSta(LOCATION_SENSOR_BIT))
{
if(!(V.toUInt()&(1<<9)))
m_SatellitePSta->SetStatus(StatusPic::PIC_OK_SHOW);
else if((V.toUInt()&(1<<9)))
m_SatellitePSta->SetStatus(StatusPic::PIC_FAILED_SHOW);
}
if(m_DataDictionary->GetSensorSta(MUL_SENSOR_BIT))
{
if(!(V.toUInt()&(1<<6)))
m_MultiComSta->SetStatus(StatusPic::PIC_OK_SHOW);
else if((V.toUInt()&(1<<6)))
m_MultiComSta->SetStatus(StatusPic::PIC_FAILED_SHOW);
}
if(m_DataDictionary->GetDevParamData(D_TOWER_CTL_FUNC).toUInt())
{
if(!(V.toUInt()&(1<<7)))
m_CtlBoardSta->SetStatus(StatusPic::PIC_OK_SHOW);
else if((V.toUInt()&(1<<7)))
m_CtlBoardSta->SetStatus(StatusPic::PIC_FAILED_SHOW);
}
break;
case M_CB_CON_STA:
QString S = m_DataDictionary->GetDevParamData(D_CB_ENALBE);
if(S.toUInt() == 0)
{
m_SmartBoardSta->SetStatus(StatusPic::PIC_HIDE);
break;
}
if(V.toUInt() == 0)
m_SmartBoardSta->SetStatus(StatusPic::PIC_FAILED_SHOW);
else if(V.toUInt() == 1)
m_SmartBoardSta->SetStatus(StatusPic::PIC_OK_SHOW);
else if(V.toUInt() == 2)
m_SmartBoardSta->SetStatus(StatusPic::PIC_FAILED_SHOW);
break;
}
}
void ToolBar::MisDataChange(MisDataIndex_t Index)
{
QString V = m_DataDictionary->GetMisData(Index);
switch (Index) {
case MIS_SERIAL_STA:
if(V.toUInt() == SERIAL_OFFLINE)
m_BlackBoxSta->SetStatus(StatusPic::PIC_FAILED_SHOW);
else if(V.toUInt() == SERIAL_ONLINE)
m_BlackBoxSta->SetStatus(StatusPic::PIC_OK_SHOW);
break;
case MIS_FACEID_START:
if(m_FaceIdSucess)
on_FaceIdButton_clicked();
on_FaceIdButton_clicked();
break;
case MIS_FACEID_QUITE:
if(m_FaceIdSucess)
on_FaceIdButton_clicked();
break;
case MIS_BLKBOX_FACEID_INFO:
if(m_DataDictionary->GetMisData(Index).toUInt() == 1 \
&& m_FaceIdSucess)
on_FaceIdButton_clicked();
break;
}
}
void ToolBar::DevParamDataChange(DevParamDataIndex_t Index)
{
QString V = m_DataDictionary->GetDevParamData(Index);
switch (Index) {
case D_CB_ENALBE:
if(V.toUInt() == 0)
m_SmartBoardSta->SetStatus(StatusPic::PIC_HIDE);
else {
V = m_DataDictionary->GetMonitorRtData(M_CB_CON_STA);
if(V.toUInt() == 0)
m_SmartBoardSta->SetStatus(StatusPic::PIC_FAILED_SHOW);
else if(V.toUInt() == 1)
m_SmartBoardSta->SetStatus(StatusPic::PIC_OK_SHOW);
else if(V.toUInt() == 2)
m_SmartBoardSta->SetStatus(StatusPic::PIC_FAILED_SHOW);
}
break;
case D_SENSOR_TYPE:
if(m_DataDictionary->GetSensorSta(LOCATION_SENSOR_BIT))
{
m_SatellitePSta->SetStatus(StatusPic::PIC_OK_SHOW);
}
else
{
m_SatellitePSta->SetStatus(StatusPic::PIC_HIDE);
}
if(m_DataDictionary->GetSensorSta(MUL_SENSOR_BIT))
{
m_MultiComSta->SetStatus(StatusPic::PIC_OK_SHOW);
}
else
{
m_MultiComSta->SetStatus(StatusPic::PIC_HIDE);
}
// if(m_DataDictionary->GetSensorSta(CTL_SENSOR_BIT))
// {
// m_CtlBoardSta->SetStatus(StatusPic::PIC_HIDE);
// }
// else
// {
// m_CtlBoardSta->SetStatus(StatusPic::PIC_HIDE);
// }
MonitorRtDataChange(M_SENSOR_STA);
break;
case D_TOWER_CTL_FUNC:
if(m_DataDictionary->GetDevParamData(Index).toUInt())
{
m_CtlBoardSta->SetStatus(StatusPic::PIC_OK_SHOW);
}
else
{
m_CtlBoardSta->SetStatus(StatusPic::PIC_HIDE);
}
break;
default:
break;
}
}
void ToolBar::SystemDataChange(SystemDataIndex_t Index)
{
QString V;
switch (Index) {
case SYS_FACEID_ENABLE:
V = m_DataDictionary->GetSystemData(Index);
FaceIdEnable(V.toUInt());
break;
}
}
void ToolBar::FaceIdEnable(bool S)
{
if(S)
{
ui->FaceIdPic->show();
ui->FaceIdName->show();
ui->FaceIdButton->show();
}
else
{
ui->FaceIdPic->hide();
ui->FaceIdName->hide();
ui->FaceIdButton->hide();
}
}
void ToolBar::SettingButtonclicked()
{
if(m_ScreenSta == SCREEN_UNLOCK)
emit SettingClicked();
}
void ToolBar::SettingButtonPress5s()
{
if(m_ScreenSta == SCREEN_LOCK)
{
ui->SettingButton->setStyleSheet("QPushButton{\
background-color: rgba(255, 255, 255,0);\
border-image: url(:/image/Transparent.png);\
image: url(:/image/ButtonSettingUnlock.png);}");
m_ScreenSta = SCREEN_UNLOCK;
AllButtonLock(false);
LockScreen(false);
}
else if(m_ScreenSta == SCREEN_UNLOCK)
{
ui->SettingButton->setStyleSheet("QPushButton{\
background-color: rgba(255, 255, 255,0);\
border-image: url(:/image/Transparent.png);\
image: url(:/image/ButtonSettinglock.png);}");
m_ScreenSta = SCREEN_LOCK;
AllButtonLock(true);
LockScreen(true);
}
}
void ToolBar::NetStaCheck()
{
QString retStr = m_Process.readAll();
QStringList list = retStr.split("\n");
QStringList Tx = list.filter("TX packets:");
if(Tx.size() > 0)
{
QString TxData = Tx[0];
QRegExp rx("(\\d+)(?:\\s*)");
rx.indexIn(TxData,0);
QString Index=rx.cap(1);
if(Index == m_NetTxBytesTmp)
{
m_LocalNetworkSta->SetStatus(StatusPic::PIC_FAILED_SHOW);
}
else
{
m_LocalNetworkSta->SetStatus(StatusPic::PIC_OK_SHOW);
}
m_NetTxBytesTmp = Index;
}
}
void ToolBar::on_FaceIdButton_clicked()
{
if(m_FaceIdSucess)
{
QuiteFaceId();
SetFaceIdButton(false);
m_FaceIdSucess = false;
ui->FaceIdPic->setPixmap(QPixmap::fromImage(QImage()));
ui->FaceIdName->setText("未识别");
DataDictionary::GetInstance()->SetMisData(MIS_FACEID_STA,0);
}
else
{
StartFaceId();
}
}
void ToolBar::on_VolumeButton_clicked()
{
VolumeClicked();
}
void ToolBar::AllButtonLock(bool S)
{
if(S)
{
ui->FaceIdButton->setEnabled(false);
ui->VolumeButton->setEnabled(false);
}
else
{
ui->FaceIdButton->setEnabled(true);
ui->VolumeButton->setEnabled(true);
}
}
ToolBar::SCREEN_STA ToolBar::GetLockScreenSta()
{
return m_ScreenSta;
}
void ToolBar::SetVolumeMute(bool S)
{
if(S)
{
ui->VolumeButton->setStyleSheet("QPushButton{background-color: rgba(255, 255, 255,0);\
border-image: url(:/image/Transparent.png);\
image: url(:/image/ButtonMute.png);}");
}
else
{
ui->VolumeButton->setStyleSheet("QPushButton{background-color: rgba(255, 255, 255,0);\
border-image: url(:/image/Transparent.png);\
image: url(:/image/ButtonSnd.png);}");
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。