FaceAccess/Linguist/recoUi/recoUiRecognize.cpp
2024-07-11 11:27:12 +08:00

2790 lines
97 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "recoUiRecognize.h"
#include <QDebug>
#include "UiConfig.h"
#include <QHBoxLayout>
#include <math.h>
#include <QTimer>
#include <QTouchEvent>
#include "UiInterfaceForBackstage.h"
#include <QPainter>
const int SceneMsgWidget::DATE_TIME_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {28, 26, 26, 10, 10};
SceneMsgWidget::SceneMsgWidget(QWidget *parent) : QWidget(parent)
{
setAutoFillBackground(true);
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText,Qt::black);
palette.setColor(QPalette::Background, QColor(Qt::white));
setPalette(palette);
setFixedSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight() / 10);
m_wgtDateTime = new DateTimeWidgetClassical(DATE_TIME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()], this);
connect(m_wgtDateTime, SIGNAL(signalNewDay()), this, SLOT(slotNewDay()));
m_labelPersonNum = new QLabel(this);
QFont ft;
ft.setPointSize(DATE_TIME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_labelPersonNum->setFont(ft);
QHBoxLayout* hlay = new QHBoxLayout();
hlay->addWidget(m_wgtDateTime);
hlay->addStretch();
hlay->addWidget(m_labelPersonNum);
hlay->setMargin(20);
setLayout(hlay);
}
int SceneMsgWidget::setType(int type)
{
qDebug() << "type:" << type << "m_type:" << m_type;
if(type < 0 || type > 2 || m_type == type){
return -1;
}
m_type = type;
if(2 == m_type){
m_labelPersonNum->setText("");
}else if(m_type >= 0){
setPersonNum(-1, 0);
}
return 0;
}
void SceneMsgWidget::setPersonNum(int source, int personNum)
{
qDebug() << "type:" << m_type << "source:" << source;
if(m_type == 2 || (source >=0 && source != m_type)){
return;
}
const QVector<QString> items{tr("今日检票:"), tr("今日通行:")};
if (m_type < items.size()) {
m_labelPersonNum->setText(items.at(m_type) + QString::number(personNum) + tr(""));
}
}
void SceneMsgWidget::setBgTransparent(bool set)
{
QPalette palette(this->palette());
palette.setColor(QPalette::Background, set ? QColor(0, 0, 0, 0) : QColor(Qt::white));
setPalette(palette);
}
void SceneMsgWidget::slotNewDay()
{
setPersonNum(-1, 0);
}
const QString TmprWidget::TEMP_BG_GREEN_TOP_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/green-top-small.png",
":/res/image/green-top-middle.png",
":/res/image/green-top-middle.png",
":/res/image/green-top-middle-rk.png",
":/res/image/green-top-middle-rk.png"
};
const QString TmprWidget::TEMP_BG_RED_TOP_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/red-top-small.png",
":/res/image/red-top-middle.png",
":/res/image/red-top-middle.png",
":/res/image/red-top-middle-rk.png",
":/res/image/red-top-middle-rk.png"
};
const int TmprWidget::TMPR_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {174, 192, 192, 193, 193};
const int TmprWidget::TMPR_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {25, 40, 40, 14, 14};
const QString MsgWidget::NO_NETWORK_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
{":/res/image/no-network-smallB.png",
":/res/image/no-network-middleB.png",
":/res/image/no-network-middleB.png",
":/res/image/no-network-middleB.png",
":/res/image/no-network-middleB.png"},
{":/res/image/no-network-small.png",
":/res/image/no-network-middle.png",
":/res/image/no-network-middle.png",
":/res/image/no-network-middle.png",
":/res/image/no-network-middle.png"},
};
const QString MsgWidget::NETWORK_CONNECTED_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
{":/res/image/network-connected-smallB.png",
":/res/image/network-connected-middleB.png",
":/res/image/network-connected-middleB.png",
":/res/image/network-connected-middleB.png",
":/res/image/network-connected-middleB.png"},
{":/res/image/network-connected-small.png",
":/res/image/network-connected-middle.png",
":/res/image/network-connected-middle.png",
":/res/image/network-connected-middle.png",
":/res/image/network-connected-middle.png"},
};
const QString MsgWidget::NETWORK_LOGGED_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
{":/res/image/network-cloud-smallB.png",
":/res/image/network-cloud-middleB.png",
":/res/image/network-cloud-middleB.png",
":/res/image/network-cloud-middleB.png",
":/res/image/network-cloud-middleB.png"},
{":/res/image/network-cloud-small.png",
":/res/image/network-cloud-middle.png",
":/res/image/network-cloud-middle.png",
":/res/image/network-cloud-middle.png",
":/res/image/network-cloud-middle.png"},
};
const QString MsgWidget::NET_ETH_IP_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
{":/res/image/network-smallB.png",
":/res/image/network-middleB.png",
":/res/image/network-middleB.png",
":/res/image/network-middleB.png",
":/res/image/network-middleB.png"},
{":/res/image/network-small.png",
":/res/image/network-middle.png",
":/res/image/network-middle.png",
":/res/image/network-middle.png",
":/res/image/network-middle.png"},
};
const QString MsgWidget::NET_WIFI_IP_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
{":/res/image/wifi-smallB.png",
":/res/image/wifi-middleB.png",
":/res/image/wifi-middleB.png",
":/res/image/wifi-middleB.png",
":/res/image/wifi-middleB.png"},
{":/res/image/wifi-small.png",
":/res/image/wifi-middle.png",
":/res/image/wifi-middle.png",
":/res/image/wifi-middle.png",
":/res/image/wifi-middle.png"},
};
const QString MsgWidget::NET_4G_IP_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/4G-small.png",
":/res/image/4G-middle.png",
":/res/image/4G-middle.png",
":/res/image/4G-middle.png",
":/res/image/4G-middle.png"
};
const QString MsgWidget::BG_BLUE_BOM_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/blue-bom-small.png",
":/res/image/blue-bom-middle.png",
":/res/image/blue-bom-middle.png",
":/res/image/blue-bom-middle.png",
":/res/image/blue-bom-middle.png"
};
const QString MsgWidget::BG_GREEN_BOM_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/green-bom-small.png",
":/res/image/green-bom-middle.png",
":/res/image/green-bom-middle.png",
":/res/image/green-bom-middle.png",
":/res/image/green-bom-middle.png"
};
const QString MsgWidget::BG_RED_BOM_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/red-bom-small.png",
":/res/image/red-bom-middle.png",
":/res/image/red-bom-middle.png",
":/res/image/red-bom-middle.png",
":/res/image/red-bom-middle.png"
};
const int MsgWidget::TIME_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {8, 24, 22, 8, 7};
const int MsgWidget::MSG_WORD_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {12, 24, 24, 8, 8};
const int MsgWidget::NOTI_MSG_WORD_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {8, 16, 15, 6, 5};
//const int DetectResultWidget::DETECT_RESULT_WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {389, 492, 492, 492, 492};
//const int DetectResultWidget::DETECT_RESULT_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {108, 134, 134, 136, 136};
const int DetectResultWidget::DETECT_RESULT_WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {389, 490, 490, 490, 490};
const int DetectResultWidget::DETECT_RESULT_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {108, 128, 128, 129, 129};
const int DetectResultWidget::MASK_LOGO_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {50, 80, 80, 64, 64};
const QString DetectResultWidget::BG_BLUE_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/msg_box_bg_blue.png",
":/res/image/msg_box_bg_type1_blue_large.png",
":/res/image/msg_box_bg_type1_blue_large.png",
":/res/image/msg_box_bg_type1_blue_large.png", //msg_box_bg_blue_middle
":/res/image/msg_box_bg_type1_blue_large.png"
};
const QString DetectResultWidget::BG_RED_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/msg_box_bg_red.png",
":/res/image/msg_box_bg_type1_red_large.png",
":/res/image/msg_box_bg_type1_red_large.png",
":/res/image/msg_box_bg_type1_red_large.png", //msg_box_bg_red_middle
":/res/image/msg_box_bg_type1_red_large.png"
};
const QString recoUiRecognize::BG_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/face-small.png",
":/res/image/jinggong-face-middle.png",
":/res/image/face_720_1280.png",
":/res/image/jinggong-face-middle.png",
":/res/image/face_720_1280.png"
};
const QString recoUiRecognize::DARK_FILL_LIGHT_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
"",
":/res/image/dark_fill_light_8inch.png",
":/res/image/dark_fill_light_5inch.png",
":/res/image/dark_fill_light_8inch.png",
":/res/image/dark_fill_light_5inch.png"
};
//7 inch: 600 * 0.1
//8 inch: 800 * 0.12
//5 inch: 720 * 0.12
const int recoUiRecognize::MSG_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {60, 96, 86, 97, 97};
const QString recoUiRecognize::SCANLINE_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/scan-line-small.png",
":/res/image/scan-line-middle.png",
":/res/image/scan-line-middle.png",
":/res/image/scan-line-middle.png",
":/res/image/scan-line-middle.png"
};
const QString recoUiRecognize::LOGO_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/logo_small.png",
":/res/image/logo2.png",
":/res/image/logo2.png",
":/res/image/logo2.png",
":/res/image/logo2.png"
};
const QString recoUiRecognize::TEMP_CALIBOX_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/calibration_box_small.png",
":/res/image/calibration_box_middle.png",
":/res/image/calibration_box_middle.png",
":/res/image/calibration_box_middle.png",
":/res/image/calibration_box_middle.png"
};
const int CenterMsgWidget::WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {459, 566, 509, 566, 509};
const int CenterMsgWidget::WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {253, 313, 282, 313, 282};
const int CenterMsgWidget::FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {14, 22, 22, 8, 8};
const QString CenterMsgWidget::BG_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/center_msg_600_1024.png",
":/res/image/center_msg_800_1280.png",
":/res/image/center_msg_720_1280.png",
":/res/image/center_msg_800_1280.png",
":/res/image/center_msg_720_1280.png"
};
const QString recoUiRecognize::PWD_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/pwd_small.png",
":/res/image/pwd_large.png",
":/res/image/pwd_middle.png",
":/res/image/pwd_large.png",
":/res/image/pwd_middle.png"
};
const QString recoUiRecognize::PWD_BTN_PRESSED[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/pwd_small_pressed.png",
":/res/image/pwd_large_pressed.png",
":/res/image/pwd_middle_pressed.png",
":/res/image/pwd_large_pressed.png",
":/res/image/pwd_middle_pressed.png"
};
const int recoUiRecognize::PWD_BTN_W_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {61, 92, 76, 93, 77};
const QString FinalResultWidget::FINAL_RESULT_OK_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/ok_small.png",
":/res/image/ok_large.png",
":/res/image/ok_middle.png",
":/res/image/ok_large.png",
":/res/image/ok_middle.png"
};
const QString FinalResultWidget::FINAL_RESULT_FAIL_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/fail_small.png",
":/res/image/fail_large.png",
":/res/image/fail_middle.png",
":/res/image/fail_large.png",
":/res/image/fail_middle.png"
};
const int FinalResultWidget::FINAL_RESULT_WIDGET_W_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {130, 173, 160, 173, 160};
const int recoUiRecognize::SWIP_CARD_WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {400, 598, 598, 598, 598};
const int recoUiRecognize::SWIP_CARD_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {70, 131, 131, 132, 132};
const QString recoUiRecognize::SWIP_CARD_DAY_MODE_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/swipe_card_day_mode_type0_large.png",
":/res/image/swipe_card_day_mode_type0_large.png",
":/res/image/swipe_card_day_mode_type0_large.png",
":/res/image/swipe_card_day_mode_type0_large.png",
":/res/image/swipe_card_day_mode_type0_large.png"
};
const QString recoUiRecognize::SWIP_CARD_NIGHT_MODE_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/swipe_card_night_mode_type0_large.png",
":/res/image/swipe_card_night_mode_type0_large.png",
":/res/image/swipe_card_night_mode_type0_large.png",
":/res/image/swipe_card_night_mode_type0_large.png",
":/res/image/swipe_card_night_mode_type0_large.png"
};
const QString recoUiRecognize::CALL_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/voice_video_call_large.png",
":/res/image/voice_video_call_large.png",
":/res/image/voice_video_call_large.png",
":/res/image/voice_video_call_large.png",
":/res/image/voice_video_call_large.png"
};
TmprWidget::TmprWidget(QWidget *parent) : QWidget (parent), m_ForeheadTmpr(0)
{
m_label_tem = new QLabel(this);
//m_label_tem->setText("--℃");
//m_label_msg = new QLabel(this);
//m_label_msg->setText(tr("体温正常"));
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText,Qt::white);
palette.setColor(QPalette::Background,QColor(0, 0, 0, 0));
setAutoFillBackground(true);
setPalette(palette);
QFont ft;
ft.setPointSize(static_cast<int>(TMPR_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] *
UiConfig::GetInstance()->recoUiTextCfgFontSize(RecoUiTextCfg::TextTemp)));
m_label_tem->setFont(ft);
//m_label_msg->setFont(ft);
QVBoxLayout* vLayout = new QVBoxLayout();
vLayout->addWidget(m_label_tem, 1, Qt::AlignTop | Qt::AlignCenter);
//vLayout->addWidget(m_label_msg, 1, Qt::AlignCenter);
setLayout(vLayout);
}
TmprWidget::~TmprWidget()
{
}
void TmprWidget::showNormalTemp(const QString& msg, float temp, bool isC)
{
//if(isHidden() || fabs(m_ForeheadTmpr - temp) > 0.1f)
{
QString strTem = msg;
QString tmpr;
const float min = (isC ? recoUiRecognize::LOW_TEMP_VALUE : recoUiRecognize::LOW_TEMP_VALUE * 1.8 + 32.0);
const float max = (isC ? recoUiRecognize::HIGH_TEMP_VALUE : recoUiRecognize::HIGH_TEMP_VALUE * 1.8 + 32.0);
if(temp < min){
strTem += "<" + tmpr.setNum(min, 'f', 1); //为了不增加新的翻译项,小于号单独加
}
else if(temp > max){
strTem += ">" + tmpr.setNum(max, 'f', 1); //为了不增加新的翻译项,大于号单独加
}
else {
strTem += tmpr.setNum(temp, 'f', 1);
}
strTem += (isC ? "" : "");
if(temp < 0.0f){
strTem = "";
}
QFont ft;
ft.setPointSize(UiConfig::GetInstance()->recoUiFontSize(RecoUiTextCfg::TextTemp) ?
UiConfig::GetInstance()->recoUiFontSize(RecoUiTextCfg::TextTemp) :
static_cast<int>(TMPR_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] *
UiConfig::GetInstance()->recoUiTextCfgFontSize(RecoUiTextCfg::TextTemp)));
m_label_tem->setFont(ft);
m_label_tem->setText(strTem);
#if 0
QPalette palette(this->palette());
palette.setColor(QPalette::Background,QColor(79, 129, 223, 200)); //蓝色正常体温
setPalette(palette);
show();
#endif
m_ForeheadTmpr = temp;
}
}
void TmprWidget::showAbnormalTemp(const QString& msg, float temp, bool isHigh, bool isC)
{
//qDebug() << "showAbnormalTemp:" << temp << "-" << isHigh;
//if(isHidden() || fabs(m_ForeheadTmpr - temp) > 0.1f)
{
const float min = (isC ? recoUiRecognize::LOW_TEMP_VALUE : recoUiRecognize::LOW_TEMP_VALUE * 1.8 + 32.0);
const float max = (isC ? recoUiRecognize::HIGH_TEMP_VALUE : recoUiRecognize::HIGH_TEMP_VALUE * 1.8 + 32.0);
QString strTem = msg;
//QPalette palette(this->palette());
/*
if( temp > static_cast<float>(-(1e-6)) && temp < static_cast<float>(1e-6) )
{
//strTem = "---℃";
//m_label_msg->setText(tr("体温测量中..."));
//palette.setColor(QPalette::Background,QColor(144, 158, 195, 200));
}
else*/
{
QString tmpr;
//if(isHigh){
if(temp < min){
strTem += "<" + tmpr.setNum(min, 'f', 1); //为了不增加新的翻译项,小于号单独加
}
else if(temp > max){
strTem += ">" + tmpr.setNum(max, 'f', 1); //为了不增加新的翻译项,大于号单独加
}
else {
strTem += tmpr.setNum(temp, 'f', 1);
}
//}
strTem += (isC ? "" : "");
//if(isHigh)
// m_label_msg->setText(tr("疑似高温"));
//else
// m_label_msg->setText(tr("低温异常"));
//palette.setColor(QPalette::Background,QColor(200, 77, 79, 200));//红色异常体温
}
if(temp < 0.0f){
strTem = "";
}
QFont ft;
ft.setPointSize(UiConfig::GetInstance()->recoUiFontSize(RecoUiTextCfg::TextTemp) ?
UiConfig::GetInstance()->recoUiFontSize(RecoUiTextCfg::TextTemp) :
static_cast<int>(TMPR_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] *
UiConfig::GetInstance()->recoUiTextCfgFontSize(RecoUiTextCfg::TextTemp)));
m_label_tem->setFont(ft);
m_label_tem->setText(strTem);
//setPalette(palette);
//show();
m_ForeheadTmpr = temp;
}
}
void TmprWidget::setBackgroundColor(WIDGET_BG_COLOR_E color)
{
QPalette pal(palette());
if(WIDGET_BG_COLOR_GREEN == color){
pal.setBrush(QPalette::Background, QBrush(QPixmap(TEMP_BG_GREEN_TOP_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
}
else if(WIDGET_BG_COLOR_RED == color){
pal.setBrush(QPalette::Background, QBrush(QPixmap(TEMP_BG_RED_TOP_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
}
pal.setColor(QPalette::WindowText,Qt::white);
setPalette(pal);
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
}
MsgWidget::MsgWidget(int timeType, int iconType, const QColor& textColor, QWidget *parent) : QWidget(parent), m_style(iconType)
{
qDebug() << "MsgWidget()";
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText, textColor);
palette.setColor(QPalette::Background, QColor(0, 0, 0, 0));
setPalette(palette);
setAutoFillBackground(true);
QFont ft;
//m_label_msgTop = new QLabel(this);
//m_label_msgTop->setText(tr("请刷脸通行"));
//ft.setPointSize(recoUiRecognize::MSG_WORD_SIZE);
//m_label_msgTop->setFont(ft);
m_label_Icon = new QLabel(this);
//m_label_Icon->setFixedSize(recoUiRecognize::LOGO_SIZE, recoUiRecognize::LOGO_SIZE);
//QPixmap pm(":/res/image/logo.png");
//m_label_Icon->setPixmap(pm.scaled(recoUiRecognize::LOGO_SIZE, recoUiRecognize::LOGO_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
m_label_Icon->setAutoFillBackground(true);
setLogo("");
m_label_msgBtm = new QLabel(this);
ft.setPointSize(MSG_WORD_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_label_msgBtm->setFont(ft);
m_label_msgNoti = new QLabel(this);
ft.setPointSize(NOTI_MSG_WORD_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_label_msgNoti->setFont(ft);
//m_label_msgNoti->setText("正在同步云端人员信息(99/100)");//for test
m_label_networkStatus = new QLabel(this);
QPixmap pm;
pm.load(NO_NETWORK_RES_FILE[m_style][UiConfig::GetInstance()->getScreenConfigIndex()]);
//pm = pm.scaled(20, 20, Qt::KeepAspectRatio);
m_label_networkStatus->setPixmap(pm);
m_label_time = new QLabel(this);
m_label_time->setText("12:34");
ft.setPointSize(TIME_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_label_time->setFont(ft);
_timerUpdate = new TimerUpdate(m_label_time, this);
if(0 == timeType){
m_label_time->hide();
}
m_label_ip = new QLabel(this);
m_label_ip->setText("xxx.xxx.xxx.xxx");
ft.setPointSize(static_cast<int>(TIME_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] * 0.8));
m_label_ip->setFont(ft);
m_label_ipType = new QLabel(this);
pm.load(NET_ETH_IP_RES_FILE[m_style][UiConfig::GetInstance()->getScreenConfigIndex()]);
//pm = pm.scaled(20, 20, Qt::KeepAspectRatio);
m_label_ipType->setPixmap(pm);
//ft.setPointSize(static_cast<int>(TIME_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] * 0.8));
m_labelDevId = new QLabel(this);
m_labelDevId->setFont(ft);
m_labelVer = new QLabel(this);
m_labelVer->setFont(ft);
QVBoxLayout* vLayoutInfo = new QVBoxLayout();
vLayoutInfo->addStretch();
vLayoutInfo->addWidget(m_labelDevId);
vLayoutInfo->addWidget(m_labelVer);
vLayoutInfo->setSpacing(0);
vLayoutInfo->setContentsMargins(10, 0, 0, 15);//setMargin(15);//
QHBoxLayout* hLayoutIcon = new QHBoxLayout();
hLayoutIcon->addWidget(m_label_Icon);
hLayoutIcon->setSpacing(0);
hLayoutIcon->setMargin(10);
QHBoxLayout* hLayoutRight = new QHBoxLayout();
hLayoutRight->addWidget(m_label_networkStatus, 8, Qt::AlignRight);
if(m_label_time){
hLayoutRight->addWidget(m_label_time, 1, Qt::AlignRight);
}
hLayoutRight->setSpacing(5);
hLayoutRight->setMargin(5);
QHBoxLayout* hLayoutIp = new QHBoxLayout();
hLayoutIp->addWidget(m_label_ipType, 8, Qt::AlignRight);
hLayoutIp->addWidget(m_label_ip, 1, Qt::AlignRight);
hLayoutIp->setSpacing(5);
hLayoutIp->setMargin(5);
QVBoxLayout* vLayout = new QVBoxLayout();
vLayout->addLayout(hLayoutRight, 50);
vLayout->addLayout(hLayoutIp, 2);
vLayout->setSpacing(0);
vLayout->setMargin(10);
//by x 20210317
QVBoxLayout* vLayoutMsg = new QVBoxLayout();
vLayoutMsg->addWidget(m_label_msgBtm);
vLayoutMsg->addWidget(m_label_msgNoti);
vLayoutMsg->setSpacing(0);
vLayoutMsg->setMargin(0);
QHBoxLayout* hLayout = new QHBoxLayout();
hLayout->addWidget(m_label_Icon);//, 1, Qt::AlignLeft
hLayout->addLayout(vLayoutInfo);//, 1
//hLayout->addStretch();
//hLayout->addWidget(m_label_msgBtm, 6, Qt::AlignCenter); //布局管理在其他组件消失时会位置偏移
//hLayout->addWidget(m_label_networkStatus, 1, Qt::AlignRight);
//hLayout->addWidget(m_label_time, 1, Qt::AlignRight);
//hLayout->addLayout(hLayoutIcon, 1);
//hLayout->addLayout(vLayoutMsg, 80); //by x 20210317
hLayout->addLayout(vLayout, 99);
hLayout->setContentsMargins(UiConfig::GetInstance()->getUiWidth() / 50, 0, 0, 0);
hLayout->setSpacing(0);
//QVBoxLayout* vLayout = new QVBoxLayout();
//vLayout->addLayout(hLayoutTop);
//vLayout->addLayout(hLayout);
//vLayout->setSpacing(20);
setLayout(hLayout);
}
MsgWidget::~MsgWidget()
{
qDebug() << "~MsgWidget()";
}
/*
void MsgWidget::setMsgTop(const QString& msg)
{
m_label_msgTop->setText(msg);
}
*/
void MsgWidget::setMsgBtm(const QString& msg, const bool setRedColor)
{
if(msg != ""){
m_label_msgBtm->setText(msg);
QPalette palette(this->palette());
palette.setColor(QPalette::Background,QColor(0, 0, 0, 0));
if(setRedColor){
palette.setColor(QPalette::WindowText,Qt::red);
}
else{
palette.setColor(QPalette::WindowText,Qt::white);
}
m_label_msgBtm->setPalette(palette);
m_label_msgBtm->setAlignment(Qt::AlignCenter);
QFont ft;
ft.setPointSize(static_cast<int>(MSG_WORD_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] *
UiConfig::GetInstance()->recoUiTextCfgFontSize(RecoUiTextCfg::TextNoEntry)));
m_label_msgBtm->setFont(ft);
//by x 20210317
m_label_msgBtm->setFixedSize(UiConfig::GetInstance()->getUiWidth() * 0.7, height() / 2);
m_label_msgBtm->move((UiConfig::GetInstance()->getUiWidth() - m_label_msgBtm->width()) / 2, 0); //(height() - m_label_msgBtm->height()) / 2);
m_label_msgBtm->show();
}
else{
m_label_msgBtm->hide();
}
}
void MsgWidget::setMsgNoti(const QString& msg, int color)
{
if(msg != ""){
m_label_msgNoti->setText(msg);
QPalette palette(this->palette());
palette.setColor(QPalette::Background,QColor(0, 0, 0, 0));
switch(color)
{
case 0:
palette.setColor(QPalette::WindowText,Qt::white);
break;
case 1:
palette.setColor(QPalette::WindowText,Qt::red);
break;
case 2:
palette.setColor(QPalette::WindowText,Qt::yellow);
break;
case 3:
break;
default:
break;
}
m_label_msgNoti->setPalette(palette);
m_label_msgNoti->setAlignment(Qt::AlignCenter);
//by x 20210317
m_label_msgNoti->setFixedSize(UiConfig::GetInstance()->getUiWidth() * 0.5, height() / 2);
m_label_msgNoti->move((UiConfig::GetInstance()->getUiWidth() - m_label_msgNoti->width()) / 2, height() / 2); //(height() - m_label_msgNoti->height()) / 2);
m_label_msgNoti->show();
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
}
else{
m_label_msgNoti->hide();
}
}
void MsgWidget::setLogo(const QString& pic, const bool scale)
{
if(!pic.isEmpty()){
QPixmap pm(pic);
if(scale){
m_label_Icon->setFixedSize(height(), height());
m_label_Icon->setPixmap(ScalePixmap2Label(pm, *m_label_Icon));
}
else {
m_label_Icon->setPixmap(pm);
}
m_label_Icon->show();
}
else{
#if 0
//使用颜色填充替代隐藏,隐藏后会导致其他组件位置变化
m_label_Icon->clear();
QPalette palette(this->palette());
palette.setColor(QPalette::Background,QColor(0, 0, 0, 0));
m_label_Icon->setPalette(palette);
#else
m_label_Icon->hide();
#endif
}
}
bool MsgWidget::hasNoMsg()
{
return (m_label_msgBtm->text() == "");
}
void MsgWidget::setNetworkStatus(const int status)
{
QPixmap pm;
switch(status)
{
case UiInterfaceForBackstage::PLATFORM_CONNECTION_STATUS_DISCONNECTED:
pm.load(NO_NETWORK_RES_FILE[m_style][UiConfig::GetInstance()->getScreenConfigIndex()]);
break;
case UiInterfaceForBackstage::PLATFORM_CONNECTION_STATUS_CONNECTED:
pm.load(NETWORK_CONNECTED_RES_FILE[m_style][UiConfig::GetInstance()->getScreenConfigIndex()]);
break;
case UiInterfaceForBackstage::PLATFORM_CONNECTION_STATUS_LOGGED:
pm.load(NETWORK_LOGGED_RES_FILE[m_style][UiConfig::GetInstance()->getScreenConfigIndex()]);
break;
default:
break;
}
//m_label_networkStatus->setPixmap(pm.scaled(20, 20, Qt::KeepAspectRatio));
m_label_networkStatus->setPixmap(pm);
}
void MsgWidget::setBackgroundColor(const WIDGET_BG_COLOR_E color)
{
QPalette pal(palette());
if(WIDGET_BG_COLOR_BLUE == color){
pal.setBrush(QPalette::Background,QBrush(QPixmap(BG_BLUE_BOM_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
}
else if(WIDGET_BG_COLOR_GREEN == color){
pal.setBrush(QPalette::Background,QBrush(QPixmap(BG_GREEN_BOM_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
}
else if(WIDGET_BG_COLOR_RED == color){
pal.setBrush(QPalette::Background,QBrush(QPixmap(BG_RED_BOM_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
}
setPalette(pal);
}
void MsgWidget::updateIp(const QString& ip, int type)
{
if(ip != "" && type >= 0){
m_label_ip->setText(ip);
m_label_ip->show();
QPixmap icon;
switch(type){
case 0:icon.load(NET_ETH_IP_RES_FILE[m_style][UiConfig::GetInstance()->getScreenConfigIndex()]);break;
case 1:icon.load(NET_WIFI_IP_RES_FILE[m_style][UiConfig::GetInstance()->getScreenConfigIndex()]);break;
#if 0
case 2:icon.load(":/res/image/4g_1.png");break;
case 3:icon.load(":/res/image/4g_2.png");break;
case 4:icon.load(":/res/image/4g_3.png");break;
case 5:icon.load(":/res/image/4g_4.png");break;
case 6:icon.load(":/res/image/4g_5.png");break;
case 7:icon.load(":/res/image/4g_0.png");break;
#else
case 2 ... 7:
icon.load(QString(":/res/image/4g_%1%2.png").arg(type <= 6 ? type - 1 : 0).arg(1 == m_style ? "B" : ""));break;
#endif
default:break;
}
m_label_ipType->setPixmap(icon);
m_label_ipType->show();
}
else {
m_label_ip->hide();
m_label_ipType->hide();
}
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
}
void MsgWidget::showDevInfo(const QString& devId, const QString& ver)
{
m_labelDevId->setText("ID:" + devId);
m_labelVer->setText("VER:" + ver.mid(8));
}
void MsgWidget::setStyle(int timeType, int iconType, const QColor& textColor)
{
if(0 == timeType){
m_label_time->hide();
}else{
m_label_time->show();
}
m_style = iconType;
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText, textColor);
setPalette(palette);
}
void MsgWidget::showRecoUiDevIdAndVer(bool show)
{
m_labelDevId->setVisible(show);
m_labelVer->setVisible(show);
}
DetectResultWidget::DetectResultWidget(QWidget *parent) : QWidget(parent)
{
qDebug() << "DetectResultWidget()";
QPalette palette;
palette.setColor(QPalette::WindowText,Qt::white);
//palette.setColor(QPalette::Background,QColor(0, 0, 0, 0));
setPalette(palette);
m_label_Icon = new QLabel(this);
m_label_msg = new QLabel(this);
m_label_msg->setPalette(palette);
QHBoxLayout* hLayout = new QHBoxLayout();
hLayout->addWidget(m_label_Icon, 1, Qt::AlignCenter);
hLayout->addWidget(m_label_msg, 4, Qt::AlignCenter);
hLayout->setMargin(0);
//hLayout->setSpacing(10);
setLayout(hLayout);
setFixedSize(DETECT_RESULT_WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()],
DETECT_RESULT_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()]);
setAutoFillBackground(true);
//hide();
}
DetectResultWidget::~DetectResultWidget()
{
qDebug() << "~DetectResultWidget()";
}
void DetectResultWidget::showMsg(const QString& msg, int msgSize, BG_COLOR_E color, const QPixmap* icon)
{
if("" == msg){
hide();
return;
}
if(icon){
m_label_Icon->setPixmap(*icon);
}
else {
m_label_Icon->hide();
}
QFont ft;
ft.setPointSize(msgSize);
m_label_msg->setFont(ft);
m_label_msg->setText(msg);
QPalette pal(palette());
if(BG_COLOR_BLUE == color){
//setStyleSheet("border-image:url(:/res/image/SmartGate_scanFail.png);");
pal.setBrush(QPalette::Background,QBrush(QPixmap(BG_BLUE_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
}
else if(BG_COLOR_RED == color){
pal.setBrush(QPalette::Background,QBrush(QPixmap(BG_RED_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
}
if(BG_COLOR_GREEN == color){
pal.setBrush(QPalette::Background,QBrush(QPixmap(":/res/image/msg_box_bg_green.png")));
}
else if(BG_COLOR_YELLOW == color){
pal.setBrush(QPalette::Background,QBrush(QPixmap(":/res/image/msg_box_bg_yellow.png")));
}
else if(BG_COLOR_TRAN == color){
m_label_msg->clear();
pal.setColor(QPalette::Background,QColor(0, 0, 0, 0));
m_label_msg->setPalette(pal);
}
pal.setColor(QPalette::WindowText,Qt::white);
setPalette(pal);
}
#if 1
void DetectResultWidget::updateMsg(const QString& msg)
{
m_label_msg->setText(msg);
}
MaskWidget_o::MaskWidget_o(QWidget *parent) : DetectResultWidget(parent), m_lastMaskOk(true)
{
qDebug() << "MaskWidget()";
m_iconMaskOk.load(":/res/image/green_mask.png");
m_iconMaskOk = m_iconMaskOk.scaled(MASK_LOGO_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()],
MASK_LOGO_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()],
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
m_iconMaskNull.load(":/res/image/red_mask.png");
m_iconMaskNull = m_iconMaskNull.scaled(MASK_LOGO_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()],
MASK_LOGO_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()],
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
void MaskWidget_o::setMaskMsg(bool maskOk, const QString& msg)
{
//qDebug() << "setMaskMsg" << maskOk;
// if(isHidden() || m_lastMaskOk != maskOk) //by x 20220323
{
//qDebug() << "m_lastMaskOk != maskOk";
//need to adjust font size
int fontSize = UiConfig::GetInstance()->recoUiFontSize(maskOk ? RecoUiTextCfg::TextMaskOk : RecoUiTextCfg::TextNOMask) ?
UiConfig::GetInstance()->recoUiFontSize(maskOk ? RecoUiTextCfg::TextMaskOk : RecoUiTextCfg::TextNOMask) :
static_cast<int>(UiConfig::MASK_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()] *
UiConfig::GetInstance()->recoUiTextCfgFontSize(maskOk ? RecoUiTextCfg::TextMaskOk : RecoUiTextCfg::TextNOMask));
if(maskOk){
showMsg(msg, fontSize, BG_COLOR_BLUE, &m_iconMaskOk);
}
else {
showMsg(msg, fontSize, BG_COLOR_RED, &m_iconMaskNull);
}
m_lastMaskOk = maskOk;
show();
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
}
}
void MaskWidget_o::showQRCodeMsg(UiInterfaceForBackstage::QRCode_Msg_E msg)
{
QString str;
BG_COLOR_E color = BG_COLOR_TRAN;
int fontSize = UiConfig::GetInstance()->recoUiFontSize(2) ? UiConfig::GetInstance()->recoUiFontSize(2) :
static_cast<int>(UiConfig::PERSON_MSG_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()] *
1);
switch (msg) {
case UiInterfaceForBackstage::QRCode_Msg_Standby:
str = tr("请出示个人平安码");
break;
case UiInterfaceForBackstage::QRCode_Msg_Verifying:
str = tr("正在验证...");
break;
case UiInterfaceForBackstage::QRCode_Msg_Error:
str = tr("验证错误请重试");
break;
case UiInterfaceForBackstage::QRCode_Msg_RedCode:
str = tr("请走人工通道"); //红码
color = BG_COLOR_RED;
break;
case UiInterfaceForBackstage::QRCode_Msg_GreenCode:
str = tr("请通行"); //绿码
color = BG_COLOR_GREEN;
break;
case UiInterfaceForBackstage::QRCode_Msg_YellowCode:
str = tr("请走人工通道"); //黄码
color = BG_COLOR_YELLOW;
break;
case UiInterfaceForBackstage::QRCode_Msg_OtherCode:
str = tr("无效平安码");
break;
case UiInterfaceForBackstage::QRCode_Msg_Overtime:
str = tr("扫码超时");
break;
default:
break;
}
showMsg(str, fontSize, color);
}
QString MaskWidget_o::curMsg() const
{
return m_label_msg->text();
}
PersonWidget_o::PersonWidget_o(QWidget *parent) : DetectResultWidget(parent), isShowingResultMsg(false)
{
qDebug() << "PersonWidget()";
if(UiConfig::GetInstance()->isRkDevice()){
m_label_msg->setAlignment(Qt::AlignCenter);
m_label_msg->setFixedSize(static_cast<int>(DETECT_RESULT_WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()] * 0.98),
64);//static_cast<int>(DETECT_RESULT_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()] * 0.5) >> 2 << 2 );
}
}
void PersonWidget_o::setPersonMsg(RecoUiTextCfg::enTextType type, const QString& msg, const BG_COLOR_E color, const bool isResultMsg)
{
//need to adjust font size
int fontSize = 0;
if(UiConfig::SUPPORT_LANGUAGE_QUANTITY > UiConfig::GetInstance()->getLanguageType()){
fontSize = UiConfig::GetInstance()->recoUiFontSize(type) ? UiConfig::GetInstance()->recoUiFontSize(type) :
static_cast<int>(UiConfig::PERSON_MSG_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()] *
UiConfig::GetInstance()->recoUiTextCfgFontSize(type));
}
showMsg(msg, fontSize, color);
//QCoreApplication::processEvents();
isShowingResultMsg = isResultMsg;
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
}
bool PersonWidget_o::allowToShow()
{
return (!isHidden() && isShowingResultMsg);
}
MaskWidget::MaskWidget(QWidget *parent) : QWidget(parent), m_lastMaskOk(true)
{
qDebug() << "MaskWidget()";
m_wgts = new QStackedWidget(this);
m_wgts->setFixedSize(DetectResultWidget::DETECT_RESULT_WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()],
DetectResultWidget::DETECT_RESULT_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()]);
MaskWidget_o* w = new MaskWidget_o(this);
w->setMaskMsg(true, "口罩检测通过");
m_wgts->addWidget(w);
w = new MaskWidget_o(this);
w->setMaskMsg(false, "未佩戴口罩");
m_wgts->addWidget(w);
m_wgts->addWidget(new QLabel(this));
QVBoxLayout* vlay = new QVBoxLayout();
vlay->addWidget(m_wgts);
vlay->setMargin(0);
setLayout(vlay);
show();
}
void MaskWidget::setMaskMsg(bool maskOk, const QString& msg)
{
MaskWidget_o* w = dynamic_cast<MaskWidget_o*>(m_wgts->widget(maskOk ? 0 : 1));
if(w && msg != w->curMsg()){
qDebug() << "-----------------------curMsg:" << w->curMsg() << ", set msg:" << msg;
w->updateMsg(msg);
}
m_wgts->setCurrentIndex(maskOk ? 0 : 1);
}
void MaskWidget::showQRCodeMsg(UiInterfaceForBackstage::QRCode_Msg_E msg)
{
}
void MaskWidget::hideSelf()
{
m_wgts->setCurrentIndex(2);
}
PersonWidget::PersonWidget(QWidget *parent) : QWidget(parent), isShowingResultMsg(false)
{
qDebug() << "MaskWidget()";
m_wgts = new QStackedWidget(this);
PersonWidget_o* w = new PersonWidget_o(this);
w->setPersonMsg(RecoUiTextCfg::TextFacePass, "111", DetectResultWidget::BG_COLOR_BLUE, false);
m_wgts->addWidget(w);
w = new PersonWidget_o(this);
w->setPersonMsg(RecoUiTextCfg::TextAuthFailed, "222", DetectResultWidget::BG_COLOR_RED, false);
m_wgts->addWidget(w);
m_wgts->addWidget(new QLabel(this));
QVBoxLayout* vlay = new QVBoxLayout();
vlay->addWidget(m_wgts);
setLayout(vlay);
m_wgts->setFixedSize(DetectResultWidget::DETECT_RESULT_WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()],
DetectResultWidget::DETECT_RESULT_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()]);
}
void PersonWidget::setPersonMsg(RecoUiTextCfg::enTextType type, const QString& msg, const BG_COLOR_E color, const bool isResultMsg)
{
if(msg.isEmpty()){
m_wgts->setCurrentIndex(2);
return;
}
if(BG_COLOR_BLUE == color){
m_wgts->setCurrentIndex(0);
PersonWidget_o* w = dynamic_cast<PersonWidget_o*>(m_wgts->widget(0));
if(w){
w->updateMsg(msg);
}
}else if(BG_COLOR_TRAN == color){
m_wgts->setCurrentIndex(2);
}else{
m_wgts->setCurrentIndex(1);
PersonWidget_o* w = dynamic_cast<PersonWidget_o*>(m_wgts->widget(1));
if(w){
w->updateMsg(msg);
}
}
isShowingResultMsg = isResultMsg;
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
QCoreApplication::processEvents();
}
bool PersonWidget::allowToShow()
{
return (!isHidden() && isShowingResultMsg);
}
#endif
recoUiRecognize::recoUiRecognize(bool isNightMode, bool hasPwdBtn, bool hasCallBtn, QWidget *parent) : PageAcceptMouseAndTouch(parent),
m_clickCount(0), m_currentBackColor(MSG_BG_COLOR_BOM_NULL),
m_tempRefresh(-1), m_maskRefresh(-1), m_personRefresh(-1), m_NotiMsgRefresh(-1), m_msgShowed(false),m_faceAivaliable(false), m_showGreenColor(0),
m_showRedColor(0), runScanLine(false), timerTimeoutOperation(0), m_widget_progress(nullptr)
{
qDebug() << "recoUiRecognize()";
//setAttribute(Qt::WA_AcceptTouchEvents);
//installEventFilter(this);//screen click event
QString backImg = BG_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()];
int msg_widget_height = MSG_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()];
m_label_back = new QLabel(this);
m_label_back->setFixedSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
if(!UiConfig::GetInstance()->isFuncNotSupport(FuncCardReaderUnderScreen)){
m_wgtCardUnderScreen = new QWidget(this);
m_wgtCardUnderScreen->setAutoFillBackground(true);
m_wgtCardUnderScreen->setFixedSize(SWIP_CARD_WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()],
SWIP_CARD_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_wgtCardUnderScreen->move((UiConfig::GetInstance()->getUiWidth() - SWIP_CARD_WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()]) / 2,
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.73));
}
else{
m_wgtCardUnderScreen = nullptr;
}
slotShowRecoUiMask(isNightMode ? 3 : 1); //for show below person wgt
int tmprWidgetHeight = TmprWidget::TMPR_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()];
m_widget_tmpr = new TmprWidget(this);
m_widget_tmpr->setFixedSize(UiConfig::GetInstance()->getUiWidth(), tmprWidgetHeight);
//m_widget_tmpr->hide();
m_widget_tmpr->move(0, UiConfig::GetInstance()->getUiHeight());
const int maskWidgetWidth = DetectResultWidget::DETECT_RESULT_WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()];
const int maskWgtx = (UiConfig::GetInstance()->getUiWidth() - maskWidgetWidth) / 2;
const int maskWgty = static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.1);
m_widget_mask = new MaskWidget(this);
m_widget_mask->move(maskWgtx, maskWgty);
#if 0
m_widget_mask->hide();//by x 20220322
#endif
m_widget_cMsg = new CenterMsgWidget(); //不继承父组件样式
//m_widget_cMsg->move((UiConfig::GetInstance()->getUiWidth() - CenterMsgWidget::WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()]) / 2,
// static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.3));
m_widget_cMsg->hide();
m_widget_person = new PersonWidget(this);
m_widget_person->setPersonMsg(RecoUiTextCfg::TextFacePass, recoUiTextCfg(RecoUiTextCfg::TextFacePass), PersonWidget::BG_COLOR_BLUE, false);//tr("请刷脸通行")
//const int m_widget_msg_height = 100;
m_widget_msg = new MsgWidget(1, 1, Qt::white, this);
m_widget_msg->setFixedSize(UiConfig::GetInstance()->getUiWidth(), msg_widget_height);
//m_widget_msg->move(0, UiConfig::SCREEN_HIGHT - m_widget_msg_height);
_moveScanner = new QLabel(this);
_moveScanner->setAutoFillBackground(true);
_moveScanner->setPixmap(SCANLINE_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()]);
_moveScanner->setFixedSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight() / 25);
_moveScanner->hide();
#if 0
_ScanCurorAnimation = new QPropertyAnimation(_moveScanner, "geometry");
_ScanCurorAnimation->setDuration(SCAN_LINE_RUN_TIME);
_ScanCurorAnimation->setStartValue(QRect(0, -SCAN_LINE_HEIGHT, _moveScanner->width(), _moveScanner->height())); //从顶端平滑出现
_ScanCurorAnimation->setEndValue(QRect(0, UiConfig::GetInstance()->getUiHeight() - SCAN_LINE_HEIGHT, _moveScanner->width(), _moveScanner->height()));
//_ScanCurorAnimation->setLoopCount(-1); //一直循环
//_ScanCurorAnimation->start();
#endif
_pShowResTimer = new QTimer(this);
connect(_pShowResTimer, SIGNAL(timeout()), this, SLOT(handleRecoResShowTime()));
//_timerId = startTimer(3000);//scaner timer
//scan line
m_timer_QRCodeScanLine = new QTimer(this);
connect(m_timer_QRCodeScanLine, SIGNAL(timeout()), this, SLOT(slotTimerQRCodeScanline()));
m_label_QRCodeScanLine = new QLabel(this);
m_label_QRCodeScanLine->setAutoFillBackground(true);
m_label_QRCodeScanLine->setPixmap(QPixmap(":/res/image/scan-line-small.png"));
m_label_QRCodeScanLine->setFixedSize(UiConfig::GetInstance()->getQRCodeAreaWidth(), UiConfig::GetInstance()->getUiHeight() / 40);
m_label_QRCodeScanLine->hide();
m_QRCodeAnimation = new QPropertyAnimation(m_label_QRCodeScanLine, "geometry");
m_QRCodeAnimation->setDuration(QRCODE_SCAN_LINE_RUN_TIME);
m_QRCodeAnimation->setStartValue(QRect(UiConfig::GetInstance()->getQRCodeAreaCoordinateX(), UiConfig::GetInstance()->getQRCodeAreaCoordinateY(),
m_label_QRCodeScanLine->width(), m_label_QRCodeScanLine->height())); //从顶端平滑出现
m_QRCodeAnimation->setEndValue(QRect(UiConfig::GetInstance()->getQRCodeAreaCoordinateX(),
UiConfig::GetInstance()->getQRCodeAreaCoordinateY() + UiConfig::GetInstance()->getQRCodeAreaHeight() - m_label_QRCodeScanLine->height(),
m_label_QRCodeScanLine->width(), m_label_QRCodeScanLine->height()));
m_QRCodeTimer = new QTimer(this);
connect(m_QRCodeTimer, SIGNAL(timeout()), this, SLOT(slotQRCodeSwitchToStandbyStatusFromOvertimeStatus()));
/*
movie = new QMovie("/nfsroot/a038/source/GateFaceHisi/build/4.gif");
m_label_back = new QLabel(this);
m_label_back->setFixedSize(600, 1024);
m_label_back->setMovie(movie);
movie->start();
*/
m_btnPwd = new QWidget(this);
m_btnPwd->setAutoFillBackground(true);
m_btnPwd->setFixedSize(PWD_BTN_W_H[UiConfig::GetInstance()->getScreenConfigIndex()],
PWD_BTN_W_H[UiConfig::GetInstance()->getScreenConfigIndex()]);
const int pwdBtnX = maskWgtx + maskWidgetWidth + (maskWgtx - PWD_BTN_W_H[UiConfig::GetInstance()->getScreenConfigIndex()]) / 2;
const int pwdBtnY = maskWgty + (DetectResultWidget::DETECT_RESULT_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()] -
PWD_BTN_W_H[UiConfig::GetInstance()->getScreenConfigIndex()]) / 2;
m_btnPwd->move(pwdBtnX, pwdBtnY);
QPalette pwdPal(m_btnPwd->palette());
pwdPal.setBrush(QPalette::Background,QBrush(QPixmap(recoUiRecognize::PWD_BTN[UiConfig::GetInstance()->getScreenConfigIndex()])));
m_btnPwd->setPalette(pwdPal);
/*QString m_btnPwd = QString("QPushButton{background:url(%1); background-color:transparent;border: none; }" //正常
"QPushButton:hover{background:url(%2); background-color:transparent; }" //滑过
"QPushButton:pressed{background:url(%3); background-color:transparent; }") //按下
.arg(PWD_BTN[UiConfig::GetInstance()->getScreenConfigIndex()])
.arg(PWD_BTN_PRESSED[UiConfig::GetInstance()->getScreenConfigIndex()])
.arg(PWD_BTN_PRESSED[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_btnPwd->setStyleSheet(styleSheet);
*/
if(!hasPwdBtn){
m_btnPwd->hide();
}
QPalette dialPal;
dialPal.setBrush(QPalette::Background,QBrush(QPixmap(":/res/image/grey_bg_large.png")));
const int callWgtWidth = 400;
const int callWgtHeight = 128;
const int callWgtPosY = static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.6);
const int callWgtDevPosX = static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.55);
const int callWgtMngCenterPosX = -(callWgtDevPosX + callWgtWidth - UiConfig::GetInstance()->getUiWidth());
QFont ft;
m_wgtCallDialDev = new RoundedWidget(this);
#if 0
dialPal.setColor(QPalette::WindowText, QColor(18, 165, 127));
#else
dialPal.setColor(QPalette::WindowText,Qt::darkGray);
m_wgtCallDialDev->setDisabled(true);
#endif
m_wgtCallDialDev->setPalette(dialPal);
m_wgtCallDialDev->setAutoFillBackground(true);
m_wgtCallDialDev->setFixedSize(callWgtWidth, callWgtHeight);
m_wgtCallDialDev->move(callWgtDevPosX, callWgtPosY);
#if 0
m_wgtCallDialDev->setFixedSize(PWD_BTN_W_H[UiConfig::GetInstance()->getScreenConfigIndex()],
PWD_BTN_W_H[UiConfig::GetInstance()->getScreenConfigIndex()]);
dialPal.setBrush(QPalette::Background,QBrush(QPixmap(recoUiRecognize::CALL_BTN[UiConfig::GetInstance()->getScreenConfigIndex()])));
m_wgtCallDialDev->move(pwdBtnX - PWD_BTN_W_H[UiConfig::GetInstance()->getScreenConfigIndex()] - 20, pwdBtnY);
#endif
QLabel* labelCallDevIcon = new QLabel(m_wgtCallDialDev);
labelCallDevIcon->setPixmap(QPixmap(":/res/image/call1_large.png"));
QLabel* labelCallDevText = new QLabel(tr("呼叫设备"), m_wgtCallDialDev);
labelCallDevText->setAlignment(Qt::AlignCenter);
ft.setPointSize(12);
labelCallDevText->setFont(ft);
QHBoxLayout* hlayCallDev = new QHBoxLayout();
hlayCallDev->setMargin(30);
hlayCallDev->addSpacing(10);
hlayCallDev->addWidget(labelCallDevIcon);
hlayCallDev->addWidget(labelCallDevText);
hlayCallDev->addStretch();
m_wgtCallDialDev->setLayout(hlayCallDev);
if(!hasCallBtn){
m_wgtCallDialDev->hide();
}
m_wgtCallMngCenter = new RoundedWidget(this);
dialPal.setColor(QPalette::WindowText, QColor(18, 150, 219));
m_wgtCallMngCenter->setPalette(dialPal);
m_wgtCallMngCenter->setAutoFillBackground(true);
m_wgtCallMngCenter->setFixedSize(callWgtWidth, callWgtHeight);
m_wgtCallMngCenter->move(callWgtMngCenterPosX, callWgtPosY);
QLabel* MngCenter = new QLabel(m_wgtCallMngCenter);
MngCenter->setPixmap(QPixmap(":/res/image/customer_service_large.png"));
QLabel* labelCallMngCenterText = new QLabel(tr("呼叫管理处"), m_wgtCallMngCenter);
labelCallMngCenterText->setFont(ft);
labelCallMngCenterText->setAlignment(Qt::AlignCenter);
QHBoxLayout* hlayCallMngCenter = new QHBoxLayout();
hlayCallMngCenter->setMargin(30);
hlayCallMngCenter->addStretch();
hlayCallMngCenter->addWidget(MngCenter);
hlayCallMngCenter->addWidget(labelCallMngCenterText);
//hlayCallMngCenter->addStretch();
m_wgtCallMngCenter->setLayout(hlayCallMngCenter);
if(!hasCallBtn){
m_wgtCallMngCenter->hide();
}
m_resWgt = new FinalResultWidget(this);
m_resWgt->move((UiConfig::GetInstance()->getUiWidth() - FinalResultWidget::FINAL_RESULT_WIDGET_W_H[UiConfig::GetInstance()->getScreenConfigIndex()]) / 2,
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.65));
m_resWgt->hide();
m_healthCodeAuthstatus = new QLabel("未授权", this);
QPalette authPal(m_healthCodeAuthstatus->palette());
authPal.setColor(QPalette::WindowText,Qt::white);
m_healthCodeAuthstatus->setPalette(authPal);
m_healthCodeAuthstatus->setAlignment(Qt::AlignRight);
m_healthCodeAuthstatus->setFixedSize(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.2),
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.05));
m_healthCodeAuthstatus->hide();
m_healthCodeAuthstatus->move(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.8),
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.9));
m_wgtSceneMsg = new SceneMsgWidget(this);
m_wgtSceneMsg->setVisible(false); // BUG B045-182: 防止其他模式刚上电时会看到这个组件
QVBoxLayout* vLayout = new QVBoxLayout();
//vLayout->addWidget(m_widget_tmpr, 1, Qt::AlignTop | Qt::AlignCenter); //温度不加如布局管理器因为使用move方式控制show 和 hide
//vLayout->addWidget(m_widget_mask, 50, Qt::AlignTop | Qt::AlignCenter); //口罩不加到布局管理器,因为温度不一定显示,如果加入,温度不显示时口罩会跳到顶端
#if 1
vLayout->addWidget(m_widget_person, 50, Qt::AlignBottom | Qt::AlignCenter);
#else
QHBoxLayout* hlayPerWgtPwdBtn = new QHBoxLayout();
hlayPerWgtPwdBtn->addSpacing((UiConfig::GetInstance()->getUiWidth() - m_widget_person->width()) / 2);
hlayPerWgtPwdBtn->addWidget(m_widget_mask);
hlayPerWgtPwdBtn->addStretch();
hlayPerWgtPwdBtn->addWidget(m_btnPwd, 1, Qt::AlignRight);
hlayPerWgtPwdBtn->setContentsMargins(0, 0, UiConfig::GetInstance()->getUiWidth() * 0.03, 0);
vLayout->addStretch(50);
vLayout->addLayout(hlayPerWgtPwdBtn);
#endif
vLayout->addWidget(m_widget_msg, 1, Qt::AlignBottom | Qt::AlignCenter);
vLayout->setMargin(0);
setLayout(vLayout);
m_widget_mask->hideSelf();
}
recoUiRecognize::~recoUiRecognize()
{
qDebug() << "~recoUiRecognize()";
if(m_widget_cMsg){
delete m_widget_cMsg;
}
}
bool recoUiRecognize::eventFilter(QObject *watched, QEvent *event)
{
if( watched == this){
if(event->type() == QEvent::MouseButtonPress){
qDebug() << "MouseButtonPress";
emit signalScreenTouch();
if(multiPressToSettingPage()){
QPoint pos;
pos.setX(UiConfig::GetInstance()->getUiWidth() / 2);
pos.setY(UiConfig::GetInstance()->getUiHeight() / 2);
QCursor::setPos(pos);
}
}
else{
return false;
}
}
else{
return QWidget::eventFilter(watched, event);
}
return false;
}
void recoUiRecognize::setBackstageUiinterface(BackstageInterfaceForUi *interface)
{
m_backstageIf = interface;
#if VERSION_XIAMEN_GONGAN == 0
if(m_backstageIf){
if(m_backstageIf->getQRCodeSwitch()){
m_widget_person->hide();
m_widget_mask->showQRCodeMsg(UiInterfaceForBackstage::QRCode_Msg_Standby);
setBackgroundColor(MSG_BG_COLOR_QRCODE);
runQRCodeScanLine();
}
char buf[64] = {'\0'};
m_backstageIf->getDeviceId(buf, sizeof(buf));
QString devId{buf};
memset(buf, 0, sizeof(buf));
m_backstageIf->getAppVersion(buf, sizeof(buf));
QString ver{buf};
m_widget_msg->showDevInfo(devId, ver);
m_widget_msg->showRecoUiDevIdAndVer(m_backstageIf->getShowIdAndVerSw());
m_wgtSceneMsg->setType(m_backstageIf->getTicketModePeopleCountType());
setTicketCheckCount(-1, m_backstageIf->getTicketCheckCountToday());
}
#endif
}
void recoUiRecognize::timerEvent(QTimerEvent *event)
{
#if 0
if(_timerId == event->timerId())
{
qDebug() << "timerEvent()";
_ScanCurorAnimation->start();
}
#endif
}
void recoUiRecognize::slotsNoSuccessPage(const int nPage)
{
//qDebug() << "slotsNoSuccessPage";
closeRecoResTime();
if(nPage >= GLOBAL_RECO_END_NO && nPage <= GLOBAL_RECO_SHOW_QRCODE)
{
showRecoFail((GLOBAL_RECO_STATE)nPage);
}
else if(GLOBAL_RECO_ID_FAILED == nPage)
{
showRecoIDFail();
}
else if(GLOBAL_RECO_IN == nPage)
{
//qDebug() << "slotsNoSuccessPageshowRecoNoScanner";
//if(!m_widget_tmpr->isHidden()){
if(0 == m_widget_tmpr->pos().y()){
//qDebug() << "cancle scanner, hide temp window";
//m_widget_tmpr->hide(); //没有人脸,转到人脸识别系统显示,此时隐藏温度提示
m_widget_tmpr->move(0, UiConfig::GetInstance()->getUiHeight());
m_widget_msg->setMsgBtm(tr(""));
}
}
else if(GLOBAL_RECO_CHECK == nPage)
{
showRetry();
}
else if(GLOBAL_RECO_MASK_REQ == nPage)
{
showNoMaskWarn(); //请戴口罩
}
else if(GLOBAL_RECO_MASK_OK == nPage)
{
showMaskOk();
}
else if(GLOBAL_RECO_TAKE_OFF_MASK == nPage)
{
showMaskWarn();
}
else if(GLOBAL_RECO_NO_ENTRY == nPage)
{
showNoEntry();
}
else if(GLOBAL_RECO_CLEAR_NO_ENTRY == nPage)
{
clearNoEntry();
}
else if(GLOBAL_RECO_CLOSE_SCANLINE == nPage)
{
//qDebug() << "GLOBAL_RECO_CLOSE_SCANLINE == nPage";
setScannerState(SCAN_LINE_SWITCH_OFF);
#if 0
//如果取消扫描线了,当前定时器在运行,立即调用槽函数
if(_pShowResTimer->isActive())
{
_pShowResTimer->stop();
_pShowResTimer->start(1);
}
#endif
}
else if(GLOBAL_RECO_SHOW_QRCODE_RECO == nPage)
{
//显示识别二维码界面
//showQRCodeReco();
}
else if(GLOBAL_RECO_SHOW_FACE_RECO == nPage)
{
showFaceReco();
}
else
{
//NOP
}
}
//返回值0 扫描线状态有变化
//返回值:-1 扫描线状态没有变化
int recoUiRecognize::setScannerState(const SCAN_LINE_SWITCH_E sw)
{
int ret = -1;
//if(sw != m_currentScanLine)
{
if(SCAN_LINE_SWITCH_OFF == sw){
//qDebug() << "runScanLine = false";
_moveScanner->hide();
if(true == runScanLine){
runScanLine = false;
ret = 0;
}
}
else if(SCAN_LINE_SWITCH_BLUE == sw){
m_widget_person->hide(); //画扫描线时关闭人员信息
if(false == runScanLine){
runScanLine = true;
_pShowResTimer->start(SCAN_LINE_RUN_TIME * 30 / 1000);
int startPos = static_cast<int>(UiConfig::GetInstance()->getUiHeight() * SCAN_LINE_START_POS_SCALE);
_moveScanner->move(0, startPos);
m_scanLinePos = startPos;
ret = 0;
}
#if 0
if(false == runScanLine){
_ScanCurorAnimation->start();
_pShowResTimer->start(SCAN_LINE_RUN_TIME);
runScanLine = true;
_moveScanner->show();
timerTimeoutOperation = 0;
//qDebug() << "runScanLine = true";
}
#endif
}
else if(SCAN_LINE_SWITCH_RED == sw){
m_widget_person->hide(); //画扫描线时关闭人员信息
#if 0
if(false == runScanLine){
_pShowResTimer->start(SCAN_LINE_TIMER);
_ScanCurorAnimation->start();
_moveScanner->show();
runScanLine = true;
timerTimeoutOperation = 0;
}
#endif
}
m_currentScanLine = sw;
}
return ret;
}
void recoUiRecognize::setBackgroundColor(const MSG_BG_COLOR_E index)
{
QPixmap pm;
switch (index) {
case MSG_BG_COLOR_BOM_BLUE:
m_widget_tmpr->move(0, UiConfig::GetInstance()->getUiHeight());
m_widget_msg->setBackgroundColor(WIDGET_BG_COLOR_BLUE);
break;
case MSG_BG_COLOR_BOM_GREEN:
break;
case MSG_BG_COLOR_BOM_TOP_GREEN:
m_widget_tmpr->setBackgroundColor(WIDGET_BG_COLOR_GREEN);
m_widget_msg->setBackgroundColor(WIDGET_BG_COLOR_GREEN);
break;
case MSG_BG_COLOR_BOM_RED:
break;
case MSG_BG_COLOR_BOM_TOP_RED:
m_widget_tmpr->setBackgroundColor(WIDGET_BG_COLOR_RED);
m_widget_msg->setBackgroundColor(WIDGET_BG_COLOR_RED);
break;
case MSG_BG_COLOR_QRCODE:
//m_stackwig_back->setCurrentIndex(3);
break;
default:
break;
}
m_currentBackColor = index;
}
void recoUiRecognize::showRecoScanner()
{
//qDebug() << "showRecoScanner";
if(0 == setScannerState(SCAN_LINE_SWITCH_BLUE)){
//m_widget_tmpr->hide();
m_widget_tmpr->move(0, UiConfig::GetInstance()->getUiHeight());
#if 0
m_widget_mask->hide();//by x 20220322
#else
m_widget_mask->hideSelf();
#endif
//qDebug() << "setBackgroundColor(MSG_BG_COLOR_BOM_BLUE)";
setBackgroundColor(MSG_BG_COLOR_BOM_BLUE);
//最终结果区域情况,跟扫描线互斥
m_widget_msg->setMsgBtm(tr(""));
}
}
void recoUiRecognize::showRetry()
{
//qDebug() << "showRetry";
//m_widget_msg->setMsgTop(tr("请靠近重试"));
// m_widget_msg->setMsgBtm(tr(""));
//setScannerState(SCAN_LINE_SWITCH_BLUE);//xxxxxxxxxxxxx
// setBackgroundColor(MSG_BG_COLOR_BOM_BLUE);
}
void recoUiRecognize::showNoMaskWarn() //请戴口罩
{
//if(! || !m_widget_mask->isHidden()){ //不阻塞扫描线
m_maskRefresh = 2;
if(_moveScanner->isHidden()){ //阻塞扫描线
showMaskMsg();
}
}
void recoUiRecognize::showMaskWarn()
{
m_maskRefresh = 3;
if(_moveScanner->isHidden()){ //阻塞扫描线
showMaskMsg();
}
}
void recoUiRecognize::showMaskOk() //口罩检测成功
{
//qDebug() << "showMaskOk";
//如果当前正在画扫描线,显示内容,没有画扫描线说明已经没有人员在画面中了,下层会出现无人在画面的调用后再调显示人员信息,导致信息残留在画面一直不消失
//如果当前口罩在显示,那可以刷新口罩内容,例如人脸在画面中一直脱戴口罩的情况,但是没有画扫描线了,此时还能刷新口罩结果
//if(! || !m_widget_mask->isHidden()){ //不阻塞扫描线
m_maskRefresh = 1;
if(_moveScanner->isHidden()){ //阻塞扫描线
showMaskMsg();
}
}
void recoUiRecognize::showNoEntry()
{
m_NoEntryRefresh = 1;
if(_moveScanner->isHidden()){
showNoEntryMsg();
}
}
void recoUiRecognize::clearNoEntry()
{
m_NoEntryRefresh = 2;
if(_moveScanner->isHidden()){
showNoEntryMsg();
}
}
int recoUiRecognize::setCamVideoWind()
{
return m_backstageIf->recoUiTypeSwitch(0, 0, UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
}
void recoUiRecognize::setStyle(int style)
{
if(4 == style){
m_bgSceneIdle = QPixmap(":/res/image/reco_ui_scene_bg_medium.jpg");
m_label_back->setPixmap(m_bgSceneIdle);
if(m_wgtCardUnderScreen){m_wgtCardUnderScreen->hide();}
m_widget_msg->setStyle(0, 0, Qt::black);
m_wgtSceneMsg->show();
}else{
m_label_back->setPixmap(m_bgPm);
if(m_wgtCardUnderScreen){m_wgtCardUnderScreen->show();}
m_widget_msg->setStyle(1, 1, Qt::white);
m_wgtSceneMsg->hide();
}
m_widget_person->setPersonMsg(RecoUiTextCfg::TextFacePass, recoUiTextCfg(RecoUiTextCfg::TextFacePass), PersonWidget::BG_COLOR_BLUE, false);
}
void recoUiRecognize::setSceneUiReco(bool toReco)
{
m_label_back->setPixmap(toReco ? m_bgPm : m_bgSceneIdle);
}
void recoUiRecognize::setTicketCheckCount(int source, int count)
{
m_wgtSceneMsg->setPersonNum(source, count);
}
void recoUiRecognize::setScenePersonCountType(int type)
{
m_wgtSceneMsg->setType(type);
}
void recoUiRecognize::slotShowOrHideFaceFrame(bool show)
{
//设备连接测温模块启动后移除测温web上设置人形框
if(UiConfig::GetInstance()->isFaceFrameShowByTempExist()){
UiConfig::GetInstance()->showFaceFrameByTempExist(false);
}
m_showFaceFrameByUser = show;
if(!m_isNightMode){
slotShowRecoUiMask(1);
}
}
void recoUiRecognize::slotShowFinalResult(bool pass)
{
if(UiConfig::GetInstance()->isRecoUiStyleStandard()){
m_resWgt->showResult(pass);
}
}
void recoUiRecognize::slotShowHealthCodeAuthStatus(int status)
{
switch(status){
case 0:m_healthCodeAuthstatus->hide();break;
case 1:m_healthCodeAuthstatus->show();break;
case 2:m_healthCodeAuthstatus->setText("未授权");break;
case 3:m_healthCodeAuthstatus->setText("已授权");break;
case 4:m_healthCodeAuthstatus->setText("授权不可用");break;
default:break;
}
}
void recoUiRecognize::slotShowCallBtn(bool show)
{
m_wgtCallDialDev->setVisible(show);
m_wgtCallMngCenter->setVisible(show);
}
void recoUiRecognize::slotShowRecoUiDevIdAndVer(bool show)
{
m_widget_msg->showRecoUiDevIdAndVer(show);
}
void recoUiRecognize::showRecoFail(GLOBAL_RECO_STATE failType)
{
m_personRefresh = failType;
if(_moveScanner->isHidden()){ // m_widget_person->allowToShow()
showPersonWidgetMsg();
}
}
void recoUiRecognize::showRecoIDFail()
{
m_personRefresh = GLOBAL_RECO_ID_FAILED;
if(_moveScanner->isHidden()){
showPersonWidgetMsg();
}
}
void recoUiRecognize::closeRecoResTime()
{
//if(_pShowResTimer->isActive())
{
// _pShowResTimer->stop();
}
}
void recoUiRecognize::slotsSuccessPage(const int nPage, const QString& name)
{
if( GLOBAL_RECO_END_OK != nPage)
{
return ;
}
closeRecoResTime();
m_personRefresh = GLOBAL_RECO_END_OK;
m_name = name;
if(_moveScanner->isHidden()){
showPersonWidgetMsg();
}
}
void recoUiRecognize::slotsDrawScanner(const int nPage, const bool faceAvailable)
{
//qDebug()<<"slotsDrawScanner():" << nPage <<" face: " << faceAvailable;
if(!faceAvailable)
{
//qDebug() << "(sum <= 0) && (nullptr == pInfo showRecoNoScanner()";
m_currentBackColor = MSG_BG_COLOR_BOM_NULL;
setScannerState(SCAN_LINE_SWITCH_OFF);
//if(!m_widget_tmpr->isHidden())
if(0 == m_widget_tmpr->pos().y())
{
//m_widget_tmpr->hide(); //没有人脸,转到人脸识别系统显示,此时隐藏温度提示
m_widget_tmpr->move(0, UiConfig::GetInstance()->getUiHeight());
}
#if 0
if(!m_widget_mask->isHidden()){
m_widget_mask->hide();//by x 20220322
}
#else
m_widget_mask->hideSelf();
#endif
setBackgroundColor(MSG_BG_COLOR_BOM_BLUE);
m_widget_person->setPersonMsg(RecoUiTextCfg::TextFacePass, recoUiTextCfg(RecoUiTextCfg::TextFacePass), PersonWidget::BG_COLOR_BLUE, false);//tr("请刷脸通行")
m_widget_msg->setMsgBtm(tr(""));
if(UiConfig::GetInstance()->isRecoUiStyleStandard()){
m_resWgt->hide();
}else if(UiConfig::GetInstance()->isRecoUiStyleScene()){
m_label_back->setPixmap(m_bgSceneIdle);
}
m_msgShowed = false;
//qDebug() << "m_faceAivaliable set false";
m_faceAivaliable = false;
m_tempRefresh = -1;
m_maskRefresh = -1;
m_personRefresh = -1;
m_NotiMsgRefresh = -1;
m_NoEntryRefresh = 0;
m_showGreenColor = 0;
m_showRedColor = 0;
return ;
}
m_faceAivaliable = true;
if(GLOBAL_RECO_IN_SCANNER != nPage)
{
return ;
}
closeRecoResTime();
showRecoScanner();
}
void recoUiRecognize::slotShowNormalTemp(const float temp, const bool isC)
{
m_widget_tmpr->showNormalTemp(recoUiTextCfg(RecoUiTextCfg::TextTemp), temp, isC);
#if 0
if(true == runScanLine){
m_tempRefresh = 1;
}
#endif
m_tempRefresh = 1;
if(_moveScanner->isHidden()){
showTempMsg();
}
}
void recoUiRecognize::slotShowAbnormalTemp(const float temp, const bool isHigh, const bool isC)
{
m_widget_tmpr->showAbnormalTemp(recoUiTextCfg(RecoUiTextCfg::TextTemp), temp, isHigh, isC);
#if 0
if(true == runScanLine){
if(isHigh){
m_tempRefresh = 2;
}
else {
m_tempRefresh = 3;
}
}
#endif
if(isHigh){
m_tempRefresh = 2;
}
else {
m_tempRefresh = 3;
}
if(_moveScanner->isHidden()){
showTempMsg();
}
}
void recoUiRecognize::slotsInteractionChange(const INTERACION_OPTION &interaction, int nSelectRes)
{
if(OPTION_LOGO == interaction){
QString logo;
if(0 == nSelectRes){
logo = LOGO_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()];
m_widget_msg->setLogo(logo);
}
else if(1 == nSelectRes){
logo = "";
m_widget_msg->setLogo(logo);
}
else if(2 == nSelectRes){ //自定义logo
if(m_backstageIf){
char logoPath[256] = {'\0'};
if(0 == m_backstageIf->getCustomLogo(logoPath, sizeof(logoPath))){
logo = QString(logoPath);
m_widget_msg->setLogo(logo, true);
}
}
}
}
}
void recoUiRecognize::slotUpdateLogo(const int option)
{
slotsInteractionChange(OPTION_LOGO, option);
}
void recoUiRecognize::handleRecoResShowTime()
{
if(m_scanLineInterval > 0 && true == runScanLine){
m_scanLineInterval -= (SCAN_LINE_RUN_TIME * 30 / 1000);
return;
}
int startPos = static_cast<int>(UiConfig::GetInstance()->getUiHeight() * SCAN_LINE_START_POS_SCALE);
int distance = static_cast<int>(UiConfig::GetInstance()->getUiHeight() * SCAN_LINE_RUN_DISTANCE_SCALE);
m_scanLinePos += (distance * 1000 / 30 / SCAN_LINE_RUN_TIME); //1000ms 30帧
if(m_scanLinePos >= (startPos + distance)){
m_scanLinePos = startPos;
m_scanLineInterval = SCAN_LINE_LOOP_INTERVAL;
_moveScanner->hide();
return;
}
_moveScanner->hide();
if(true == runScanLine){
_moveScanner->move(0, m_scanLinePos);
}
do{
#if 0
if(showTempMsg()){
break;
}
if(showMaskMsg()){
break;
}
if(showPersonWidgetMsg()){
break;
}
if(showNoEntryMsg()){
break;
}
if(showNotiMsg()){
break;
}
#else
if(showPersonWidgetMsg()){
break;
}
if(showMaskMsg()){
break;
}
if(showTempMsg()){
break;
}
if(showNoEntryMsg()){
break;
}
if(showNotiMsg()){
break;
}
#endif
}while(0);
if(false == runScanLine && 0 == m_showGreenColor && 0 == m_showRedColor){
_pShowResTimer->stop();
_moveScanner->hide();
m_scanLineInterval = 0;
}
else {
if(true == runScanLine)
_moveScanner->show();
}
}
void recoUiRecognize::slotUpdatePlatformConnectionStatus(const int status)
{
m_widget_msg->setNetworkStatus(status);
}
void recoUiRecognize::slotsResetRecoUi()
{
//人脸识别 / 二维码 二选一
#if 0
if(m_backstageIf){
if(m_backstageIf->getQRCodeSwitch()){
//二维码扫描模式不复位到人脸识别界面,否则会出现人脸框叠加二维码扫描框
}
else {
slotsDrawScanner(0, nullptr, 0);
}
}
#endif
slotsDrawScanner(0, false);
}
void recoUiRecognize::slotShowQRCodeMsg(const int msg)
{
m_widget_mask->showQRCodeMsg(static_cast<UiInterfaceForBackstage::QRCode_Msg_E>(msg));
if(UiInterfaceForBackstage::QRCode_Msg_Error == static_cast<UiInterfaceForBackstage::QRCode_Msg_E>(msg)){
m_QRCodeTimer->start(QRCODE_FAILED_MSG_DISPLAY_TIME);
}
else {
m_QRCodeTimer->stop();
}
}
void recoUiRecognize::slotChangeRecoUiMode()
{
if(m_backstageIf->getQRCodeSwitch()){
//qDebug() << "recoUiRecognize::slotChangeRecoUiMode QRCode mode!";
showQRCodeReco();
}
else {
//qDebug() << "recoUiRecognize::slotChangeRecoUiMode face reco mode!";
showFaceReco();
}
}
void recoUiRecognize::slotTimerQRCodeScanline()
{
runQRCodeScanLine();
}
void recoUiRecognize::runQRCodeScanLine()
{
if(m_label_QRCodeScanLine->isHidden())
m_label_QRCodeScanLine->show();
m_QRCodeAnimation->start();
m_timer_QRCodeScanLine->start(QRCODE_SCAN_LINE_RUN_INTERVAL_TIME);
}
void recoUiRecognize::showQRCodeReco()
{
//停止人脸识别界面一切活动
slotsResetRecoUi();
m_widget_tmpr->hide();
m_widget_person->hide();
m_widget_msg->setMsgBtm(tr(""));
//_pShowResTimer->stop();
_moveScanner->hide();
_ScanCurorAnimation->stop();
//切换到二维码识别界面
setBackgroundColor(MSG_BG_COLOR_QRCODE);
m_widget_mask->showQRCodeMsg(UiInterfaceForBackstage::QRCode_Msg_Standby);
runQRCodeScanLine();
}
void recoUiRecognize::showFaceReco()
{
m_label_QRCodeScanLine->hide();
m_QRCodeAnimation->stop();
m_timer_QRCodeScanLine->stop();
#if 0
m_widget_mask->hide();
#else
m_widget_mask->hideSelf();
#endif
slotsResetRecoUi();
}
bool recoUiRecognize::showPersonWidgetMsg()
{
bool ret = false;
if(m_personRefresh >= 0)
{
switch(m_personRefresh)
{
case GLOBAL_RECO_END_OK:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextAllowPass, recoUiTextCfg(RecoUiTextCfg::TextAllowPass), PersonWidget::BG_COLOR_BLUE, true);//m_name
break;
case GLOBAL_RECO_END_NO:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextAuthFailed, recoUiTextCfg(RecoUiTextCfg::TextAuthFailed), PersonWidget::BG_COLOR_RED, true);//tr("未经许可人员")
break;
case GLOBAL_RECO_FACE_CARD_NOT_MATCH:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextUseOwnCertifi, recoUiTextCfg(RecoUiTextCfg::TextUseOwnCertifi), PersonWidget::BG_COLOR_RED, true);//tr("请用本人证件")
break;
case GLOBAL_RECO_SWIPE_CARD:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextTapCard, recoUiTextCfg(RecoUiTextCfg::TextTapCard), PersonWidget::BG_COLOR_RED, true);//tr("请刷卡")
break;
case GLOBAL_RECO_FACE_CAMERA:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextFaceCam, recoUiTextCfg(RecoUiTextCfg::TextFaceCam), PersonWidget::BG_COLOR_RED, true);//tr("请正视镜头")
break;
case GLOBAL_RECO_NOT_PASS_TIME:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextNoEntryTime, recoUiTextCfg(RecoUiTextCfg::TextNoEntryTime), PersonWidget::BG_COLOR_RED, true);//tr("禁止通行时段")
break;
case GLOBAL_RECO_ID_FAILED:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("身份证核验失败"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_NEED_RECHECK:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("身份核验中"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_PLATFORM_DISCONNECTED:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("服务器连接失败"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_SWIPE_CARD_HERE:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("请在此处刷卡"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_HIDE_NAME_AREA:
#if 0
m_widget_person->hide();
#else
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, "", PersonWidget::BG_COLOR_TRAN, true);
#endif
break;
case GLOBAL_RECO_NOT_LIVING:
if(!UiConfig::GetInstance()->isRecoUiStyleScene()){
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("请调整人脸角度"), PersonWidget::BG_COLOR_RED, true);
}
break;
case GLOBAL_RECO_SHOW_QRCODE:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("请刷二维码"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_UNAUTH_CARD:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("未授权卡片"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_PLS_TAP_ID_CARD:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("请刷身份证"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_PLS_CHECK_STATIC:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("请测试静电"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_STATIC_ABNORMAL:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("静电测试异常"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_SWIPE_ID_OR_HEALEH_CODE:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("请刷身份证或扫码"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_CHECKING:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("健康码查询中"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_CHECK_FAILED:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("查询失败"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_QRCODE_OVERDUE:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("二维码已过期"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_NETWORK_ERROR:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("网络异常"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_PLATFORM_ERROR:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("服务器异常"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_REQUEST_OVERTIME:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("服务器请求超时"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_SWIPE_TRIP_CARD:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("请刷行程卡"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_SHOW_HEALTH_CODE:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("请扫健康码"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_RESWIPE_TRIP_CARD:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("请重刷行程卡"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_SWIPE_ID_AND_TRIP_CARD:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("刷身份证扫行程卡"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_TRIP_CARD_CHECKING:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("行程卡查询中"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_SCAN_YUEJUMA:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("请扫粤居码"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_SCAN_YUEJUMA_OR_SWIPE_ID:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("请刷粤居码/身份证"), PersonWidget::BG_COLOR_RED, true);
break;
case GLOBAL_RECO_PATROL_OK:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("巡更成功"), PersonWidget::BG_COLOR_BLUE, true);
break;
case GLOBAL_RECO_PATROL_NOT_RIGHT_TIME:
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tr("非巡更时段"), PersonWidget::BG_COLOR_RED, true);
break;
default:
break;
}
ret = true;
}
if(ret){
m_personRefresh = -1;
m_msgShowed = true;
ret = runScanLine;
}
return ret;
}
bool recoUiRecognize::showNoEntryMsg()
{
bool ret = false;
if(1 == m_NoEntryRefresh){
m_widget_msg->setMsgBtm(recoUiTextCfg(RecoUiTextCfg::TextNoEntry), MSG_BG_COLOR_BOM_TOP_GREEN == m_currentBackColor);//tr("禁止通行")
ret = true;
}
else if(2 == m_NoEntryRefresh){
m_widget_msg->setMsgBtm(tr(""));
ret = true;
}
if(ret){
m_NoEntryRefresh = 0;
m_msgShowed = true;
ret = runScanLine;
}
return ret;
}
bool recoUiRecognize::showNotiMsg()
{
bool ret = false;
if(GLOBAL_RECO_SHOW_NOTI_MSG == m_NotiMsgRefresh){
m_widget_msg->setMsgNoti(m_notimsg, m_notiMsgColor);
ret = true;
}
if(ret){
m_NotiMsgRefresh = -1;
m_msgShowed = true;
ret = runScanLine;
}
return ret;
}
bool recoUiRecognize::showTempMsg()
{
bool ret = false;
if(1 == m_tempRefresh || 3 == m_tempRefresh){
m_showRedColor = 0;
if(0 == m_showGreenColor){
m_widget_tmpr->setBackgroundColor(WIDGET_BG_COLOR_GREEN);
m_showGreenColor = 1;
}
else if(1 == m_showGreenColor){
m_widget_msg->setBackgroundColor(WIDGET_BG_COLOR_GREEN);
m_showGreenColor = 0;
m_tempRefresh = -1;
}
else {
m_showGreenColor = 0;
}
ret = true;
}
else if(2 == m_tempRefresh){
m_showGreenColor = 0;
if(0 == m_showRedColor){
m_widget_tmpr->setBackgroundColor(WIDGET_BG_COLOR_RED);
m_showRedColor = 1;
}
else if(1 == m_showRedColor){
m_widget_msg->setBackgroundColor(WIDGET_BG_COLOR_RED);
m_showRedColor = 0;
m_tempRefresh = -1;
}
else {
m_showRedColor = 0;
}
ret = true;
}
if(ret){
m_widget_tmpr->move(0, 0);
m_msgShowed = true;
ret = runScanLine;
}
return ret;
}
bool recoUiRecognize::showMaskMsg()
{
bool ret = false;
if(1 == m_maskRefresh){
m_widget_mask->setMaskMsg(true, recoUiTextCfg(RecoUiTextCfg::TextMaskOk));
ret = true;
}else if(2 == m_maskRefresh){
m_widget_mask->setMaskMsg(false, recoUiTextCfg(RecoUiTextCfg::TextNOMask));
ret = true;
}else if(3 == m_maskRefresh){
m_widget_mask->setMaskMsg(false, tr("请摘下口罩"));
ret = true;
}
if(ret){
m_maskRefresh = -1;
m_msgShowed = true;
ret = runScanLine;
}
return ret;
}
bool recoUiRecognize::event(QEvent *event)
{
switch( event->type() )
{
case QEvent::TouchBegin:
{
do{
qDebug() << "recoUiRecognize touch begin";
if(UiConfig::GetInstance()->getHardwareTesting()){
break;
}
QList<QTouchEvent::TouchPoint> touch_list = static_cast<QTouchEvent*>(event)->touchPoints();
QPoint mousePos = mapFromGlobal(QPoint(touch_list.at(0).pos().x(),touch_list.at(0).pos().y()));
if(!m_btnPwd->isHidden() && m_btnPwd->geometry().contains(mousePos)){
//qDebug() << touch_list.at(0).pos().x();
//qDebug() << touch_list.at(0).pos().y();
//QMouseEvent mouseEvent(QEvent::MouseButtonPress,QPointF(touch_list.at(0).pos().x(),touch_list.at(0).pos().y()),Qt::LeftButton,Qt::LeftButton,Qt::NoModifier);
//QCoreApplication::sendEvent(this,&mouseEvent);
m_backstageIf->playAudio(audioInputPwd);
slotPwdBtnClicked();
break;
}
#if 0 // 设备对讲还有缺陷,暂不支持
if(!m_wgtCallDialDev->isHidden() && m_wgtCallDialDev->geometry().contains(mousePos)){
emit callDialButtonClicked();
break;
}
#endif
if(!m_wgtCallMngCenter->isHidden() && m_wgtCallMngCenter->geometry().contains(mousePos)){
emit callPlatformButtonClicked("管理处");
break;
}
isTouched = true;
_preTime = QTime::currentTime();
longPressToSettingPage();
emit signalScreenTouch();
}while(0);
event->accept();
return true;
}
case QEvent::TouchUpdate:
{
//QTouchEvent* touch = static_cast<QTouchEvent*>(event);
//if(touch->touchPointStates() & Qt::TouchPointPressed){
//判断是否有触摸点处于TouchPointPressed或TouchPointMoved或TouchPointStationary或TouchPointReleased
//}
event->accept();
return true;
}
case QEvent::TouchEnd:
{
//QTouchEvent* touch = static_cast<QTouchEvent*>(event);
qDebug() << "recoUiRecognize touch end!";
isTouched = false;
_preTime = QTime::currentTime();
event->accept();
return true;
}
default:
break;
}
return QWidget::event(event);
}
bool recoUiRecognize::multiPressToSettingPage()
{
bool bRet = false;
QTime time = QTime::currentTime();
if(0 != m_clickCount) {
if( _preTime.msecsTo(time) > clickGrap) {
//qDebug() << "_preTime.msecsTo(time) > clickGrap()";
m_clickCount = 0;
}
}
//qDebug()<<"m_clickCount = "<<m_clickCount;
if(0 == m_clickCount)
{
//qDebug() << "wakeUpFromScreenSaverOrScreenOff";
if(m_backstageIf)
m_backstageIf->wakeUpFromScreenSaverOrScreenOff();
}
m_clickCount++;
_preTime = time;
if(m_clickCount == clickNum)
{
m_clickCount = 0;
if(!UiConfig::GetInstance()->isTpAvailable()){
emit signalChangePage();
}
bRet = true;
}
return bRet;
}
void recoUiRecognize::slotLongPressShowSetting()
{
//qDebug() << "isTouched:" << isTouched << ", pre time:" << _preTime.msecsTo(QTime::currentTime()) << ", need time:" << UiConfig::TOUCH_TIME_TO_SETTING - 200;
if(isTouched && _preTime.msecsTo(QTime::currentTime()) > (UiConfig::TOUCH_TIME_TO_SETTING - 200)){
qDebug() << "into setting...";
emit signalChangePage();
}
}
bool recoUiRecognize::longPressToSettingPage()
{
//qDebug() << "longPressToSettingPage";
if(m_backstageIf)
m_backstageIf->wakeUpFromScreenSaverOrScreenOff();
QTimer::singleShot(UiConfig::TOUCH_TIME_TO_SETTING, this, SLOT(slotLongPressShowSetting()));
return true;
}
void recoUiRecognize::slotCenterMsg(const int nPage, const QString& msg)
{
//if( GLOBAL_RECO_SHOW_CENTER_MSG != nPage){
//return ;
//}
//no scanner, no color
//m_MsgCenterRefresh = GLOBAL_RECO_SHOW_CENTER_MSG;
//m_centermsg = msg;
//m_centerMsgColor = color;
if(_moveScanner->isHidden()){
showCenterMsg(msg, nPage);
}
}
void recoUiRecognize::slotPwdBtnClicked()
{
emit signalShowPwdPage("");
}
void recoUiRecognize::slotSetUserPwdButton(bool visible)
{
if(visible){
m_btnPwd->show();
}else{
m_btnPwd->hide();
}
}
void recoUiRecognize::slotQRCodeSwitchToStandbyStatusFromOvertimeStatus()
{
m_widget_mask->showQRCodeMsg(UiInterfaceForBackstage::QRCode_Msg_Standby);
}
void recoUiRecognize::slotUpdateRecoUiIpDisplay(const bool switchStatus) //增加识别界面ip显示开关更新信号
{
if(switchStatus){
if(m_backstageIf){
char ip[16] = {0};
int type = 0;
if(0 == m_backstageIf->getIP(ip, sizeof (ip), type)){
m_widget_msg->updateIp(ip, type);
}
}
}
else {
m_widget_msg->updateIp("");
}
}
void recoUiRecognize::slotShowFeatureUpdateProgress(const unsigned current, const unsigned all)
{
if(nullptr == m_widget_progress){
m_widget_progress = new ProgressWidget(tr("人脸特征更新中..."));
m_widget_progress->setFixedSize(UiConfig::GetInstance()->getUiWidth() / 1.8, UiConfig::GetInstance()->getUiHeight() / 8);
m_widget_progress->move((UiConfig::GetInstance()->getUiWidth() - m_widget_progress->width()) / 2,
(UiConfig::GetInstance()->getUiHeight() - m_widget_progress->height()) / 2);
m_widget_progress->show();
}
m_widget_progress->setMsg(current, all);
}
void recoUiRecognize::slotCloseFeatureUpdateProgress()
{
if(nullptr != m_widget_progress){
delete m_widget_progress;
m_widget_progress = nullptr;
}
}
void recoUiRecognize::slotShowRecoUiMask(int maskType)
{
qDebug() << "reco ui type:" << maskType;
if(maskType > 3){
return;
}
if(0 == maskType){
//m_label_back->clear();
m_bgPm = QPixmap();
m_isNightMode = false;
}else if(1 == maskType){
if(UiConfig::GetInstance()->isFaceFrameShowByTempExist()){
//m_label_back->setPixmap(
m_bgPm = QPixmap(UiConfig::GetInstance()->is8inchA038HaimanFaceFrame() ?
":/res/image/haiman-face-middle.png" : BG_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()]);
}else if(m_showFaceFrameByUser){
//m_label_back->setPixmap(
m_bgPm = QPixmap(BG_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()]);
}else{
//m_label_back->clear();
m_bgPm = QPixmap();
}
m_isNightMode = false;
}else if(2 == maskType){
//m_label_back->setPixmap(QPixmap(TEMP_CALIBOX_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()]));
m_bgPm = QPixmap(TEMP_CALIBOX_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_isNightMode = false;
}else if(3 == maskType){
//m_label_back->setPixmap(QPixmap(DARK_FILL_LIGHT_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()]));
m_bgPm = QPixmap(DARK_FILL_LIGHT_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_isNightMode = true;
}
if(!UiConfig::GetInstance()->isRecoUiStyleScene()){
m_label_back->setPixmap(m_bgPm);
}
setCardReaderUnderScreenInstructions(m_isNightMode);
}
void recoUiRecognize::slotNotiMsg(const int nPage, const QString& msg, int color)
{
if( GLOBAL_RECO_SHOW_NOTI_MSG != nPage)
{
return ;
}
m_NotiMsgRefresh = GLOBAL_RECO_SHOW_NOTI_MSG;
m_notimsg = msg;
m_notiMsgColor = color;
if(_moveScanner->isHidden())
{
showNotiMsg();
}
}
QString recoUiRecognize::recoUiTextCfg(RecoUiTextCfg::enTextType type)
{
const QString texts[] = {tr("请刷脸通行"), m_name, tr("未经许可人员"), tr("禁止通行"), tr("未佩戴口罩"),
tr("口罩检测通过"), tr("体温:"), tr("请刷卡"), tr("请用本人证件"), tr("请正视镜头"),
tr("禁止通行时段")};
if(UiConfig::GetInstance()->isRecoUiStyleScene() && RecoUiTextCfg::enTextType::TextFacePass == type){
return "";
}
if(RecoUiTextCfg::DisModeHide == UiConfig::GetInstance()->m_textCfg[type].m_mode){
return "";
}
else if(RecoUiTextCfg::DisModeCustom == UiConfig::GetInstance()->m_textCfg[type].m_mode){
return UiConfig::GetInstance()->m_textCfg[type].m_cusText;
}
return texts[type];
}
bool recoUiRecognize::showCenterMsg(const QString& msg, int type) //no buf, show msg immediately
{
#if 0
bool ret = false;
//if(GLOBAL_RECO_SHOW_CENTER_MSG == m_centerMsgRefresh){
m_widget_cMsg->showMsg(msg, type);
ret = true;
//}
if(ret){
//m_centerMsgRefresh = -1;
m_msgShowed = true;
ret = runScanLine;
}
return ret;
#else
if(msg.isEmpty()){
//m_widget_person->show();
m_widget_cMsg->hide();
}
else{
//m_widget_person->hide();
//m_widget_msg->hide();
m_widget_cMsg->showMsg(msg, type);
m_msgShowed = true;
m_widget_cMsg->show();
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
//TODO.....................................................
//m_backstageIf->stopIdentyState();//bt lock unlocking or other situation which showing this widget, pause face recognition
}
QCoreApplication::processEvents();
return runScanLine;
#endif
}
void recoUiRecognize::setCardReaderUnderScreenInstructions(bool isNightMode)
{
if(nullptr == m_wgtCardUnderScreen){
return;
}
QPalette pal(m_wgtCardUnderScreen->palette());
pal.setBrush(QPalette::Background,QBrush(QPixmap(isNightMode ?
SWIP_CARD_NIGHT_MODE_WIDGET_BG[UiConfig::GetInstance()->getScreenConfigIndex()] :
SWIP_CARD_DAY_MODE_WIDGET_BG[UiConfig::GetInstance()->getScreenConfigIndex()])));
m_wgtCardUnderScreen->setPalette(pal);
}
CenterMsgWidget::CenterMsgWidget(QWidget *parent) : QWidget(parent)
{
qDebug() << "CenterMsgWidget()";
m_label_msg = new QLabel(this);
//m_label_msg->setPalette(palette);
m_label_msg->setGeometry(QRect(328, 240, 329, 27*4)); //四倍行距
m_label_msg->setWordWrap(true);
m_label_msg->setAlignment(Qt::AlignCenter);
//m_label_msg->setAutoFillBackground(true);
m_label_msg->setStyleSheet("background-color:transparent;");
//QFont ft;
//ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
//m_label_msg->setFont(ft);
//m_label_msg->setStyleSheet("background-color:transparent;font-size:40px");
QHBoxLayout* hLayout = new QHBoxLayout();
hLayout->addWidget(m_label_msg, 4, Qt::AlignCenter);
setLayout(hLayout);
#if 1 //bg img
setAutoFillBackground(true);
#else
setFixedWidth(WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()]);
setStyleSheet("background-color:rgba(0, 0, 0, 100);border-radius:10px;padding:2px 4px;focus{outline: none;}");
setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明
setWindowFlags(Qt::FramelessWindowHint); //设置无边框窗口
#endif
}
CenterMsgWidget::~CenterMsgWidget()
{
qDebug() << "~CenterMsgWidget()";
}
void CenterMsgWidget::showMsg(const QString& msg, int type)
{
if("" == msg){
hide();
#if 0
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
#endif
return;
}
#if 0
if(m_centerMsgType != type){
QPalette palette;
palette.setColor(QPalette::WindowText,Qt::white);
if(GLOBAL_RECO_SHOW_CENTER_MSG == type){
#if 0 //bg img
palette.setBrush(QPalette::Background,QBrush(QPixmap(BG_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
setFixedHeight(WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()]);
#else
setFixedHeight(UiConfig::GetInstance()->getUiHeight() / 5);
#endif
}
else{ //if(GLOBAL_RECO_SHOW_CENTER_MSG_BIG == type || GLOBAL_RECO_SHOW_CENTER_MSG_BIG_RED == type){
setFixedHeight(static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.8));
}
m_label_msg->setPalette(palette);
m_centerMsgType = type;
}
#endif
QPoint posi(0, 0);
QFont ft;
QPalette pal(this->palette());
m_label_msg->setAutoFillBackground(false);
if(GLOBAL_RECO_SHOW_CENTER_MSG_BIG_RED == type){
QStringList list = msg.split("\n");
QString str;
int segNum = list.length() - 1;
if(segNum){
//qDebug() << "segNum:" << segNum;
for(int i=0; i<segNum - 1; i++){
//qDebug() << "list[" << i << "]:" << list[i];
str += QString("<font color = #FFFFFF >%1</font>").arg(list[i]) + "<br>";
}
str += QString("<font color = #FF0000 >%1</font>").arg(list[segNum - 1]);
}
//setStyleSheet("background-color:rgba(0, 0, 0, 100);border-radius:10px;padding:2px 4px;focus{outline: none;}");
pal.setBrush(QPalette::Background,QBrush(QColor(0, 0, 0, 100)));
//setFixedHeight(static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.5));
setFixedSize(WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()],
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.5));
ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] * 1.5);
m_label_msg->setFont(ft);
m_label_msg->setText(str);
posi.setX((UiConfig::GetInstance()->getUiWidth() - WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()]) / 2);
posi.setY(static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.2));
}else{
switch(type){
case GLOBAL_RECO_SHOW_CENTER_MSG_BG_GREEN:
pal.setBrush(QPalette::Background,QBrush(QPixmap(":/res/image/bg_green_large.png")));
setFixedSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] * 2);
break;
case GLOBAL_RECO_SHOW_CENTER_MSG_BG_YELLOW:
pal.setBrush(QPalette::Background,QBrush(QPixmap(":/res/image/bg_yellow_large.png")));
setFixedSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] * 2);
break;
case GLOBAL_RECO_SHOW_CENTER_MSG_BG_RED:
pal.setBrush(QPalette::Background,QBrush(QPixmap(":/res/image/bg_red_large.png")));
setFixedSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] * 2);
break;
case GLOBAL_RECO_SHOW_CENTER_MSG_BG_PURPLE:
pal.setBrush(QPalette::Background,QBrush(QPixmap(":/res/image/bg_purple_large.png")));
setFixedSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] * 2);
break;
case GLOBAL_RECO_SHOW_CENTER_MSG_BG_BLACK:
pal.setBrush(QPalette::Background, QBrush(Qt::black));
setFixedSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] * 2);
break;
case GLOBAL_RECO_SHOW_CENTER_MSG_FIRE_ALARM:
//m_label_msg->clear();
m_label_msg->setFixedSize(200, 200);
m_label_msg->setAutoFillBackground(true);
m_label_msg->setPixmap(QPixmap(":/res/image/fire_alarm.png"));
pal.setBrush(QPalette::Background,QBrush(QColor(255, 255, 255, 255)));
setFixedSize(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.8),
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.3));
posi.setX((UiConfig::GetInstance()->getUiWidth() - static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.8)) / 2);
posi.setY(static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.3));
const_cast<QString&>(msg).clear();
break;
default:
pal.setBrush(QPalette::Background,QBrush(QColor(0, 0, 0, 100)));
setFixedSize(WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()],
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.5));
posi.setX((UiConfig::GetInstance()->getUiWidth() - WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()]) / 2);
posi.setY(static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.2));
ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()] * 1.5);
break;
}
if(!msg.isEmpty()){
m_label_msg->setFixedSize(static_cast<int>(width() * 0.8), static_cast<int>(height() * 0.8));
m_label_msg->setFont(ft);
QPalette palette;
palette.setColor(QPalette::WindowText,Qt::white);
m_label_msg->setPalette(palette);
m_label_msg->setText(msg);
}
setPalette(pal);
}
move(posi.x(), posi.y());
show();
}
void CenterMsgWidget::paintEvent(QPaintEvent *event)
{
QStyleOption opt;
opt.initFrom(this);
QPainter pr(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &pr, this);//绘制样式
return QWidget::paintEvent(event);
}
FinalResultWidget::FinalResultWidget(QWidget *parent) : QWidget(parent)
{
setFixedSize(FinalResultWidget::FINAL_RESULT_WIDGET_W_H[UiConfig::GetInstance()->getScreenConfigIndex()],
FinalResultWidget::FINAL_RESULT_WIDGET_W_H[UiConfig::GetInstance()->getScreenConfigIndex()] + 1);
setAutoFillBackground(true);
hide();
}
FinalResultWidget::~FinalResultWidget()
{
}
void FinalResultWidget::showResult(bool pass)
{
QPalette pal(palette());
pal.setBrush(QPalette::Background,QBrush(QPixmap(pass ?
FinalResultWidget::FINAL_RESULT_OK_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()] :
FinalResultWidget::FINAL_RESULT_FAIL_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
setPalette(pal);
show();
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
}