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

1273 lines
47 KiB
C++

#include "recoUiRecognizeTypeBase.h"
#include <QTouchEvent>
#include <QDebug>
#include "DndModeCountDownItem.h"
const int RecoResultWidget::FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {25, 28, 28, 10, 10};
const QString RecoResultWidget::RECO_OK_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_msg_reco_ok_large.png",
":/res/image/reco_msg_reco_ok_large.png",
":/res/image/reco_msg_reco_ok_large.png",
":/res/image/reco_msg_reco_ok_large.png",
":/res/image/reco_msg_reco_ok_large.png"
};
const QString RecoResultWidget::RECO_FAIL_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_msg_reco_fail_large.png",
":/res/image/reco_msg_reco_fail_large.png",
":/res/image/reco_msg_reco_fail_large.png",
":/res/image/reco_msg_reco_fail_large.png",
":/res/image/reco_msg_reco_fail_large.png"
};
const QString RecoResultWidget::RECO_WARN_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_msg_reco_warn_large.png",
":/res/image/reco_msg_reco_warn_large.png",
":/res/image/reco_msg_reco_warn_large.png",
":/res/image/reco_msg_reco_warn_large.png",
":/res/image/reco_msg_reco_warn_large.png"
};
const QString RecoResultWidget::MASK_OK_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_msg_mask_ok_large.png",
":/res/image/reco_msg_mask_ok_large.png",
":/res/image/reco_msg_mask_ok_large.png",
":/res/image/reco_msg_mask_ok_large.png",
":/res/image/reco_msg_mask_ok_large.png"
};
const QString RecoResultWidget::MASK_NULL_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_msg_mask_null_large.png",
":/res/image/reco_msg_mask_null_large.png",
":/res/image/reco_msg_mask_null_large.png",
":/res/image/reco_msg_mask_null_large.png",
":/res/image/reco_msg_mask_null_large.png"
};
const QString RecoResultWidget::TEMP_OK_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_msg_temp_ok_large.png",
":/res/image/reco_msg_temp_ok_large.png",
":/res/image/reco_msg_temp_ok_large.png",
":/res/image/reco_msg_temp_ok_large.png",
":/res/image/reco_msg_temp_ok_large.png"
};
const QString RecoResultWidget::TEMP_ABN_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_msg_temp_abnorm_large.png",
":/res/image/reco_msg_temp_abnorm_large.png",
":/res/image/reco_msg_temp_abnorm_large.png",
":/res/image/reco_msg_temp_abnorm_large.png",
":/res/image/reco_msg_temp_abnorm_large.png"
};
RecoResultWidget::RecoResultWidget(QWidget *parent) : QWidget(parent)
{
QFont ft;
m_label_identity_icon = new QLabel(this);
m_label_identity_word = new QLabel(this);
m_label_identity_word->setAlignment(Qt::AlignLeft);
ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);// * 1.1
m_label_identity_word->setFont(ft);
QHBoxLayout* hlayId = new QHBoxLayout();
hlayId->addWidget(m_label_identity_icon, 1, Qt::AlignLeft);
hlayId->addWidget(m_label_identity_word, 10, Qt::AlignLeft);
m_label_mask_icon = new QLabel(this);
m_label_mask_word = new QLabel(this);
m_label_mask_word->setAlignment(Qt::AlignLeft);
ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_label_mask_word->setFont(ft);
QHBoxLayout* hlayMask = new QHBoxLayout();
hlayMask->addSpacing(10); //id icon:60, mask icon:40
hlayMask->addWidget(m_label_mask_icon, 1, Qt::AlignLeft);
hlayMask->addSpacing(10);
hlayMask->addWidget(m_label_mask_word, 10, Qt::AlignLeft);
m_label_temp_icon = new QLabel(this);
m_label_temp_word = new QLabel(this);
m_label_temp_word->setAlignment(Qt::AlignLeft);
m_label_temp_word->setFont(ft);
QHBoxLayout* hlayTemp = new QHBoxLayout();
hlayTemp->addSpacing(10);
hlayTemp->addWidget(m_label_temp_icon, 1, Qt::AlignLeft);
hlayMask->addSpacing(10);
hlayTemp->addWidget(m_label_temp_word, 10, Qt::AlignLeft);
QVBoxLayout* vlay = new QVBoxLayout();
vlay->addStretch();
vlay->addLayout(hlayId);
vlay->addLayout(hlayMask);
vlay->addLayout(hlayTemp);
vlay->addStretch();
vlay->setMargin(0);
setLayout(vlay);
}
void RecoResultWidget::showIdentityResult(GLOBAL_RECO_STATE state, const QString& msg)
{
qDebug() << "show result:" << state;
if(GLOBAL_RECO_END_OK == state){
qDebug() << "show name";
m_label_identity_icon->setPixmap(RECO_OK_IMG[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_label_identity_icon->show();
m_label_identity_word->setText(msg);
m_label_identity_word->show();
}
else if (GLOBAL_RECO_NOT_LIVING == state ||
GLOBAL_RECO_SWIPE_CARD == state ||
GLOBAL_RECO_FACE_CAMERA == state) {
m_label_identity_icon->setPixmap(RECO_WARN_IMG[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_label_identity_icon->show();
m_label_identity_word->setText(msg);
m_label_identity_word->show();
}
else {
m_label_identity_icon->setPixmap(RECO_FAIL_IMG[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_label_identity_icon->show();
m_label_identity_word->setText(msg);
m_label_identity_word->show();
}
}
void RecoResultWidget::showMaskResult(bool hasMask, const QString& msg)
{
m_label_mask_icon->setPixmap(hasMask ? MASK_OK_IMG[UiConfig::GetInstance()->getScreenConfigIndex()] :
MASK_NULL_IMG[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_label_mask_icon->show();
m_label_mask_word->setText(msg);
m_label_mask_word->show();
}
void RecoMsgWidget::setDndMode(bool dndMode, const std::chrono::system_clock::time_point &endTime) {
m_dndItem->setVisible(dndMode);
QVector<QWidget *> widgets;
int timeWidgetIndex = -1;
int dndItemIndex = -1;
for (int i = 0; i < m_stackWgt_msg->count(); i++) {
auto current = m_stackWgt_msg->widget(i);
widgets.push_back(current);
if (dynamic_cast<TimeWidget *>(current) == m_widget_time) {
timeWidgetIndex = i;
} else if (dynamic_cast<DndModeCountDownItem *>(current) == m_dndItem) {
dndItemIndex = i;
}
}
for (auto widget : widgets) {
m_stackWgt_msg->removeWidget(widget);
}
if (dndMode) {
if (timeWidgetIndex >= 0) {
widgets[timeWidgetIndex] = m_dndItem;
}
m_dndItem->setEndTime(endTime);
} else {
if (dndItemIndex >= 0) {
widgets[dndItemIndex] = m_widget_time;
}
}
for (auto widget : widgets) {
m_stackWgt_msg->addWidget(widget);
}
}
void RecoResultWidget::showTempResult(const QString& msg, float temp, bool isNormal, bool isC)
{
m_label_temp_icon->setPixmap(isNormal ? TEMP_OK_IMG[UiConfig::GetInstance()->getScreenConfigIndex()] :
TEMP_ABN_IMG[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_label_temp_icon->show();
QString strTem = msg;
if(temp > 1.0f){
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 += "<";
}
else if(temp > max){
strTem += ">";
}
strTem += QString().setNum(temp, 'f', 1);
strTem += (isC ? "" : "");
}
m_label_temp_word->setText(strTem);
m_label_temp_word->show();
}
void RecoResultWidget::reset()
{
m_label_identity_icon->hide();
m_label_identity_word->hide();
m_label_mask_icon->hide();
m_label_mask_word->hide();
m_label_temp_icon->hide();
m_label_temp_word->hide();
}
const int RecoMsgWidget::TIME_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {30, 55, 55, 20, 20};
const int RecoMsgWidget::DATE_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {24, 22, 22, 8, 8};
const int RecoMsgWidget::MSG_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {256, 256, 258, 257, 257};
const int RecoMsgWidget::PIC_WIDGET_H_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {200, 200, 200, 201, 201};
const QString RecoMsgWidget::PIC_WIDGET_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_msg_face_pic_large.png",
":/res/image/reco_msg_face_pic_large.png",
":/res/image/reco_msg_face_pic_large.png",
":/res/image/reco_msg_face_pic_large.png",
":/res/image/reco_msg_face_pic_large.png"
};
const QString RecoMsgWidget::IDLE_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_msg_bg_idle_middle.png",
":/res/image/reco_msg_bg_idle_large.png",
":/res/image/reco_msg_bg_idle_middle.png",
":/res/image/reco_msg_bg_idle_large.png",
":/res/image/reco_msg_bg_idle_middle.png"
};
const QString RecoMsgWidget::OK_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_msg_bg_pass_middle.png",
":/res/image/reco_msg_bg_pass_large.png",
":/res/image/reco_msg_bg_pass_middle.png",
":/res/image/reco_msg_bg_pass_large.png",
":/res/image/reco_msg_bg_pass_middle.png"
};
const QString RecoMsgWidget::FAIL_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_msg_bg_fail_middle.png",
":/res/image/reco_msg_bg_fail_large.png",
":/res/image/reco_msg_bg_fail_middle.png",
":/res/image/reco_msg_bg_fail_large.png",
":/res/image/reco_msg_bg_fail_middle.png"
};
const QString RecoMsgWidget::WARN_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_msg_bg_warn_middle.png",
":/res/image/reco_msg_bg_warn_large.png",
":/res/image/reco_msg_bg_warn_middle.png",
":/res/image/reco_msg_bg_warn_large.png",
":/res/image/reco_msg_bg_warn_middle.png"
};
const QString RecoMsgWidget::T1_IDLE_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/t1_reco_msg_bg_idle_middle.png",
":/res/image/t1_reco_msg_bg_idle_large.png",
":/res/image/t1_reco_msg_bg_idle_middle.png",
":/res/image/t1_reco_msg_bg_idle_large.png",
":/res/image/t1_reco_msg_bg_idle_middle.png"
};
const QString RecoMsgWidget::T1_OK_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/t1_reco_msg_bg_pass_middle.png",
":/res/image/t1_reco_msg_bg_pass_large.png",
":/res/image/t1_reco_msg_bg_pass_middle.png",
":/res/image/t1_reco_msg_bg_pass_large.png",
":/res/image/t1_reco_msg_bg_pass_middle.png"
};
const QString RecoMsgWidget::T1_FAIL_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/t1_reco_msg_bg_fail_middle.png",
":/res/image/t1_reco_msg_bg_fail_large.png",
":/res/image/t1_reco_msg_bg_fail_middle.png",
":/res/image/t1_reco_msg_bg_fail_large.png",
":/res/image/t1_reco_msg_bg_fail_middle.png"
};
const QString RecoMsgWidget::T1_WARN_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/t1_reco_msg_bg_warn_middle.png",
":/res/image/t1_reco_msg_bg_warn_large.png",
":/res/image/t1_reco_msg_bg_warn_middle.png",
":/res/image/t1_reco_msg_bg_warn_large.png",
":/res/image/t1_reco_msg_bg_warn_middle.png"
};
RecoMsgWidget::RecoMsgWidget(bool hasFacePic, bool enTimeType, int bgImgType, QWidget *parent)
: QWidget(parent), m_bgImgType(bgImgType)
{
if(hasFacePic){
m_widget_pic = new QWidget(this);
m_widget_pic->setAutoFillBackground(true);
}
else{
m_widget_pic = nullptr;
}
m_stackWgt_msg = new QStackedWidget(this);
m_stackWgt_msg->setFixedSize(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.55),
static_cast<int>(MSG_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()] * 0.9));
m_widget_time = new TimeWidget(enTimeType, TIME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()],
DATE_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()], this);
m_stackWgt_msg->addWidget(m_widget_time);
m_dndItem = new DndModeCountDownItem(this);
m_dndItem->hide();
m_widget_result = new RecoResultWidget(this);
m_stackWgt_msg->addWidget(m_widget_result);
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText,Qt::white);
setAutoFillBackground(true);
setPalette(palette);
#if 0
QHBoxLayout* hlay = new QHBoxLayout();
if(m_widget_pic){
hlay->addWidget(m_widget_pic);
hlay->addSpacing(UiConfig::GetInstance()->getUiWidth() / 15);
}
else{
hlay->addSpacing(UiConfig::GetInstance()->getUiWidth() / 3);
}
hlay->addWidget(m_stackWgt_msg);
hlay->setContentsMargins(UiConfig::GetInstance()->getUiWidth() / 10, 10, UiConfig::GetInstance()->getUiWidth() / 10, 0);
setLayout(hlay);
#else
if(m_widget_pic){
m_widget_pic->move(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.1),
static_cast<int>(MSG_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()] * 0.15));
}
m_stackWgt_msg->move(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.38),
static_cast<int>(MSG_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()] * 0.07));
#endif
setFixedSize(UiConfig::GetInstance()->getUiWidth(), MSG_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()]);
reset();
}
void RecoMsgWidget::showFacePic(const QString& picPath)
{
if(!m_widget_pic){
return;
}
QPalette pal(m_widget_pic->palette());
#if 1
QPixmap pm(ScalePixmap(QPixmap(picPath),
QSize(PIC_WIDGET_H_W[UiConfig::GetInstance()->getScreenConfigIndex()],
PIC_WIDGET_H_W[UiConfig::GetInstance()->getScreenConfigIndex()])));
qDebug() << "w:" << pm.width() << " h:" << pm.height();
m_widget_pic->setFixedSize(pm.width(), pm.height());
pal.setBrush(QPalette::Background,QBrush(pm));
#else
pal.setBrush(QPalette::Background, QBrush(QPixmap(picPath).scaled(
PIC_WIDGET_H_W[UiConfig::GetInstance()->getScreenConfigIndex()],
PIC_WIDGET_H_W[UiConfig::GetInstance()->getScreenConfigIndex()],
Qt::IgnoreAspectRatio, Qt::SmoothTransformation)));
#endif
m_widget_pic->setPalette(pal);
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
QCoreApplication::processEvents();
}
void RecoMsgWidget::showFacePic(const unsigned char* jpgDate, int len)
{
if(jpgDate == nullptr || len <= 0){
return;
}
QImage faceImg;
faceImg.loadFromData(jpgDate, len, "JPG");
if(!faceImg.isNull()){
QPalette pal(m_widget_pic->palette());
#if 1
QImage img(ScaleImage(faceImg,
QSize(PIC_WIDGET_H_W[UiConfig::GetInstance()->getScreenConfigIndex()],
PIC_WIDGET_H_W[UiConfig::GetInstance()->getScreenConfigIndex()])));
qDebug() << "w:" << img.width() << " h:" << img.height();
m_widget_pic->setFixedSize(img.width(), img.height());
pal.setBrush(QPalette::Background, QBrush(img));
#else
pal.setBrush(QPalette::Background, QBrush(QPixmap::fromImage(*image).scaled(
PIC_WIDGET_H_W[UiConfig::GetInstance()->getScreenConfigIndex()],
PIC_WIDGET_H_W[UiConfig::GetInstance()->getScreenConfigIndex()],
Qt::IgnoreAspectRatio, Qt::SmoothTransformation)));
#endif
m_widget_pic->setPalette(pal);
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
}
QCoreApplication::processEvents();
}
void RecoMsgWidget::facePicReset()
{
if(!m_widget_pic){
return;
}
m_widget_pic->setFixedSize(PIC_WIDGET_H_W[UiConfig::GetInstance()->getScreenConfigIndex()],
PIC_WIDGET_H_W[UiConfig::GetInstance()->getScreenConfigIndex()]);
QPalette pal(m_widget_pic->palette());
pal.setBrush(QPalette::Background,QBrush(QPixmap(PIC_WIDGET_IMG[UiConfig::GetInstance()->getScreenConfigIndex()])));
m_widget_pic->setPalette(pal);
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
QCoreApplication::processEvents();
}
void RecoMsgWidget::showIdentityResult(GLOBAL_RECO_STATE state, const QString& msg)
{
m_widget_result->showIdentityResult(state, msg);
m_stackWgt_msg->setCurrentIndex(1);
m_widget_time->enableUpdate(false);
QCoreApplication::processEvents();
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
}
void RecoMsgWidget::showMaskResult(bool hasMask, const QString& msg)
{
m_widget_result->showMaskResult(hasMask, msg);
m_stackWgt_msg->setCurrentIndex(1);
m_widget_time->enableUpdate(false);
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
}
void RecoMsgWidget::showTempResult(const QString& msg, float temp, bool isNormal, bool isC)
{
m_widget_result->showTempResult(msg, temp, isNormal, isC);
m_stackWgt_msg->setCurrentIndex(1);
m_widget_time->enableUpdate(false);
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
}
void RecoMsgWidget::reset()
{
m_widget_result->reset();
m_widget_time->enableUpdate(true);
switchBg(0);
facePicReset();
m_stackWgt_msg->setCurrentIndex(0);
}
void RecoMsgWidget::switchBg(int type)
{
type += (m_bgImgType * 10);
QPalette palette(this->palette());
switch (type) {
case 0:
palette.setBrush(QPalette::Background, QBrush(QPixmap(IDLE_BG_IMG[UiConfig::GetInstance()->getScreenConfigIndex()])));
break;
case 1:
palette.setBrush(QPalette::Background, QBrush(QPixmap(OK_BG_IMG[UiConfig::GetInstance()->getScreenConfigIndex()])));
break;
case 2:
palette.setBrush(QPalette::Background, QBrush(QPixmap(FAIL_BG_IMG[UiConfig::GetInstance()->getScreenConfigIndex()])));
break;
case 3:
palette.setBrush(QPalette::Background, QBrush(QPixmap(WARN_BG_IMG[UiConfig::GetInstance()->getScreenConfigIndex()])));
break;
case 10:
palette.setBrush(QPalette::Background, QBrush(QPixmap(T1_IDLE_BG_IMG[UiConfig::GetInstance()->getScreenConfigIndex()])));
break;
case 11:
palette.setBrush(QPalette::Background, QBrush(QPixmap(T1_OK_BG_IMG[UiConfig::GetInstance()->getScreenConfigIndex()])));
break;
case 12:
palette.setBrush(QPalette::Background, QBrush(QPixmap(T1_FAIL_BG_IMG[UiConfig::GetInstance()->getScreenConfigIndex()])));
break;
case 13:
palette.setBrush(QPalette::Background, QBrush(QPixmap(T1_WARN_BG_IMG[UiConfig::GetInstance()->getScreenConfigIndex()])));
break;
default:
break;
}
setPalette(palette);
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
}
const QString RecoTypeResultWidget::RESULT_OK_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/final_res_ok_middle.png",
":/res/image/final_res_ok_large.png",
":/res/image/final_res_ok_middle.png",
":/res/image/final_res_ok_large.png",
":/res/image/final_res_ok_middle.png"
};
const QString RecoTypeResultWidget::RESULT_FAIL_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/final_res_fail_middle.png",
":/res/image/final_res_fail_large.png",
":/res/image/final_res_fail_middle.png",
":/res/image/final_res_fail_large.png",
":/res/image/final_res_fail_middle.png"
};
const QString RecoTypeResultWidget::RESULT_WARN_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/final_res_warn_middle.png",
":/res/image/final_res_warn_large.png",
":/res/image/final_res_warn_middle.png",
":/res/image/final_res_warn_large.png",
":/res/image/final_res_warn_middle.png"
};
RecoTypeResultWidget::RecoTypeResultWidget(QWidget *parent) : QWidget(parent)
{
setFixedSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
setAutoFillBackground(true);
hide();
}
void RecoTypeResultWidget::showResult(int type)
{
QPalette pal(palette());
if(type == 2){
pal.setBrush(QPalette::Background, QBrush(QPixmap(RecoTypeResultWidget::RESULT_WARN_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
}
else{
pal.setBrush(QPalette::Background,QBrush(QPixmap(1 == type ?
RecoTypeResultWidget::RESULT_OK_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()] :
RecoTypeResultWidget::RESULT_FAIL_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
}
setPalette(pal);
show();
if(UiConfig::GetInstance()->isRkDevice()){
dynamic_cast<QWidget*>(parent())->update();
}
}
const int recoUiRecognizeTypeBase::TOP_MSG_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {89, 89, 89, 90, 90};
const int recoUiRecognizeTypeBase::AD_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {1052, 1052, 1052, 1053, 1053};
const QString recoUiRecognizeTypeBase::TOP_MSG_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/top_msg_large.png",
":/res/image/top_msg_large.png",
":/res/image/top_msg_large.png",
":/res/image/top_msg_large.png",
":/res/image/top_msg_large.png"
};
const int recoUiRecognizeTypeBase::SWIP_CARD_WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {400, 746, 720, 746, 720};
const int recoUiRecognizeTypeBase::SWIP_CARD_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {70, 104, 104, 105, 105};
const QString recoUiRecognizeTypeBase::SWIP_CARD_DAY_MODE_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/swipe_card_day_mode_type1_large.png",
":/res/image/swipe_card_day_mode_type1_large.png",
":/res/image/swipe_card_day_mode_type1_large.png",
":/res/image/swipe_card_day_mode_type1_large.png",
":/res/image/swipe_card_day_mode_type1_large.png"
};
const QString recoUiRecognizeTypeBase::SWIP_CARD_NIGHT_MODE_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/swipe_card_night_mode_type1_large.png",
":/res/image/swipe_card_night_mode_type1_large.png",
":/res/image/swipe_card_night_mode_type1_large.png",
":/res/image/swipe_card_night_mode_type1_large.png",
":/res/image/swipe_card_night_mode_type1_large.png"
};
recoUiRecognizeTypeBase::recoUiRecognizeTypeBase(bool isNightMode, bool hasPwdBtn, bool hasCallBtn, int type, QWidget *parent) : PageAcceptMouseAndTouch(parent), m_uiType(type)
{
const bool hasFaceImg = (0 == type);
const bool hasAd = (1 == type);
const int recoMsgBgType = type;
m_wgtBack = new QWidget(this);
m_wgtBack->setAutoFillBackground(true);
m_wgtBack->setFixedSize(UiConfig::GetInstance()->getUiWidth(), AD_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()]);
if(hasAd){
m_widget_ad = new recoUiScreensaver(1, this);
m_widget_ad->resize(UiConfig::GetInstance()->getUiWidth(), AD_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()]);
}
else{
m_widget_ad = nullptr;
}
if(!UiConfig::GetInstance()->isFuncNotSupport(FuncCardReaderUnderScreen)){
qDebug() << "show swipe card area";
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()]);
}
else{
m_wgtCardUnderScreen = nullptr;
}
slotShowRecoUiMask(3); //set night mode for ui init
m_widget_reco = new RecoMsgWidget(hasFaceImg, UiConfig::GetInstance()->getLanguageType() != 0, recoMsgBgType, this);
m_widget_result = new RecoTypeResultWidget(this);
m_widget_msg = new MsgWidget(1, 1, Qt::white, this);
m_widget_msg->setFixedSize(UiConfig::GetInstance()->getUiWidth(), TOP_MSG_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()]);
setMsgWidgetBg(0);
#if 0
m_wgtCallDial = new QWidget(this);
m_wgtCallDial->setAutoFillBackground(true);
m_wgtCallDial->setFixedSize(recoUiRecognize::PWD_BTN_W_H[UiConfig::GetInstance()->getScreenConfigIndex()],
recoUiRecognize::PWD_BTN_W_H[UiConfig::GetInstance()->getScreenConfigIndex()]);
QPalette dialPal(m_wgtCallDial->palette());
dialPal.setBrush(QPalette::Background,QBrush(QPixmap(recoUiRecognize::CALL_BTN[UiConfig::GetInstance()->getScreenConfigIndex()])));
m_wgtCallDial->setPalette(dialPal);
if(!hasCallBtn){
m_wgtCallDial->hide();
}
#else
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);
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();
}
#endif
QHBoxLayout* hlayBtn = new QHBoxLayout();
m_wgtBtnPwd = new QWidget(this);
m_wgtBtnPwd->setAutoFillBackground(true);
m_wgtBtnPwd->setFixedSize(recoUiRecognize::PWD_BTN_W_H[UiConfig::GetInstance()->getScreenConfigIndex()],
recoUiRecognize::PWD_BTN_W_H[UiConfig::GetInstance()->getScreenConfigIndex()]);
if(!hasPwdBtn){
m_wgtBtnPwd->hide();
}
QPalette pwdPal(m_wgtBtnPwd->palette());
pwdPal.setBrush(QPalette::Background,QBrush(QPixmap(recoUiRecognize::PWD_BTN[UiConfig::GetInstance()->getScreenConfigIndex()])));
m_wgtBtnPwd->setPalette(pwdPal);
hlayBtn->addWidget(m_wgtBtnPwd, 1, Qt::AlignTop | Qt::AlignRight);
hlayBtn->setMargin(UiConfig::GetInstance()->getUiWidth() / 15);
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_vlay = new QVBoxLayout();
m_vlay->setMargin(0);
m_vlay->setSpacing(0);
m_vlay->addWidget(m_widget_msg, 1, Qt::AlignTop);
m_vlay->addLayout(hlayBtn, 1);
m_vlay->addStretch(10);
if (m_wgtCardUnderScreen) {
m_vlay->addWidget(m_wgtCardUnderScreen, 1, Qt::AlignBottom | Qt::AlignCenter);
}
m_vlay->addWidget(m_widget_reco, 1, Qt::AlignBottom);
setLayout(m_vlay);
slotShowRecoUiMask(isNightMode ? 3 : 1);
}
recoUiRecognizeTypeBase::~recoUiRecognizeTypeBase()
{
if(m_widget_cMsg){
delete m_widget_cMsg;
}
}
bool recoUiRecognizeTypeBase::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;
}
bool recoUiRecognizeTypeBase::event(QEvent *event)
{
switch( event->type() ){
case QEvent::TouchBegin:
do{
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_wgtBtnPwd->isHidden() && m_wgtBtnPwd->geometry().contains(mousePos)){
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:
event->accept();
return true;
case QEvent::TouchEnd:
isTouched = false;
_preTime = QTime::currentTime();
event->accept();
return true;
default:
break;
}
return QWidget::event(event);
}
bool recoUiRecognizeTypeBase::multiPressToSettingPage()
{
bool bRet = false;
QTime time = QTime::currentTime();
if(0 != m_clickCount) {
if( _preTime.msecsTo(time) > UiConfig::MOUSE_CLICK_INTERVAL_MAX) {
m_clickCount = 0;
}
}
if(0 == m_clickCount){
if(m_backstageIf)
m_backstageIf->wakeUpFromScreenSaverOrScreenOff();
}
m_clickCount++;
_preTime = time;
if(m_clickCount == UiConfig::MOUSE_CLICK_TIMES_TO_SETTING){
m_clickCount = 0;
if(!UiConfig::GetInstance()->isTpAvailable()){
emit signalChangePage();
}
bRet = true;
}
return bRet;
}
void recoUiRecognizeTypeBase::slotLongPressShowSetting()
{
if(isTouched && _preTime.msecsTo(QTime::currentTime()) > (UiConfig::TOUCH_TIME_TO_SETTING - 200)){
emit signalChangePage();
}
}
bool recoUiRecognizeTypeBase::longPressToSettingPage()
{
if(m_backstageIf)
m_backstageIf->wakeUpFromScreenSaverOrScreenOff();
QTimer::singleShot(UiConfig::TOUCH_TIME_TO_SETTING, this, SLOT(slotLongPressShowSetting()));
return true;
}
void recoUiRecognizeTypeBase::slotsNoSuccessPage(int nPage)
{
if(nPage >= GLOBAL_RECO_END_NO && nPage <= GLOBAL_RECO_SHOW_QRCODE){
switch(nPage)
{
case GLOBAL_RECO_END_OK:
break;
case GLOBAL_RECO_END_NO:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, recoUiTextCfg(RecoUiTextCfg::TextAuthFailed));
break;
case GLOBAL_RECO_FACE_CARD_NOT_MATCH:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, recoUiTextCfg(RecoUiTextCfg::TextUseOwnCertifi));
break;
case GLOBAL_RECO_SWIPE_CARD:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, recoUiTextCfg(RecoUiTextCfg::TextTapCard));
break;
case GLOBAL_RECO_FACE_CAMERA:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, recoUiTextCfg(RecoUiTextCfg::TextFaceCam));
break;
case GLOBAL_RECO_NOT_PASS_TIME:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, recoUiTextCfg(RecoUiTextCfg::TextNoEntryTime));
break;
case GLOBAL_RECO_NEED_RECHECK:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("身份核验中"));
break;
case GLOBAL_RECO_PLATFORM_DISCONNECTED:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("服务器连接失败"));
break;
case GLOBAL_RECO_SWIPE_CARD_HERE:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请在此处刷卡"));
break;
case GLOBAL_RECO_HIDE_NAME_AREA:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, "");
break;
case GLOBAL_RECO_NOT_LIVING:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请调整人脸角度"));
break;
case GLOBAL_RECO_SHOW_QRCODE:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请刷二维码"));
break;
case GLOBAL_RECO_UNAUTH_CARD:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("未授权卡片"));
break;
case GLOBAL_RECO_PLS_TAP_ID_CARD:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请刷身份证"));
break;
case GLOBAL_RECO_PLS_CHECK_STATIC:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请测试静电"));
break;
case GLOBAL_RECO_STATIC_ABNORMAL:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("静电测试异常"));
break;
case GLOBAL_RECO_SWIPE_ID_OR_HEALEH_CODE:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请刷身份证或扫码"));
break;
case GLOBAL_RECO_CHECKING:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("健康码查询中"));
break;
case GLOBAL_RECO_CHECK_FAILED:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("查询失败"));
break;
case GLOBAL_RECO_QRCODE_OVERDUE:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("二维码已过期"));
break;
case GLOBAL_RECO_NETWORK_ERROR:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("网络异常"));
break;
case GLOBAL_RECO_PLATFORM_ERROR:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("服务器异常"));
break;
case GLOBAL_RECO_REQUEST_OVERTIME:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("服务器请求超时"));
break;
case GLOBAL_RECO_SWIPE_TRIP_CARD:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请刷行程卡"));
break;
case GLOBAL_RECO_SHOW_HEALTH_CODE:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请扫健康码"));
break;
case GLOBAL_RECO_RESWIPE_TRIP_CARD:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请重刷行程卡"));
break;
case GLOBAL_RECO_SWIPE_ID_AND_TRIP_CARD:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("刷身份证扫行程卡"));
break;
case GLOBAL_RECO_TRIP_CARD_CHECKING:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("行程卡查询中"));
break;
case GLOBAL_RECO_SCAN_YUEJUMA:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请扫粤居码"));
break;
case GLOBAL_RECO_SCAN_YUEJUMA_OR_SWIPE_ID:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请刷粤居码/身份证"));
break;
case GLOBAL_RECO_PATROL_OK:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("巡更成功"));
break;
case GLOBAL_RECO_PATROL_NOT_RIGHT_TIME:
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("非巡更时段"));
break;
default:
break;
}
}
else if(GLOBAL_RECO_ID_FAILED == nPage) {
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("身份证核验失败"));
}
else if(GLOBAL_RECO_IN == nPage){
uiReset();
}
else if(GLOBAL_RECO_CHECK == nPage){
}
else if(GLOBAL_RECO_MASK_REQ == nPage){
m_widget_reco->showMaskResult(false, recoUiTextCfg(RecoUiTextCfg::TextNOMask));
}
else if(GLOBAL_RECO_MASK_OK == nPage){
m_widget_reco->showMaskResult(true, recoUiTextCfg(RecoUiTextCfg::TextMaskOk));
}
else if(GLOBAL_RECO_TAKE_OFF_MASK == nPage){
m_widget_reco->showMaskResult(false, tr("请摘下口罩"));
}
else if(GLOBAL_RECO_NO_ENTRY == nPage){
//m_widget_msg->setMsgBtm(recoUiTextCfg(RecoUiTextCfg::TextNoEntry), true);
}
else if(GLOBAL_RECO_CLEAR_NO_ENTRY == nPage){
//m_widget_msg->setMsgBtm("");
}
else if(GLOBAL_RECO_CLOSE_SCANLINE == nPage){
}
else if(GLOBAL_RECO_SHOW_QRCODE_RECO == nPage){
}
else if(GLOBAL_RECO_SHOW_FACE_RECO == nPage){
uiReset();
}
if (GLOBAL_RECO_NOT_LIVING == nPage ||
GLOBAL_RECO_SWIPE_CARD == nPage ||
GLOBAL_RECO_FACE_CAMERA == nPage) {
m_widget_result->showResult(2);
setMsgWidgetBg(1);
m_widget_reco->switchBg(3);
}
}
void recoUiRecognizeTypeBase::slotsSuccessPage(const int nPage, const QString& name)
{
if( GLOBAL_RECO_END_OK != nPage){
return ;
}
m_name = name;
m_widget_reco->showIdentityResult((GLOBAL_RECO_STATE)nPage, recoUiTextCfg(RecoUiTextCfg::TextAllowPass));
}
void recoUiRecognizeTypeBase::slotsDrawScanner(const int nPage, const bool faceAvailable)
{
if(!faceAvailable){
uiReset();
}
}
void recoUiRecognizeTypeBase::slotsInteractionChange(const INTERACION_OPTION &interaction, int nSelectRes)
{
if(OPTION_LOGO == interaction){
QString logo;
if(0 == nSelectRes){
logo = recoUiRecognize::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 recoUiRecognizeTypeBase::slotShowNormalTemp(const float temp, const bool isC)
{
m_widget_reco->showTempResult(recoUiTextCfg(RecoUiTextCfg::TextTemp), temp, true, isC);
}
void recoUiRecognizeTypeBase::slotShowAbnormalTemp(const float temp, const bool isHigh, const bool isC)
{
Q_UNUSED(isHigh);
m_widget_reco->showTempResult(recoUiTextCfg(RecoUiTextCfg::TextTemp), temp, false, isC);
}
void recoUiRecognizeTypeBase::slotUpdateLogo(const int option)
{
slotsInteractionChange(OPTION_LOGO, option);
}
void recoUiRecognizeTypeBase::slotUpdatePlatformConnectionStatus(const int status)
{
m_widget_msg->setNetworkStatus(status);
}
void recoUiRecognizeTypeBase::slotsResetRecoUi()
{
slotsDrawScanner(0, false);
}
void recoUiRecognizeTypeBase::slotUpdateRecoUiIpDisplay(const bool switchStatus)
{
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 recoUiRecognizeTypeBase::slotShowRecoUiMask(int maskType)
{
if(maskType > 3){
return;
}
if(1 == maskType){ //day mode
m_wgtBack->hide();
if(1 == m_uiType){
m_widget_ad->show();
}
setCardReaderUnderScreenInstructions(false);
}
else if(3 == maskType){ //night mode
QPalette pal(m_wgtBack->palette());
if(0 == m_uiType){
pal.setBrush(QPalette::Background,QBrush(QPixmap(recoUiRecognize::DARK_FILL_LIGHT_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
}
else if(1 == m_uiType){
pal.setColor(QPalette::Background, QColor(Qt::white));
m_widget_ad->hide();
}
setCardReaderUnderScreenInstructions(true);
m_wgtBack->setPalette(pal);
m_wgtBack->show();
}
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
}
void recoUiRecognizeTypeBase::slotNotiMsg(const int nPage, const QString& msg, int color)
{
Q_UNUSED(nPage);
m_widget_msg->setMsgNoti(msg, color);
}
void recoUiRecognizeTypeBase::slotCenterMsg(const int nPage, const QString& msg)
{
m_widget_cMsg->showMsg(msg, nPage);
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
}
void recoUiRecognizeTypeBase::slotPwdBtnClicked()
{
emit signalShowPwdPage("");
}
void recoUiRecognizeTypeBase::slotSetUserPwdButton(bool visible)
{
if(visible){
m_wgtBtnPwd->show();
}else{
m_wgtBtnPwd->hide();
}
}
void recoUiRecognizeTypeBase::slotShowFinalResult(bool pass)
{
m_widget_result->showResult(static_cast<int>(pass));
m_widget_reco->switchBg(pass ? 1 : 2);
m_widget_reco->show();
setMsgWidgetBg(1);
QCoreApplication::processEvents();
}
void recoUiRecognizeTypeBase::slotShowCallBtn(bool show)
{
//m_wgtCallDial->setVisible(show);
m_wgtCallDialDev->setVisible(show);
m_wgtCallMngCenter->setVisible(show);
}
void recoUiRecognizeTypeBase::slotShowRecoUiDevIdAndVer(bool show)
{
m_widget_msg->showRecoUiDevIdAndVer(show);
}
QString recoUiRecognizeTypeBase::recoUiTextCfg(RecoUiTextCfg::enTextType type)
{
const QString texts[] = {tr("请刷脸通行"), m_name, tr("未经许可人员"), tr("禁止通行"), tr("未佩戴口罩"),
tr("口罩检测通过"), tr("体温:"), tr("请刷卡"), tr("请用本人证件"), tr("请正视镜头"),
tr("禁止通行时段")};
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];
}
void recoUiRecognizeTypeBase::uiReset()
{
m_widget_reco->reset();
m_widget_result->hide();
setMsgWidgetBg(0);
//m_widget_msg->setMsgBtm("");
}
void recoUiRecognizeTypeBase::setMsgWidgetBg(int bgType)
{
QPalette pal(m_widget_msg->palette());
if(0 == bgType){
pal.setBrush(QPalette::Background, QBrush(QPixmap(TOP_MSG_WIDGET_BG[UiConfig::GetInstance()->getScreenConfigIndex()])));
}
else if(1 == bgType){
pal.setColor(QPalette::Background, QColor(0, 0, 0, 0));
}
m_widget_msg->setPalette(pal);
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
}
void recoUiRecognizeTypeBase::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);
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
}
recoUiRecognizeTypeColor::recoUiRecognizeTypeColor(bool isNightMode, bool hasPwdBtn, bool hasCallBtn, QWidget *parent)
: recoUiRecognizeTypeBase(isNightMode, hasPwdBtn, hasCallBtn, 0, parent)
{
}
int recoUiRecognizeTypeColor::setCamVideoWind()
{
return m_backstageIf->recoUiTypeSwitch(0, 0, UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
}
void recoUiRecognizeTypeColor::slotShowRecoUiColorFaceSnapshot(const QString& path)
{
m_widget_reco->showFacePic(path);
}
void recoUiRecognizeTypeColor::slotShowRecoUiColorFaceSnapshot(const unsigned char* jpgDate, int len)
{
m_widget_reco->showFacePic(jpgDate, len);
}
void recoUiRecognizeTypeColor::setBackstageUiinterface(BackstageInterfaceForUi *interface)
{
m_backstageIf = interface;
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());
}
const int recoUiRecognizeTypeAd::CAM_WIN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][4] = {
{94, 1052, 134, 216},
{94, 1042, 140, 224},
{94, 1052, 134, 216},
{94, 1042, 140, 224},
{94, 1052, 134, 216}
};
recoUiRecognizeTypeAd::recoUiRecognizeTypeAd(bool isNightMode, bool hasPwdBtn, bool hasCallBtn, QWidget *parent) :
recoUiRecognizeTypeBase(isNightMode, hasPwdBtn, hasCallBtn, 1, parent)
{
connect(this, SIGNAL(signalUpdateScreenSaver()), m_widget_ad, SLOT(slotUpdateScreenSaver()));
connect(m_widget_ad, SIGNAL(signalCurrentChange(int)), this, SLOT(slotCurrentChange(int)));
}
int recoUiRecognizeTypeAd::setCamVideoWind()
{
return m_backstageIf->recoUiTypeSwitch(CAM_WIN[UiConfig::GetInstance()->getScreenConfigIndex()][0],
CAM_WIN[UiConfig::GetInstance()->getScreenConfigIndex()][1],
CAM_WIN[UiConfig::GetInstance()->getScreenConfigIndex()][2],
CAM_WIN[UiConfig::GetInstance()->getScreenConfigIndex()][3]);
}
void recoUiRecognizeTypeAd::slotCurrentChange(int index)
{
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
}
void recoUiRecognizeTypeAd::setBackstageUiinterface(BackstageInterfaceForUi *interface)
{
m_backstageIf = interface;
m_widget_ad->setBackstageUiinterface(interface);
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());
}
void recoUiRecognizeTypeAd::updateAdWidget()
{
//m_widget_ad->slotUpdateScreenSaver();
emit signalUpdateScreenSaver();
}
void recoUiRecognizeTypeAd::setDndMode(bool dndMode, const std::chrono::system_clock::time_point &endTime) {
if (m_wgtCardUnderScreen != nullptr) {
m_wgtCardUnderScreen->setVisible(!dndMode);
}
if (m_widget_reco != nullptr) {
m_widget_reco->setDndMode(dndMode, endTime);
}
}