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

812 lines
28 KiB
C++

#include "recoUiRecognizeScene.h"
#include <QTouchEvent>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
const int recoUiRecognizeScene::TOP_MSG_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {89, 89, 89, 90, 90};
const QString recoUiRecognizeScene::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 recoUiRecognizeScene::SWIP_CARD_WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {400, 746, 720, 746, 720};
const int recoUiRecognizeScene::SWIP_CARD_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {70, 104, 104, 105, 105};
const QString recoUiRecognizeScene::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 recoUiRecognizeScene::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"
};
const QString recoUiRecognizeScene::PAGE_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_ui_scene_bg_medium.jpg",
":/res/image/reco_ui_scene_bg_medium.jpg",
":/res/image/reco_ui_scene_bg_medium.jpg",
":/res/image/reco_ui_scene_bg_medium.jpg",
":/res/image/reco_ui_scene_bg_medium.jpg"
};
const QString recoUiRecognizeScene::PAGE_STATUS_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_ui_scene_result_bg_medium.jpg",
":/res/image/reco_ui_scene_result_bg_medium.jpg",
":/res/image/reco_ui_scene_result_bg_medium.jpg",
":/res/image/reco_ui_scene_result_bg_medium.jpg",
":/res/image/reco_ui_scene_result_bg_medium.jpg"
};
recoUiRecognizeScene::recoUiRecognizeScene(bool isNightMode, bool hasPwdBtn, QWidget *parent) : PageAcceptMouseAndTouch(parent)
{
qDebug() << "recoUiRecognizeScene";
setAutoFillBackground(true);
m_wgtBack = new QWidget(this);
m_wgtBack->setAutoFillBackground(true);
m_wgtBack->setFixedSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
#if 0
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()]);
}
#endif
//m_wgtSceneMsg = new SceneMsgWidget(this);
m_wgtDevMsg = new MsgWidget(0, 0, Qt::black, this);
m_wgtDevMsg->setFixedSize(UiConfig::GetInstance()->getUiWidth(), recoUiRecognize::MSG_WIDGET_HEIGHT[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_wgtDevMsg->setBackgroundColor(WIDGET_BG_COLOR_BLUE);
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);
QHBoxLayout* hlayBtn = new QHBoxLayout();
hlayBtn->addWidget(m_wgtBtnPwd, 1, Qt::AlignTop | Qt::AlignRight);
hlayBtn->setMargin(UiConfig::GetInstance()->getUiWidth() / 15);
#if 0
m_wgtStatusTip = new QLabel(this);
QFont ft;
ft.setBold(true);
ft.setPointSize(16);
m_wgtStatusTip->setFont(ft);
#else
m_widget_person = new PersonWidget(this);
m_widget_person->setPersonMsg(RecoUiTextCfg::TextFacePass, recoUiTextCfg(RecoUiTextCfg::TextFacePass), PersonWidget::BG_COLOR_BLUE, false);
#endif
m_widget_cMsg = new CenterMsgWidget();
m_widget_cMsg->hide();
QVBoxLayout* vlay = new QVBoxLayout();
vlay->setMargin(0);
vlay->setSpacing(0);
//vlay->addWidget(m_wgtSceneMsg, 1, Qt::AlignTop);
vlay->addLayout(hlayBtn, 1);
vlay->addSpacing(UiConfig::GetInstance()->getUiHeight() / 4);
//vlay->addWidget(m_wgtStatusTip, 1, Qt::AlignBottom | Qt::AlignCenter);
vlay->addStretch(10);
vlay->addWidget(m_widget_person, 50, Qt::AlignBottom | Qt::AlignCenter);
vlay->addSpacing(UiConfig::GetInstance()->getUiHeight() / 15);
if(m_wgtCardUnderScreen){
vlay->addWidget(m_wgtCardUnderScreen, 1, Qt::AlignBottom | Qt::AlignCenter);
}
vlay->addWidget(m_wgtDevMsg, 1, Qt::AlignBottom);
setLayout(vlay);
//slotShowRecoUiMask(isNightMode ? 3 : 1);
//m_pageIdle = QBrush(QPixmap(PAGE_BG[UiConfig::GetInstance()->getScreenConfigIndex()]));
//m_pageIdle = QBrush(QColor(0, 0, 0, 0));
//m_pageStatusTip = QBrush(QPixmap(PAGE_STATUS_BG[UiConfig::GetInstance()->getScreenConfigIndex()]));
m_pageReco = QBrush(QPixmap(recoUiRecognize::BG_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()]));
}
recoUiRecognizeScene::~recoUiRecognizeScene()
{
if(m_widget_cMsg){
delete m_widget_cMsg;
}
}
bool recoUiRecognizeScene::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 recoUiRecognizeScene::event(QEvent *event)
{
switch( event->type() ){
case QEvent::TouchBegin:
do{
if(UiConfig::GetInstance()->getHardwareTesting()){
break;
}
if(!m_wgtBtnPwd->isHidden()){
QTouchEvent* touch = static_cast<QTouchEvent*>(event);
QList<QTouchEvent::TouchPoint> touch_list = touch->touchPoints();
QRect widgetRect = m_wgtBtnPwd->geometry();
QPoint mousePos = mapFromGlobal(QPoint(touch_list.at(0).pos().x(),touch_list.at(0).pos().y()));
if (widgetRect.contains(mousePos)){
slotPwdBtnClicked();
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 recoUiRecognizeScene::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 recoUiRecognizeScene::slotLongPressShowSetting()
{
if(isTouched && _preTime.msecsTo(QTime::currentTime()) > (UiConfig::TOUCH_TIME_TO_SETTING - 200)){
emit signalChangePage();
}
}
bool recoUiRecognizeScene::longPressToSettingPage()
{
if(m_backstageIf)
m_backstageIf->wakeUpFromScreenSaverOrScreenOff();
QTimer::singleShot(UiConfig::TOUCH_TIME_TO_SETTING, this, SLOT(slotLongPressShowSetting()));
return true;
}
void recoUiRecognizeScene::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_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, recoUiTextCfg(RecoUiTextCfg::TextAuthFailed));
break;
case GLOBAL_RECO_FACE_CARD_NOT_MATCH:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, recoUiTextCfg(RecoUiTextCfg::TextUseOwnCertifi));
break;
case GLOBAL_RECO_SWIPE_CARD:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, recoUiTextCfg(RecoUiTextCfg::TextTapCard));
showStatusTip(recoUiTextCfg(RecoUiTextCfg::TextTapCard));
break;
case GLOBAL_RECO_FACE_CAMERA:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, recoUiTextCfg(RecoUiTextCfg::TextFaceCam));
//slotShowRecoUiMask(99);
showStatusTip(recoUiTextCfg(RecoUiTextCfg::TextFaceCam));
break;
case GLOBAL_RECO_NOT_PASS_TIME:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, recoUiTextCfg(RecoUiTextCfg::TextNoEntryTime));
break;
case GLOBAL_RECO_NEED_RECHECK:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("身份核验中"));
showStatusTip(tr("身份核验中"));
break;
case GLOBAL_RECO_PLATFORM_DISCONNECTED:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("服务器连接失败"));
break;
case GLOBAL_RECO_SWIPE_CARD_HERE:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请在此处刷卡"));
break;
case GLOBAL_RECO_HIDE_NAME_AREA:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, "");
break;
case GLOBAL_RECO_NOT_LIVING:
showStatusTip(tr("请调整人脸角度"));
break;
case GLOBAL_RECO_SHOW_QRCODE:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请刷二维码"));
showStatusTip(tr("请刷二维码"));
break;
case GLOBAL_RECO_UNAUTH_CARD:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("未授权卡片"));
break;
case GLOBAL_RECO_PLS_TAP_ID_CARD:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请刷身份证"));
showStatusTip(tr("请刷身份证"));
break;
case GLOBAL_RECO_PLS_CHECK_STATIC:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请测试静电"));
showStatusTip(tr("请测试静电"));
break;
case GLOBAL_RECO_STATIC_ABNORMAL:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("静电测试异常"));
break;
case GLOBAL_RECO_SWIPE_ID_OR_HEALEH_CODE:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请刷身份证或扫码"));
showStatusTip(tr("请刷身份证或扫码"));
break;
case GLOBAL_RECO_CHECKING:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("健康码查询中"));
break;
case GLOBAL_RECO_CHECK_FAILED:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("查询失败"));
break;
case GLOBAL_RECO_QRCODE_OVERDUE:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("二维码已过期"));
break;
case GLOBAL_RECO_NETWORK_ERROR:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("网络异常"));
break;
case GLOBAL_RECO_PLATFORM_ERROR:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("服务器异常"));
break;
case GLOBAL_RECO_REQUEST_OVERTIME:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("服务器请求超时"));
break;
case GLOBAL_RECO_SWIPE_TRIP_CARD:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请刷行程卡"));
break;
case GLOBAL_RECO_SHOW_HEALTH_CODE:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请扫健康码"));
break;
case GLOBAL_RECO_RESWIPE_TRIP_CARD:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请重刷行程卡"));
break;
case GLOBAL_RECO_SWIPE_ID_AND_TRIP_CARD:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("刷身份证扫行程卡"));
break;
case GLOBAL_RECO_TRIP_CARD_CHECKING:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("行程卡查询中"));
break;
case GLOBAL_RECO_SCAN_YUEJUMA:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请扫粤居码"));
showStatusTip(tr("请扫粤居码"));
break;
case GLOBAL_RECO_SCAN_YUEJUMA_OR_SWIPE_ID:
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, tr("请刷粤居码/身份证"));
showStatusTip(tr("请刷粤居码/身份证"));
break;
default:
break;
}
}
else if(GLOBAL_RECO_ID_FAILED == nPage) {
//m_wgtIdentity->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_wgtIdentity->showMaskResult(false, recoUiTextCfg(RecoUiTextCfg::TextNOMask));
}
else if(GLOBAL_RECO_MASK_OK == nPage){
//m_wgtIdentity->showMaskResult(true, recoUiTextCfg(RecoUiTextCfg::TextMaskOk));
}
else if(GLOBAL_RECO_TAKE_OFF_MASK == nPage){
//m_wgtIdentity->showMaskResult(false, tr("请摘下口罩"));
}
else if(GLOBAL_RECO_NO_ENTRY == nPage){
//m_wgtDevMsg->setMsgBtm(recoUiTextCfg(RecoUiTextCfg::TextNoEntry), true);
}
else if(GLOBAL_RECO_CLEAR_NO_ENTRY == nPage){
//m_wgtDevMsg->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 0
if (GLOBAL_RECO_NOT_LIVING == nPage ||
GLOBAL_RECO_SWIPE_CARD == nPage ||
GLOBAL_RECO_FACE_CAMERA == nPage) {
m_widget_result->showResult(2);
setMsgWidgetBg(1);
m_wgtIdentity->switchBg(3);
}
#endif
}
void recoUiRecognizeScene::slotsSuccessPage(const int nPage, const QString& name)
{
if( GLOBAL_RECO_END_OK != nPage){
return ;
}
m_name = name;
//m_wgtIdentity->showIdentityResult((GLOBAL_RECO_STATE)nPage, recoUiTextCfg(RecoUiTextCfg::TextAllowPass));
}
void recoUiRecognizeScene::slotsDrawScanner(const int nPage, const bool faceAvailable)
{
if(!faceAvailable){
uiReset();
}
}
void recoUiRecognizeScene::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_wgtDevMsg->setLogo(logo);
}
else if(1 == nSelectRes){
logo = "";
m_wgtDevMsg->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_wgtDevMsg->setLogo(logo, true);
}
}
}
}
}
void recoUiRecognizeScene::slotShowNormalTemp(const float temp, const bool isC)
{
//m_wgtIdentity->showTempResult(recoUiTextCfg(RecoUiTextCfg::TextTemp), temp, true, isC);
}
void recoUiRecognizeScene::slotShowAbnormalTemp(const float temp, const bool isHigh, const bool isC)
{
Q_UNUSED(isHigh);
//m_wgtIdentity->showTempResult(recoUiTextCfg(RecoUiTextCfg::TextTemp), temp, false, isC);
}
void recoUiRecognizeScene::slotUpdateLogo(const int option)
{
slotsInteractionChange(OPTION_LOGO, option);
}
void recoUiRecognizeScene::slotUpdatePlatformConnectionStatus(const int status)
{
m_wgtDevMsg->setNetworkStatus(status);
}
void recoUiRecognizeScene::slotsResetRecoUi()
{
slotsDrawScanner(0, false);
}
void recoUiRecognizeScene::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_wgtDevMsg->updateIp(ip, type);
}
}
}
else {
m_wgtDevMsg->updateIp("");
}
}
void recoUiRecognizeScene::slotShowRecoUiMask(int maskType)
{
qDebug() << "slotShowRecoUiMask:" << maskType;
if(1 == maskType){ //day mode
#if 0
setBg(m_pageIdle);
m_wgtStatusTip->hide();
#else
m_wgtBack->hide();
recoUiTextCfg(RecoUiTextCfg::TextFacePass);
#endif
//setCardReaderUnderScreenInstructions(false);
}else if(3 == maskType){ //night mode
//pal.setColor(QPalette::Background, QColor(Qt::white));
//setCardReaderUnderScreenInstructions(true);
}else if(99 == maskType){
if(1){//cam video with face frame m_backstageIf->getFaceFrameShowSw()
setBg(m_pageReco);
}else{//cam video without face frame
m_wgtBack->hide();
}
}
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
}
void recoUiRecognizeScene::slotNotiMsg(const int nPage, const QString& msg, int color)
{
Q_UNUSED(nPage);
m_wgtDevMsg->setMsgNoti(msg, color);
}
void recoUiRecognizeScene::slotCenterMsg(const int nPage, const QString& msg)
{
m_widget_cMsg->showMsg(msg, nPage);
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
}
void recoUiRecognizeScene::slotPwdBtnClicked()
{
emit signalShowPwdPage("");
}
void recoUiRecognizeScene::slotSetUserPwdButton(bool visible)
{
if(visible){
m_wgtBtnPwd->show();
}else{
m_wgtBtnPwd->hide();
}
}
void recoUiRecognizeScene::slotShowFinalResult(bool pass)
{
#if 0
m_widget_result->showResult(static_cast<int>(pass));
m_wgtIdentity->switchBg(pass ? 1 : 2);
m_wgtIdentity->show();
setMsgWidgetBg(1);
QCoreApplication::processEvents();
#endif
}
QString recoUiRecognizeScene::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 recoUiRecognizeScene::uiReset()
{
slotShowRecoUiMask(1);
#if 0
m_wgtIdentity->reset();
m_widget_result->hide();
setMsgWidgetBg(0);
#endif
}
void recoUiRecognizeScene::setTicketCheckCount(int source, int count)
{
//m_wgtSceneMsg->setPersonNum(count);
}
void recoUiRecognizeScene::setMsgWidgetBg(int bgType)
{
QPalette pal(m_wgtDevMsg->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_wgtDevMsg->setPalette(pal);
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
}
void recoUiRecognizeScene::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();
}
}
void recoUiRecognizeScene::setBg(const QBrush& brush)
{
QPalette pal(m_wgtBack->palette());
pal.setBrush(QPalette::Background, brush);
m_wgtBack->setPalette(pal);
m_wgtBack->show();
}
void recoUiRecognizeScene::showStatusTip(const QString& tip)
{
#if 0
setBg(m_pageStatusTip);
m_wgtStatusTip->setText(tip);
m_wgtStatusTip->show();
#else
m_widget_person->setPersonMsg(RecoUiTextCfg::TextOtherRecoResult, tip, PersonWidget::BG_COLOR_RED, true);
#endif
}
int recoUiRecognizeScene::setCamVideoWind()
{
return m_backstageIf->recoUiTypeSwitch(0, 0, UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
}
void recoUiRecognizeScene::updateBg()
{
qDebug() << "updateBg";
return;//TODO
#if 0
stScreensaverCfg cfg;
if(0 != m_backstageIf->getRecoUiAdConfig(cfg)){
qDebug() << "getRecoUiAdConfig failed!";
return;
}
m_pageIdle = cfg.picQty ? QBrush(QPixmap(cfg.pic[0])) : QBrush(QPixmap(PAGE_BG[UiConfig::GetInstance()->getScreenConfigIndex()]));
setBg(m_pageIdle);
#endif
}
void recoUiRecognizeScene::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_wgtDevMsg->showDevInfo(devId, ver);
setTicketCheckCount(-1, m_backstageIf->getTicketCheckCountToday());
}
const QString recoUiSceneResult::PAGE_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_ui_scene_result_bg_medium.jpg",
":/res/image/reco_ui_scene_result_bg_medium.jpg",
":/res/image/reco_ui_scene_result_bg_medium.jpg",
":/res/image/reco_ui_scene_result_bg_medium.jpg",
":/res/image/reco_ui_scene_result_bg_medium.jpg"
};
recoUiSceneResult::recoUiSceneResult(QWidget *parent) : QWidget(parent)
{
setAutoFillBackground(true);
QPalette palette(this->palette());
//palette.setBrush(QPalette::Background, QBrush(QPixmap(PAGE_BG[UiConfig::GetInstance()->getScreenConfigIndex()])));
palette.setColor(QPalette::WindowText,Qt::black);
setPalette(palette);
m_wgtSceneMsg = new SceneMsgWidget(this);
QFont ft;
ft.setBold(true);
ft.setPointSize(16);
m_labelResult = new QLabel(this);
m_labelResult->setAlignment(Qt::AlignCenter);
m_labelResult->setWordWrap(true);
m_labelResult->setFont(ft);
ft.setBold(false);
ft.setPointSize(12);
m_labelBussInfo = new QLabel(this);
m_labelBussInfo->setFont(ft);
m_labelBussInfo->setAlignment(Qt::AlignCenter);
m_labelBussInfo->setWordWrap(true);
m_labelBussInfo->setFixedWidth(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.8));
m_labelBussPersonNum = new QLabel(this);
m_labelBussPersonNum->setAlignment(Qt::AlignCenter);
m_labelBussPersonNum->setFont(ft);
#if 0
m_accMsg = new QWidget(this);
m_accMsg->setFixedSize(UiConfig::GetInstance()->getUiWidth(), static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.2));
m_accMsg->setAutoFillBackground(true);
m_labelAcc = new QLabel(m_accMsg);
m_labelAcc->setPixmap(QPixmap(":/res/image/icon_arrow_upward_medium.png"));
m_labelAccRes = new QLabel(m_accMsg);
m_labelAccRes->setAlignment(Qt::AlignCenter);
m_labelAccRes->setMinimumWidth(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.4));
m_labelAccRes->setWordWrap(true);
QPalette labelPal;
labelPal.setColor(QPalette::WindowText, Qt::white);
m_labelAccRes->setPalette(labelPal);
ft.setBold(true);
m_labelAccRes->setFont(ft);
QHBoxLayout* hlayAcc = new QHBoxLayout();
hlayAcc->addStretch(10);
hlayAcc->addWidget(m_labelAcc, 1, Qt::AlignCenter);
hlayAcc->addWidget(m_labelAccRes, 1, Qt::AlignCenter);
hlayAcc->addStretch(10);
hlayAcc->setSpacing(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.05));
m_accMsg->setLayout(hlayAcc);
#endif
QVBoxLayout* vlay = new QVBoxLayout();
vlay->setMargin(0);
vlay->addWidget(m_wgtSceneMsg, 1, Qt::AlignTop);
vlay->addSpacing(static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.3));
vlay->addWidget(m_labelResult, 1, Qt::AlignCenter);
vlay->addWidget(m_labelBussInfo, 1, Qt::AlignCenter);
vlay->addWidget(m_labelBussPersonNum, 1, Qt::AlignCenter);
vlay->addStretch(10);
//vlay->addSpacing(UiConfig::GetInstance()->getUiHeight() / 3);
//vlay->addWidget(m_accMsg, Qt::AlignCenter);
setLayout(vlay);
m_bgWhiteList = QBrush(QPixmap(":/res/image/reco_ui_scene_bg_white_list_medium.jpg"));
m_bgSceneOk = QBrush(QPixmap(":/res/image/reco_ui_scene_bg_ok_medium.jpg"));
m_bgSceneFailed = QBrush(QPixmap(":/res/image/reco_ui_scene_bg_failed_medium.jpg"));
}
void recoUiSceneResult::showResult(bool pass, const QString& result, const QString& businessInfo)
{
m_labelResult->setText("");
m_labelBussInfo->setText("");
m_labelBussPersonNum->setText("");
QPalette palette(this->palette());
if(!businessInfo.isEmpty()){
QJsonParseError jsonError;
const QJsonDocument doc = QJsonDocument::fromJson(businessInfo.toUtf8(), &jsonError);
if (doc.isNull() || (jsonError.error != QJsonParseError::NoError)) {return;}
const QJsonObject obj = doc.object();
QString visitorInfo;
const QString personInfo{obj.value("personInfo").toString()};
if(!personInfo.isEmpty()){visitorInfo += personInfo;visitorInfo += "\n";}
const QString ticket{obj.value("ticket").toString()};
if(!ticket.isEmpty()){visitorInfo += ticket;}
m_labelBussInfo->setText(visitorInfo);
if(obj.contains("personNum") && obj.value("personNum").toInt() > 1){
//m_personAccessed = 0;
//m_personAll = obj.value("personNum").toInt();
m_labelBussPersonNum->setText(QString("0/%1").arg(obj.value("personNum").toInt()));
}
palette.setBrush(QPalette::Background, pass ? m_bgSceneOk : m_bgSceneFailed);
}else if(!result.isEmpty()){
m_labelResult->setText(result);
//m_personAccessed = 0;
//m_personAll = 1;
palette.setBrush(QPalette::Background, m_bgWhiteList);
}else{
//m_labelResult->setText("无效票\nIneffectiveness");
palette.setBrush(QPalette::Background, m_bgSceneFailed);
}
setPalette(palette);
#if 0
static const QPixmap ok(":/res/image/icon_arrow_upward_medium.png");
static const QPixmap failed(":/res/image/forward slash_medium.png");
m_labelAcc->setPixmap(pass ? ok : failed);
m_labelAccRes->setText(pass ? tr("请通行\nPass through") : tr("禁止通行\nNo Passing"));
QPalette pal(m_accMsg->palette());
pal.setBrush(QPalette::Background, pass ? QColor(31, 164, 38) : QColor(250, 59, 59));
m_accMsg->setPalette(pal);
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
#endif
}
bool recoUiSceneResult::updatePersonNumAccessed(int personAccess, int personAll)
{
m_personAccessed = personAccess;
m_personAll = personAll;
if(personAll > 1){
m_labelBussPersonNum->setText(QString("%1/%2").arg(m_personAccessed).arg(m_personAll));
}
return m_personAccessed >= m_personAll;
}
void recoUiSceneResult::setTicketCheckCount(int source, int count)
{
m_wgtSceneMsg->setPersonNum(source, count);
}
bool recoUiSceneResult::isPassing() const
{
return m_personAccessed < m_personAll;
}
void recoUiSceneResult::resetPersonCount()
{
m_personAccessed = 0;
m_personAll = 0;
}
void recoUiSceneResult::setPersonCountType(int type)
{
m_wgtSceneMsg->setType(type);
}