add linguist for facetick.

This commit is contained in:
luocai 2024-07-11 11:27:12 +08:00
parent fe9e585973
commit 2c52d2a68f
82 changed files with 71594 additions and 0 deletions

3071
Linguist/FaceTick_DE.ts Normal file

File diff suppressed because it is too large Load Diff

3134
Linguist/FaceTick_EN.ts Normal file

File diff suppressed because it is too large Load Diff

3071
Linguist/FaceTick_FR.ts Normal file

File diff suppressed because it is too large Load Diff

3071
Linguist/FaceTick_HU.ts Normal file

File diff suppressed because it is too large Load Diff

3071
Linguist/FaceTick_IT.ts Normal file

File diff suppressed because it is too large Load Diff

3071
Linguist/FaceTick_IW.ts Normal file

File diff suppressed because it is too large Load Diff

3071
Linguist/FaceTick_JP.ts Normal file

File diff suppressed because it is too large Load Diff

3071
Linguist/FaceTick_KR.ts Normal file

File diff suppressed because it is too large Load Diff

3071
Linguist/FaceTick_PT.ts Normal file

File diff suppressed because it is too large Load Diff

3071
Linguist/FaceTick_SP.ts Normal file

File diff suppressed because it is too large Load Diff

3072
Linguist/FaceTick_TC.ts Normal file

File diff suppressed because it is too large Load Diff

3071
Linguist/FaceTick_TH.ts Normal file

File diff suppressed because it is too large Load Diff

3071
Linguist/FaceTick_TR.ts Normal file

File diff suppressed because it is too large Load Diff

123
Linguist/facetick.pro Normal file
View File

@ -0,0 +1,123 @@
#-------------------------------------------------
#
# Project created by QtCreator 2020-09-14T10:46:41
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = facetick
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES += \
keyboard/keyboard.cpp \
keyboard/LineEditWithKeyboard.cpp \
keyboard/LineEditWithPopup.cpp \
interface/View.cpp \
interface/BackstageInterfaceForUi.cpp \
interface/BackStage.cpp \
recoUi/recoUiRecognize.cpp \
recoUi/recoUiCallConsole.cpp \
recoUi/recoUiRecognizeScene.cpp \
recoUi/recoUiUnauthorized.cpp \
recoUi/recoUiCallDial.cpp \
recoUi/recoUiRecognizeTypeBase.cpp \
recoUi/recoUiPassword.cpp \
recoUi/recoUiHealthCode.cpp \
recoUi/recoUi.cpp \
recoUi/recoUiScreensaver.cpp \
setupUi/SetupUi.cpp \
setUi/settingUiFastCfg.cpp \
setUi/settingUiSysMng.cpp \
setUi/settingUiInfo.cpp \
setUi/settingUiAccMng.cpp \
setUi/settingUIProjectSet.cpp \
setUi/settingUiFaceMng.cpp \
setUi/settingUi.cpp \
setUi/settingUiDevMng.cpp \
setUi/settingUiRecoSet.cpp \
setUi/settingUiDevTest.cpp \
utility/DndModeCountDownItem.cpp \
utility/SwitchControl.cpp \
utility/UiTools.cpp \
mainUi/UiConfig.cpp \
mainUi/mainUi.cpp
HEADERS += \
keyboard/LineEditWithKeyboard.h \
keyboard/keyboard.h \
keyboard/LineEditWithPopup.h \
interface/BackStage.h \
interface/View.h \
interface/BackstageInterfaceForUi.h \
interface/UiInterfaceForBackstage.h \
recoUi/recoUiHealthCode.h \
recoUi/recoUiCallDial.h \
recoUi/recoUiCallConsole.h \
recoUi/recoUiPassword.h \
recoUi/recoUiRecognizeScene.h \
recoUi/recoUiRecognize.h \
recoUi/recoUiScreensaver.h \
recoUi/recoUiUnauthorized.h \
recoUi/recoUiRecognizeTypeBase.h \
recoUi/recoUi.h \
setupUi/SetupUi.h \
setUi/settingUiDevTest.h \
setUi/settingUiAccMng.h \
setUi/settingUIProjectSet.h \
setUi/settingUiFastCfg.h \
setUi/settingUi.h \
setUi/settingUiRecoSet.h \
setUi/settingUiDevMng.h \
setUi/settingUiSysMng.h \
setUi/settingUiInfo.h \
setUi/settingUiFaceMng.h \
utility/AsyncEvent.h \
utility/SwitchControl.h \
utility/DndModeCountDownItem.h \
utility/UiTools.h \
mainUi/debug.h \
mainUi/UiConfig.h \
mainUi/UiCommon.h \
mainUi/mainUi.h
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
res.qrc
CONFIG += C++11
#CONFIG += console pro
TRANSLATIONS += FaceTick_TC.ts
TRANSLATIONS += FaceTick_EN.ts
TRANSLATIONS += FaceTick_JP.ts
TRANSLATIONS += FaceTick_KR.ts
TRANSLATIONS += FaceTick_SP.ts
TRANSLATIONS += FaceTick_TH.ts
TRANSLATIONS += FaceTick_PT.ts
TRANSLATIONS += FaceTick_IT.ts
TRANSLATIONS += FaceTick_FR.ts
TRANSLATIONS += FaceTick_IW.ts
TRANSLATIONS += FaceTick_DE.ts
TRANSLATIONS += FaceTick_TR.ts
TRANSLATIONS += FaceTick_HU.ts

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,344 @@
#ifndef BACKSTAGEI_H
#define BACKSTAGEI_H
#include "BackstageInterfaceForUi.h"
#include "param_manage.h"
#include "golib/golib.h"
class Backstage : public BackstageInterfaceForUi
{
public:
Backstage(void* pParaMng, void* pObjs);
virtual ~Backstage();
int registerPerson(char *name, char *term, int nDataOrigin = 1);
int startIdentyState(bool setfaceReco = true, bool setPeInput = true);
int stopIdentyState(bool setfaceReco = true, bool setPeInput = true);
//工程设置
int verifyFactorySettingPwd(const char *pwd);//验证密码
int recoveryFactorySetting();//恢复出厂设置
//设备设置
int getDeviceId(char *devId, int len);//获取设备id
int getHardwareConfig(char *hardVer, int len);
int getStorSpace(int &total, float &free);//获取存储空间
int getAppVersion(char *appVer, int len);//获取应用版本号
int getRegisterNum();//获取注册人员数
int getAccessRecordNotUpload();//获取未上传通行记录
int getAccessRecordQty();//获取通行记录条数
int getVolume();//获取音量大小
int setVolume(int vol);//设置音量大小
int getLcdBrightness();//获取屏幕亮度
int setLcdBrightness(int brightness);//设置屏幕亮度
bool getFillLightSw();//获取智能补光开关
int setFillLightSw(bool isOpen);//获取智能补光开关
int getStandbyTime();//获取待机时间
int setStandbyTime(int time);//设置待机时间
int getCloseScreenTime();//获取关屏等待时间
int setCloseScreenTime(int time);//获取关屏等待时间
int getLanguage();//获取语言
int setLanguage(int lang);//设置语言
//网络设置
int getIP(char *ip, int len, int& type);//获取IP
int setIP(char *ip);//设置IP
enIpMethod getIpMethod();//获取IP方法
int setIpMethod(enIpMethod ipMethod);//设置IP方法
int getSubnetMask(char *mask, int len);//获取子网掩码
int setSubnetMask(char *mask);//设置子网掩码
int getGateway(char *gateway, int len);//获取默认网关
int setGateway(char *gateway);//设置默认网关
int getDNS(char *dns, int len);//获取DNS
int setDNS(char *dns);//设置DNS
int getEthMac(char *mac, int len);//获取mac
int getWifiMac(char *mac, int len);//获取wifi mac
int getServerAddr(char *addr, int len);//获取服务器ip
int setServerAddr(char *addr, bool byQrcode = false);//设置服务器ip
int testServerIP(char *addr, float &time);//测试服务器ip,成功返回0失败-1
int getIotServerIP(char *ip, int len);//获取服务器ip
int setIotServerIP(char *ip);//设置服务器ip
int getIotPort();//获取端口号, 成功返回端口号,失败返回-1
int setIotPort(int port);//设置端口号
bool getIpShowSw();
int setIpShowSw(bool sw);
//蓝牙设置
//if success, return 0, else return err num;
int getBtSwitch(bool &isOpen);
int getBtName(string &devName);
int getBtPairedDev(list<BluetoothDev_t> &devList);
int getBtAvailDev(list<BluetoothDev_t> &devList);
int getBtAllInfo(BluetoothStat_t &bluetoothStat);
int btScan(list<BluetoothDev_t> &devList);//这个接口不需要吧?现在是定时的去搜索?所以点击“可用设备"条目时直接调用getBtAvailDev就可以了
int btSetSwitch(bool isOpen);
int btSetName(const string &devName);
int btPaire(const string &devId);
int btDisPaire(const string &devId);
int btConnect(const string &devId);
int btDisConnect(const string &devId);
int btRenameDev(const string &devId, const string &devName);
bool getParamBluetoothEnable();//获取蓝牙的开关
int setParamBluetoothEnable(bool sw);//设置蓝牙的开关
std::string getParamBluetoothName();//获取蓝牙设备名称
int setParamBluetoothName(std::string name);//设置蓝牙设备名称
//门禁设置
int getUnlockTime();//获取开锁时间
int setUnlockTime(int time);//设置开锁时间
int getUnlockDelay();//获取开锁延时
int setUnlockDelay(int time);//设置开锁延时
enUnlockSignal getUnlockSig();//获取开锁信号
int setUnlockSig(enUnlockSignal value);//设置开锁信号
enAssist getAssistIn();//获取辅助输入
int setAssistIn(enAssist assist);//设置辅助输入
enAssist getAssistOut();//获取辅助输出
int setAssistOut(enAssist assist);//设置辅助输出
enWiegand getWiegandIn();//获取韦根输入
int setWiegandIn(enWiegand wiegand);//设置韦根输入
enWiegand getWiegandOut();//获取韦根输出
int setWiegandOut(enWiegand wiegand);//设置韦根输出
enBaudRate getBaudRate();//获取波特率
int setBaudRate(enBaudRate baudRate);//设置波特率
int getWarningSig();//获取报警信号
int setWarningSig(int signal);//设置报警信号
//交互提示
enLogo getLogo();//获取logo
int setLogo(enLogo logo);//设置logo
int getCustomLogo(char *logo, int len);
enLogo getLogoTime();//获取logo+time
int setLogoTime(enLogo logo);//设置logo+time
enLogo getBackground();//获取背景图
int setBackground(enLogo logo);//设置背景图
enRecogResult getSuccessResult(char *data, int len);//获取成功结果
int setSuccessResult(enRecogResult result, char *data);//设置成功结果
enRecogResult getFailResult(char *data, int len);//获取失败结果
int setFailResult(enRecogResult result, char *data);//设置失败结果
bool getPlayAudioSw();//获取语音播报开关
int setPlayAudioSw(bool isOpen);//设置语音播报开关
//人脸识别
bool getIdentificationSw();//获取身份核验开关
int setIdentificationSw(bool sw);//设置身份核验开关
enSimilarityTh getSimilarityTh();//获取相似度阈值
int setSimilarityTh(enSimilarityTh th);//设置相似度阈值
int setCustomSimilarity(int sim);//设置自定义识别相似度
int getCustomSimilarity();//获取自定义识别相似度
bool getLivingBodySw();//获取活体开关
int setLivingBodySw(bool isOpen);//设置活体开关
enLivingBodyTh getLivingBodyTh();//获取活体检测阈值
int setLivingBodyTh(enLivingBodyTh th);//设置活体检测阈值
bool getLivingBodyFailSw();//获取活体失败图片留存开关
int setLivingBodyFailSw(bool isOpen);//设置失败图片留存开关
int getVerifyInterval();//获取验证间隔时间
int setVerifyInterval(int time);//设置验证间隔时间
enRecogDistance getRecogDistance();//获取识别距离
int setRecogDistance(enRecogDistance distance);//设置识别距离
enRecogAngle getRecogAngle();//获取识别角度
int setRecogAngle(enRecogAngle angle);//设置识别角度
int getMaxTraceNum();//获取人脸最大跟踪数
int setMaxTraceNum(int num);//设置人脸最大跟踪数
enFaceQuality getFaceQuality();//获取人脸质量阈值
int setFaceQuality(enFaceQuality quality);//设置人脸质量阈值
virtual bool getDynamicFeatureSw();//获取动态底库的开关
virtual int setDynamicFeatureSw(bool sw);//设置动态底库的开关
//系统设置
bool getNtpServerSw();//获取NTP服务开关
int setNtpServerSw(bool isOpen);//设置NTP服务开关
int getNtpServerAddr(char *addr, int len);//获取NTP服务地址
int setNtpServerAddr(char *addr);//设置NTP服务地址
int testNtpServer(char *addr, float &time);//测试NTP服务, 成功返回0失败-1
int getNtpServerPort();//获取NTP端口成功返回端口号失败返回-1
int setNtpServerPort(int port);//设置NTP服务端口
int getNtpCheckInterval();
int setNtpCheckInterval(int interval);
int getNtpTimeZone(char *timeZone, int len);
int setNtpTimeZone(char *timeZone);
int setVerifyFactorySettingPwd(char *pwd);//设置工程密码
int testHardware();//硬件检测
int cleanData();//清除数据
int devReboot();//重启设备
int startCapture();//start capture on register
int deletePerson(long long personID);
int queryPersonList(long long* pPersonIDBuff, int nBuffCount, long long startID, int& nRealPerson);
unsigned queryPerson(const char* searchText);
unsigned queryPerson(const char* searchText, int pageIndex, stQueryPersonInfo personRet[], int personRetSize);
unsigned queryAccessRecord(const char* name, const char* time);
unsigned queryAccessRecord(const char* name, const char* time, int pageIndex, stQueryAccRedInfo recordRet[], int recordRetSize);
int clearPeople();
int getPersonListState(int &sum, unsigned long long &maxPersonID);
int wakeUpFromScreenSaverOrScreenOff();
virtual int delPerson(long long personId);
virtual int modifyPerson(stQueryPersonInfo &personInfo);
virtual int addPerson(stQueryPersonInfo &personInfo);
virtual int snapFace(std::string &feature, std::string &savePath);
bool getMaskCheckSwitch();
int setMaskCheckSwitch(const bool sw);
bool getNoMaskNoPassSwitch();
int setNoMaskNoPassSwitch(const bool sw);
bool getTemperatureCheckSwitch();
int setTemperatureCheckSwitch(const bool sw);
bool getNoTemperatureNoPassSwitch();
int setNoTemperatureNoPassSwitch(const bool sw);
float getLowTemperature();
int setLowTemperature(const float temp);
float getHighTemperature();
int setHighTemperature(const float temp);
bool getQRCodeSwitch();
int setQRCodeSwitch(const bool sw);
bool getDataEncryptSw();
int setDataEncryptSw(bool sw);
int setDateTime(const char *dateTime);
bool getAutoRebootSw();
int setAutoRebootSw(bool sw);
int getAutoRebootTime(char* time, int len);
int setAutoRebootTime(const char *time);
int getAutoRebootInterval();
int setAutoRebootInterval(int interval);
int ntpTimeCorrect();
int ntpTimeCorrectForDevTest(const std::string& ntpServerIp);
int getNetWireCfg(stNetWire& wireCfg);
int setNetWireCfg(const stNetWire& wireCfg);
int setNetWireEnable(bool enable);
int getNetWifiCfg(stNetWifi& wifiCfg);
int setNetWifiCfg(const stNetWifi& wifiCfg);
int setNetWifiEnable(bool enable);
int getSsidList(stAccPoint accPointList[], int accPointListSize);
int claerNetWifiCfg();
int getNet4GCfg(stNet4G& n4gCfg);
int setNet4GEnable(bool enable);
int reboot4G();
int getScreenSaverConfig(stScreensaverCfg& cfg);
int sendPassword(const char *password);
void resetDecisionCenterTimer();
int pauseDataFlow();
int resumeDataFlow();
int candidateChoosedInPopupWindow(int index);
bool isWiegandIoTestOk();
bool isRelayAndGpioTestOk();
bool isRs485TestOk();
bool isReaderUnderScreenTestOk();
bool isWifiTestOk();
bool isRtcTestOk();
bool isWireEthTestOk();
bool is4gTestOk();
bool isSerial1TestOk();
void screenTest();
void speakerTest();
void microphoneTest(bool record) final;
void audioSwitchTest() final;
void tpTest();
void irCamTest();
void irLedTest();
void ageingTest(unsigned hours);
int getMacFromMes(const char* mesAddrAndProdNo, const char* pcbSeq, std::string& mac);
bool isAgeing(std::string& hours);
int getKeyDataMac(std::string& mac);
int getRecoUiAdConfig(stScreensaverCfg& cfg);
int recoUiTypeSwitch(unsigned x, unsigned y, unsigned w, unsigned h);
int getDevPwd(int& type, std::string& pwd);
int setLocalDevPwd(const std::string& pwd);
int getKeyDataHardware(std::string& hardware);
int setKeyDataHardwareAndUpdataFunction(const std::string& hardware);
int setSetupAlreadyFlag();
int getParkInfo(std::string& info);
int setParkInfo(const std::string& info);
int getDevPosi(std::string& posi);
int setDevPosi(const std::string& posi);
int getRs485Cfg();
int setRs485Cfg(int cfg);
int getRs485Prot1Addr();
int setRs485Prot1Addr(int addr);
int getRs485Prot3Cfg(int& handCfg, int& feetCfg);
int setRs485Prot3Cfg(int handCfg, int feetCfg);
int getGPIOCfg();
int setGPIOCfg(int cfg);
int setReverseAccessSw(bool enabled) final;
bool getReverseAccessSw() const final;
int getIDFaceVerifySw();
int setIDFaceVerifySw(bool sw);
int getBtLockCfg(BtDoorLock& cfg);
int setBtLockCfg(const BtDoorLock& cfg);
int getBtLockRemainingBatPwr(const std::string& mac);
bool getHealthCodeSw();
int setHealthCodeSw(bool sw);
bool getHealthCodeNoFaceRequired();
int setHealthCodeNoFaceRequired(bool sw);
bool getHealthCodeAllowStranger();
int setHealthCodeAllowStranger(bool sw);
int getHealthCodePassCfg(int& codeColorCfg, int& c19tCfg, int& tripCfg, int& abtCfg);
int setHealthCodePassCfg(int codeColorCfg, int c19tCfg, int tripCfg, int abtCfg);
std::string utfRawStrToEncodeStr(const std::string &str);
std::string getUnderScreenNfcModuleId();
std::string getExtendNfcModuleId();
bool isIdModuleInfoUploaded();
bool isDevSettingDisable();
void setAntiDemolitionAvail(bool avail, bool upload);
bool getAntiDemolitionSw();
void setAntiDemolitionSw(bool sw);
int getAntiDemolitionOutput();
void setAntiDemolitionOutput(int output);
int getGpio4Cfg();
void setGpio4Cfg(int cfg);
int getGpio5Cfg();
void setGpio5Cfg(int cfg);
int getDoorCloseOvertime();
void setDoorCloseOvertime(int overtime);
bool getDisableDevSettingSw();
void setDisableDevSettingSw(bool sw);
int getTicketCheckCountToday();
int getTicketModePeopleCountType();
int getCallDevList();//获取通话设备列表
int queryCallDevList(const std::string& text, std::vector<stCallDev>& devList);//查询指定的通话设备
int callDev(const std::string& devTag, int devType);//发起通话请求
int callAbort();//放弃通话(拨通之前)
int callHangUp();//挂断
int callReject();//拒接
int callAccept();//接听
int callSetVideoStream(bool enable);//允许/禁用视频
int openCallRemoteDoor() final; // 被打入电话过程中,打开对面面板机控制的闸机
void verifyAbort();
bool getShowIdAndVerSw();
int setShowIdAndVerSw(bool sw);
int playAudio(enAudioIndex index);
int userItemChoose(int index);
private:
int udpSend(const string &sendData, string &recvData);
int resetNetworkCfg();
int udpLoopToSvr(const std::string &sendData);
private:
ParamManage *m_paramMng = nullptr;
GOBJ m_objs = nullptr;
};
#endif

View File

@ -0,0 +1,6 @@
#include "BackstageInterfaceForUi.h"

View File

@ -0,0 +1,574 @@
#ifndef BACKSTAGEINTERFACEFORUI
#define BACKSTAGEINTERFACEFORUI
#include <QWidget>
using namespace std;
typedef unsigned char UINT8;
typedef unsigned short int UINT16;
typedef unsigned int UINT32;
typedef unsigned long long int UINT64;
typedef enum
{
DHCP, //DHCP方式
STATIC //静态
}enIpMethod;
typedef enum _unlockSignal
{
DISABLE = 0, //禁用
UnlockSigRelay, //继电器
UnlockSigWiegand26, //韦根
UnlockSigWiegand34, //韦根
UnlockSigWiegand42, //韦根
UnlockSigRs485, //485
UnlockSigButt
}enUnlockSignal;
typedef enum _assist
{
FireFightingLinkage, //消防联动
NormallyOpenOutput, //常开输出
Nothing //无
}enAssist;
typedef enum _Wiegand
{
Wiegand26, //韦根26
Wiegand34, //韦根34
Wiegand37 //韦根37
}enWiegand;
typedef enum _Logo
{
LogoDefault, //默认
LogoNeutral, //中性
LogoServerSetting//平台配置
}enLogo;
typedef enum _recogResult
{
RecogResultDefault, //默认
RecogResultShowName, //显示人员姓名(识别成功时使用)
RecogResultNotRegister, //未注册(识别失败时使用)
RecogResultCustom, //自定义
RecogResultButt //出错时返回
}enRecogResult;
typedef enum _similarityTh
{
SimilarityThLoose, //宽松
SimilarityThGeneral, //一般
SimilarityThDefault, //默认
SimilarityThStrict, //严格
SimilarityThVeryStrict, //极严格
SimilarityThCustom //自定义
}enSimilarityTh;
typedef enum _livingBodyTh
{
LivingBodyLoose, //宽松
LivingBodyGeneral, //一般
LivingBodyStrict, //严格
}enLivingBodyTh;
typedef enum _recogDistance
{
RecogDistanceNear, //近
RecogDistanceMid, //适中
RecogDistanceFar, //远
RecogDistanceFarther //更远
}enRecogDistance;
typedef enum _recogAngle
{
RecogAngleLittle, //15°
RecogAngleMid, //30°
RecogAngleBig, //45°
}enRecogAngle;
typedef enum _faceQuality
{
FaceQualityBad, //较差
FaceQualityGood, //适中
FaceQualityBetter, //较好
}enFaceQuality;
typedef enum _baudRate
{
BaudRate9600,
BaudRate14400,
BaudRate19200,
BaudRate38400,
BaudRate57600,
BaudRate115200
}enBaudRate;
typedef struct
{
std::string imgPath;
std::string name;
std::string expTime;
std::string regTime;
long long personId;
std::string idNum;
std::string jobNum;
std::string phoneNum;
std::string icNum;
std::string feature;
int personType;
void clear()
{
personId = -1;
imgPath.clear();
name.clear();
expTime.clear();
regTime.clear();
idNum.clear();
jobNum.clear();
phoneNum.clear();
icNum.clear();
feature.clear();
personType = -1;
}
}stQueryPersonInfo;
typedef struct
{
char imgPath[128];
char name[64];
char accessTime[64];
bool allowPass;
}stQueryAccRedInfo;
typedef struct
{
int type; //0:static, 1:DHCP
char ip[16];
char mask[16];
char gw[16];
char dns[16];
bool enable;
}stNetworkPara;
typedef struct
{
stNetworkPara cfg;
}stNetWire;
typedef struct
{
stNetworkPara cfg;
char encType[16];
char ssid[64];
char pwd[64];
bool isConnected;
bool enableAp;
char apPwd[32];
bool isAPCfg = false;
}stNetWifi;
typedef struct
{
char ssid[32];
int sigLev;
bool isEncrypt;
bool isConnected;
}stAccPoint;
typedef struct
{
//char provider[32];
int provider;
bool enable;
bool available;
}stNet4G;
typedef struct
{
int type;
int interval;
int picQty;
char pic[10][128];
}stScreensaverCfg;
enum BlueToothDevStat_e
{
BlueToothDevStat_idle,
BlueToothDevStat_pairing,
BlueToothDevStat_paired,
BlueToothDevStat_connecting,
BlueToothDevStat_connected
//...
};
struct BluetoothDev_t
{
string id;//唯一的标识?
string name;
//other attribute
//e.g 当前dev的状态已连接/连接中/空闲...
BlueToothDevStat_e devStat;
BluetoothDev_t(){}
BluetoothDev_t(string _id, string _name, BlueToothDevStat_e _devStat):id(_id), name(_name), devStat(_devStat){}
void clear(){id.clear(); name.clear();devStat = BlueToothDevStat_idle;}
};
struct BluetoothStat_t
{
string devName;
bool isEnable;
list<BluetoothDev_t> pairedDev;
list<BluetoothDev_t> availableDev;
void clear(){devName.clear(); isEnable=false; pairedDev.clear(); availableDev.clear();}
};
struct BtDoorLock
{
bool isEnable = false;
int qty = 0;
std::vector<int> manufacturer;
std::vector<std::string> position;
std::vector<std::string> mac;
};
typedef struct{
std::string name;
std::string code;
std::string devTag;
int type;
int status;
}stCallDev;
typedef enum {
audioInputPwd = 0
}enAudioIndex;
class BackstageInterfaceForUi
{
public:
virtual ~BackstageInterfaceForUi(){}
virtual int registerPerson(char *name, char *term, int nDataOrigin = 1) = 0;//注册人员返回值成功0失败-1
virtual int startIdentyState(bool setfaceReco = true, bool setPeInput = true) = 0;//开始识别
virtual int stopIdentyState(bool setfaceReco = true, bool setPeInput = true) = 0;//停止识别
//工程设置
virtual int verifyFactorySettingPwd(const char *pwd) = 0;//验证密码返回值0、验证成功 -1失败
virtual int recoveryFactorySetting() = 0;//恢复出厂设置返回值0、成功 -1失败
//设备设置
virtual int getDeviceId(char *devId, int len) = 0;//获取设备id
virtual int getHardwareConfig(char *config, int len) = 0;//获取硬件配置
virtual int getStorSpace(int &total, float &free) = 0;//获取存储空间
virtual int getAppVersion(char *appVer, int len) = 0;//获取应用版本号
virtual int getRegisterNum() = 0;//获取注册人员数
virtual int getAccessRecordNotUpload() = 0;//获取未上传通行记录
virtual int getAccessRecordQty() = 0;//获取通行记录条数
virtual int getVolume() = 0;//获取音量大小
virtual int setVolume(int vol) = 0;//设置音量大小
virtual int getLcdBrightness() = 0;//获取屏幕亮度
virtual int setLcdBrightness(int brightness) = 0;//设置屏幕亮度
virtual bool getFillLightSw() = 0;//获取智能补光开关
virtual int setFillLightSw(bool isOpen) = 0;//获取智能补光开关
virtual int getStandbyTime() = 0;//获取待机时间
virtual int setStandbyTime(int time) = 0;//设置待机时间
virtual int getCloseScreenTime() = 0;//获取关屏等待时间
virtual int setCloseScreenTime(int time) = 0;//获取关屏等待时间
virtual int getLanguage() = 0;//获取语言
virtual int setLanguage(int lang) = 0;//设置语言
//网络设置
virtual int getIP(char *ip, int len, int& type) = 0;//获取IP
virtual int setIP(char *ip) = 0;//设置IP
virtual enIpMethod getIpMethod() = 0;//获取IP方法
virtual int setIpMethod(enIpMethod ipMethod) = 0;//设置IP方法
virtual int getSubnetMask(char *mask, int len) = 0;//获取子网掩码
virtual int setSubnetMask(char *mask) = 0;//设置子网掩码
virtual int getGateway(char *gateway, int len) = 0;//获取默认网关
virtual int setGateway(char *gateway) = 0;//设置默认网关
virtual int getDNS(char *dns, int len) = 0;//获取DNS
virtual int setDNS(char *dns) = 0;//设置DNS
virtual int getEthMac(char *mac, int len) = 0;//获取mac
virtual int getWifiMac(char *mac, int len) = 0;//获取wifi mac
virtual int getServerAddr(char *addr, int len) = 0;//获取服务器ip
virtual int setServerAddr(char *addr, bool byQrcode = false) = 0;//设置服务器ip
virtual int testServerIP(char *addr, float &time) = 0;//测试服务器ip,成功返回0失败-1
virtual int getIotServerIP(char *ip, int len) = 0;//获取服务器ip
virtual int setIotServerIP(char *ip) = 0;//设置服务器ip
virtual int getIotPort() = 0;//获取端口号, 成功返回端口号,失败返回-1
virtual int setIotPort(int port) = 0;//设置端口号
virtual bool getIpShowSw() = 0;//获取IP是否在屏幕上显示的开关
virtual int setIpShowSw(bool sw) = 0;//设置IP是否在屏幕上显示的开关
//蓝牙设置
//if success, return 0, else return err num;
virtual int getBtSwitch(bool &isOpen) = 0;
virtual int getBtName(string &devName) = 0;
virtual int getBtPairedDev(list<BluetoothDev_t> &devList) = 0;
virtual int getBtAvailDev(list<BluetoothDev_t> &devList) = 0;
virtual int getBtAllInfo(BluetoothStat_t &bluetoothStat) = 0;
virtual int btScan(list<BluetoothDev_t> &devList) = 0;//这个接口不需要吧?现在是定时的去搜索?所以点击“可用设备"条目时直接调用getBtAvailDev就可以了
virtual int btSetSwitch(bool isOpen) = 0;
virtual int btSetName(const string &devName) = 0;
virtual int btPaire(const string &devId) = 0;
virtual int btDisPaire(const string &devId) = 0;
virtual int btConnect(const string &devId) = 0;
virtual int btDisConnect(const string &devId) = 0;
virtual int btRenameDev(const string &devId, const string &devName) = 0;
virtual bool getParamBluetoothEnable() = 0;//获取蓝牙的开关
virtual int setParamBluetoothEnable(bool sw) = 0;//设置蓝牙的开关
virtual std::string getParamBluetoothName() = 0;//获取蓝牙设备名称
virtual int setParamBluetoothName(std::string name) = 0;//设置蓝牙设备名称
//门禁设置
virtual int getUnlockTime() = 0;//获取开锁时间,取值范围是1-10秒。默认值为1秒
virtual int setUnlockTime(int time) = 0;//设置开锁时间
virtual int getUnlockDelay() = 0;//获取开锁延时,取值范围是0-10秒。默认值为0秒
virtual int setUnlockDelay(int time) = 0;//设置开锁延时
virtual enUnlockSignal getUnlockSig() = 0;//获取开锁信号
virtual int setUnlockSig(enUnlockSignal value) = 0;//设置开锁信号,返回-1:不支持,-2表示和报警信号冲突0成功
virtual enAssist getAssistIn() = 0;//获取辅助输入
virtual int setAssistIn(enAssist assist) = 0;//设置辅助输入
virtual enAssist getAssistOut() = 0;//获取辅助输出
virtual int setAssistOut(enAssist assist) = 0;//设置辅助输出
virtual enWiegand getWiegandIn() = 0;//获取韦根输入
virtual int setWiegandIn(enWiegand wiegand) = 0;//设置韦根输入
virtual enWiegand getWiegandOut() = 0;//获取韦根输出
virtual int setWiegandOut(enWiegand wiegand) = 0;//设置韦根输出
virtual enBaudRate getBaudRate() = 0;//获取波特率
virtual int setBaudRate(enBaudRate baudRate) = 0;//设置波特率
virtual int getWarningSig() = 0;//获取报警信号
virtual int setWarningSig(int signal) = 0;//设置报警信号, signal,0:禁用1继电器。返回-1:和开门信号设置的继电器有冲突返回0:成功
virtual int setReverseAccessSw(bool enabled) = 0;
virtual bool getReverseAccessSw() const = 0;
//交互提示
virtual enLogo getLogo() = 0;//获取logo
virtual int setLogo(enLogo logo) = 0;//设置logo
virtual int getCustomLogo(char *logo, int len) = 0;
virtual enLogo getLogoTime() = 0;//获取logo+time
virtual int setLogoTime(enLogo logo) = 0;//设置logo+time
virtual enLogo getBackground() = 0;//获取背景图
virtual int setBackground(enLogo logo) = 0;//设置背景图
virtual enRecogResult getSuccessResult(char *data = nullptr, int len = 0) = 0;//获取成功结果
virtual int setSuccessResult(enRecogResult result = RecogResultDefault, char *data = nullptr) = 0;//设置成功结果
virtual enRecogResult getFailResult(char *data = nullptr, int len = 0) = 0;//获取失败结果
virtual int setFailResult(enRecogResult result = RecogResultDefault, char *data = nullptr) = 0;//设置失败结果
virtual bool getPlayAudioSw() = 0;//获取语音播报开关
virtual int setPlayAudioSw(bool isOpen) = 0;//设置语音播报开关
//人脸识别
virtual bool getIdentificationSw() = 0;//获取身份核验开关
virtual int setIdentificationSw(bool sw) = 0;//设置身份核验开关
virtual enSimilarityTh getSimilarityTh() = 0;//获取相似度阈值
virtual int setSimilarityTh(enSimilarityTh th) = 0;//设置相似度阈值
virtual int setCustomSimilarity(int sim) = 0;//设置自定义识别相似度
virtual int getCustomSimilarity() = 0;//获取自定义识别相似度
virtual bool getLivingBodySw() = 0;//获取活体开关
virtual int setLivingBodySw(bool isOpen) = 0;//设置活体开关
virtual enLivingBodyTh getLivingBodyTh() = 0;//获取活体检测阈值
virtual int setLivingBodyTh(enLivingBodyTh th) = 0;//设置活体检测阈值
virtual bool getLivingBodyFailSw() = 0;//获取活体失败图片留存开关
virtual int setLivingBodyFailSw(bool isOpen) = 0;//设置失败图片留存开关
virtual int getVerifyInterval() = 0;//获取验证间隔时间,取值范围0-5秒。0秒表示一人只做一次识别。大于1秒时当上次同一人识别时间超过设定间隔时再次进行识别
virtual int setVerifyInterval(int time) = 0;//设置验证间隔时间
virtual enRecogDistance getRecogDistance() = 0;//获取识别距离
virtual int setRecogDistance(enRecogDistance distance) = 0;//设置识别距离
virtual enRecogAngle getRecogAngle() = 0;//获取识别角度
virtual int setRecogAngle(enRecogAngle angle) = 0;//设置识别角度
virtual int getMaxTraceNum() = 0;//获取人脸最大跟踪数,取值范围是1-10. 默认值为1.即每次只识别画面中最大的人脸
virtual int setMaxTraceNum(int num) = 0;//设置人脸最大跟踪数
virtual enFaceQuality getFaceQuality() = 0;//获取人脸质量阈值
virtual int setFaceQuality(enFaceQuality quality) = 0;//设置人脸质量阈值
virtual bool getDynamicFeatureSw() = 0;//获取动态底库的开关
virtual int setDynamicFeatureSw(bool sw) = 0;//设置动态底库的开关
//系统设置
virtual bool getNtpServerSw() = 0;//获取NTP服务开关
virtual int setNtpServerSw(bool isOpen) = 0;//设置NTP服务开关
virtual int getNtpServerAddr(char *addr, int len) = 0;//获取NTP服务地址
virtual int setNtpServerAddr(char *addr) = 0;//设置NTP服务地址
virtual int testNtpServer(char *addr, float &time) = 0;//测试NTP服务 成功返回0失败-1
virtual int getNtpServerPort() = 0;//获取NTP端口成功返回端口号失败返回-1
virtual int setNtpServerPort(int port) = 0;//设置NTP服务端口
virtual int getNtpCheckInterval() = 0;///////////////////////////////////////////
virtual int setNtpCheckInterval(int interval) = 0;///////////////////////////////////////////
virtual int getNtpTimeZone(char *timeZone, int len) = 0;///////////////////////////////////////////
virtual int setNtpTimeZone(char* timeZone) = 0;///////////////////////////////////////////
virtual int setVerifyFactorySettingPwd(char *pwd) = 0;//设置工程密码密码要求数字0-9字母a-zA-Z共6位。默认密码为666666
virtual int testHardware() = 0;//硬件检测,包括a)双摄像头的回显, b)补光灯的点亮,c)继电器开关,d)刷卡信息的显示
virtual int cleanData() = 0;//清除数据
virtual int devReboot() = 0;//重启设备
virtual int startCapture() = 0;//start capture on register
virtual int deletePerson(long long personID) = 0;
/*query person ID
*pPersonIDBuff : [out]person id list
*nBuffCount : [in] buff size
*startID : [in] start id, the param greater zero
*/
virtual int queryPersonList(long long* pPersonIDBuff, int nBuffCount, long long startID, int& nRealPerson) = 0;
virtual int clearPeople() = 0;
virtual unsigned queryPerson(const char* searchText) = 0;
virtual unsigned queryPerson(const char* searchText, int pageIndex, stQueryPersonInfo personRet[], int personRetSize) = 0;
virtual unsigned queryAccessRecord(const char* name, const char* time) = 0;
virtual unsigned queryAccessRecord(const char* name, const char* time, int pageIndex, stQueryAccRedInfo recordRet[], int recordRetSize) = 0;
virtual int getPersonListState(int &sum, unsigned long long &maxPersonID) = 0;
virtual int wakeUpFromScreenSaverOrScreenOff() = 0;
virtual int delPerson(long long personId) = 0;
virtual int modifyPerson(stQueryPersonInfo &personInfo) = 0;
virtual int addPerson(stQueryPersonInfo &personInfo) = 0;
virtual int snapFace(std::string &feature, std::string &savePath) = 0;
virtual bool getMaskCheckSwitch() = 0;
virtual int setMaskCheckSwitch(const bool sw) = 0;
virtual bool getNoMaskNoPassSwitch() = 0;
virtual int setNoMaskNoPassSwitch(const bool sw) = 0;
virtual bool getTemperatureCheckSwitch() = 0;
virtual int setTemperatureCheckSwitch(const bool sw) = 0;
virtual bool getNoTemperatureNoPassSwitch() = 0;
virtual int setNoTemperatureNoPassSwitch(const bool sw) = 0;
virtual float getLowTemperature() = 0;
virtual int setLowTemperature(const float temp) = 0;
virtual float getHighTemperature() = 0;
virtual int setHighTemperature(const float temp) = 0;
virtual bool getQRCodeSwitch() = 0;
virtual int setQRCodeSwitch(const bool sw) = 0;
virtual int setDateTime(const char *dateTime) = 0;
virtual bool getDataEncryptSw() = 0;
virtual int setDataEncryptSw(bool sw) = 0;
virtual bool getAutoRebootSw() = 0;
virtual int setAutoRebootSw(bool sw) = 0;
virtual int getAutoRebootTime(char* time, int len) = 0;
virtual int setAutoRebootTime(const char *time) = 0;
virtual int getAutoRebootInterval() = 0;
virtual int setAutoRebootInterval(int interval) = 0;
virtual int ntpTimeCorrect() = 0;
virtual int ntpTimeCorrectForDevTest(const std::string& ntpServerIp) = 0;
virtual int getNetWireCfg(stNetWire& wireCfg) = 0;
virtual int setNetWireCfg(const stNetWire& wireCfg) = 0;
virtual int setNetWireEnable(bool enable) = 0;
virtual int getNetWifiCfg(stNetWifi& wifiCfg) = 0;
virtual int setNetWifiCfg(const stNetWifi& wifiCfg) = 0;
virtual int setNetWifiEnable(bool enable) = 0;
virtual int getSsidList(stAccPoint accPointList[], int accPointListSize) = 0;
virtual int claerNetWifiCfg() = 0;
virtual int getNet4GCfg(stNet4G& n4gCfg) = 0;
virtual int setNet4GEnable(bool enable) = 0;
virtual int reboot4G() = 0;
virtual int getScreenSaverConfig(stScreensaverCfg& cfg) = 0;
virtual int sendPassword(const char *password) = 0;
virtual void resetDecisionCenterTimer() = 0;
virtual int pauseDataFlow() = 0;
virtual int resumeDataFlow() = 0;
virtual int candidateChoosedInPopupWindow(int index) = 0;
virtual bool isWiegandIoTestOk() = 0;
virtual bool isRelayAndGpioTestOk() = 0;
virtual bool isRs485TestOk() = 0;
virtual bool isReaderUnderScreenTestOk() = 0;
virtual bool isWifiTestOk() = 0;
virtual bool isRtcTestOk() = 0;
virtual bool isWireEthTestOk() = 0;
virtual bool is4gTestOk() = 0;
virtual bool isSerial1TestOk() = 0;
virtual void screenTest() = 0;
virtual void speakerTest() = 0;
virtual void microphoneTest(bool record) = 0;
virtual void audioSwitchTest() = 0;
virtual void tpTest() = 0;
virtual void irCamTest() = 0;
virtual void irLedTest() = 0;
virtual void ageingTest(unsigned hours) = 0;
virtual int getMacFromMes(const char* mesAddrAndProdNo, const char* pcbSeq, std::string& mac) = 0;
virtual bool isAgeing(std::string& hours) = 0;
virtual int getKeyDataMac(std::string& mac) = 0;
virtual int getRecoUiAdConfig(stScreensaverCfg& cfg) = 0;
virtual int recoUiTypeSwitch(unsigned x, unsigned y, unsigned w, unsigned h) = 0;
virtual int getDevPwd(int& type, std::string& pwd) = 0;
virtual int setLocalDevPwd(const std::string& pwd) = 0;
virtual int getKeyDataHardware(std::string& hardware) = 0;
virtual int setKeyDataHardwareAndUpdataFunction(const std::string& hardware) = 0;
virtual int setSetupAlreadyFlag() = 0;
virtual int getParkInfo(std::string& info) = 0;
virtual int setParkInfo(const std::string& info) = 0;
virtual int getDevPosi(std::string& posi) = 0;
virtual int setDevPosi(const std::string& posi) = 0;
virtual int getRs485Cfg() = 0;
virtual int setRs485Cfg(int cfg) = 0;
virtual int getRs485Prot1Addr() = 0;
virtual int setRs485Prot1Addr(int addr) = 0;
virtual int getRs485Prot3Cfg(int& handCfg, int& feetCfg) = 0;
virtual int setRs485Prot3Cfg(int handCfg, int feetCfg) = 0;
virtual int getGPIOCfg() = 0;
virtual int setGPIOCfg(int cfg) = 0;
virtual int getIDFaceVerifySw() = 0;
virtual int setIDFaceVerifySw(bool sw) = 0;
virtual int getBtLockCfg(BtDoorLock& cfg) = 0;
virtual int setBtLockCfg(const BtDoorLock& cfg) = 0;
virtual int getBtLockRemainingBatPwr(const std::string& mac) = 0;
virtual bool getHealthCodeSw() = 0;
virtual int setHealthCodeSw(bool sw) = 0;
virtual bool getHealthCodeNoFaceRequired() = 0;
virtual int setHealthCodeNoFaceRequired(bool sw) = 0;
virtual bool getHealthCodeAllowStranger() = 0;
virtual int setHealthCodeAllowStranger(bool sw) = 0;
virtual int getHealthCodePassCfg(int& codeColorCfg, int& c19tCfg, int& tripCfg, int& abtCfg) = 0;
virtual int setHealthCodePassCfg(int codeColorCfg, int c19tCfg, int tripCfg, int abtCfg) = 0;
virtual std::string getUnderScreenNfcModuleId() = 0;
virtual std::string getExtendNfcModuleId() = 0;
virtual bool isIdModuleInfoUploaded() = 0;
virtual bool isDevSettingDisable() = 0;
virtual void setAntiDemolitionAvail(bool avail, bool upload) = 0;
virtual bool getAntiDemolitionSw() = 0;
virtual void setAntiDemolitionSw(bool sw) = 0;
virtual int getAntiDemolitionOutput() = 0;
virtual void setAntiDemolitionOutput(int output) = 0;
virtual int getGpio4Cfg() = 0;
virtual void setGpio4Cfg(int cfg) = 0;
virtual int getGpio5Cfg() = 0;
virtual void setGpio5Cfg(int cfg) = 0;
virtual int getDoorCloseOvertime() = 0;
virtual void setDoorCloseOvertime(int overtime) = 0;
virtual bool getDisableDevSettingSw() = 0;
virtual void setDisableDevSettingSw(bool sw) = 0;
virtual int getTicketCheckCountToday() = 0;
virtual int getTicketModePeopleCountType() = 0;
virtual std::string utfRawStrToEncodeStr(const std::string &str) = 0;
virtual int getCallDevList() = 0;
virtual int queryCallDevList(const std::string& text, std::vector<stCallDev>& devList) = 0;
virtual int callDev(const std::string& devTag, int devType) = 0;
virtual int callAbort() = 0;
virtual int callHangUp() = 0;
virtual int callReject() = 0;
virtual int callAccept() = 0;
virtual int callSetVideoStream(bool enable) = 0;
virtual int openCallRemoteDoor() = 0;
virtual void verifyAbort() = 0;
virtual bool getShowIdAndVerSw() = 0;
virtual int setShowIdAndVerSw(bool sw) = 0;
virtual int playAudio(enAudioIndex index) = 0;
virtual int userItemChoose(int index) = 0;
};
#endif // BACKSTAGEINTERFACEFORUI

View File

@ -0,0 +1,120 @@
#ifndef UIINTERFACEFORBACKSTAGE
#define UIINTERFACEFORBACKSTAGE
#include "UiTools.h"
#include <chrono>
class UiInterfaceForBackstage : public WidgetWithBackstageInterface
{
public:
typedef enum
{
PLATFORM_CONNECTION_STATUS_DISCONNECTED,
PLATFORM_CONNECTION_STATUS_CONNECTED,
PLATFORM_CONNECTION_STATUS_LOGGED
}PLATFORM_CONNECTION_STATUS_E;
typedef enum
{
QRCode_Msg_Standby,
QRCode_Msg_GreenCode,
QRCode_Msg_YellowCode,
QRCode_Msg_RedCode,
QRCode_Msg_Verifying,
QRCode_Msg_Error,
QRCode_Msg_OtherCode,
QRCode_Msg_Overtime
}QRCode_Msg_E;
virtual long long getUiVersion() = 0;
virtual void showUnauthorizedPage() = 0;
virtual void showScreenSaverPage() = 0;
virtual void showRecoMsgReco() = 0;
virtual void showRecoMsgRetry() = 0;
virtual void showRecoMsgFail(int failType) = 0;
virtual void notifyFaceInfo(const bool faceAvailable) = 0;
virtual void showRecoSuccess(const char *name) = 0;
virtual void showRecoMsgIDFail() = 0;
virtual int showFaceImg(const unsigned char *imgData, const int imgLen) = 0;
virtual void updatePlatformConnectionStatus(const PLATFORM_CONNECTION_STATUS_E) = 0;
virtual void showRecoMsgMoveForehead() = 0; //移动到额头区
virtual void showRecoMsgForeheadNormalTemp(const float temp, const bool isC) = 0; //显示正常温度
virtual void showRecoMsgForeheadAbnormalTemp(const float temp, const bool isHigh, const bool isC) = 0; //显示异常温度
virtual void showRecoMsgReadTempFailed() = 0; //体温检测失败
virtual void showRecoMsgNoMaskWarn() = 0; //请戴口罩
virtual void showRecoMsgMaskOk() = 0;
virtual void showRecoMsgMaskWarn() = 0;
virtual void showRecoMsgNoEntry(const bool) = 0; //显示禁止通行
virtual void turnOffScanLine() = 0;
virtual void clearLocalFacePage() = 0; //清除本地人脸库数据,在平台清空本地人脸的时候
virtual void updateLogo(const enLogo) = 0; //更新logo
virtual void showQRCodeMsg(const QRCode_Msg_E) = 0;
virtual void showQRCodeReco() = 0;
virtual void showFaceReco() = 0;
virtual void updateRecoUiIp() = 0;
virtual void showFeatureUpdateProgress(const unsigned current, const unsigned all) = 0;
virtual void closeFeatureUpdateProgress() = 0;
virtual void showRecoUiMask(int maskType) = 0;
virtual void showNotiMsg(const char *msg, int color) = 0;
virtual void updateScreenSaver() = 0;
virtual int grabScreen(const QString& picName, int rotate = 0) = 0;
virtual void showDrawPage() = 0;
virtual int switchToRecoUi() = 0;
virtual int showCenterMsg(const char* msg, int type) = 0;
virtual int showUserPwd(const char* name) = 0;
virtual void setPwdButton(bool visible) = 0;
virtual void showPwdUiPersonName(const char* name) = 0;
virtual void showUserPwdError(int type, int color) = 0;
virtual void showUserCandidate(const char* title, const char** opns, int opnsNum) = 0;
virtual void showDevTestPage(const char* devCfgMsg) = 0;
virtual void setDevTestMesAddrAndProdNoText(const char* text) = 0;
virtual void setDevTestPcbSeqText(const char* text) = 0;
virtual void setDevTestConfigInfo(const char* text) = 0;
virtual void showOrHideFaceFrame(bool show) = 0;
virtual void showPassResult(bool pass) = 0;
virtual void showRecoUiColorFaceSnapshot(const char* path) = 0;
virtual void showRecoUiColorFaceSnapshot(const unsigned char* jpgDate, int len) = 0;
virtual void recoUiswitchToType(int type) = 0;
virtual void qrcodeFastCfgResult(bool isSuccessed) = 0;
virtual void icCardResult(const char *icCardNum) = 0;
virtual void showHealthMsg(int type, float temp, const char * msg, bool pass, const unsigned char* jpgDate,
int jpgLen, const char * tripCity, const char* failReason, int bgColor, int displayTime) = 0;
virtual void showHealthCodeAuthStatus(int status) = 0;
virtual void showAntiDismantleDetect(bool upload) = 0;
virtual void showSceneResult(int result, const char* resultText, const char* businessInfo, int displayTime) = 0;
virtual void updatePersonNumAccessed(int personAccess, int personAll) = 0;
virtual bool isScenePassing() = 0;
virtual void setSceneUiPersonCountType(int type) = 0;
virtual void updateSceneUiPersonCount(int count) = 0;
virtual void showCallDialPage() = 0;
virtual void setCallConsoleStatus(int status, const char* tip) = 0;
virtual void setDndMode(bool enabled, const std::chrono::system_clock::time_point &time) = 0;
virtual void showRecoUiDevIdAndVer(bool show) = 0;
virtual void showUserItemChoose(const std::vector<std::string>& items) = 0;
};
#endif // UIINTERFACEFORBACKSTAGE

635
Linguist/interface/View.cpp Normal file
View File

@ -0,0 +1,635 @@
/********************************************************************
* Name : View.cpp
* Param :
* Return :
* Describ :
* Author :
* Date :
********************************************************************/
#include "View.h"
#include "rw_zlog.h"
#include "param_manage.h"
#include "timer/timer.h"
#include "AsyncEvent.h"
#include "recoUiCallConsole.h"
View * View::m_this = nullptr;
View::View( )
{
m_ui = nullptr;
m_backstage = nullptr;
}
View* View::getInstance()
{
if( nullptr == m_this )
{
m_this = new View;
}
return m_this;
}
int View::viewInitBackstage( void* pParaMng, void* pObjs, bool needSetupWizard)
{
m_backstage = new Backstage(pParaMng, pObjs);
m_backstage->stopIdentyState();
m_needSetupWizard = needSetupWizard;
return 0;
}
int View::viewCreateUi(int languageType, bool showCursor)
{
LOGD("language type: %d", languageType);
if(languageType < 0){
return -1;
}
m_ui = new mainUi(languageType, m_needSetupWizard);
if(nullptr == m_backstage){
LOGE("backstage not ready!!!");
return -2;
}
showCursorSwitch(showCursor);
m_ui->setBackstageUiinterface(m_backstage);
LOGI("ui version:%lld", m_ui->getUiVersion());
return 0;
}
int View::viewCreateSettingUi()
{
int ret = -1;
if(m_ui){
m_ui->createSettingUi();
ret = 0;
}
return ret;
}
void View::showRecoMsgReco()
{
if (m_ui)
{
m_ui->showRecoMsgReco();
}
}
void View::showUnauthorizedPage()
{
if (m_ui)
{
m_ui->showUnauthorizedPage();
}
}
void View::showScreenSaverPage()
{
if (m_ui)
{
m_ui->showScreenSaverPage();
}
}
void View::showErrorDisplayPage(enErrCode errCode)
{
}
void View::notifyFaceInfo(const bool faceAvailable)
{
if(m_ui)
{
m_ui->notifyFaceInfo(faceAvailable);
}
}
void View::showRecoMsgRetry()
{
if (m_ui)
{
m_ui->showRecoMsgRetry();
}
}
void View::showRecoMsgFail(int failType)//未经许可人员
{
if (m_ui)
{
m_ui->showRecoMsgFail(failType);
}
}
void View::showRecoSuccess(const char *name)
{
if (m_ui)
{
m_ui->showRecoSuccess(name);
}
}
void View::showFaceImg(const unsigned char *imgData, const int imgLen)
{
if (m_ui)
{
m_ui->showFaceImg(imgData, imgLen);
}
}
void View::showRecoMsgIDFail()//身份证核验失败
{
if (m_ui)
{
m_ui->showRecoMsgIDFail();
}
}
void View::updatePlatformConnectionStatus(UiInterfaceForBackstage::PLATFORM_CONNECTION_STATUS_E state)
{
//LOGD("m_ui===%p", m_ui);
if (m_ui)
{
m_ui->updatePlatformConnectionStatus(state);
}
}
void View::showRecoMsgMoveForehead() //移动到额头区
{
if (m_ui)
{
m_ui->showRecoMsgMoveForehead();
}
}
void View::showRecoMsgForeheadNormalTemp(const float temp, const bool isC) //显示正常温度
{
//LOGD("view show temp: %f", temp);
if (m_ui)
{
m_ui->showRecoMsgForeheadNormalTemp(temp, isC);
}
}
void View::showRecoMsgForeheadAbnormalTemp(const float temp, const bool isHigh, const bool isC) //显示异常温度
{
//LOGD("view show temp: %f", temp);
if (m_ui)
{
m_ui->showRecoMsgForeheadAbnormalTemp(temp, isHigh, isC);
}
}
void View::showRecoMsgReadTempFailed() //体温检测失败
{
if (m_ui)
{
m_ui->showRecoMsgReadTempFailed();
}
}
void View::showRecoMsgNoMaskWarn() //请戴口罩
{
if (m_ui)
{
m_ui->showRecoMsgNoMaskWarn();
}
}
void View::showRecoMsgMaskOk() //口罩检测成功
{
if (m_ui)
{
m_ui->showRecoMsgMaskOk();
}
}
void View::showRecoMsgNoEntry(const bool noEntry) //禁止通行
{
if (m_ui)
{
m_ui->showRecoMsgNoEntry(noEntry);
}
}
void View::showRecoMsgMaskWarn()
{
m_ui->showRecoMsgMaskWarn();
}
void View::turnOffScanLine() //关闭扫描线
{
if (m_ui)
{
m_ui->turnOffScanLine();
}
}
void View::updateLogo(int logo)
{
if (m_ui)
{
LOGD("logo=======%d", logo);
m_ui->updateLogo((enLogo)logo);
}
}
void View::showQRCodeResult(int result)
{
if (m_ui)
{
if(result)LOGD("result=======%d", result);
m_ui->showQRCodeMsg(static_cast<UiInterfaceForBackstage::QRCode_Msg_E>(result));
}
}
void View::showQRCodeReco()
{
LOGD("m_ui==%p", m_ui);
if (m_ui)
{
m_ui->showQRCodeReco();
}
}
void View::showFaceReco()
{
if (m_ui)
{
m_ui->showFaceReco();
}
}
void View::updateRecoUiIp()
{
if (m_ui)
{
m_ui->updateRecoUiIp();
}
}
void View::showFeatureUpdateProgress(const unsigned current, const unsigned all)
{
if (m_ui){
m_ui->showFeatureUpdateProgress(current, all);
}
}
void View::closeFeatureUpdateProgress()
{
if (m_ui){
m_ui->closeFeatureUpdateProgress();
}
}
void View::showCalibrationBox()
{
if (m_ui)
{
m_ui->showRecoUiMask((int)View::enRecoUiMaskType::enRecoUiMaskTempCalibra);
}
}
void View::closeCalibrationBox()
{
if (m_ui)
{
m_ui->showRecoUiMask((int)View::enRecoUiMaskType::enRecoUiMaskLight);
}
}
void View::showNotiMsg(const char *msg, int color, double displayTime)
{
if (m_ui && msg){
m_ui->showNotiMsg(msg, color);
if(strlen(msg)){
rw_timer_del(m_ullNotiMsgShowTmr);
rw_timer_add(&m_ullNotiMsgShowTmr, displayTime, 1, msgShowOvertimeCloseCB, (void*)0);
}
}
}
void View::switchLightOrDarkRecoUi(bool isDark)
{
if (m_ui)
{
View::enRecoUiMaskType type = View::enRecoUiMaskType::enRecoUiMaskLight;
if(isDark){
type = View::enRecoUiMaskType::enRecoUiMaskDark;
}
m_ui->showRecoUiMask((int)type);
}
}
void View::updateScreenSaver()
{
if (m_ui)
{
m_ui->updateScreenSaver();
}
}
void View::grabScreen(const char* picName, int rotate)
{
if (m_ui)
{
m_ui->grabScreen(picName, rotate);
}
}
void View::switchToRecoUi()
{
if (m_ui)
{
m_ui->switchToRecoUi();
}
}
void View::showCenterMsg(const char* msg, double displayTime, int type)
{
if (m_ui && msg){
LOGI("showCenterMsg:%s", msg);
m_ui->showCenterMsg(msg, type);
rw_timer_del(m_ullCenterMsgShowTmr);
if(strlen(msg)){
LOGI("enable timer...");
rw_timer_add(&m_ullCenterMsgShowTmr, displayTime, 1, msgShowOvertimeCloseCB, (void*)1);
}
}
}
void View::closeCenterMsgWin()
{
LOGI("close center msg window");
m_ui->showCenterMsg("", 0);
rw_timer_del(m_ullCenterMsgShowTmr);
}
void View::showDrawPage()
{
if (m_ui){
m_ui->showDrawPage();
}
}
void View::showCursorSwitch(bool sw)
{
if (m_ui){
m_ui->showCursorSwitch(sw);
}
}
void View::setPwdButton(bool visible)
{
if (m_ui){
m_ui->setPwdButton(visible);
}
}
void View::showPwdUiPersonName(const char* name)
{
if (m_ui){
m_ui->showPwdUiPersonName(name);
}
}
View::~View()
{
delete m_ui;
delete m_backstage;
}
int View::msgShowOvertimeCloseCB(void *data)
{
if(0 == (int)data){
View::getInstance()->showNotiMsg("", 0);
}else if(1 == (int)data){
View::getInstance()->showCenterMsg("");
}
return 0;
}
int View::setNetWire(const stNetWire& wireCfg)
{
return m_backstage->setNetWireCfg(wireCfg);
}
int View::setServerAddr(const char *addr, bool byQrcode)
{
return m_backstage->setServerAddr((char*)addr, byQrcode);
}
void View::showUserPwd(const char* name)
{
if (m_ui){
m_ui->showUserPwd(name);
}
}
void View::showUserPwdError(int type, int color)
{
if (m_ui){
m_ui->showUserPwdError(type, color);
}
}
void View::showUserCandidate(const char** opns, int opnsNum)
{
if (m_ui){
m_ui->showUserCandidate("请选择项目", opns, opnsNum);
}
}
void View::showDevTestPage(const char* devCfgMsg)
{
if (m_ui){
m_ui->showDevTestPage(devCfgMsg);
UiConfig::GetInstance()->setDevTestStatus(true);
}
}
void View::setDevTestMesAddrAndProdNoText(const char* text)
{
if (m_ui){
m_ui->setDevTestMesAddrAndProdNoText(text);
}
}
void View::setDevTestPcbSeqText(const char* text)
{
if (m_ui){
m_ui->setDevTestPcbSeqText(text);
}
}
#if 0
void View::setDevTestConfigInfo(const char* text)
{
m_ui->setDevTestConfigInfo(text);
}
#endif
void View::showOrHideFaceFrame(bool show)
{
if (m_ui){
m_ui->showOrHideFaceFrame(show);
}
}
void View::showPassResult(bool pass)
{
if (m_ui){
m_ui->showPassResult(pass);
}
}
void View::showRecoUiColorFaceSnapshot(const char* path)
{
m_ui->showRecoUiColorFaceSnapshot(path);
}
void View::showRecoUiColorFaceSnapshot(const unsigned char* jpgDate, int len)
{
m_ui->showRecoUiColorFaceSnapshot(jpgDate, len);
}
void View::recoUiswitchToType(int type)
{
m_ui->recoUiswitchToType(type);
}
void View::qrcodeFastCfgResult(bool isSuccessed)
{
m_ui->qrcodeFastCfgResult(isSuccessed);
}
void View::icCardResult(const char *icCardNum)
{
m_ui->icCardResult(icCardNum);
}
bool View::isInSettingUi()
{
return m_ui->isInSettingUi();
}
void View::updateAdScreen()
{
return m_ui->updateAdScreen();
}
void View::showHealthMsg(int type, float temp, const char* msg, bool pass,
const unsigned char* jpgDate, int jpgLen, const char* tripCity, const char* failReason, int bgColor, int displayTime)
{
m_ui->showHealthMsg(type, temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor, displayTime);
}
/*
0
1
2
3
4
*/
void View::showHealthCodeAuthStatus(int status)
{
m_ui->showHealthCodeAuthStatus(status);
}
void View::showAntiDismantleDetect(bool upload)
{
m_ui->showAntiDismantleDetect(upload);
}
void View::showSceneResult(int result, const char* resultText, const char* businessInfo, int displayTime)
{
m_ui->showSceneResult(result, resultText, businessInfo, displayTime);
}
void View::updatePersonNumAccessed(int personAccess, int personAll)
{
m_ui->updatePersonNumAccessed(personAccess, personAll);
}
bool View::isScenePassing()
{
return m_ui->isScenePassing();
}
void View::setSceneUiPersonCountType(int type)
{
return m_ui->setSceneUiPersonCountType(type);
}
void View::updateSceneUiPersonCount(int count)
{
m_ui->updateSceneUiPersonCount(count);
}
void View::showCallBtn(bool callButton, bool videoButton) {
auto event = new AsyncEvent([=]() {
emit m_ui->signalShowCallBtn(callButton, videoButton);
});
QCoreApplication::postEvent(m_ui, event);
}
void View::showCallDialPage()
{
m_ui->showCallDialPage();
}
void View::showCallReceiverCallIn(const char* callerName, bool videoEnable)
{
m_ui->setCallConsoleStatus(videoEnable ? 51 : 50, callerName);
}
void View::showCallInitiatorConnected(bool videoEnable)
{
m_ui->setCallConsoleStatus(videoEnable ? 1 : 0, "");
}
void View::exitCall()
{
m_ui->setCallConsoleStatus(100, "");
}
void View::showCallPlatformCallIn(const char *callerName) {
m_ui->setCallConsoleStatus(recoUiCallConsole::PlatformCallIn, callerName);
}
void View::showCallVideoPlayer(bool show) {
m_ui->setCallConsoleStatus(show ? recoUiCallConsole::ShowVideo : recoUiCallConsole::HideVideo, "");
}
void View::setDndMode(bool enabled, const std::chrono::system_clock::time_point &time) {
auto event = new AsyncEvent([=]() { m_ui->setDndMode(enabled, time); });
QCoreApplication::postEvent(m_ui, event);
}
void View::showRecoUiDevIdAndVer(bool show)
{
m_ui->showRecoUiDevIdAndVer(show);
}
void View::showUserItemChoose(const std::vector<std::string>& items)
{
m_ui->showUserItemChoose(items);
}
#include <QImage>
#include <QMatrix>
void rotateRgbImage(const unsigned char* inputImage, int width, int height, unsigned char* outptuImg, double angle)
{
QImage inputImg((const uchar*)inputImage, width, height, QImage::Format_RGB888);
QMatrix matrix;
matrix.rotate(angle);
memcpy(outptuImg, inputImg.transformed(matrix).bits(), width * height * 3);
}

174
Linguist/interface/View.h Normal file
View File

@ -0,0 +1,174 @@
/********************************************************************
* Name : View.h
* Param :
* Return :
* Describ :
* Author : Zhang Botong
* Date : 2019-11-13
********************************************************************/
#ifndef VIEW_H
#define VIEW_H
#include "BackStage.h"
#include "mainUi.h"
typedef enum
{
Error1_N = 1000,
Error_INPUT_PARAM,
Error1_1,
ErrorLive,
Error_PERSON_ID_NO_EXIST,
Error_REGISTER_PERSON,
Error_DELETE_PERSON,
Error_CLEAR_PERSON,
Error_QUERY_PERSON_COUNT,
Error_QUERY_MAX_PERSON_ID,
Error_NO_FACE,
Error_NO_FACE_IMAGE,
Error_REGISTER_FACE,
Error_DELETE_FACE,
Error_QUERY_PERSONID,
Error_QUERY
}enErrCode;
class View
{
public:
enum class enRecoUiMaskType
{
enRecoUiMaskNormal,
enRecoUiMaskTempCalibra,
enRecoUiMaskLight,
enRecoUiMaskDark,
enRecoUiMaskMax
};
static View* getInstance();
static int msgShowOvertimeCloseCB(void *data);
int viewInitBackstage(void* pParaMng, void* pObjs, bool needSetupWizard);
int viewCreateUi(int languageType, bool showCursor);
int viewCreateSettingUi();
virtual ~View();
void showRecoMsgReco();
void showUnauthorizedPage();
void showScreenSaverPage();
void showErrorDisplayPage(enErrCode errCode);
void notifyFaceInfo(const bool faceAvailable);
void showRecoMsgRetry();
void showRecoMsgFail(int failType = 0);
void showRecoSuccess(const char *name);
void showFaceImg(const unsigned char *imgData, const int imgLen);
void showRecoMsgIDFail();
void startCapture();
void updatePlatformConnectionStatus(UiInterfaceForBackstage::PLATFORM_CONNECTION_STATUS_E state);
void showRecoMsgMoveForehead(); //移动到额头区
void showRecoMsgForeheadNormalTemp(const float temp, const bool isC); //显示正常温度
void showRecoMsgForeheadAbnormalTemp(const float temp, const bool isHigh, const bool isC); //显示异常温度
void showRecoMsgReadTempFailed(); //体温检测失败
void showRecoMsgNoMaskWarn(); //请戴口罩
void showRecoMsgMaskOk(); //口罩检测成功
void showRecoMsgNoEntry(const bool noEntry); //禁止通行或者清除禁止通行
void showRecoMsgMaskWarn();
void turnOffScanLine(); //关闭扫描线
void updateLogo(int logo);
void showQRCodeResult(int result);
void showQRCodeReco();
void showFaceReco();
void updateRecoUiIp();
void showFeatureUpdateProgress(const unsigned current, const unsigned all);
void closeFeatureUpdateProgress();
void showCalibrationBox();
void closeCalibrationBox();
//color:0-white, 1-red, 2-yellow
void showNotiMsg(const char *msg, int color, double displayTime = 3600 * 8);
void switchLightOrDarkRecoUi(bool isDark);
void updateScreenSaver();
void grabScreen(const char* picName, int rotate = 0);
void showDrawPage();
void switchToRecoUi();
void showCenterMsg(const char* msg, double displayTime = 3.0, int type = 0);
void closeCenterMsgWin();
void showCursorSwitch(bool sw);
void setPwdButton(bool visible);
int setNetWire(const stNetWire& wireCfg);
int setServerAddr(const char *addr, bool byQrcode = false);
void showPwdUiPersonName(const char* name);
void showUserPwd(const char* name);
void showUserPwdError(int type, int color = 0);
void showUserCandidate(const char** opns, int opnsNum);
void showDevTestPage(const char* devCfgMsg);
void setDevTestMesAddrAndProdNoText(const char* text);
void setDevTestPcbSeqText(const char* text);
#if 0
void setDevTestConfigInfo(const char* text);
#endif
void showOrHideFaceFrame(bool show);
void showPassResult(bool pass);
void showRecoUiColorFaceSnapshot(const char* path);
void showRecoUiColorFaceSnapshot(const unsigned char* jpgDate, int len);
void recoUiswitchToType(int type);
void qrcodeFastCfgResult(bool isSuccessed);
void icCardResult(const char* icCardNum);
bool isInSettingUi();
void updateAdScreen();
void showHealthMsg(int type, float temp, const char* msg, bool pass, const unsigned char* jpgDate,
int jpgLen, const char* tripCity, const char* failReason, int bgColor, int displayTime = 3);
void showHealthCodeAuthStatus(int status);
void showAntiDismantleDetect(bool upload);
void showSceneResult(int result, const char* resultText, const char* businessInfo, int displayTime);
void updatePersonNumAccessed(int personAccess, int personAll);
bool isScenePassing();
void setSceneUiPersonCountType(int type);
void updateSceneUiPersonCount(int count);
void showCallBtn(bool callButton, bool videoButton);//显示/隐藏通话按键
void showCallDialPage();//显示拨号页面
void showCallReceiverCallIn(const char* callerName, bool videoEnable);//显示接收者通话拨入
void showCallInitiatorConnected(bool videoEnable);//显示发起者通话接通
void exitCall();//退出通话界面
void showCallPlatformCallIn(const char* callerName);//显示平台通话拨入
void showCallVideoPlayer(bool show);//显示/隐藏视频播放
void setDndMode(bool enabled, const std::chrono::system_clock::time_point &time);
void showRecoUiDevIdAndVer(bool show);
void showUserItemChoose(const std::vector<std::string>& items);
protected:
View();
private:
Backstage* m_backstage;
mainUi* m_ui;
static View * m_this;
bool m_needSetupWizard = false;
unsigned long long m_ullNotiMsgShowTmr = 0;
unsigned long long m_ullCenterMsgShowTmr = 0;
};
void rotateRgbImage(const unsigned char* inputImage, int width, int height, unsigned char* outptuImg, double angle);
#endif

View File

@ -0,0 +1,33 @@
#include "LineEditWithKeyboard.h"
#include <QDebug>
#include "keyboard.h"
LineEditWithKeyboard::LineEditWithKeyboard(QWidget *parent) :
QLineEdit(parent), m_keyboard(nullptr)
{
}
void LineEditWithKeyboard::mousePressEvent(QMouseEvent *event)
{
qDebug() << "LineEditWithKeyboard::mousePressEvent";
emit signalMousePressed();
keyboard::GetInstance(this);
QLineEdit::mousePressEvent(event);
}
void LineEditWithKeyboard::slotWordChoose(QString word)
{
setText(text() + word);
}
void LineEditWithKeyboard::keyPressEvent(QKeyEvent* event)
{
//qDebug() << "LineEditWithKeyboard::keyPressEvent";
emit signalMousePressed();
QWidget* w = dynamic_cast<QWidget*>(parent());
if(w)
w->setFocus();
QLineEdit::keyPressEvent(event);
}

View File

@ -0,0 +1,28 @@
#ifndef LINEDIT_WITH_KEYBOARD
#define LINEDIT_WITH_KEYBOARD
#include <QWidget>
#include <QLineEdit>
#include "keyboard.h"
class LineEditWithKeyboard : public QLineEdit
{
Q_OBJECT
public:
LineEditWithKeyboard(QWidget *parent = nullptr);
protected:
void mousePressEvent(QMouseEvent *event);
signals:
void signalMousePressed();
public slots:
void slotWordChoose(QString word);
private:
void keyPressEvent(QKeyEvent* event);
keyboard* m_keyboard;
};
#endif // LINEDIT_WITH_KEYBOARD

View File

@ -0,0 +1,17 @@
#include "LineEditWithPopup.h"
LineEditWithPopup::LineEditWithPopup(QWidget *parent) : QLineEdit(parent)
{
connect(this, SIGNAL(signalCallPopup()), this, SLOT(slotShowPopup));
}
void LineEditWithPopup::mousePressEvent(QMouseEvent *event)
{
QLineEdit::mousePressEvent(event);
}
void LineEditWithPopup::slotShowPopup()
{
}

View File

@ -0,0 +1,23 @@
#ifndef LINEEDITWITHPOPUP_H
#define LINEEDITWITHPOPUP_H
#include <QLineEdit>
#include <QStringList>
class LineEditWithPopup : public QLineEdit
{
Q_OBJECT
public:
explicit LineEditWithPopup(QWidget *parent = nullptr);
signals:
void signalCallPopup();
public slots:
void slotShowPopup();
private:
QStringList* m_list;
void mousePressEvent(QMouseEvent *event);
};
#endif // LINEEDITWITHPOPUP_H

View File

@ -0,0 +1,594 @@
#include "keyboard.h"
#include "LineEditWithKeyboard.h"
#include <QEvent>
#include <QKeyEvent>
#include <QApplication>
#include <QDebug>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPainter>
#include <QMessageBox>
#include <QLabel>
#include <QTimer>
#include "UiConfig.h"
#include "UiTools.h"
//∧ len:3
#define KEY_COL_UNIT 4
#define KEY_HIDE " ▼ "
#define KEY_UPPER "△"
#define KEY_LOWER "∧"
#define KEY_SYMBOL " !@# "
#define KEY_SYMBOL_BACK "Back"
#define KEY_CN "中"
#define KEY_EN "En"
#define KEY_SPACE " Space "
#define KEY_BACKSPACE " ← "
#define KEY_ENTER "Enter"
//添加按键时需要注意不要超出头文件中定义的按键个数
static const char* lower_letter[] = {KEY_HIDE,
"1","2","3","4","5","6","7","8","9","0",
"q","w","e","r","t","y","u","i","o","p",
"a","s","d","f","g","h","j","k","l",
KEY_UPPER,"z","x","c","v","b","n","m",KEY_BACKSPACE,
KEY_CN,KEY_SYMBOL,KEY_SPACE,".",KEY_ENTER};
static const char* upper_letter[] = {KEY_HIDE,
"1","2","3","4","5","6","7","8","9","0",
"Q","W","E","R","T","Y","U","I","O","P",
"A","S","D","F","G","H","J","K","L",
KEY_LOWER,"Z","X","C","V", "B","N","M",KEY_BACKSPACE,
KEY_CN,KEY_SYMBOL,KEY_SPACE,".",KEY_ENTER};
static const char* cn_letter[] = {KEY_HIDE,
"-","=","[","]","\\",";","\'",",","?","/",
"!","@","#","$","%","^","&&","*","(",")",
"_","+","{","}","|",":","\"","<",">",
"~","·","×","÷","","","","",KEY_BACKSPACE,
KEY_CN,KEY_SYMBOL_BACK,KEY_SPACE,".",KEY_ENTER};
static const int COL_NUM_EACH_ROW[] = {1, 10, 10, 9, 9, 5};
static const int KEY_NUM = sizeof(lower_letter) / sizeof(*lower_letter);
#if 0
QPushButton* keyboard::m_btn[KEYS_QUANTITY_MAX] = {nullptr};
//chinese support
QVector<QPushButton*>* keyboard::m_btnsCnCdd = nullptr;
QLineEdit* keyboard::m_editCn = nullptr;
QPushButton* keyboard::m_btnCnPrePage = nullptr;
QPushButton* keyboard::m_btnCnNextPage = nullptr;
#endif
QFile* keyboard::m_pinyinFile = nullptr;
QRegExp* keyboard::m_regExp = nullptr;
QMultiMap<QString, QString>* keyboard::m_pinyinMap = nullptr;
keyboard* keyboard::m_instance = nullptr;
keyboard::enKeyboardStatus keyboard::m_status = enKeyboardNotGen;
keyboard* keyboard::GetInstance(QWidget *parent)
{
if(nullptr == m_instance && nullptr != parent){
qDebug() << "create keyboard";
m_status = enKeyboardCreating;
m_instance = new keyboard(parent);
m_instance->popup();
m_status = enKeyboardCreated;
}
if(parent){
QObject* recv = static_cast<QObject*>(parent);
if(m_instance->receiver() != recv){
m_instance->setReceiver(static_cast<QObject*>(parent));
}
}
return m_instance;
}
void keyboard::close()
{
if(m_instance){
if(enKeyboardCreated == m_status){
qDebug() << "close keyboard";
m_instance->slotClose();
}
else {
qDebug() << "close keyboard later";
QTimer::singleShot(500, m_instance, SLOT(slotClose()));
}
}
}
void keyboard::preLoad()
{
if(nullptr == m_instance){
qDebug() << "keyboard pre load";
keyboard();
}
}
keyboard::keyboard(QWidget *parent) : QDialog(parent), m_receiver(nullptr)
{
m_status = enKeyboardNotGen;
m_editCn = nullptr;
m_btnCnPrePage = nullptr;
m_btnCnNextPage = nullptr;
setReceiver(static_cast<QObject*>(parent));
qDebug() << "keyboard()";
QPalette palette(this->palette());
palette.setColor(QPalette::ButtonText, Qt::white);
const int chooseBtnHeight = UiConfig::GetInstance()->getUiWidth() / 16;
m_btnsCnCdd.resize(8);
QHBoxLayout* hLayoutCdd = new QHBoxLayout();
for(auto &b : m_btnsCnCdd)
{
//if(nullptr == b){
b = new QPushButton();
b->setFixedWidth(static_cast<int>(UiConfig::GetInstance()->getUiWidth()) / m_btnsCnCdd.size());
b->setPalette(palette);
b->setStyleSheet("background-color: transparent;");
b->setFlat(true);
b->setFixedSize(chooseBtnHeight * 2, chooseBtnHeight);
connect(b, SIGNAL(clicked(bool)), this, SLOT(slotCandidateBtnClicked()));
//}
hLayoutCdd->addWidget(b, 1, Qt::AlignLeft);
}
hLayoutCdd->addWidget(new QLabel(this), 100, Qt::AlignRight);
if(nullptr == m_editCn){
m_editCn = new QLineEdit();
m_editCn->setReadOnly(true);
palette.setColor(QPalette::Text, Qt::white);
m_editCn->setPalette(palette);
m_editCn->setFixedSize(chooseBtnHeight * 4, chooseBtnHeight);
m_editCn->setStyleSheet("background:transparent;border-width:0;border-style:outset");
}
if(nullptr == m_btnCnPrePage){
m_btnCnPrePage = new QPushButton();
m_btnCnPrePage->setText("");
m_btnCnPrePage->setPalette(palette);
m_btnCnPrePage->setFixedSize(chooseBtnHeight * 2, chooseBtnHeight);
m_btnCnPrePage->setStyleSheet("background-color: rgb(57, 53, 50);");
connect(m_btnCnPrePage, SIGNAL(clicked(bool)), this, SLOT(slotPageTurnBtnClicked()));
}
if(nullptr == m_btnCnNextPage){
m_btnCnNextPage = new QPushButton();
m_btnCnNextPage->setText("");
m_btnCnNextPage->setPalette(palette);
m_btnCnNextPage->setFixedSize(chooseBtnHeight * 2, chooseBtnHeight);
m_btnCnNextPage->setStyleSheet("background-color: rgb(57, 53, 50);");
connect(m_btnCnNextPage, SIGNAL(clicked(bool)), this, SLOT(slotPageTurnBtnClicked()));
}
QVBoxLayout* vLayout = new QVBoxLayout();
vLayout->addLayout(hLayoutCdd);
QHBoxLayout* hLayoutLine[ROW_NUM] = {nullptr};
for(int i = 0; i < ROW_NUM; i ++)
{
hLayoutLine[i] = new QHBoxLayout();
hLayoutLine[i]->setMargin(0);
//hLayoutLine[i]->setSpacing(15);
if(i < ROW_NUM - 1){ //最后一列不需要
hLayoutLine[i]->addStretch(0);
}
}
hLayoutLine[0]->addWidget(m_editCn, 2, Qt::AlignLeft);
hLayoutLine[0]->addWidget(m_btnCnPrePage, 1, Qt::AlignLeft);
hLayoutLine[0]->addWidget(m_btnCnNextPage, 1, Qt::AlignLeft);
int col = 0;
int row = 0;
int colMax = 0; //最大列数
int colTaken = 0;
palette.setColor(QPalette::ButtonText, Qt::white);
QFont ft;
ft.setPointSize(UiConfig::GetInstance()->isRkDevice() ? 12 : 24);
for(int i = 0; i < KEY_NUM; i ++)
{
m_btn[i] = new QPushButton(this);
m_btn[i]->setPalette(palette);
m_btn[i]->setStyleSheet("background-color: rgb(57, 53, 50);");
m_btn[i]->setFocusPolicy(Qt::NoFocus);
m_btn[i]->setFont(ft);
//m_btn[i]->setFlat(true);
connect(m_btn[i], SIGNAL(clicked(bool)), this, SLOT(slotBtnClicked()));
connect(m_btn[i], SIGNAL(pressed()), this, SLOT(slotBtnPressed()));
connect(m_btn[i], SIGNAL(released()), this, SLOT(slotBtnReleased()));
int btnCol = (strlen(lower_letter[i]) / KEY_COL_UNIT) + 1;
hLayoutLine[row]->addWidget(m_btn[i]);
colTaken += btnCol;
col++;
if(COL_NUM_EACH_ROW[row] == col)
{
col = 0;
row++;
if(colTaken > colMax){
colMax = colTaken;
}
colTaken = 0;
}
}
int unit = (UiConfig::GetInstance()->getUiWidth() - ((colMax - 1) * SPACE)) / colMax;
for(int i = 0; i < KEY_NUM; i ++)
{
int btnCol = (strlen(lower_letter[i]) / KEY_COL_UNIT) + 1;
m_btn[i]->setFixedSize(unit * btnCol, static_cast<int>(unit));
}
for(int i = 0; i < ROW_NUM; i ++)
{
if(i > 0 && i < ROW_NUM - 1){ //首行和尾行不需要
hLayoutLine[i]->addStretch(0);
}
vLayout->addLayout(hLayoutLine[i]);
}
vLayout->setSpacing(5);//10
vLayout->setContentsMargins(0, 10, 0, 10);
setLayout(vLayout);
setFocusPolicy(Qt::NoFocus);
setWindowFlags( Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool | Qt::WindowDoesNotAcceptFocus);
if(nullptr == m_pinyinFile){
m_pinyinFile = new QFile();
m_pinyinFile->setFileName(":/res/inputCn/pinyin-utf8"); //设置QFile的名称
if(!m_pinyinFile->open(QIODevice::ReadOnly) ){ //只读模式,打开文件
QMessageBox::warning(nullptr, "pinyin file", "can't load"); //打开失败,则报错
}
}
if(nullptr == m_regExp){
m_regExp = new QRegExp();
m_regExp->setCaseSensitivity(Qt::CaseSensitive); //设置正则表达式的参数,Qt::CaseInsensitive,大小写敏感
m_regExp->setPattern(QString("([a-z]+)")); //获得正则本身,获取a-z
}
if(nullptr == m_pinyinMap){
m_pinyinMap = new QMultiMap<QString, QString>();
while(!m_pinyinFile->atEnd())
{
QByteArray lineData = m_pinyinFile->readLine(); //读取一行
//qDebug() << "line:" << QString(data.data());
int ret = m_regExp->indexIn(QString(lineData.data()), 0, QRegExp::CaretAtZero); //进行匹配如果成功则返回index不成功返回-1 data.data()是读取到的一行数据,返回值应该是匹配到的位置
//qDebug() << "ret =" << ret;
//qDebug() << "m_regExp.cap(1):" << m_regExp.cap(1) << "QString(lineData.data()).left(ret):" << QString(lineData.data()).left(ret);
if("\r\n" != QString(lineData.data()).left(ret)){
m_pinyinMap->insert(m_regExp->cap(1), QString(lineData.data()).left(ret)); //将mmap对象的成员初始化;key是字母value是行字
}
}
m_pinyinFile->close();
}
setInputMethodCn(false);
setAttribute(Qt::WA_DeleteOnClose);
setFixedWidth(UiConfig::GetInstance()->getUiWidth());
m_labelTip = new QLabel(this);
m_labelTip->setFixedSize(unit, static_cast<int>(unit * 1.5));
m_labelTip->setFont(ft);
m_labelTip->setStyleSheet("background-color: rgb(15, 116, 248);");
m_labelTip->setAlignment(Qt :: AlignCenter);
m_labelTip->hide();
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimer()));
shiftkeyboard(2);
}
keyboard::~keyboard()
{
qDebug() << "~keyboard()";
m_instance = nullptr;
}
void keyboard::setInputMethodCn(bool setCn)
{
if(setCn){
m_editCn->clear();
m_editCn->show();
}
else {
for(auto &b : m_btnsCnCdd){
b->hide();
}
m_editCn->hide();
m_btnCnPrePage->hide();
m_btnCnNextPage->hide();
}
isInputMethodCn = setCn;
}
void keyboard::shiftkeyboard(int caps)
{
const char** letter = nullptr;
if(0 == caps){
letter = upper_letter;
}
else if (1 == caps) {
letter = cn_letter;
}
else if (2 == caps) {
letter = lower_letter;
}
for(int i = 0; i < KEY_NUM; i ++){
if(m_btn[i]->text().isEmpty()){ //if has icon, clear first
m_btn[i]->setIcon(QIcon());
}
if(QString(letter[i]) == KEY_BACKSPACE){
m_btn[i]->setText("");
//m_btn[i]->setIcon(QIcon(":res/image/pwd_del_large.png"));
setButtonBackImage(m_btn[i], ":res/image/pwd_del_large_black.png", m_btn[i]->height() / 2 , static_cast<int>(m_btn[i]->height() * 0.34));//w/2*(24/35)
m_btn[i]->setStyleSheet("background-color: rgb(57, 53, 50);");
m_btn[i]->setProperty("key", letter[i]);
}
else if(QString(letter[i]) == KEY_UPPER){
m_btn[i]->setText("");
//m_btn[i]->setIcon(QIcon(":res/image/shift_large.png"));
setButtonBackImage(m_btn[i], ":res/image/shift_large_black.png", m_btn[i]->height() / 2, m_btn[i]->height() / 2);
m_btn[i]->setStyleSheet("background-color: rgb(57, 53, 50);");
m_btn[i]->setProperty("key", letter[i]);
}
else if(QString(letter[i]) == KEY_LOWER){
m_btn[i]->setText("");
//m_btn[i]->setIcon(QIcon(":res/image/shift_lock_large.png"));
setButtonBackImage(m_btn[i], ":res/image/shift_lock_large_black.png", m_btn[i]->height() / 2, m_btn[i]->height() / 2);
m_btn[i]->setStyleSheet("background-color: rgb(57, 53, 50);");
m_btn[i]->setProperty("key", letter[i]);
}
else{
m_btn[i]->setText(letter[i]);
}
}
}
void keyboard::slotBtnPressed()
{
//qDebug() << "unit:" << dynamic_cast<QPushButton*>(sender())->width();
QPushButton* btn = dynamic_cast<QPushButton*>(sender());
if(btn){
for(int i = 0; i < KEY_NUM - 4; i ++){
if(btn == m_btn[i]){
int len = strlen(btn->text().toStdString().c_str());
if(len > 0 && len <= 3){
m_labelTip->setText(btn->text());
m_labelTip->move(btn->x(), btn->y() - m_labelTip->height());
m_labelTip->show();
}
}
}
m_curPressedKey = btn;
m_timer->start(500);
}
}
void keyboard::slotBtnReleased()
{
m_labelTip->hide();
m_timer->stop();
m_curPressedKey = nullptr;
}
void keyboard::slotBtnClicked()
{
for(int i = 0; i < KEY_NUM; i ++){
if(sender() == m_btn[i]){
keyPress(m_btn[i]);
break;
}
}
}
void keyboard::slotPageTurnBtnClicked()
{
if(sender() == m_btnCnPrePage){
changePage(--m_iCddPageIndex);
}
else if (sender() == m_btnCnNextPage) {
changePage(++m_iCddPageIndex);
}
}
void keyboard::slotCandidateBtnClicked()
{
for(auto &b : m_btnsCnCdd){
if(sender() == b){
emit signalWordChoose(b->text());
m_editCn->clear();
for(auto &btn : m_btnsCnCdd){
btn->hide();
}
m_btnCnPrePage->hide();
m_btnCnNextPage->hide();
break;
}
}
}
void keyboard::slotClose()
{
done(0);
}
void keyboard::slotTimer()
{
if(m_curPressedKey){
m_timer->start(100);
keyPress(m_curPressedKey);
}
}
void keyboard::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.fillRect(this->rect(), QColor(0, 0, 0,/*0x1f, 0x28, 0x41,*/ 255)); //QColor最后一个参数代表背景的透明度
return QWidget::paintEvent(event);
}
void keyboard::keyPress(const QPushButton* btn)
{
if(!btn){
return;
}
QString str = btn->text();
if(str.isEmpty()){
str = btn->property("key").toString();
}
QKeyEvent* event = nullptr;
if(str == KEY_BACKSPACE){
event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier);
}else if(str == KEY_ENTER){
event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
}else if(str == KEY_UPPER){
shiftkeyboard(0);//upper_letter
}else if(str == KEY_LOWER){
shiftkeyboard(2);//lower_letter
}else if(str == KEY_CN){
shiftkeyboard(2);
for(int j = 0; j < KEY_NUM; j ++){
if(m_btn[j]->text() == KEY_CN){
m_btn[j]->setText(KEY_EN);
}
}
setInputMethodCn(true);
}else if(str == KEY_EN){
for(int j = 0; j < KEY_NUM; j ++){
if(m_btn[j]->text() == KEY_EN){
m_btn[j]->setText(KEY_CN);
}
}
setInputMethodCn(false);
}else if(str == KEY_HIDE){
slotClose();
}else if(str == KEY_SYMBOL){
shiftkeyboard(1);
}else if(str == KEY_SYMBOL_BACK){
shiftkeyboard(2);
}else{
if(str == KEY_SPACE)
str = " ";
else if (str == "&&") {
str = "&";
}
event = new QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier, str);
}
if(isInputMethodCn){
if(str >= "a" && str <= "z"){ //qt5.5 does not have isLower() func
m_editCn->setText(m_editCn->text() + str);
matching(m_editCn->text());
}else if (str == KEY_BACKSPACE) {
if("" != m_editCn->text()){
m_editCn->setText(m_editCn->text().remove(m_editCn->text().length() - 1, 1));
matching(m_editCn->text());
}else{
QApplication::sendEvent(m_receiver, new QKeyEvent(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier));
}
}else {
if(nullptr != event){
QApplication::sendEvent(m_receiver, event);
}
}
}else{
if(nullptr != event){
QApplication::sendEvent(m_receiver, event);
}
}
static_cast<QWidget*>(m_receiver)->setFocus();
}
void keyboard::popup(const int posToBottom)
{
qDebug() << "keyboard popup";
show();
move(0, UiConfig::GetInstance()->getUiHeight() - height() - posToBottom);
#if 0
qDebug() << "child: " << children().size();
QObjectList& childList = const_cast<QObjectList&>(children());
childList.clear();
qDebug() << "****************child: " << children().size();
#endif
}
void keyboard::matching(const QString& userInput)
{
//qDebug() << "input:" << userInput;
QList<QString> list = m_pinyinMap->values(userInput);
int foundQty = list.size();
//qDebug() << "list:" << foundQty;
m_pinyinList.clear();
#if 0
for (QList<QString>::const_reverse_iterator itr = list.rbegin(); itr != list.rend(); ++itr){
m_pinyinList.append(*itr);
}
#else
for(int i=0; i<foundQty; i++){
m_pinyinList.append(list.takeLast());
}
#endif
//for(auto &str : m_pinyinList)
//qDebug() << "-------:" << str;
changePage(0);
m_iCddPageIndex = 0;
}
void keyboard::changePage(int index)
{
for(auto &b : m_btnsCnCdd){
b->hide();
}
const int matchQty = m_pinyinList.size();
//qDebug() << "matchQty:" << matchQty;
if(matchQty){
const int btnQty = m_btnsCnCdd.size();
const int showQty = matchQty - (index * btnQty) > btnQty ? btnQty : matchQty - (index * btnQty);
for(int i=0; i<showQty; i++)
{
if(m_btnsCnCdd.at(i)->isHidden()){
m_btnsCnCdd.at(i)->show();
}
m_btnsCnCdd.at(i)->setText(m_pinyinList.value(i + index * btnQty));
//qDebug() << "word:" << m_pinyinList.value(i + index * btnQty);
}
m_btnCnPrePage->show();
m_btnCnNextPage->show();
m_btnCnPrePage->setEnabled(0 != index);
m_btnCnNextPage->setEnabled( (showQty == btnQty) && (matchQty - ((index + 1) * btnQty)) );
}
else {
m_btnCnPrePage->hide();
m_btnCnNextPage->hide();
}
}
void keyboard::setReceiver(QObject* receiver)
{
if(nullptr != receiver){
if(m_receiver){
disconnect(this, SIGNAL(signalWordChoose(QString)), m_receiver, SLOT(slotWordChoose(QString)));
}
m_receiver = receiver;
connect(this, SIGNAL(signalWordChoose(QString)), m_receiver, SLOT(slotWordChoose(QString)));
}
}
QObject* keyboard::receiver() const
{
return m_receiver;
}

View File

@ -0,0 +1,85 @@
#ifndef KEYBOARD_H
#define KEYBOARD_H
#include <QWidget>
#include <QPushButton>
#include <QDialog>
#include <QLabel>
//chinese support
#include <QFile>
#include <QMultiMap>
#include <QLineEdit>
#include <QMutex>
class keyboard : public QDialog
{
Q_OBJECT
public:
typedef enum
{
enKeyboardNotGen,
enKeyboardCreating,
enKeyboardCreated
}enKeyboardStatus;
static const int KEYS_QUANTITY_MAX = 60;
static const int SPACE = 5;
static const int ROW_NUM = 6;
static keyboard* GetInstance(QWidget *parent);
static void preLoad();
static void close();
~keyboard();
void popup(const int posToBottom = 0);
signals:
void signalWordChoose(QString word);
public slots:
void slotBtnClicked();
void slotBtnPressed();
void slotBtnReleased();
void slotPageTurnBtnClicked();
void slotCandidateBtnClicked();
void slotClose();
void slotTimer();
private:
static keyboard* m_instance;
QObject* m_receiver;
static enKeyboardStatus m_status;
QPushButton* m_btn[KEYS_QUANTITY_MAX];
//chinese support
QVector<QPushButton*> m_btnsCnCdd;
QLineEdit* m_editCn;
QPushButton* m_btnCnPrePage;
QPushButton* m_btnCnNextPage;
static QFile* m_pinyinFile;
static QRegExp* m_regExp;
static QMultiMap<QString, QString>* m_pinyinMap;
bool isInputMethodCn;
int m_iCddPageIndex;
QList<QString> m_pinyinList;
QLabel* m_labelTip;
QTimer* m_timer;
QPushButton* m_curPressedKey;
explicit keyboard(QWidget *parent = nullptr);
void setInputMethodCn(bool setCn);
void matching(const QString& userInput);
void changePage(int index);
void setReceiver(QObject*);
QObject* receiver() const;
void shiftkeyboard(int caps);
void paintEvent(QPaintEvent *event);
void keyPress(const QPushButton* btn);
};
#endif // KEYBOARD_H

View File

@ -0,0 +1,16 @@
#ifndef UICOMMON_H
#define UICOMMON_H
typedef enum
{
OPTION_LOGO = 0,
OPTION_LOGOTIME,
OPTION_BACKGROUND,
OPTION_RECOGNIZE_OK,
OPTION_RECOGNIZE_FAIL,
OPTION_AUDIO_OK,
OPTION_AUDIO_FAIL,
OPTION_OTHERS
}INTERACION_OPTION;
#endif // UICOMMON_H

View File

@ -0,0 +1,369 @@
#include "UiConfig.h"
#include <QVector>
#include <QDebug>
const int UiConfig::GLOBAL_FONT_SIZE[SUPPORT_SCREEN_SIZE_QUANTITY] = {11, 20, 20, 8, 8};
const QString UiConfig::WELCOME[SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/start-600-1024.jpg",
":/res/image/start-800-1280.jpg",
":/res/image/start-720-1280.jpg",
":/res/image/start-800-1280.jpg",
":/res/image/start-720-1280.jpg"
};
const QString UiConfig::LANGUAGE_FILE[SUPPORT_LANGUAGE_QUANTITY] = {
"", "FaceTick_TC.qm", "FaceTick_EN.qm", "FaceTick_JP.qm", "FaceTick_KR.qm",
"FaceTick_SP.qm", "FaceTick_TH.qm", "FaceTick_PT.qm", "FaceTick_IT.qm", "FaceTick_IW.qm",
"FaceTick_FR.qm", "FaceTick_DE.qm", "FaceTick_TR.qm", "FaceTick_HU.qm"};
const int UiConfig::DEV_NAME_FONT_SIZE[SUPPORT_SCREEN_SIZE_QUANTITY][SUPPORT_LANGUAGE_QUANTITY] = {
{25, 25, 15, 25, 25, 15, 25, 15, 15, 15, 15, 15, 15, 15},
{50, 50, 30, 50, 50, 30, 50, 30, 30, 30, 30, 30, 30, 30},
{50, 50, 30, 50, 50, 30, 50, 30, 30, 30, 30, 30, 30, 30},
{20, 20, 12, 20, 20, 12, 20, 12, 12, 12, 12, 12, 12, 12},
{20, 20, 12, 20, 20, 12, 20, 12, 12, 12, 12, 12, 12, 12}
};
const int UiConfig::MASK_FONT_SIZE[SUPPORT_SCREEN_SIZE_QUANTITY][SUPPORT_LANGUAGE_QUANTITY] = {
{20, 20, 14, 12, 20, 12, 12, 12, 8, 12, 12, 14, 12, 12},
{40, 40, 28, 24, 40, 24, 24, 26, 18, 24, 24, 28, 24, 24},
{40, 40, 28, 24, 40, 24, 24, 26, 18, 24, 24, 28, 24, 24},
{15, 15, 10, 9, 12, 10, 10, 8, 7, 10, 10, 11, 10, 8},
{15, 15, 10, 9, 12, 10, 10, 8, 7, 10, 10, 11, 10, 8}
};
const int UiConfig::PERSON_MSG_FONT_SIZE[SUPPORT_SCREEN_SIZE_QUANTITY][SUPPORT_LANGUAGE_QUANTITY] = {
{20, 20, 14, 15, 12, 15, 14, 13, 9, 12, 10, 13, 13, 9},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{14, 15, 9, 10, 10, 12, 11, 8, 8, 10, 6, 8, 10, 8},
{15, 15, 9, 10, 10, 12, 11, 8, 8, 10, 6, 8, 10, 8}
};
const long long UiConfig::UI_VERSION = 202011171553;
UiConfig* UiConfig::m_instance = nullptr;
UiConfig* UiConfig::GetInstance()
{
if( m_instance == nullptr )
{
m_instance = new UiConfig();
}
return m_instance;
}
UiConfig::UiConfig()
{
m_languageType = 0;
memset(m_recoUiTunningFontSize, 0, sizeof(m_recoUiTunningFontSize));
}
UiConfig::~UiConfig()
{
}
void UiConfig::setUiConfig(const ScreenSize_E config)
{
m_screenSize = config;
if(ScreenSize_7inch == config){ //haiqing 7inch
m_screenWidth = 600;
m_screenHeight = 1024;
}
else if(ScreenSize_8inch == config || ScreenSize_8inch_rk == config){
m_screenWidth = 800;
m_screenHeight = 1280;
}
else if(ScreenSize_5inch == config || ScreenSize_5inch_rk == config){
m_screenWidth = 720;
m_screenHeight = 1280;
}
else {
//nop
}
}
void UiConfig::setUiFaceFrameSize(const FaceFrameSize_E config)
{
m_faceFrameSize = config;
}
int UiConfig::getUiWidth() const
{
return m_screenWidth;
}
int UiConfig::getUiHeight() const
{
return m_screenHeight;
}
const QString& UiConfig::getWelcome() const
{
return WELCOME[(int)m_screenSize];
}
#if 0
bool UiConfig::is7inch() const
{
return (ScreenSize_7inch == m_screenSize);
}
bool UiConfig::is8inch() const
{
return (ScreenSize_8inch == m_screenSize);
}
bool UiConfig::is5inch() const
{
return (ScreenSize_5inch == m_screenSize);
}
#endif
bool UiConfig::is8inchA038HaimanFaceFrame() const
{
return FaceFrameSize_8inchHaiman_A038 == m_faceFrameSize;
}
bool UiConfig::is8inchA038JinggongFaceFrame() const
{
return FaceFrameSize_8inchJinggong_A038 == m_faceFrameSize;
}
int UiConfig::getScreenConfigIndex() const
{
return static_cast<int>(m_screenSize);
}
int UiConfig::getGlobalFontSize() const
{
return GLOBAL_FONT_SIZE[static_cast<int>(m_screenSize)];
}
int UiConfig::setLanguageType(const int type)
{
m_languageType = type;
return 0;
}
int UiConfig::getLanguageType() const
{
return m_languageType;
}
#ifdef CUSTOM_QRCODE_AREA //自定义扫描框
int UiConfig::getQRCodeAreaCoordinateX() const
{
return m_QRCodeAreaX;
}
int UiConfig::getQRCodeAreaCoordinateY() const
{
return m_QRCodeAreaY;
}
int UiConfig::getQRCodeAreaWidth() const
{
return (m_screenWidth - (m_QRCodeAreaX * 2));
}
int UiConfig::getQRCodeAreaHeight() const
{
//区域为正方形
return getQRCodeAreaWidth();
}
void UiConfig::setQRCodeAreaCoordinateX(const int x)
{
m_QRCodeAreaX = x;
}
void UiConfig::setQRCodeAreaCoordinateY(const int y)
{
m_QRCodeAreaY = y;
}
#else
int UiConfig::getQRCodeAreaCoordinateX() const
{
return QRCODE_AREA_COORDINATE_X;
}
int UiConfig::getQRCodeAreaCoordinateY() const
{
return QRCODE_AREA_COORDINATE_Y;
}
int UiConfig::getQRCodeAreaWidth() const
{
return (m_screenWidth - (QRCODE_AREA_COORDINATE_X * 2));
}
int UiConfig::getQRCodeAreaHeight() const
{
//区域为正方形
return getQRCodeAreaWidth();
//return (m_screenHeight - (QRCODE_AREA_COORDINATE_Y * 2));
}
#endif
void UiConfig::setHardwareTesting(bool sw)
{
m_bIsHardwareTesting = sw;
}
bool UiConfig::getHardwareTesting() const
{
return m_bIsHardwareTesting;
}
void UiConfig::showFaceFrameByTempExist(bool set)
{
m_bShowFaceFrame = set;
}
bool UiConfig::isFaceFrameShowByTempExist() const
{
return m_bShowFaceFrame;
}
void UiConfig::setTpAvailable(bool available)
{
m_bTpAvailable = available;
}
bool UiConfig::isTpAvailable() const
{
return m_bTpAvailable;
}
void UiConfig::setfuncNotSupport(Func_E func)
{
if(func < sizeof(m_ullfuncNotSupp) * 8){
m_ullfuncNotSupp |= (1 << func);
}
}
bool UiConfig::isFuncNotSupport(Func_E func) const
{
if(func < sizeof(m_ullfuncNotSupp) * 8){
return (bool)(m_ullfuncNotSupp & (1 << func));
}
return true;
}
void UiConfig::setRecoUiStyle(int style) {
if (style >= 0) {
m_recoUiStyle = style;
}
}
bool UiConfig::isRecoUiStyleClassical() const
{
return (0 == m_recoUiStyle);
}
bool UiConfig::isRecoUiStyleStandard() const
{
return (1 == m_recoUiStyle);
}
bool UiConfig::isRecoUiStyleColor() const
{
return (2 == m_recoUiStyle);
}
bool UiConfig::isRecoUiStyleAd() const
{
return (3 == m_recoUiStyle);
}
bool UiConfig::isRecoUiStyleScene() const
{
return (4 == m_recoUiStyle);
}
#if 0
void UiConfig::setRecoUiFontSizeScale(int sizeType)
{
m_recoUiFontSizeType = sizeType;
}
float UiConfig::recoUiFontSizeScale() const
{
const QVector<float> scales{1.0f, 1.25f, 1.5f};
return m_recoUiFontSizeType < scales.size() ? scales[m_recoUiFontSizeType] : 1.0f;
}
#endif
void UiConfig::setRecoUiFontSize(unsigned index, int size)
{
if(index < sizeof (m_recoUiTunningFontSize) / sizeof (m_recoUiTunningFontSize[0])){
m_recoUiTunningFontSize[index] = size;
}
}
int UiConfig::recoUiFontSize(unsigned index) const
{
if(index < sizeof (m_recoUiTunningFontSize) / sizeof (m_recoUiTunningFontSize[0])){
return m_recoUiTunningFontSize[index];
}
return 0;
}
int UiConfig::setRecoUITextCfg(RecoUiTextCfg::enTextType type, RecoUiTextCfg::enDisMode mode, const char* cusText, RecoUiTextCfg::enFontSize fontSize)
{
m_textCfg[type].m_mode = mode;
m_textCfg[type].m_cusText = cusText;
m_textCfg[type].m_fontSize = fontSize;
return 0;
}
float UiConfig::recoUiTextCfgFontSize(RecoUiTextCfg::enTextType type)
{
const float scales[] = {1.0f, 1.2f, 0.8f, 1.4f};
return scales[UiConfig::GetInstance()->m_textCfg[type].m_fontSize];
}
void UiConfig::setDefaultScreensaver(int index)
{
m_defaultScreensaver = index;
}
int UiConfig::defaultScreensaver() const
{
return m_defaultScreensaver;
}
bool UiConfig::isRkDevice() const
{
return (ScreenSize_8inch_rk == m_screenSize || ScreenSize_5inch_rk == m_screenSize);
}
void UiConfig::setDevTestStatus(bool test)
{
m_isDevTesting = test;
}
bool UiConfig::isDevTesting() const
{
return m_isDevTesting;
}
void UiConfig::setFastCfgStatus(bool cfg)
{
m_isFastCfging = cfg;
}
bool UiConfig::isFastCfging() const
{
return m_isFastCfging;
}

303
Linguist/mainUi/UiConfig.h Normal file
View File

@ -0,0 +1,303 @@
#ifndef UICONFIG_H
#define UICONFIG_H
#include "memory.h"
#include <QString>
//#define DEBUG_MODE
#define QRCODE_SUPPORT
#ifdef QRCODE_SUPPORT
#define CUSTOM_QRCODE_AREA
#endif
typedef enum
{
ScreenSize_7inch,
ScreenSize_8inch,
ScreenSize_5inch,
ScreenSize_8inch_rk,
ScreenSize_5inch_rk
}ScreenSize_E;
typedef enum
{
FaceFrameSize_8inchJinggong_B020,
FaceFrameSize_8inchHaiman_A038,
FaceFrameSize_8inchJinggong_A038,
FaceFrameSize_Butt
}FaceFrameSize_E;
typedef enum
{
FuncWifi,
FuncWg42,
FuncCardReaderUnderScreen,
FuncDataEncrypt
}Func_E;
class RecoUiTextCfg
{
public:
typedef enum
{
TextOtherRecoResult,
TextFacePass = 0,
TextAllowPass,
TextAuthFailed,
TextNoEntry,
TextNOMask,
TextMaskOk,
TextTemp,
TextTapCard,
TextUseOwnCertifi,
TextFaceCam,
TextNoEntryTime,
TextCfgMax
}enTextType;
typedef enum
{
DisModeDefault,
DisModeHide,
DisModeCustom,
DisModeHideKeyWord
}enDisMode;
typedef enum
{
FontSizeDefault,
FontSizeLarge,
FontSizeSmall,
FontSizeHuge
}enFontSize;
enDisMode m_mode = DisModeDefault;
QString m_cusText;
enFontSize m_fontSize = FontSizeDefault;
char m_padding[4];
};
class UiConfig
{
public:
static const long long UI_VERSION;
static const int SUPPORT_SCREEN_SIZE_QUANTITY = 5;
static const int SUPPORT_LANGUAGE_QUANTITY = 14; //简 繁 英 日 韩 西班牙 泰 葡萄牙 意大利 希伯来 法 德 土耳其 匈牙利
static const int GLOBAL_FONT_SIZE[SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString WELCOME[SUPPORT_SCREEN_SIZE_QUANTITY];
static const int DEV_NAME_FONT_SIZE[SUPPORT_SCREEN_SIZE_QUANTITY][SUPPORT_LANGUAGE_QUANTITY];
static const int MASK_FONT_SIZE[SUPPORT_SCREEN_SIZE_QUANTITY][SUPPORT_LANGUAGE_QUANTITY];
static const int PERSON_MSG_FONT_SIZE[SUPPORT_SCREEN_SIZE_QUANTITY][SUPPORT_LANGUAGE_QUANTITY];
static const QString LANGUAGE_FILE[SUPPORT_LANGUAGE_QUANTITY];
//大 86 294
//小133 324
static const int QRCODE_AREA_COORDINATE_X = 133;
static const int QRCODE_AREA_COORDINATE_Y = 324;
//static const int QRCODE_AREA_WIDTH = 0;
//static const int QRCODE_AREA_HEIGHT = 0;
RecoUiTextCfg m_textCfg[RecoUiTextCfg::TextCfgMax];
typedef enum
{
#ifndef DEBUG_MODE
//启动画面展示时间,单位:毫秒
START_SCREEN_TIMEOUT = 4000,
//设置界面密码多次输错等待时间,单位:分钟
PWD_ACCEPT_DELAY_TIME = 2,
//设置界面密码尝试次数,到达次数后需要等待一段时间
RETRY_TIMES_MAX_PER_GROUP = 6,
//设置界面密码输入无操作自动返回时间,单位:秒
NO_OPERATION_OVERTIME_RETURN = 30,
//识别界面鼠标点击进入设置界面次数
MOUSE_CLICK_TIMES_TO_SETTING = 10,
//长按时长进设置界面需大于200ms单位毫秒
TOUCH_TIME_TO_SETTING = 1000, //3000
#define SPECIAL_PWD_1 "recon123"
#else
//启动画面展示时间,单位:毫秒
START_SCREEN_TIMEOUT = 1000,
//设置界面密码多次输错等待时间,单位:分钟
PWD_ACCEPT_DELAY_TIME = 1,
//设置界面密码尝试次数,到达次数后需要等待一段时间
RETRY_TIMES_MAX_PER_GROUP = 2,
//设置界面密码输入无操作自动返回时间,单位:秒
NO_OPERATION_OVERTIME_RETURN = 10,
//识别界面鼠标点击进入设置界面次数
MOUSE_CLICK_TIMES_TO_SETTING = 2,
//长按时长进设置界面需大于200ms单位毫秒
TOUCH_TIME_TO_SETTING = 300,
#define SPECIAL_PWD_1 "x"
#endif
//主风格颜色
MAIN_STYLE_COLOR_RED = 255,
MAIN_STYLE_COLOR_GREEN = 255,
MAIN_STYLE_COLOR_BLUE = 255,
MAIN_STYLE_COLOR_TRAN = 255,
//主界面背景颜色
//主界面字体颜色
SUB_STYLE_COLOR_RED = 245,
SUB_STYLE_COLOR_GREEN = 243,
SUB_STYLE_COLOR_BLUE = 251,
SUB_STYLE_COLOR_TRAN = 255,
DIALOG_SCREEN_BG_COLOR = 0xFFFFFF, //0x929292,
DIALOG_SCREEN_BG_TRAN = 200,
//同一风格按键背景颜色
//同一风格按键字体颜色
//弹窗背景颜色
//弹窗字体颜色
//弹窗确认按键背景颜色
//弹窗确认按键字体颜色
//弹窗取消按键背景颜色
//弹窗取消按键字体颜色
//键盘背景颜色
//键盘按键颜色
//键盘字体颜色
//人脸库管理每页显示人数
LOCAL_FACE_QUANTITY_EACH_PAGE = 20,
//设置界面item条目高度
SETTING_PAGE_ITEM_HEIGHT = 41,
//设置界面到边框距离
SETTING_PAGE_WIDGET_TO_FRAME = 30,
//识别界面鼠标点击进入设置界面两次点击间最长间隔,单位:毫秒
MOUSE_CLICK_INTERVAL_MAX = 1000,
}UiConfig_E;
~UiConfig();
static UiConfig* GetInstance();
void setUiConfig(const ScreenSize_E config);
void setUiFaceFrameSize(const FaceFrameSize_E config);
int getUiWidth() const;
int getUiHeight() const;
const QString& getWelcome() const;
#if 0
bool is7inch() const;
bool is8inch() const;
bool is5inch() const;
#endif
bool is8inchA038HaimanFaceFrame() const;
bool is8inchA038JinggongFaceFrame() const;
int getScreenConfigIndex() const;
int getGlobalFontSize() const;
int setLanguageType(const int);
int getLanguageType() const;
int getQRCodeAreaCoordinateX() const;
int getQRCodeAreaCoordinateY() const;
int getQRCodeAreaWidth() const;
int getQRCodeAreaHeight() const;
#ifdef CUSTOM_QRCODE_AREA //自定义扫描框
void setQRCodeAreaCoordinateX(const int);
void setQRCodeAreaCoordinateY(const int);
#endif
void setHardwareTesting(bool sw);
bool getHardwareTesting() const;
void showFaceFrameByTempExist(bool set);
bool isFaceFrameShowByTempExist() const;
void setTpAvailable(bool available);
bool isTpAvailable() const;
void setfuncNotSupport(Func_E func);
bool isFuncNotSupport(Func_E func) const;
void setRecoUiStyle(int style);
bool isRecoUiStyleClassical() const;
bool isRecoUiStyleStandard() const;
bool isRecoUiStyleColor() const;
bool isRecoUiStyleAd() const;
bool isRecoUiStyleScene() const;
#if 0
void setRecoUiFontSizeScale(int sizeType);
float recoUiFontSizeScale() const;
#endif
void setRecoUiFontSize(unsigned index, int size);
int recoUiFontSize(unsigned index) const;
bool isRkDevice() const;
int setRecoUITextCfg(RecoUiTextCfg::enTextType type, RecoUiTextCfg::enDisMode mode, const char* cusText, RecoUiTextCfg::enFontSize fontSize);
float recoUiTextCfgFontSize(RecoUiTextCfg::enTextType type);
void setDefaultScreensaver(int index);
int defaultScreensaver() const;
void setDevTestStatus(bool test);
bool isDevTesting() const;
void setFastCfgStatus(bool cfg);
bool isFastCfging() const;
private:
static UiConfig* m_instance;
ScreenSize_E m_screenSize;
int m_screenWidth;
int m_screenHeight;
int m_languageType;
FaceFrameSize_E m_faceFrameSize = FaceFrameSize_8inchJinggong_B020;
bool m_bShowFaceFrame = false;
bool m_bTpAvailable = true;
unsigned long long m_ullfuncNotSupp = 0;
#ifdef CUSTOM_QRCODE_AREA //自定义扫描框
int m_QRCodeAreaX;
int m_QRCodeAreaY;
#endif
bool m_bIsHardwareTesting = false; //do not enter setting if testing touch screen
int m_recoUiFontSizeType = 0;
int m_recoUiTunningFontSize[RecoUiTextCfg::TextCfgMax];
int m_recoUiStyle = 0;
int m_defaultScreensaver = 0;
bool m_isDevTesting = false;
bool m_isFastCfging = false;
UiConfig();
};
#endif // UICONFIG_H

24
Linguist/mainUi/debug.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef DEBUG_H
#define DEBUG_H
//#define x86
//#define DEBUG_MODE
#ifdef x86
#define GATE_FACE_PRJ
#define LANGUAGE_TYPE 2 //繁体1 英文2
#define LANGUAGE_DIR_PATH "Z:\\a038\\source\\GateFaceHisi\\View\\build-qt-a038-Desktop_Qt_5_12_3_MinGW_64_bit-Debug\\debug"
#endif
#endif // DEBUG_H

826
Linguist/mainUi/mainUi.cpp Normal file
View File

@ -0,0 +1,826 @@
#include "mainUi.h"
#include <QDebug>
#include <QThread>
#include <QVBoxLayout>
#include <QTimer>
#include "UiTools.h"
#include "UiConfig.h"
#include <QApplication>
SplashScreenWithMsg::SplashScreenWithMsg(const int languageType)
{
m_label_msg = new QLabel(this);
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText,QColor(0x0e, 0xbc, 0xf8, 0xFF));
QFont ft;
//need to adjust font size
m_label_msg->setText(tr("人脸识别终端"));
int fontSize = 10;
if(UiConfig::SUPPORT_LANGUAGE_QUANTITY > languageType)
{
fontSize = UiConfig::DEV_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][languageType];
}
ft.setPointSize(fontSize);
m_label_msg->setFont(ft);
m_label_msg->setPalette(palette);
m_label_msg->setAlignment(Qt::AlignCenter);
m_label_msg->setFixedWidth(UiConfig::GetInstance()->getUiWidth());
m_label_msg->move(0, UiConfig::GetInstance()->getUiHeight() / 4);
setPixmap(QPixmap(UiConfig::GetInstance()->getWelcome()));
show();
}
SplashScreenWithMsg::~SplashScreenWithMsg()
{
}
mainUi::mainUi(const int languageType, bool needSetupWizard)
: m_reTryTimes(0), pwdAcceptDelay(false), m_isPasswordDialogShowed(false), m_settingUi(nullptr)
{
qDebug() << "mainUi()";
#if 0
setCursor(QCursor(Qt::BlankCursor));
#endif
UiConfig::GetInstance()->setLanguageType(languageType);
setFixedSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
//this->setWindowOpacity(1);
//this->setAttribute(Qt::WA_TranslucentBackground);
QPalette pal = palette();
pal.setColor(QPalette::Background, Qt::transparent);
setPalette(pal);
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText,Qt::black);
m_stackWidget_mainUi = new QStackedWidget(this);
//m_splash_startPage = new SplashScreenWithMsg(languageType);
m_splash_startPage = nullptr;
//计算启动时间
m_time_startupCost = new QTime();
m_time_startupCost->start();
if(needSetupWizard){
m_setupUi = new SetupUi(this);
connect(m_setupUi, SIGNAL(signalSetupDone()), this, SLOT(slotSetupDone()));
m_stackWidget_mainUi->addWidget(m_setupUi);
}
m_recoUi = new recoUi(this);
m_stackWidget_mainUi->addWidget(m_recoUi);
connect(m_recoUi, SIGNAL(signalShowSettingPage()), this, SLOT(slotShowSettingPage()));
connect(this, SIGNAL(signalShowRecoUiPage(int)), m_recoUi, SLOT(slotShowRecoUiPage(int)));
connect(this, SIGNAL(signalNoSuccessPage(int)), m_recoUi, SLOT(slotNoSuccessPage(int)));
connect(this, SIGNAL(signalSuccessPage(const int, const QString&)), \
m_recoUi, SIGNAL(signalSuccessPage(const int, const QString&)));
connect(this, SIGNAL(signalUpdatePlatformConnectionStatus(const int)), m_recoUi, SLOT(slotUpdatePlatformConnectionStatus(const int)));
connect(this, SIGNAL(signalShowUserCandidate(const QString&, const QStringList&)), this,
SLOT(slotShowUserCandidate(const QString&, const QStringList&)));
connect(this, SIGNAL(signalRecoUiswitchToType(int)), m_recoUi, SLOT(slotRecoUiswitchToType(int)));
connect(this, SIGNAL(signalCreateAndShowDevTestPage(const QString&)), this, SLOT(slotCreateAndShowDevTestPage(const QString&)));
connect(this, SIGNAL(signalDelayResetRecoUi()), this, SLOT(slotDelayResetRecoUi()));
connect(this, SIGNAL(signalShowAntiDismantleDetect(bool)), this, SLOT(slotShowAntiDismantleDetect(bool)));
connect(this, SIGNAL(signalShowCallDialPage()), m_recoUi, SLOT(slotShowCallDialPage()));
connect(this, SIGNAL(signalSetCallConsoleStatus(int, const QString&)), m_recoUi, SLOT(slotSetCallConsoleStatus(int, const QString&)));
connect(this, SIGNAL(signalShowUserItemChoose(const QStringList&)), this, SLOT(slotShowUserItemChoose(const QStringList&)));
#if 0
m_settingUi = new settingUi(this); //nullptr; //
m_stackWidget_mainUi->addWidget(m_settingUi);
connect(m_settingUi, SIGNAL(signalShowRecoPage()), this, SLOT(slotShowRecoPage()));
connect(m_settingUi, SIGNAL(signalChangeRecoUiMode()), m_recoUi, SIGNAL(signalChangeRecoUiMode()));
connect(m_settingUi, SIGNAL(signalUpdateRecoUiIpDisplay(bool)), m_recoUi, SIGNAL(signalUpdateRecoUiIpDisplay(bool)));
#endif
QVBoxLayout* vbLayout = new QVBoxLayout();
vbLayout->addWidget(m_stackWidget_mainUi);
vbLayout->setMargin(0);
setLayout(vbLayout);
m_timer = new QTimer(this);
connect( m_timer, SIGNAL(timeout()), this, SLOT(slotPwdAcceptDelayUpdate()) );
//int startPageShowTime = (START_SCREEN_TIMEOUT - m_time_startupCost->elapsed() > 0 ? START_SCREEN_TIMEOUT - m_time_startupCost->elapsed() : 1);
//QTimer::singleShot(startPageShowTime, this, SLOT(slotCloseStartPage()) );
slotCloseStartPage();
}
mainUi::~mainUi()
{
qDebug() << "~mainUi()";
if(nullptr != m_splash_startPage)
{
delete m_splash_startPage;
m_splash_startPage = nullptr;
}
}
void mainUi::createSettingUi()
{
if(m_settingUi){
return;
}
qDebug() << "create setting Ui";
m_settingUi = new settingUi(this);
m_stackWidget_mainUi->addWidget(m_settingUi);
connect(m_settingUi, SIGNAL(signalShowRecoPage()), this, SLOT(slotShowRecoPage()));
connect(m_settingUi, SIGNAL(signalChangeRecoUiMode()), m_recoUi, SIGNAL(signalChangeRecoUiMode()));
connect(m_settingUi, SIGNAL(signalUpdateRecoUiIpDisplay(bool)), m_recoUi, SIGNAL(signalUpdateRecoUiIpDisplay(bool)));
connect(this, SIGNAL(signalShowDevTestPage()), m_settingUi, SLOT(slotShowDevTestPage()));
qDebug() << "setting ui setBackstageUiinterface before ...";
m_settingUi->setBackstageUiinterface(m_backstageIf);
qDebug() << "setting ui setBackstageUiinterface after ...";
}
void mainUi::setBackstageUiinterface(BackstageInterfaceForUi* interface)
{
m_backstageIf = interface;
if(m_setupUi){
m_setupUi->setBackstageUiinterface(interface);
}
m_recoUi->setBackstageUiinterface(interface);
#if 0
m_settingUi->setBackstageUiinterface(interface);
#endif
updateAllOption();
}
void mainUi::slotCloseStartPage()
{
if(m_splash_startPage)
{
m_splash_startPage->finish(this);
delete m_splash_startPage;
m_splash_startPage = nullptr;
}
if(m_time_startupCost)
{
delete m_time_startupCost;
m_time_startupCost = nullptr;
}
show();
QTimer::singleShot(100, this, SLOT(slotShowRecoPage()));
}
void mainUi::slotShowRecoPage()
{
m_stackWidget_mainUi->setCurrentIndex(MAIN_UI_PAGE_RECOGNIZE);
m_recoUi->updateVideoWind();
if(!m_setupUi){
qDebug() << "m_backstageIf->startIdentyState()";
m_backstageIf->startIdentyState();
}
keyboard::preLoad();
}
int mainUi::settingPageAuthentication(const QString& dialogTitle, const QString& okBtn, const QString& cancelBtn, bool overtimeClose)
{
if(pwdAcceptDelay){
InfoDialog(tr("由于之前多次密码验证错误,请稍后再重试!"), m_settingUi, tr("知道了"), 30000).exec();
return -1;
}
if(m_isPasswordDialogShowed){
qDebug() << "isPasswordDialogShowed";
return -1;
}
m_isPasswordDialogShowed = true;
m_backstageIf->stopIdentyState();
QString userInput;
QString devId(tr("设备编码:"));
char buf[64] = {'\0'};
if(0 == m_backstageIf->getDeviceId(buf, sizeof(buf))){
devId += buf;
}
do{
PasswordDialog pwd_check(dialogTitle, tr("admin"), overtimeClose ? UiConfig::NO_OPERATION_OVERTIME_RETURN * 1000 : 0,
m_settingUi, userInput, devId, okBtn, cancelBtn);
//connect(&pwd_check, SIGNAL(signalRestoreFactory()), m_settingUi, SLOT(slotRestoreFactory()));
int ret = pwd_check.exec();
if(QDialog::Rejected == ret){
slotShowRecoPage();
m_isPasswordDialogShowed = false;
return -1;
}
userInput = pwd_check.getPwd();
#if 0
if(0 == userInput.compare(SPECIAL_PWD_1))
{
emit signalShowLogoChooseDialogBySpecialPwd();
emit signalResetRecoUi();
reOpen = false;
}
else{
#endif
if(0 == m_backstageIf->verifyFactorySettingPwd(userInput.toStdString().c_str())){
emit signalResetRecoUi();
m_isPasswordDialogShowed = false;
return 0;
}else {
InfoDialog(tr("密码错误,请重试"), m_settingUi).exec();
if(overtimeClose && ++m_reTryTimes >= RETRY_TIMES_MAX_PER_GROUP){
m_reTryTimes = 0;
pwdAcceptDelay = true;
m_timer->start(PWD_ACCEPT_DELAY_TIME);
slotShowRecoPage();
m_isPasswordDialogShowed = false;
return -1;
}
}
}while(true);
return -1;
}
void mainUi::slotShowSettingPage()
{
if(m_backstageIf->isDevSettingDisable()){
#if 0
m_backstageIf->stopIdentyState();
InfoDialog(tr("设备设置页面已被禁用!"), m_settingUi, tr("知道了"), 30000).exec();
m_backstageIf->startIdentyState();
#endif
return;
}
if(0 == settingPageAuthentication(tr("请输入密码"), tr("确定"), tr("取消"), true)){
//m_settingUi->reset();
m_stackWidget_mainUi->setCurrentIndex(MAIN_UI_PAGE_SETTING);
}
}
void mainUi::slotPwdAcceptDelayUpdate()
{
pwdAcceptDelay = false;
}
void mainUi::slotUpdateIp()
{
if(m_settingUi){
m_settingUi->update_IpBar();
}
if(m_recoUi){
m_recoUi->update_IpBar();
}
}
//设置接口后刷新页面
void mainUi::updateAllOption()
{
}
//ui接口
long long mainUi::getUiVersion()
{
return UiConfig::UI_VERSION;
}
//switch from standby to reco
void mainUi::showRecoMsgReco()
{
//qDebug()<<"void mainUi::showRecoMsgReco()";
emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalNoSuccessPage(GLOBAL_RECO_IN);
}
void mainUi::showRecoMsgRetry()
{
//qDebug()<<"void mainUi::showRecoMsgRetry()";
emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalNoSuccessPage(GLOBAL_RECO_CHECK);
}
void mainUi::showRecoMsgFail(int failType)
{
//qDebug()<<"void mainUi::showRecoMsgFail()" << failType;
GLOBAL_RECO_STATE state = (GLOBAL_RECO_STATE)(GLOBAL_RECO_END_NO + failType);
if(state >= GLOBAL_RECO_END_NO && failType <= GLOBAL_RECO_SHOW_QRCODE)
{
emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalNoSuccessPage(state);
}
}
void mainUi::notifyFaceInfo(const bool faceAvailable)
{
//qDebug()<<"void mainUi::notifyFaceInfo():" << faceAvailable;
if(!faceAvailable){ //不绘制扫描线,只处理人脸离开复位情况
emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalDrawScanner(GLOBAL_RECO_IN_SCANNER, faceAvailable);
}
}
void mainUi::showRecoSuccess(const char* name)
{
//qDebug()<<"void mainUi::showRecoSuccess()";
emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
if (name){
emit signalSuccessPage(GLOBAL_RECO_END_OK, QString(name));
}
}
void mainUi::showRecoMsgIDFail()
{
emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalNoSuccessPage(GLOBAL_RECO_ID_FAILED);
}
void mainUi::showUnauthorizedPage()
{
emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalNoSuccessPage(GLOBAL_RECO_BEGIN_AUTH);
}
void mainUi::showScreenSaverPage()
{
emit signalShowRecoUiPage(RECO_UI_PAGE_SCREENSAVER);
}
int mainUi::showFaceImg(const unsigned char *imgData, const int imgLen)
{
//qDebug()<<"void mainUi::showFaceImg()";
if(imgData == nullptr)
return -1;
emit signalShowAddFaceImg(imgData, imgLen);
return 0;
}
void mainUi::updatePlatformConnectionStatus(const PLATFORM_CONNECTION_STATUS_E status)
{
emit signalUpdatePlatformConnectionStatus(static_cast<int>(status));
}
void mainUi::showRecoMsgMoveForehead()
{
//qDebug() << "showRecoMsgMoveForehead()";
emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalNoSuccessPage(GLOBAL_RECO_TEMP_REQ);
}
void mainUi::showRecoMsgForeheadNormalTemp(const float temp, const bool isC) //显示正常温度
{
//qDebug() << "showRecoMsg Normal Temp";
emit signalShowForeheadNormalTemp(temp, isC);
}
void mainUi::showRecoMsgForeheadAbnormalTemp(const float temp, const bool isHigh, const bool isC) //显示异常温度
{
//qDebug() << "showRecoMsg Abnormal Temp:" << isHigh;
emit signalShowForeheadAbnormalTemp(temp, isHigh, isC);
}
void mainUi::showRecoMsgReadTempFailed() //体温检测失败
{
//qDebug() << "showRecoMsgRead Temp Failed";
emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalNoSuccessPage(GLOBAL_RECO_READ_TEMP_FAILED);
}
void mainUi::showRecoMsgNoMaskWarn() //请戴口罩
{
//qDebug() << "showRecoMsgNoMaskWarn";
//emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalNoSuccessPage(GLOBAL_RECO_MASK_REQ);
}
void mainUi::showRecoMsgMaskOk()
{
//qDebug() << "showRecoMsgMaskOk";
//emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalNoSuccessPage(GLOBAL_RECO_MASK_OK);
}
void mainUi::showRecoMsgMaskWarn()
{
emit signalNoSuccessPage(GLOBAL_RECO_TAKE_OFF_MASK);
}
void mainUi::showRecoMsgNoEntry(const bool noEntry)
{
//qDebug() << "showRecoMsgNoEntry";
//emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
if(noEntry)
emit signalNoSuccessPage(GLOBAL_RECO_NO_ENTRY);
else {
emit signalNoSuccessPage(GLOBAL_RECO_CLEAR_NO_ENTRY);
}
//测试QRcode
/*
static int i = 0;
emit signalShowQRCodeMsg(i);
i++;
if(i > 5) i = 0;
*/
}
void mainUi::turnOffScanLine()
{
//qDebug() << "turnOffScanLine";
//emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalNoSuccessPage(GLOBAL_RECO_CLOSE_SCANLINE);
}
void mainUi::clearLocalFacePage()
{
emit signalClearLocalFacePage();
}
void mainUi::updateLogo(const enLogo option)
{
emit signalUpdateLogo(static_cast<int>(option));//切换ui时logo没有显示没有信号更新---------------------------------------------------------------------------------------------------------------
}
void mainUi::showQRCodeMsg(const QRCode_Msg_E msg)
{
emit signalShowQRCodeMsg(static_cast<int>(msg));
}
void mainUi::showQRCodeReco()
{
//qDebug() << "showQRCodeReco";
emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalNoSuccessPage(GLOBAL_RECO_SHOW_QRCODE_RECO);
}
void mainUi::showFaceReco()
{
//qDebug() << "showFaceReco";
emit signalShowRecoUiPage(RECO_UI_PAGE_RECOGNIZE);
emit signalNoSuccessPage(GLOBAL_RECO_SHOW_FACE_RECO);
}
void mainUi::updateRecoUiIp()
{
m_recoUi->update_IpBar();
}
void mainUi::showFeatureUpdateProgress(const unsigned current, const unsigned all)
{
emit signalShowFeatureUpdateProgress(current, all);
}
void mainUi::closeFeatureUpdateProgress()
{
emit signalCloseFeatureUpdateProgress();
}
void mainUi::showRecoUiMask(int maskType)
{
int type = 0;
if(0 == maskType){ //normal
//if(UiConfig::GetInstance()->isFaceFrameShowByTempExist()){
type = 1; // bg
//}
}else if(1 == maskType){ //TempCalibra
type = 2; //TempCalibra
}else if(2 == maskType){ //day mode
//if(UiConfig::GetInstance()->isFaceFrameShowByTempExist()){
type = 1; //bg
//}
}else if(3 == maskType){ //night mode
type = 3; //night mode
}
emit signalShowRecoUiMask(type);
}
void mainUi::showNotiMsg(const char *msg, int color)
{
//qDebug()<<"void mainUi::showRecoSuccess()";
if (msg)
{
emit signalNotiMsg(GLOBAL_RECO_SHOW_NOTI_MSG, QString(msg), color);
}
}
void mainUi::updateScreenSaver()
{
m_stackWidget_mainUi->setCurrentIndex(MAIN_UI_PAGE_RECOGNIZE);
QCoreApplication::processEvents();
emit signalUpdateScreenSaver();
}
int mainUi::grabScreen(const QString& picName, int rotate)
{
if(UiConfig::GetInstance()->isRkDevice()){
QMatrix matrix;
matrix.rotate(rotate);
QPixmap pixmap = grab(QRect(0, 0, UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight()));
pixmap.transformed(matrix, Qt::SmoothTransformation).save(picName, "jpg");
}
else{
GrabFullScreen(picName, rotate); //A038选择角度问题
}
return 0;
}
int mainUi::switchToRecoUi()
{
emit signalShowRecoUiPage(RECO_UI_PAGE_WORK_MODE);
return 0;
}
int mainUi::showCenterMsg(const char* msg, int type)
{
if(msg){
emit signalCenterMsg(GLOBAL_RECO_SHOW_CENTER_MSG + type, QString(msg));
}
if(strlen(msg)){
emit signalDelayResetRecoUi();
}
QCoreApplication::processEvents();
return 0;
}
void mainUi::showDrawPage()
{
emit signalShowRecoUiPage(RECO_UI_PAGE_DRAW);
}
void mainUi::showCursorSwitch(bool sw)
{
QApplication::setOverrideCursor(sw ? Qt::ArrowCursor : Qt::BlankCursor);
}
int mainUi::showUserPwd(const char* name)
{
emit signalShowUserPwd(QString(name));
return 0;
}
void mainUi::setPwdButton(bool visible)
{
emit signalSetUserPwdButton(visible);
}
void mainUi::showPwdUiPersonName(const char* name)
{
emit signalShowPwdUiPersonName(name);
}
void mainUi::showUserPwdError(int type, int color)
{
emit signalShowUserPwdError(type, color);
}
void mainUi::showUserCandidate(const char* title, const char** opns, int opnsNum)
{
if(nullptr == title || nullptr == opns || opnsNum <= 0){
return;
}
QStringList options;
for(int i=0; i<opnsNum; i++){
options << opns[i];
}
emit signalShowUserCandidate(title, options);
}
void mainUi::showDevTestPage(const char* devCfgMsg)
{
emit signalCreateAndShowDevTestPage(devCfgMsg ? QString(devCfgMsg) : QString());
}
void mainUi::setDevTestMesAddrAndProdNoText(const char* text)
{
emit signalDevTestMesAddrAndProdNoText(QString(text));
}
void mainUi::setDevTestPcbSeqText(const char* text)
{
emit signalDevTestPcbSeqText(QString(text));
}
void mainUi::setDevTestConfigInfo(const char* text)
{
emit signalDevTestConfigInfo(QString(text));
}
void mainUi::showPassResult(bool pass)
{
emit signalShowFinalResult(pass);
}
void mainUi::showRecoUiColorFaceSnapshot(const char* path)
{
emit signalShowRecoUiColorFaceSnapshot(QString(path));
}
void mainUi::showRecoUiColorFaceSnapshot(const unsigned char* jpgDate, int len)
{
emit signalShowRecoUiColorFaceSnapshot(jpgDate, len);
}
void mainUi::showOrHideFaceFrame(bool show)
{
emit signalShowOrHideFaceFrame(show);
}
void mainUi::slotShowUserCandidate(const QString& title, const QStringList& opns)
{
m_backstageIf->pauseDataFlow();
StyleItemChooseDialog dlg(title, opns, m_backstageIf);
int ret = dlg.exec();
if(QDialog::Accepted == ret){
m_backstageIf->resetDecisionCenterTimer();
const int userChoose = dlg.getChoosedIndex();
//qDebug() << "user choose:" << userChoose;
m_backstageIf->candidateChoosedInPopupWindow(userChoose);
}
else if(QDialog::Rejected == ret){
m_backstageIf->candidateChoosedInPopupWindow(-1);
}
//m_backstageIf->resumeDataFlow();
}
void mainUi::slotShowSettingUi()
{
m_stackWidget_mainUi->setCurrentIndex(MAIN_UI_PAGE_SETTING);
}
void mainUi::slotSetupDone()
{
m_stackWidget_mainUi->removeWidget(m_setupUi);
delete m_setupUi;
m_setupUi = nullptr;
m_backstageIf->startIdentyState();
}
void mainUi::slotScreenTouch()
{
createSettingUi();
}
void mainUi::slotCreateAndShowDevTestPage(const QString& devCfgMsg)
{
MsgDialog msgdlg(tr("正在加载测试页面,请稍候..."));
msgdlg.show();
QCoreApplication::processEvents();
createSettingUi();
emit signalShowDevTestPage();
emit signalDevTestConfigInfo(devCfgMsg);
}
void mainUi::slotDelayResetRecoUi()
{
QTimer::singleShot(200, this, [this]{notifyFaceInfo(false);});
}
void mainUi::slotShowAntiDismantleDetect(bool upload)
{
qDebug() << "slotShowAntiDismantleDetect";
m_backstageIf->setAntiDemolitionAvail(true, upload);
if(0 == settingPageAuthentication(tr("检测到强拆设备"), tr("解除锁定"), "", false)){
m_backstageIf->startIdentyState();
m_backstageIf->setAntiDemolitionAvail(false, false);
}
}
void mainUi::recoUiswitchToType(int type)
{
emit signalRecoUiswitchToType(type);
}
void mainUi::qrcodeFastCfgResult(bool isSuccessed)
{
emit signalQrcodeFastCfgResult(isSuccessed);
}
void mainUi::icCardResult(const char *icCardNum)
{
emit signalIcCardResult(QString(icCardNum));
}
bool mainUi::isInSettingUi()
{
return (m_stackWidget_mainUi->currentIndex() == MAIN_UI_PAGE_SETTING);
}
void mainUi::updateAdScreen()
{
emit signalUpdateAdWidget();
}
void mainUi::showHealthMsg(int type, float temp, const char * msg, bool pass,
const unsigned char* jpgDate, int jpgLen, const char* tripCity, const char* failReason, int bgColor, int displayTime)
{
emit signalShowHealthMsg(type, temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor, displayTime);
if(type > 0){
emit signalDelayResetRecoUi();
}
QCoreApplication::processEvents();
}
void mainUi::showHealthCodeAuthStatus(int status)
{
emit signalShowHealthCodeAuthStatus(status);
}
void mainUi::showAntiDismantleDetect(bool upload)
{
if(m_backstageIf->getAntiDemolitionSw()){
emit signalShowAntiDismantleDetect(upload);
}
}
void mainUi::showSceneResult(int result, const char* resultText, const char* businessInfo, int displayTime)
{
if(!UiConfig::GetInstance()->isRecoUiStyleScene()){
return;
}
emit signalShowSceneResult(result, resultText, businessInfo, displayTime);
QCoreApplication::processEvents();
}
void mainUi::updatePersonNumAccessed(int personAccess, int personAll)
{
emit signalUpdatePersonNumAccessed(personAccess, personAll);
}
bool mainUi::isScenePassing()
{
return m_recoUi->isScenePassing();
}
void mainUi::setSceneUiPersonCountType(int type)
{
emit signalSetSceneUiPersonCountType(type);
}
void mainUi::updateSceneUiPersonCount(int count)
{
emit signalUpdateSceneUiPersonCount(count);
}
void mainUi::showCallDialPage()
{
emit signalShowCallDialPage();
}
void mainUi::setCallConsoleStatus(int status, const char* tip)
{
emit signalSetCallConsoleStatus(status, tip);
}
void mainUi::setDndMode(bool enabled, const std::chrono::system_clock::time_point &time) {
m_recoUi->setDndMode(enabled,time);
}
void mainUi::showRecoUiDevIdAndVer(bool show)
{
emit signalShowRecoUiDevIdAndVer(show);
}
void mainUi::showUserItemChoose(const std::vector<std::string>& items)
{
QStringList options;
for(const auto& i : items){
options << QString(i.c_str());
}
emit signalShowUserItemChoose(options);
}
void mainUi::slotShowUserItemChoose(const QStringList& opns)
{
m_backstageIf->stopIdentyState();
StyleItemChooseDialog dlg("请选择", opns, m_backstageIf);
int ret = dlg.exec();
if(QDialog::Accepted == ret){
m_backstageIf->resetDecisionCenterTimer();
const int userChoose = dlg.getChoosedIndex();
//qDebug() << "user choose:" << userChoose;
m_backstageIf->startIdentyState();
m_backstageIf->userItemChoose(userChoose);
}else if(QDialog::Rejected == ret){
m_backstageIf->startIdentyState();
m_backstageIf->userItemChoose(-1);
}
}

255
Linguist/mainUi/mainUi.h Normal file
View File

@ -0,0 +1,255 @@
#ifndef MAINUI_H
#define MAINUI_H
#include <QWidget>
#include <QStackedWidget>
#include <QSplashScreen>
#include <QTime>
#include <QTranslator>
#include "UiInterfaceForBackstage.h"
#include "settingUi.h"
#include "recoUi.h"
#include "BackstageInterfaceForUi.h"
#include "UiCommon.h"
#include "UiConfig.h"
#include "SetupUi.h"
class SplashScreenWithMsg : public QSplashScreen
{
Q_OBJECT //多语言
public:
explicit SplashScreenWithMsg(const int languageType);
~SplashScreenWithMsg();
private:
QLabel* m_label_msg;
};
class mainUi : public UiInterfaceForBackstage
{
Q_OBJECT
public:
static const int START_SCREEN_TIMEOUT = UiConfig::START_SCREEN_TIMEOUT;
static const int PWD_ACCEPT_DELAY_TIME = UiConfig::PWD_ACCEPT_DELAY_TIME * 60 * 1000; //min to ms
static const int RETRY_TIMES_MAX_PER_GROUP = UiConfig::RETRY_TIMES_MAX_PER_GROUP;
explicit mainUi(const int languageType, bool needSetupWizard);
~mainUi();
void createSettingUi();
virtual void setBackstageUiinterface(BackstageInterfaceForUi* interface);
//UI提供给后台的接口
virtual long long getUiVersion();
virtual void showUnauthorizedPage();
virtual void showScreenSaverPage();
virtual void showRecoMsgReco();
virtual void showRecoMsgRetry();
virtual void showRecoMsgFail(int failType);
virtual void notifyFaceInfo(const bool faceAvailable);
virtual void showRecoSuccess(const char* name);
virtual void showRecoMsgIDFail();
virtual int showFaceImg(const unsigned char *imgData, const int imgLen);
virtual void updatePlatformConnectionStatus(const PLATFORM_CONNECTION_STATUS_E);
virtual void showRecoMsgMoveForehead(); //移动到额头区
virtual void showRecoMsgForeheadNormalTemp(const float temp, const bool isC); //显示正常温度
virtual void showRecoMsgForeheadAbnormalTemp(const float temp, const bool isHigh, const bool isC); //显示异常温度
virtual void showRecoMsgReadTempFailed(); //体温检测失败
virtual void showRecoMsgNoMaskWarn(); //请戴口罩
virtual void showRecoMsgMaskOk(); //口罩检测通过
virtual void showRecoMsgMaskWarn();
virtual void showRecoMsgNoEntry(const bool); //显示禁止通行
virtual void turnOffScanLine();
virtual void clearLocalFacePage();
virtual void updateLogo(const enLogo);
virtual void showQRCodeMsg(const QRCode_Msg_E);
virtual void showQRCodeReco();
virtual void showFaceReco();
virtual void updateRecoUiIp();
virtual void showFeatureUpdateProgress(const unsigned current, const unsigned all);
virtual void closeFeatureUpdateProgress();
virtual void showRecoUiMask(int maskType);
virtual void showNotiMsg(const char *msg, int color);
virtual void updateScreenSaver();
virtual int grabScreen(const QString& picName, int rotate = 0);
virtual int switchToRecoUi();
virtual int showCenterMsg(const char* msg, int type);
virtual int showUserPwd(const char* name);
void showDrawPage();
void showCursorSwitch(bool sw);
void setPwdButton(bool visible);
void showPwdUiPersonName(const char* name);
void showUserPwdError(int type, int color);
void showUserCandidate(const char* title, const char** opns, int opnsNum);
void showDevTestPage(const char* devCfgMsg);
void setDevTestMesAddrAndProdNoText(const char* text);
void setDevTestPcbSeqText(const char* text);
void setDevTestConfigInfo(const char* text);
void showOrHideFaceFrame(bool show);
void showPassResult(bool pass);
void showRecoUiColorFaceSnapshot(const char* path);
void showRecoUiColorFaceSnapshot(const unsigned char* jpgDate, int len);
void recoUiswitchToType(int type);
void qrcodeFastCfgResult(bool isSuccessed);
void icCardResult(const char* icCardNum);
bool isInSettingUi();
void updateAdScreen();
void showHealthMsg(int type, float temp, const char * msg, bool pass, const unsigned char* jpgDate,
int jpgLen, const char* tripCity, const char* failReason, int bgColor, int displayTime);
void showHealthCodeAuthStatus(int status);
void showAntiDismantleDetect(bool upload);
void showSceneResult(int result, const char* resultText, const char* businessInfo, int displayTime);
void updatePersonNumAccessed(int personAccess, int personAll);
bool isScenePassing();
void setSceneUiPersonCountType(int type);
void updateSceneUiPersonCount(int count);
void showCallDialPage();
void setCallConsoleStatus(int status, const char* tip);
void setDndMode(bool enabled, const std::chrono::system_clock::time_point &time) final;
void showRecoUiDevIdAndVer(bool show);
void showUserItemChoose(const std::vector<std::string>& items);
signals:
void signalShowRecoUiPage(const int);
void signalShowRecoState(const int);
void signalNoSuccessPage(const int);
void signalSuccessPage(const int nPage, const QString& name);
void signalDrawScanner(const int nPage, const bool faceAvailable);
void signalShowAddFaceImg(const unsigned char* imgData, int len);
void signalUpdatePlatformConnectionStatus(const int);
void signalInteraction(const INTERACION_OPTION& interaction, int nSelectRes); //后面去掉
void signalShowForeheadNormalTemp(const float temp, const bool isC);
void signalShowForeheadAbnormalTemp(const float temp, const bool isHigh, const bool isC);
void signalClearLocalFacePage();
void signalShowLogoChooseDialogBySpecialPwd();
void signalUpdateLogo(const int);
void signalShowQRCodeMsg(const int);
void signalResetRecoUi(); //在识别界面进入设置界面时复位识别界面,否则可能导致扫描线定时器一直在被调用
void signalShowFeatureUpdateProgress(const unsigned current, const unsigned all);
void signalCloseFeatureUpdateProgress();
void signalShowRecoUiMask(int maskType);
void signalNotiMsg(const int nPage, const QString& msg, int color);
void signalUpdateScreenSaver();
void signalCenterMsg(const int nPage, const QString& msg);
void signalShowUserPwd(const QString& name);
void signalShowUserPwdButton();
void signalSetUserPwdButton(bool visible);
void signalShowPwdUiPersonName(const QString& name);
void signalShowUserPwdError(int type, int color);
void signalShowUserCandidate(const QString& title, const QStringList& opns);
void signalCreateAndShowDevTestPage(const QString& devCfgMsg);
void signalDevTestMesAddrAndProdNoText(const QString& text);
void signalDevTestPcbSeqText(const QString& text);
void signalDevTestConfigInfo(const QString& text);
void signalShowOrHideFaceFrame(bool show);
void signalShowFinalResult(bool pass);
void signalShowDevTestPage();
void signalShowRecoUiColorFaceSnapshot(const QString& path);
void signalShowRecoUiColorFaceSnapshot(const unsigned char* jpgDate, int len);
void signalRecoUiswitchToType(int type);
void signalQrcodeFastCfgResult(bool isSuccessed);
void signalIcCardResult(const QString& icCard);
void signalUpdateAdWidget();
void signalShowHealthMsg(int type, float temp, const QString& msg, bool pass, const unsigned char* jpgDate,
int jpgLen, const QString& tripCity, const QString& failReason, int bgColor, int displayTime);
void signalShowHealthCodeAuthStatus(int status);
void signalDelayResetRecoUi();
void signalShowAntiDismantleDetect(bool);
void signalShowSceneResult(int result, const QString& resultText, const QString& businessInfo, int displayTime);
void signalUpdatePersonNumAccessed(int personAccess, int personAll);
void signalSetSceneUiPersonCountType(int type);
void signalUpdateSceneUiPersonCount(int count);
void signalShowCallDialPage();
void signalSetCallConsoleStatus(int status, const QString& text);
void signalShowCallBtn(bool callButton, bool videoButton);
void signalShowRecoUiDevIdAndVer(bool);
void signalShowUserItemChoose(const QStringList& opns);
public slots:
void slotCloseStartPage();
void slotShowRecoPage();
void slotShowSettingPage();
void slotPwdAcceptDelayUpdate();
void slotUpdateIp(); //刷新识别界面的IP设置界面没有IP显示了后面去掉
void slotShowUserCandidate(const QString& title, const QStringList& opns);
void slotShowSettingUi();
void slotSetupDone();
void slotScreenTouch();
void slotCreateAndShowDevTestPage(const QString& devCfgMsg);
void slotDelayResetRecoUi();
void slotShowAntiDismantleDetect(bool);
void slotShowUserItemChoose(const QStringList& opns);
private:
typedef enum
{
MAIN_UI_PAGE_RECOGNIZE,
MAIN_UI_PAGE_SETTING
}MAIN_UI_PAGE_E;
QStackedWidget* m_stackWidget_mainUi;
//QSplashScreen *m_splash_startPage;
SplashScreenWithMsg *m_splash_startPage;
QTime* m_time_startupCost;
SetupUi* m_setupUi = nullptr;
settingUi* m_settingUi = nullptr;;
recoUi* m_recoUi;
QTranslator *m_translatorEnglish;
//密码多次输错处理
QTimer *m_timer;
int m_reTryTimes;
bool pwdAcceptDelay;
bool m_isPasswordDialogShowed;
void updateAllOption();
int settingPageAuthentication(const QString& dialogTitle, const QString& okBtn, const QString& cancelBtn, bool overtimeClose);
//void getBackImgPath(QString& imgPath);
//void getSaverPath(QString &imgPath);
};
#endif // MAINUI_H

607
Linguist/recoUi/recoUi.cpp Normal file
View File

@ -0,0 +1,607 @@
#include "recoUi.h"
#include <QDebug>
#include <QVBoxLayout>
#include <QPainter>
#include "UiTools.h"
#include "UiInterfaceForBackstage.h"
#include "mainUi.h"
statusbarUi::statusbarUi(QWidget *parent) : MyWidgetWithMainStyleColor(parent)
{
qDebug() << "statusbarUi()";
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText,Qt::white);
m_label_ip = new QLabel(this);
//m_label_ip->setText("192.168.10.106");
m_label_ip->setPalette(palette);
m_label_ip->installEventFilter(this);
m_label_platform = new QLabel(this);
QPixmap pm(":/res/image/disconnect.png");
pm = pm.scaled(20, 20, Qt::KeepAspectRatio);
m_label_platform->setPixmap(pm);
// m_label_wifi = new QLabel(this);
// pm.load(":/res/image/Wifi.png");
// pm = pm.scaled(20, 20, Qt::KeepAspectRatio);
// m_label_wifi->setPixmap(pm);
// m_label_4g = new QLabel(this);
// pm.load(":/res/image/4G.png");
// pm = pm.scaled(20, 20, Qt::KeepAspectRatio);
// m_label_4g->setPixmap(pm);
m_label_time = new QLabel(this);
// m_label_time->setText("12:34");
m_label_time->setPalette(palette);
qDebug()<<"recoUi _labelTime = "<<m_label_time;
_timerUpdate = new TimerUpdate(m_label_time, this);
m_label_time->installEventFilter(this);
QHBoxLayout* hbLayout = new QHBoxLayout();
hbLayout->addWidget(m_label_ip, 20, Qt::AlignLeft);
hbLayout->addWidget(m_label_platform, 1, Qt::AlignRight);
// hbLayout->addWidget(m_label_wifi, 1, Qt::AlignRight);
// hbLayout->addWidget(m_label_4g, 1, Qt::AlignRight);
hbLayout->addWidget(m_label_time, 1, Qt::AlignRight);
setLayout(hbLayout);
}
statusbarUi:: ~statusbarUi()
{
if(nullptr != _timerUpdate)
{
delete _timerUpdate;
}
qDebug() << "~statusbarUi()";
}
void statusbarUi::updatePlatformConnectionStatus(const int status)
{
QPixmap pm;
switch(status)
{
case UiInterfaceForBackstage::PLATFORM_CONNECTION_STATUS_DISCONNECTED:
pm.load(":/res/image/disconnect.png");
break;
case UiInterfaceForBackstage::PLATFORM_CONNECTION_STATUS_CONNECTED:
pm.load(":/res/image/display.png");
break;
case UiInterfaceForBackstage::PLATFORM_CONNECTION_STATUS_LOGGED:
pm.load(":/res/image/display.png");
break;
default:
break;
}
m_label_platform->setPixmap(pm.scaled(20, 20, Qt::KeepAspectRatio));
}
void statusbarUi::updateIpLabel(QString &ipStr)
{
if(m_label_ip)
{
m_label_ip->setText(ipStr);
}
}
//bool statusbarUi::eventFilter(QObject *watched, QEvent *event)
//{
// if( ( m_label_ip == watched ) && (event->type() == QEvent::MouseButtonPress) )
// {
// emit signalChangeRecoPage();
// }
// if( ( m_label_time == watched ) && (event->type() == QEvent::MouseButtonPress) )
// {
// emit signalTestChangePage();
// }
//}
recoUi::recoUi(QWidget *parent) : WidgetWithBackstageInterface(parent)
{
qDebug() << "recoUi()";
m_stack_recoPage = new QStackedWidget(this);
// m_statusbar = new statusbarUi(this);
if(UiConfig::GetInstance()->isRecoUiStyleColor()){
m_recoPageColor = new recoUiRecognizeTypeColor(false, false, false, this);
m_stack_recoPage->addWidget(m_recoPageColor);
}else if (UiConfig::GetInstance()->isRecoUiStyleAd()){
m_recoPageAd = new recoUiRecognizeTypeAd(false, false, false, this);
m_stack_recoPage->addWidget(m_recoPageAd);
}
#if 0
else if(UiConfig::GetInstance()->isRecoUiStyleScene()){
m_recoPageScene = new recoUiRecognizeScene(false, false, this);
m_stack_recoPage->addWidget(m_recoPageScene);
}
#endif
else {
m_recoPage = new recoUiRecognize(false, false, false, this);
m_stack_recoPage->addWidget(m_recoPage);
}
m_ssPage = new recoUiScreensaver(0, this);
m_stack_recoPage->addWidget(m_ssPage);
m_pwdPage = new recoUiPassword(this);
m_stack_recoPage->addWidget(m_pwdPage);
m_healthMsgPage = new recoUiHealthCode(this);
m_stack_recoPage->addWidget(m_healthMsgPage);
m_sceneResult = new recoUiSceneResult(this);
m_stack_recoPage->addWidget(m_sceneResult);
m_callDialPage = new recoUiCallDial(this);
m_stack_recoPage->addWidget(m_callDialPage);
m_callConsolePage = new recoUiCallConsole(this);
m_stack_recoPage->addWidget(m_callConsolePage);
if(UiConfig::GetInstance()->isRkDevice()){
DrawPage* draw = new DrawPage(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight(), this);
m_stack_recoPage->addWidget(draw);
}
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimer()));
QVBoxLayout* vbLayout = new QVBoxLayout();
vbLayout->addWidget(m_stack_recoPage, 90);
//vbLayout->addWidget(m_statusbar, 1);
vbLayout->setMargin(0);
vbLayout->setSpacing(0);
setLayout(vbLayout);
connect(parent, SIGNAL(signalUpdateScreenSaver()), m_ssPage, SLOT(slotUpdateScreenSaver()));
connect(parent, SIGNAL(signalShowUserPwd(const QString&)), this, SLOT(slotShowPasswordPage(const QString&)));
connect(m_pwdPage, SIGNAL(signalShowRecognizePage()), this, SLOT(slotShowRecognizePage()));
connect(parent, SIGNAL(signalShowPwdUiPersonName(const QString&)), m_pwdPage, SLOT(slotShowPwdUiPersonName(const QString&)));
connect(parent, SIGNAL(signalShowUserPwdError(int, int)), m_pwdPage, SLOT(slotShowUserPwdError(int, int)));
connect(parent, SIGNAL(signalSetUserPwdButton(bool)), this, SLOT(slotSaveRecoUiPwdBtnStatus(bool)));
connect(parent, SIGNAL(signalShowRecoUiMask(int)), this, SLOT(slotSaveRecoUiNightModeStatus(int)));
connect(parent, SIGNAL(signalUpdateAdWidget()), this, SLOT(slotUpdateAdScreen()));
connect(parent, SIGNAL(signalShowHealthMsg(int, float, const QString&, bool, const unsigned char*, int, const QString&, const QString&, int, int)),
this, SLOT(slotShowHealthMsg(int, float, const QString&, bool, const unsigned char*, int, const QString&, const QString&, int, int)));
connect(parent, SIGNAL(signalShowSceneResult(int, const QString&, const QString&, int)),
this, SLOT(slotShowSceneResult(int, const QString&, const QString&, int)));
connect(parent, SIGNAL(signalUpdatePersonNumAccessed(int, int)), this, SLOT(slotUpdatePersonNumAccessed(int, int)));
connect(parent, SIGNAL(signalSetSceneUiPersonCountType(int)), this, SLOT(slotSetSceneUiPersonCountType(int)));
connect(parent, SIGNAL(signalUpdateSceneUiPersonCount(int)), this, SLOT(slotUpdateSceneUiPersonCount(int)));
connect(m_callDialPage, SIGNAL(signalShowRecognizePage()), this, SLOT(slotShowRecognizePage()));
connect(m_callConsolePage, SIGNAL(signalShowRecognizePage()), this, SLOT(slotShowRecognizePage()));
connect(m_callDialPage, SIGNAL(signalCallBtnPressed(const QString&)), this, SLOT(slotShowCallConsolePage(const QString&)));
connect(m_callConsolePage, SIGNAL(signalCallAgain()), m_callDialPage, SLOT(slotCall()));
auto p = dynamic_cast<mainUi *>(parent);
if (p != nullptr) {
connect(p, &mainUi::signalShowCallBtn, this, &recoUi::slotShowCallBtn);
}
}
recoUi::~recoUi()
{
qDebug() << "~recoUi()";
}
void recoUi::setBackstageUiinterface(BackstageInterfaceForUi* interface)
{
m_backstageIf = interface;
if(m_recoPage){
m_recoPage->setBackstageUiinterface(m_backstageIf);
connectRecoPage(m_recoPage);
m_recoPage->setStyle(UiConfig::GetInstance()->isRecoUiStyleScene() ? 4 : 0);
}else if(m_recoPageColor){
m_recoPageColor->setBackstageUiinterface(m_backstageIf);
connectRecoPage(m_recoPageColor);
}else if(m_recoPageAd){
m_recoPageAd->setBackstageUiinterface(m_backstageIf);
connectRecoPage(m_recoPageAd);
QTimer::singleShot(1000, this, [this]{m_recoPageAd->setCamVideoWind();});
}
if (m_sceneResult != nullptr && m_backstageIf != nullptr) { // 初始化检票人数
m_sceneResult->setPersonCountType(m_backstageIf->getTicketModePeopleCountType());
m_sceneResult->setTicketCheckCount(-1, m_backstageIf->getTicketCheckCountToday());
}
#if 0
else if(m_recoPageScene){
connectRecoPage(m_recoPageScene);
m_recoPageScene->setBackstageUiinterface(m_backstageIf);
}
#endif
m_ssPage->setBackstageUiinterface(m_backstageIf);
m_pwdPage->setBackstageUiinterface(m_backstageIf);
m_healthMsgPage->setBackstageUiinterface(m_backstageIf);
m_callDialPage->setBackstageUiinterface(m_backstageIf);
m_callConsolePage->setBackstageUiinterface(m_backstageIf);
update_IpBar();
}
//statusbarUi *recoUi::getStatusInstance()
//{
// return m_statusbar;
//}
void recoUi::slotShowSettingPage()
{
emit signalShowSettingPage();
}
void recoUi::slotShowRecoUiPage(const int nPage)
{
int index = m_stack_recoPage->currentIndex();
if(nPage == RECO_UI_PAGE_WORK_MODE){
if(index == RECO_UI_PAGE_SCREENSAVER){
m_stack_recoPage->setCurrentIndex(RECO_UI_PAGE_RECOGNIZE);
}
return;
}else if(index == RECO_UI_PAGE_HEALTHCODE || index == RECO_UI_PAGE_SCENERESULT || index == RECO_UI_PAGE_CALL_DIAL || index == RECO_UI_PAGE_CALL_CONSOLE){
return;
}
m_stack_recoPage->setCurrentIndex(nPage);
}
void recoUi::slotUpdatePlatformConnectionStatus(int status) {
m_isPlatformConnected = (status == UiInterfaceForBackstage::PLATFORM_CONNECTION_STATUS_LOGGED);
if (m_callDialPage != nullptr) {
m_callDialPage->setPlatformConnected(status == UiInterfaceForBackstage::PLATFORM_CONNECTION_STATUS_LOGGED);
}
}
void recoUi::slotShowPasswordPage(const QString& name)
{
m_pwdPage->reset(name);
slotShowRecoUiPage(RECO_UI_PAGE_PASSWORD);
}
void recoUi::slotShowRecognizePage()
{
m_stack_recoPage->setCurrentIndex(RECO_UI_PAGE_RECOGNIZE);
m_backstageIf->startIdentyState();
}
void recoUi::update_IpBar()
{
if(nullptr == m_backstageIf)
{
return ;
}
#if 0
const int nSize = 128;
char buf[nSize] = "";
m_backstageIf->getIP(buf, nSize);
QString ipStr = buf;
m_statusbar->updateIpLabel(ipStr);
#endif
if(m_backstageIf){
emit signalUpdateRecoUiIpDisplay(m_backstageIf->getIpShowSw());
}
}
void recoUi::updateVideoWind()
{
QWidget *curWidget = m_stack_recoPage->currentWidget();
if(curWidget == m_recoPage){
m_recoPage->setCamVideoWind();
}else if(curWidget == m_recoPageColor){
m_recoPageColor->setCamVideoWind();
}else if(curWidget == m_recoPageAd){
m_recoPageAd->setCamVideoWind();
}
#if 0
else if(curWidget == m_recoPageScene){
m_recoPageScene->setCamVideoWind();
}
#endif
}
bool recoUi::isScenePassing()
{
return m_stack_recoPage->currentIndex() == RECO_UI_PAGE_SCENERESULT;//m_sceneResult->isPassing();
}
void recoUi::connectRecoPage(const QObject* recoPage)
{
connect(recoPage, SIGNAL(signalChangePage()), this, SLOT(slotShowSettingPage()));
connect(this, SIGNAL(signalNoSuccessPage(const int)), recoPage, SLOT(slotsNoSuccessPage(const int)));
connect(this, SIGNAL(signalSuccessPage(const int, const QString&)), recoPage, SLOT(slotsSuccessPage(const int, const QString&)));
connect(parent()->parent(), SIGNAL(signalDrawScanner(const int, const bool)), recoPage, SLOT(slotsDrawScanner(const int, const bool)));
connect(parent()->parent(), SIGNAL(signalInteraction(const INTERACION_OPTION& , int )),
recoPage, SLOT(slotsInteractionChange(const INTERACION_OPTION& , int )));
connect(parent()->parent(), SIGNAL(signalShowForeheadNormalTemp(const float, const bool)), recoPage, SLOT(slotShowNormalTemp(const float, const bool)));
connect(parent()->parent(), SIGNAL(signalShowForeheadAbnormalTemp(const float, const bool, const bool)), recoPage, SLOT(slotShowAbnormalTemp(const float, const bool, const bool)));
connect(parent()->parent(), SIGNAL(signalUpdateLogo(const int)), recoPage, SLOT(slotUpdateLogo(const int)));
connect(parent()->parent(), SIGNAL(signalUpdatePlatformConnectionStatus(const int)), recoPage, SLOT(slotUpdatePlatformConnectionStatus(const int)));
connect(parent()->parent(), SIGNAL(signalResetRecoUi()), recoPage, SLOT(slotsResetRecoUi()));
connect(parent()->parent(), SIGNAL(signalShowQRCodeMsg(int)), recoPage, SLOT(slotShowQRCodeMsg(int)));
connect(this, SIGNAL(signalChangeRecoUiMode()), recoPage, SLOT(slotChangeRecoUiMode()));
connect(this, SIGNAL(signalUpdateRecoUiIpDisplay(bool)), recoPage, SLOT(slotUpdateRecoUiIpDisplay(bool)));
connect(parent()->parent(), SIGNAL(signalShowFeatureUpdateProgress(const unsigned, const unsigned)), recoPage, SLOT(slotShowFeatureUpdateProgress(const unsigned, const unsigned)));
connect(parent()->parent(), SIGNAL(signalCloseFeatureUpdateProgress()), recoPage, SLOT(slotCloseFeatureUpdateProgress()));
connect(parent()->parent(), SIGNAL(signalShowRecoUiMask(int)), recoPage, SLOT(slotShowRecoUiMask(int)));
connect(parent()->parent(), SIGNAL(signalNotiMsg(const int, const QString&, int)), recoPage, SLOT(slotNotiMsg(const int, const QString&, int)));
connect(parent()->parent(), SIGNAL(signalCenterMsg(const int, const QString&)), recoPage, SLOT(slotCenterMsg(const int, const QString&)));
connect(recoPage, SIGNAL(signalShowPwdPage(const QString&)), this, SLOT(slotShowPasswordPage(const QString&)));
connect(parent()->parent(), SIGNAL(signalSetUserPwdButton(bool)), recoPage, SLOT(slotSetUserPwdButton(bool)));
connect(parent()->parent(), SIGNAL(signalShowOrHideFaceFrame(bool)), recoPage, SLOT(slotShowOrHideFaceFrame(bool)));
connect(parent()->parent(), SIGNAL(signalShowFinalResult(bool)), recoPage, SLOT(slotShowFinalResult(bool)));
connect(parent()->parent(), SIGNAL(signalShowRecoUiColorFaceSnapshot(const QString&)), recoPage, SLOT(slotShowRecoUiColorFaceSnapshot(const QString&)));
connect(parent()->parent(), SIGNAL(signalShowRecoUiColorFaceSnapshot(const unsigned char*, int)), recoPage, SLOT(slotShowRecoUiColorFaceSnapshot(const unsigned char*, int)));
connect(parent()->parent(), SIGNAL(signalUpdateScreenSaver()), recoPage, SIGNAL(signalUpdateScreenSaver()));
connect(recoPage, SIGNAL(signalScreenTouch()), parent()->parent(), SLOT(slotScreenTouch()));
connect(parent()->parent(), SIGNAL(signalShowHealthCodeAuthStatus(int)), recoPage, SLOT(slotShowHealthCodeAuthStatus(int)));
connect(parent()->parent(), SIGNAL(signalShowRecoUiDevIdAndVer(bool)), recoPage, SLOT(slotShowRecoUiDevIdAndVer(bool)));
if ((m_recoPage != nullptr) && (dynamic_cast<const recoUiRecognize *>(recoPage) == m_recoPage)) {
connect(m_recoPage, &recoUiRecognize::callDialButtonClicked, this, &recoUi::slotShowCallDialPage);
connect(m_recoPage, &recoUiRecognize::callPlatformButtonClicked, this, &recoUi::slotShowCallConsolePage);
} else if ((m_recoPageColor != nullptr) && (dynamic_cast<const recoUiRecognizeTypeColor *>(recoPage) == m_recoPageColor)) {
connect(m_recoPageColor, &recoUiRecognizeTypeColor::callDialButtonClicked, this, &recoUi::slotShowCallDialPage);
connect(m_recoPageColor, &recoUiRecognizeTypeColor::callPlatformButtonClicked, this, &recoUi::slotShowCallConsolePage);
} else if ((m_recoPageAd != nullptr) && (dynamic_cast<const recoUiRecognizeTypeAd *>(recoPage) == m_recoPageAd)) {
connect(m_recoPageAd, &recoUiRecognizeTypeAd::callDialButtonClicked, this, &recoUi::slotShowCallDialPage);
connect(m_recoPageAd, &recoUiRecognizeTypeAd::callPlatformButtonClicked, this, &recoUi::slotShowCallConsolePage);
}
}
void recoUi::slotRecoUiswitchToType(int type)
{
if( (0 == type && UiConfig::GetInstance()->isRecoUiStyleClassical()) ||
(1 == type && UiConfig::GetInstance()->isRecoUiStyleStandard()) ||
(2 == type && UiConfig::GetInstance()->isRecoUiStyleColor()) ||
(3 == type && UiConfig::GetInstance()->isRecoUiStyleAd()) ||
(4 == type && UiConfig::GetInstance()->isRecoUiStyleScene()) ){
return;
}
if( ( (0 == type || 4 == type) && !UiConfig::GetInstance()->isRecoUiStyleStandard()) ||
( (1 == type || 4 == type) && !UiConfig::GetInstance()->isRecoUiStyleClassical()) ||
( (0 == type || 1 == type) && !UiConfig::GetInstance()->isRecoUiStyleScene()) ){
if(!m_recoPage){
m_recoPage = new recoUiRecognize(m_isNightMode, m_showPwdBtn, m_showCallBtn, this);
connectRecoPage(m_recoPage);
m_recoPage->setBackstageUiinterface(m_backstageIf);
}
m_stack_recoPage->insertWidget(0, m_recoPage);
m_recoPage->setCamVideoWind();
}else if(2 == type){
if(!m_recoPageColor){
m_recoPageColor = new recoUiRecognizeTypeColor(m_isNightMode, m_showPwdBtn, m_showCallBtn, this);
connectRecoPage(m_recoPageColor);
m_recoPageColor->setBackstageUiinterface(m_backstageIf);
}
m_stack_recoPage->insertWidget(0, m_recoPageColor);
m_recoPageColor->setCamVideoWind();
}else if(3 == type){
if(!m_recoPageAd){
m_recoPageAd = new recoUiRecognizeTypeAd(m_isNightMode, m_showPwdBtn, m_showCallBtn, this);
connectRecoPage(m_recoPageAd);
m_recoPageAd->setBackstageUiinterface(m_backstageIf);
}
m_stack_recoPage->insertWidget(0, m_recoPageAd);
m_recoPageAd->setCamVideoWind();
}
#if 0
else if(4 == type){
if(!m_recoPageScene){
m_recoPageScene = new recoUiRecognizeScene(m_isNightMode, m_showPwdBtn, m_showCallBtn, this);
connectRecoPage(m_recoPageScene);
m_recoPageScene->setBackstageUiinterface(m_backstageIf);
}
m_stack_recoPage->insertWidget(0, m_recoPageScene);
m_recoPageScene->setCamVideoWind();
}
#endif
if( (1 != type && 4 != type && UiConfig::GetInstance()->isRecoUiStyleClassical()) ||
(0 != type && 4 != type && UiConfig::GetInstance()->isRecoUiStyleStandard()) ||
(0 != type && 1 != type && UiConfig::GetInstance()->isRecoUiStyleScene()) ){
m_stack_recoPage->removeWidget(m_recoPage);
}else if(2 != type && UiConfig::GetInstance()->isRecoUiStyleColor()){
m_stack_recoPage->removeWidget(m_recoPageColor);
}else if(3 != type && UiConfig::GetInstance()->isRecoUiStyleAd()){
m_stack_recoPage->removeWidget(m_recoPageAd);
}
#if 0
else if(4 != type && UiConfig::GetInstance()->isRecoUiStyleScene()){
m_stack_recoPage->removeWidget(m_recoPageScene);
}
#endif
m_stack_recoPage->setCurrentIndex(0);
UiConfig::GetInstance()->setRecoUiStyle(type);
if( m_recoPage && (0 == type || 1 == type || 4 == type) ){
m_recoPage->setStyle(type);
}
}
void recoUi::slotSaveRecoUiPwdBtnStatus(bool status)
{
qDebug() << "slotSaveRecoUiPwdBtnStatus:" << status;
m_showPwdBtn = status;
}
void recoUi::slotSaveRecoUiNightModeStatus(int type)
{
//qDebug() << "slotSaveRecoUiNightModeStatus:" << type;
m_isNightMode = (3 == type);
}
void recoUi::slotUpdateAdScreen()
{
if(m_recoPageAd){
m_recoPageAd->updateAdWidget();
}
}
void recoUi::slotTimer()
{
m_timer->stop();
m_recoPage->slotsResetRecoUi(); // 这里直接调用 reset, 否则RECO_UI_PAGE_RECOGNIZE可能会出现中间态
m_stack_recoPage->setCurrentIndex(RECO_UI_PAGE_RECOGNIZE);
if(UiConfig::GetInstance()->isRecoUiStyleScene()){
m_sceneResult->resetPersonCount();
}
}
void recoUi::slotShowHealthMsg(int type, float temp, const QString& msg, bool pass, const unsigned char* jpgDate,
int jpgLen, const QString& tripCity, const QString& failReason, int bgColor, int displayTime)
{
if(type < 0){
m_timer->stop();
m_stack_recoPage->setCurrentIndex(RECO_UI_PAGE_RECOGNIZE);
return;
}
m_healthMsgPage->showHealthMsg(type, temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor);
m_stack_recoPage->setCurrentIndex(RECO_UI_PAGE_HEALTHCODE);
m_timer->start(displayTime * 1000);
}
void recoUi::slotShowSceneResult(int result, const QString& resultText, const QString& businessInfo, int displayTime)
{
if(result < 0){
if(-1 == result){ //超时
m_sceneResult->resetPersonCount();
m_recoPage->setSceneUiReco(false);
}else{
m_recoPage->setSceneUiReco(true);
}
m_timer->stop();
m_stack_recoPage->setCurrentIndex(RECO_UI_PAGE_RECOGNIZE);
return;
}
if(result > 0){//通过才更新
int count = m_backstageIf->getTicketCheckCountToday();
m_sceneResult->setTicketCheckCount(0, count);
m_recoPage->setTicketCheckCount(0, count);
#if 0
m_recoPageScene->setTicketCheckCount(count);
#endif
}
m_sceneResult->showResult(result, resultText, businessInfo);
m_stack_recoPage->setCurrentIndex(RECO_UI_PAGE_SCENERESULT);
m_timer->start(displayTime);
}
void recoUi::slotUpdatePersonNumAccessed(int personAccess, int personAll)
{
if(m_stack_recoPage->currentIndex() != RECO_UI_PAGE_SCENERESULT){
return;
}
if(m_sceneResult->updatePersonNumAccessed(personAccess, personAll)){
m_timer->start(1000);
}
}
void recoUi::slotNoSuccessPage(int result)
{
if(UiConfig::GetInstance()->isRecoUiStyleScene()){
if(m_stack_recoPage->currentIndex() == RECO_UI_PAGE_SCENERESULT){
if(GLOBAL_RECO_FACE_CAMERA == result){
m_stack_recoPage->setCurrentIndex(RECO_UI_PAGE_RECOGNIZE);//请正视镜头可以打断场景结果,需要切换页面
}else{
return;
}
}
if(result != GLOBAL_RECO_NO_ENTRY && result != GLOBAL_RECO_CLEAR_NO_ENTRY){
m_recoPage->setSceneUiReco(true);
}
}
emit signalNoSuccessPage(result);
}
void recoUi::slotSetSceneUiPersonCountType(int type)
{
m_sceneResult->setPersonCountType(type);
m_recoPage->setScenePersonCountType(type);
}
void recoUi::slotUpdateSceneUiPersonCount(int count)
{
m_sceneResult->setTicketCheckCount(1, count);
m_recoPage->setTicketCheckCount(1, count);
}
void recoUi::slotShowCallDialPage() {
if (m_isPlatformConnected) {
m_callDialPage->reset();
m_stack_recoPage->setCurrentIndex(RECO_UI_PAGE_CALL_DIAL);
m_backstageIf->getCallDevList();
} else {
if (m_recoPage != nullptr) {
emit m_recoPage->slotCenterMsg(64, "当前设备离线,请稍后重试");
QTimer::singleShot(1500, this, [this]() { emit m_recoPage->slotCenterMsg(64, ""); });
}
if (m_recoPageColor != nullptr) {
emit m_recoPageColor->slotCenterMsg(64, "当前设备离线,请稍后重试");
QTimer::singleShot(1500, this, [this]() { emit m_recoPageColor->slotCenterMsg(64, ""); });
}
if (m_recoPageAd != nullptr) {
emit m_recoPageAd->slotCenterMsg(64, "当前设备离线,请稍后重试");
QTimer::singleShot(1500, this, [this]() { emit m_recoPageAd->slotCenterMsg(64, ""); });
}
}
}
void recoUi::slotShowCallConsolePage(const QString &contactName) {
if (m_isPlatformConnected) {
m_callConsolePage->reset(contactName);
m_stack_recoPage->setCurrentIndex(RECO_UI_PAGE_CALL_CONSOLE);
if (contactName == "管理处") {
m_backstageIf->callDev("", 2);
}
} else {
if (m_recoPage != nullptr) {
emit m_recoPage->slotCenterMsg(64, "当前设备离线,请稍后重试");
QTimer::singleShot(1500, this, [this]() { emit m_recoPage->slotCenterMsg(64, ""); });
}
if (m_recoPageColor != nullptr) {
emit m_recoPageColor->slotCenterMsg(64, "当前设备离线,请稍后重试");
QTimer::singleShot(1500, this, [this]() { emit m_recoPageColor->slotCenterMsg(64, ""); });
}
if (m_recoPageAd != nullptr) {
emit m_recoPageAd->slotCenterMsg(64, "当前设备离线,请稍后重试");
QTimer::singleShot(1500, this, [this]() { emit m_recoPageAd->slotCenterMsg(64, ""); });
}
}
}
void recoUi::slotSetCallConsoleStatus(int status, const QString& text)
{
m_callConsolePage->setStatus(status, text);
if(status < 100){
m_stack_recoPage->setCurrentIndex(RECO_UI_PAGE_CALL_CONSOLE);
}
}
void recoUi::slotShowCallBtn(bool callButton, bool videoButton) {
m_showCallBtn = callButton;
if (m_recoPage != nullptr) {
m_recoPage->slotShowCallBtn(m_showCallBtn);
}
if (m_recoPageColor != nullptr) {
m_recoPageColor->slotShowCallBtn(m_showCallBtn);
}
if (m_recoPageAd != nullptr) {
m_recoPageAd->slotShowCallBtn(m_showCallBtn);
}
if (m_callConsolePage != nullptr) {
m_callConsolePage->setVideoButtonVisible(videoButton);
}
}
void recoUi::setDndMode(bool enabled, const std::chrono::system_clock::time_point &time) {
if (m_recoPageAd) {
m_recoPageAd->setDndMode(enabled, time);
}
}

130
Linguist/recoUi/recoUi.h Normal file
View File

@ -0,0 +1,130 @@
#ifndef RECOUI_H
#define RECOUI_H
#include <QWidget>
#include <QStackedWidget>
#include "recoUiUnauthorized.h"
#include "recoUiRecognize.h"
#include "recoUiScreensaver.h"
#include "recoUiPassword.h"
#include "UiTools.h"
#include "BackstageInterfaceForUi.h"
#include "recoUiRecognizeTypeBase.h"
#include "recoUiHealthCode.h"
#include "recoUiRecognizeScene.h"
#include "recoUiCallDial.h"
#include "recoUiCallConsole.h"
class statusbarUi : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
explicit statusbarUi(QWidget *parent = nullptr);
~statusbarUi();
void updatePlatformConnectionStatus(const int);
void updateIpLabel(QString& ipStr);
signals:
public slots:
private:
QLabel* m_label_ip;
QLabel* m_label_platform;
//QLabel* m_label_wifi;
//QLabel* m_label_4g;
QLabel* m_label_time;
TimerUpdate* _timerUpdate;
};
typedef enum
{
RECO_UI_PAGE_RECOGNIZE,
RECO_UI_PAGE_SCREENSAVER,
RECO_UI_PAGE_PASSWORD,
RECO_UI_PAGE_HEALTHCODE,
RECO_UI_PAGE_SCENERESULT,
RECO_UI_PAGE_CALL_DIAL,
RECO_UI_PAGE_CALL_CONSOLE,
RECO_UI_PAGE_DRAW,
RECO_UI_PAGE_MAX,
RECO_UI_PAGE_WORK_MODE
}RECO_UI_PAGE_E;
class recoUi : public WidgetWithBackstageInterface
{
Q_OBJECT
public:
explicit recoUi(QWidget *parent = nullptr);
~recoUi();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
//statusbarUi* getStatusInstance();
void update_IpBar();
void updateVideoWind();
bool isScenePassing();
void setDndMode(bool enabled, const std::chrono::system_clock::time_point &time);
signals:
void signalShowSettingPage();
void signalNoSuccessPage(int);
void signalSuccessPage(int nPage, const QString& name);
// void signalDrawScanner(const int nPage, RWFaceInfo* pInfo, int sum);
void signalChangeRecoUiMode(); //底下的页面开关二维码模式信号
void signalUpdateRecoUiIpDisplay(const bool); //增加识别界面ip显示开关更新信号
public slots:
void slotShowSettingPage();
void slotShowRecoUiPage(int);
void slotUpdatePlatformConnectionStatus(int);
void slotShowPasswordPage(const QString& name);
void slotShowRecognizePage();
void slotRecoUiswitchToType(int type);
void slotSaveRecoUiPwdBtnStatus(bool status);
void slotSaveRecoUiNightModeStatus(int type);
void slotUpdateAdScreen();
void slotShowHealthMsg(int type, float temp, const QString& msg, bool pass, const unsigned char* jpgDate,
int jpgLen, const QString& tripCity, const QString& failReason, int bgColor, int displayTime);
void slotTimer();
void slotShowSceneResult(int result, const QString& resultText, const QString& businessInfo, int displayTime);
void slotUpdatePersonNumAccessed(int personAccess, int personAll);
void slotNoSuccessPage(int);
void slotSetSceneUiPersonCountType(int type);
void slotUpdateSceneUiPersonCount(int count);
void slotShowCallDialPage();
void slotShowCallConsolePage(const QString&);
void slotSetCallConsoleStatus(int status, const QString& text);
void slotShowCallBtn(bool callButton, bool videoButton);
private:
QStackedWidget* m_stack_recoPage;
// statusbarUi* m_statusbar;
recoUiRecognize* m_recoPage = nullptr;
recoUiRecognizeTypeColor* m_recoPageColor = nullptr;
recoUiRecognizeTypeAd* m_recoPageAd = nullptr;
//recoUiRecognizeScene* m_recoPageScene = nullptr;
recoUiScreensaver* m_ssPage;
recoUiPassword* m_pwdPage;
recoUiHealthCode* m_healthMsgPage;
recoUiSceneResult* m_sceneResult;
recoUiCallDial* m_callDialPage = nullptr;
recoUiCallConsole* m_callConsolePage = nullptr;
bool m_showPwdBtn = false;
bool m_isNightMode = false;
bool m_showCallBtn = false;
bool m_isPlatformConnected = false;
QTimer* m_timer = nullptr;
void connectRecoPage(const QObject* recoPage);
void disconnectRecoPage(const QObject* recoPage);
};
#endif // RECOUI_H

View File

@ -0,0 +1,288 @@
#include "recoUiCallConsole.h"
#include <QDebug>
#include <QPainter>
#include <QVBoxLayout>
recoUiCallConsole::recoUiCallConsole(QWidget *parent) : WidgetWithBackstageInterface(parent)
{
qDebug() << "recoUiCallConsole()";
resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
QLabel* labelImg = new QLabel(this);
labelImg->setPixmap(QPixmap(":/res/image/reco_msg_face_pic_large.png"));
m_labelContactName = new QLabel(this);
m_labelTip = new QLabel("xxxxxx", this);
m_btnCancel = createButton(QPixmap(":/res/image/fail2_large.png"), tr("取消"));
m_btnHungUp = createButton(QPixmap(":/res/image/hung_up_large.png"), tr("结束通话"));
m_btnCallAgain = createButton(QPixmap(":/res/image/call_large.png"), tr("重拨"));
m_btnVideoCtrl = createButton(QPixmap(":/res/image/enable_video_large.png"), tr("启用摄像头"));
m_btnAccept = createButton(QPixmap(":/res/image/call_large.png"), tr("接听"));
m_btnReject = createButton(QPixmap(":/res/image/hung_up_large.png"), tr("拒绝"));
m_btnOpenDoor = createButton(QPixmap(":/res/image/key-large.png"),"开门");
QHBoxLayout* hlayBtns = new QHBoxLayout();
hlayBtns->addWidget(m_btnOpenDoor);
hlayBtns->addWidget(m_btnCancel);
hlayBtns->addWidget(m_btnVideoCtrl);
hlayBtns->addWidget(m_btnHungUp);
hlayBtns->addWidget(m_btnCallAgain);
hlayBtns->addWidget(m_btnReject);
hlayBtns->addWidget(m_btnAccept);
QVBoxLayout* vlay = new QVBoxLayout();
vlay->addWidget(labelImg, 1, Qt::AlignCenter | Qt::AlignTop);
vlay->addWidget(m_labelContactName, 1, Qt::AlignCenter | Qt::AlignTop);
vlay->addSpacing(UiConfig::GetInstance()->getUiHeight() / 15);
vlay->addWidget(m_labelTip, 1, Qt::AlignCenter | Qt::AlignTop);
vlay->addStretch(10);
vlay->addLayout(hlayBtns);
vlay->setContentsMargins(0, UiConfig::GetInstance()->getUiHeight() / 10, 0, UiConfig::GetInstance()->getUiHeight() / 10);
setLayout(vlay);
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
setBackgroundTransparent(false);
setVideoButtonVisible(false);
}
void recoUiCallConsole::setBackgroundTransparent(bool transparent) {
if (transparent) {
setAutoFillBackground(false);
} else {
setAutoFillBackground(true);
QPalette palette(this->palette());
palette.setBrush(QPalette::Window, Qt::darkGray);
palette.setColor(QPalette::WindowText, Qt::white);
palette.setColor(QPalette::Text, Qt::white);
setPalette(palette);
}
}
void recoUiCallConsole::setVideoButtonVisible(bool visible) {
m_videoButtonVisible = visible;
m_btnVideoCtrl->setVisible(visible);
}
void recoUiCallConsole::reset(const QString& contactName)
{
m_labelContactName->setText(contactName);
setBackgroundTransparent(false);
setStatus(99);
m_timeCount = 0;
m_timer->start(TIMEOUT);
m_btnOpenDoor->hide();
m_initiatorDoorCfg = false;
}
void recoUiCallConsole::setStatus(int status, const QString& text)
{
switch(status){
//发起者
case 0://通话接通,不允许开关视频
case 1://通话接通,允许开关视频
m_btnHungUp->show();
m_btnCancel->hide();
m_btnCallAgain->hide();
m_btnReject->hide();
m_btnAccept->hide();
videoCtrl(false);
m_labelTip->setText("00:00");
m_timeCount = 1;
m_timer->start(1000);
if(status - 0){
m_btnVideoCtrl->show();
}else{
m_btnVideoCtrl->hide();
}
break;
case ShowVideo: {
setBackgroundTransparent(true);
break;
}
case HideVideo: {
setBackgroundTransparent(false);
break;
}
//接收者
case 50://设备通话请求到达,不允许开关视频
case 51://设备通话请求到达,允许开关视频
setBackgroundTransparent(false);
m_btnHungUp->hide();
m_btnCancel->hide();
m_btnCallAgain->hide();
m_btnReject->show();
m_btnAccept->show();
m_btnVideoCtrl->hide();
m_labelContactName->setText(text);
m_labelTip->setText("");
videoCtrl(false);
m_initiatorVideoCfg = status - 50;
m_btnOpenDoor->hide();
m_initiatorDoorCfg = true;
m_backstageIf->stopIdentyState();
break;
case PlatformCallIn://平台通话请求到达,不允许开关视频
setBackgroundTransparent(false);
m_initiatorDoorCfg = false;
m_btnOpenDoor->hide(); // 平台没有开门需求
m_btnHungUp->hide();
m_btnCancel->hide();
m_btnCallAgain->hide();
m_btnReject->hide();
m_btnAccept->hide();
videoCtrl(false);
m_btnVideoCtrl->hide();
m_labelContactName->setText(text);
m_labelTip->setText("00:00");
m_timeCount = 1;
m_timer->start(1000);
m_backstageIf->stopIdentyState();
break;
case 100:
m_timer->stop();
emit signalShowRecognizePage();
break;
//内部处理
case 99://发起者呼叫中
m_btnCancel->show();
m_btnCallAgain->hide();
m_btnVideoCtrl->hide();
m_btnHungUp->hide();
m_btnReject->hide();
m_btnAccept->hide();
m_labelTip->setText(tr("呼叫中 ..."));
break;
case 98://发起者超时未接通
m_btnCancel->show();
m_btnCallAgain->show();
m_btnVideoCtrl->hide();
m_btnHungUp->hide();
m_btnReject->hide();
m_btnAccept->hide();
m_labelTip->setText(tr("对方长时间未接听"));
break;
case 97://接收者接通
m_btnCancel->hide();
m_btnCallAgain->hide();
m_btnHungUp->show();
m_btnReject->hide();
m_btnAccept->hide();
m_labelTip->setText("00:00");
m_timeCount = 1;
m_timer->start(1000);
if(m_initiatorVideoCfg){
m_btnVideoCtrl->show();
}else{
m_btnVideoCtrl->hide();
}
m_btnOpenDoor->setVisible(m_initiatorDoorCfg);
break;
default:break;
}
}
void recoUiCallConsole::slotBtnClicked()
{
const QObject* send = sender();
if (send == m_btnCallAgain) {
emit signalCallAgain();
setStatus(99);
m_timeCount = 0;
m_timer->start(TIMEOUT);
}else if (send == m_btnHungUp) {
m_timer->stop();
m_backstageIf->callHangUp();
emit signalShowRecognizePage();
}else if (send == m_btnCancel) {
m_timer->stop();
m_backstageIf->callAbort();
emit signalShowRecognizePage();
}else if(send == m_btnVideoCtrl){
m_videoEnable = !m_videoEnable;
videoCtrl(m_videoEnable);
m_backstageIf->callSetVideoStream(m_videoEnable);
}else if(send == m_btnReject){
m_backstageIf->callReject();
emit signalShowRecognizePage();
}else if(send == m_btnAccept){
m_backstageIf->callAccept();
setStatus(97);
} else if (send == m_btnOpenDoor) {
m_backstageIf->openCallRemoteDoor();
}
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
}
void recoUiCallConsole::slotTimeout()
{
if(m_timeCount){
updateCallTime(m_timeCount++);
}else{
m_timer->stop();
m_backstageIf->callAbort();
setStatus(98);
}
}
void recoUiCallConsole::videoCtrl(bool enable)
{
QLabel *icon = m_btnVideoCtrl->findChild<QLabel*>("icon");
if (!icon) {
qDebug() << "video btn label not found";
return;
}
QLabel *text = m_btnVideoCtrl->findChild<QLabel*>("text");
if (!icon) {
qDebug() << "video btn text not found";
return;
}
text->setText(enable ? tr("禁用摄像头") : tr("启用摄像头"));
QPixmap pm(enable ? ":/res/image/disable_video_large.png" : ":/res/image/enable_video_large.png");
pm = pm.scaled(120, 120, Qt::KeepAspectRatio);
icon->setPixmap(pm);
m_videoEnable = enable;
}
QPushButton* recoUiCallConsole::createButton(const QPixmap& icon, const QString& btnText)
{
QPushButton* btn = new QPushButton(this);
btn->setFocusPolicy(Qt::NoFocus);
btn->setFixedSize(240, 240);
btn->setStyleSheet("background-color: transparent;");
connect(btn, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
QLabel* labelIcon = new QLabel(btn);
labelIcon->setObjectName("icon");
QPixmap pm(icon);
pm = pm.scaled(120, 120, Qt::KeepAspectRatio);
labelIcon->setPixmap(pm);
QLabel *btnName = new QLabel(btnText, btn);
btnName->setObjectName("text");
btnName->setStyleSheet("color: white;");
QVBoxLayout* vlay = new QVBoxLayout(btn);
vlay->addWidget(labelIcon, 9, Qt::AlignCenter);
vlay->addWidget(btnName, 1, Qt::AlignCenter);
vlay->setAlignment(Qt::AlignCenter);
return btn;
}
void recoUiCallConsole::updateCallTime(int second)
{
m_labelTip->setText(QString::number(second / 60).rightJustified(2, QChar('0')) + ":" + QString::number(second % 60).rightJustified(2, QChar('0')));
}

View File

@ -0,0 +1,83 @@
#ifndef RECOUICALLCONSOLE_H
#define RECOUICALLCONSOLE_H
#include "UiTools.h"
#include "UiConfig.h"
class recoUiCallConsole : public WidgetWithBackstageInterface
{
Q_OBJECT
public:
static const int PASSWORD_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const int NUM_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const int CONFIRM_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const QString PWD_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString CONFIRM_BTN_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString CONFIRM_BTN_DISABLE_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int CONFIRM_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int CONFIRM_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BACK_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int BACK_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int BACK_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString DEL_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int DEL_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int DEL_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NUM_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
enum Status {
PlatformCallIn = 60, // 平台打过来
ShowVideo = 101, // 背景透明,显示对方视频
HideVideo = 102, // 背景不透明, 不显示对方视频
};
explicit recoUiCallConsole(QWidget *parent = nullptr);
void reset(const QString& contactName);
void setStatus(int status, const QString& text = QString());
void setVideoButtonVisible(bool visible);
signals:
void signalShowRecognizePage();
void signalCallAgain();
public slots:
void slotBtnClicked();
void slotTimeout();
protected:
/**
* @brief
*
* @param transparent
*/
void setBackgroundTransparent(bool transparent);
private:
enum{
TIMEOUT = 30000,
};
QLabel* m_labelContactName;
QLabel* m_labelTip;
QPushButton* m_btnCancel;
QPushButton* m_btnHungUp;
QPushButton* m_btnCallAgain;
QPushButton* m_btnVideoCtrl;
QPushButton* m_btnAccept;
QPushButton* m_btnReject;
QPushButton *m_btnOpenDoor = nullptr;
QTimer* m_timer;
bool m_videoButtonVisible = false;
bool m_videoEnable = false;
bool m_initiatorVideoCfg = false;
bool m_initiatorDoorCfg = false;
int m_timeCount = 0;
QPushButton* createButton(const QPixmap& icon, const QString& btnText);
void videoCtrl(bool enable);
void updateCallTime(int second);
};
#endif // RECOUICALLCONSOLE_H

View File

@ -0,0 +1,370 @@
#include "recoUiCallDial.h"
#include <QDebug>
#include <QPainter>
#include "AsyncEvent.h"
#include "recoUiRecognize.h"
const int recoUiCallDial::DEV_CODE_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY] = {
{20, 20, 14, 15, 12, 15, 14, 13, 9, 12, 10, 13, 13, 9},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{14, 14, 11, 12, 10, 12, 11, 10, 8, 10, 9, 10, 10, 8},
{14, 14, 11, 12, 10, 12, 11, 10, 8, 10, 9, 10, 10, 8}
};
const int recoUiCallDial::NUM_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY] = {
{20, 20, 14, 15, 12, 15, 14, 13, 9, 12, 10, 13, 13, 9},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{16, 16, 11, 12, 10, 12, 11, 10, 8, 10, 9, 10, 10, 8},
{16, 16, 11, 12, 10, 12, 11, 10, 8, 10, 9, 10, 10, 8}
};
const int recoUiCallDial::CALL_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY] = {
{20, 20, 14, 15, 12, 15, 14, 13, 9, 12, 10, 13, 13, 9},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{14, 14, 10, 11, 9, 11, 10, 9, 7, 9, 8, 9, 9, 7},
{14, 14, 10, 11, 9, 11, 10, 9, 7, 9, 8, 9, 9, 7}
};
const QString recoUiCallDial::DIAL_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/pwd_bg_small.jpg",
":/res/image/pwd_bg_large.jpg",
":/res/image/pwd_bg_middle.jpg",
":/res/image/pwd_bg_large.jpg",
":/res/image/pwd_bg_middle.jpg"
};
const QString recoUiCallDial::CALL_BTN_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/pwd_confirm_small.png",
":/res/image/pwd_confirm_large.png",
":/res/image/pwd_confirm_middle.png",
":/res/image/pwd_confirm_large.png",
":/res/image/pwd_confirm_middle.png"
};
const QString recoUiCallDial::CALL_BTN_DISABLE_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/pwd_confirm_small_disable.png",
":/res/image/pwd_confirm_large_disable.png",
":/res/image/pwd_confirm_middle_disable.png",
":/res/image/pwd_confirm_large_disable.png",
":/res/image/pwd_confirm_middle_disable.png"
};
const int recoUiCallDial::CALL_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {344, 430, 430, 430, 430};
const int recoUiCallDial::CALL_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {72, 90, 90, 90, 90};
const QString recoUiCallDial::BACK_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/pwd_back_small.png",
":/res/image/pwd_back_large.png",
":/res/image/pwd_back_middle.png",
":/res/image/pwd_back_large.png",
":/res/image/pwd_back_middle.png"
};
const int recoUiCallDial::BACK_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {20, 24, 24, 24, 24};
const int recoUiCallDial::BACK_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {35, 44, 44, 44, 44};
const QString recoUiCallDial::DEL_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/pwd_del_small.png",
":/res/image/pwd_del_large_black.png",
":/res/image/pwd_del_middle.png",
":/res/image/pwd_del_large_black.png",
":/res/image/pwd_del_middle.png"
};
const int recoUiCallDial::DEL_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {344, 35, 35, 35, 35};
const int recoUiCallDial::DEL_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {344, 24, 24, 24, 24};
const QString recoUiCallDial::NUM_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/num_btn_small.png",
":/res/image/num_btn_large.png",
":/res/image/num_btn_middle.png",
":/res/image/num_btn_large.png",
":/res/image/num_btn_middle.png"
};
recoUiCallDial::recoUiCallDial(QWidget *parent) : WidgetWithBackstageInterface(parent)
{
qDebug() << "recoUiCallDial()";
resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
setAutoFillBackground(true);
QPalette palette(this->palette());
palette.setBrush(QPalette::Window,QBrush(QPixmap(DIAL_BG[UiConfig::GetInstance()->getScreenConfigIndex()])));
//palette.setBrush(QPalette::Window, Qt::white);
setPalette(palette);
const int btnWidth = UiConfig::GetInstance()->getUiWidth() / 8;
m_btnBack = new QPushButton(this);
setButtonBackImage(m_btnBack, BACK_BTN[UiConfig::GetInstance()->getScreenConfigIndex()],
BACK_BTN_W[UiConfig::GetInstance()->getScreenConfigIndex()],
BACK_BTN_H[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_btnBack->setFixedSize(btnWidth, btnWidth);
//m_btnBack->setStyleSheet("QPushButton:focus{outline: none;}");
m_btnBack->setFocusPolicy(Qt::NoFocus);
connect(m_btnBack, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
QFont ft;
ft.setWeight(ft.weight() * 2 > 99 ? 99 : ft.weight() * 2);//Weight must be between 0 and 99
m_editDevCode = new QLineEdit(this);
m_editDevCode->setFixedWidth(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.9));
m_editDevCode->setReadOnly(true);
QPalette lineEditPal;
lineEditPal.setColor(QPalette::Text,QColor(255, 255, 255, 255));
m_editDevCode->setPalette(lineEditPal);
ft.setPointSize(DEV_CODE_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_editDevCode->setFont(ft);
m_editDevCode->setStyleSheet("background:transparent;border-width:0;border-style:outset");
m_editDevCode->setAlignment(Qt::AlignCenter);
connect(m_editDevCode, SIGNAL(textChanged(const QString&)), this, SLOT(slotTextChanged(const QString&)));
QPalette btnPal;
btnPal.setColor(QPalette::ButtonText,QColor(255, 255, 255, 255));
QGridLayout* glayMid = new QGridLayout();
for(int i=0; i<NUM_BTNS_QTY; i++){
m_btnsNum[i] = new QPushButton(this);
m_btnsNum[i]->setText(QString::number(i));
m_btnsNum[i]->setPalette(btnPal);
ft.setPointSize(NUM_BTN_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_btnsNum[i]->setFont(ft);
m_btnsNum[i]->setFlat(true);
m_btnsNum[i]->setCursor(QCursor(Qt::PointingHandCursor));
m_btnsNum[i]->setFocusPolicy(Qt::NoFocus);
m_btnsNum[i]->setFixedSize(btnWidth, btnWidth);
m_btnsNum[i]->setStyleSheet("background-color:transparent;border-radius:0px;focus{outline: none;}");
connect(m_btnsNum[i], SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
if(!UiConfig::GetInstance()->isRkDevice()){
connect(m_btnsNum[i], SIGNAL(pressed()), this, SLOT(slotBtnPressed()));
connect(m_btnsNum[i], SIGNAL(released()), this, SLOT(slotBtnReleased()));
}
if(i > 0){
const int pos = i - 1;
glayMid->addWidget(m_btnsNum[i], pos / 3, pos % 3);
}
}
m_btnBackspace = new QPushButton(this);
setButtonBackImage(m_btnBackspace, DEL_BTN[UiConfig::GetInstance()->getScreenConfigIndex()],
DEL_BTN_W[UiConfig::GetInstance()->getScreenConfigIndex()],
DEL_BTN_H[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_btnBackspace->setFixedSize(btnWidth, btnWidth);
connect(m_btnBackspace, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
glayMid->addWidget(m_btnsNum[0], 3, 1);
glayMid->addWidget(m_btnBackspace, 3, 2);
m_btnCall = new QPushButton(this);
m_btnCall->setText(tr("呼叫"));
m_btnCall->setPalette(btnPal);
m_btnCall->setFlat(true);
m_btnCall->setCursor(QCursor(Qt::PointingHandCursor));
m_btnCall->setFocusPolicy(Qt::NoFocus);
m_btnCall->setFixedSize(CALL_BTN_W[UiConfig::GetInstance()->getScreenConfigIndex()],
UiConfig::GetInstance()->isRkDevice() ?
(CALL_BTN_H[UiConfig::GetInstance()->getScreenConfigIndex()] >> 2 << 2) :
CALL_BTN_H[UiConfig::GetInstance()->getScreenConfigIndex()]);
ft.setPointSize(CALL_BTN_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_btnCall->setFont(ft);
/*m_btnCall->setStyleSheet(QString("background-color:transparent;"
"color:white;"
"border-image: url(%1);"
).arg(CALL_BTN_BG[UiConfig::GetInstance()->getScreenConfigIndex()]));*/
m_btnCall->setStyleSheet("QPushButton {"
"border: 0px;"
"border-radius:10px;"
"background-color:rgb(31, 164, 38);"
"focus{outline: none;}"
"}"
"QPushButton:pressed {"
"background-color:rgb(31, 255, 38);"
"focus{outline: none;}"
"}");
connect(m_btnCall, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
QVBoxLayout* vlay = new QVBoxLayout();
vlay->addWidget(m_btnBack, 1, Qt::AlignLeft | Qt::AlignTop);
vlay->addWidget(m_editDevCode, 1, Qt::AlignCenter | Qt::AlignTop);
vlay->addSpacing(UiConfig::GetInstance()->getUiHeight() / 3);
vlay->addLayout(glayMid);
vlay->addStretch(100);
vlay->addWidget(m_btnCall, 1, Qt::AlignCenter | Qt::AlignBottom);
vlay->setContentsMargins(0, 10, 0, UiConfig::GetInstance()->getUiHeight() / 20);
setLayout(vlay);
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
m_tooltip = new CenterMsgWidget(this); // 不继承父组件样式
m_tooltip->hide();
m_tooltipTimer = new QTimer(this);
m_tooltipTimer->setSingleShot(true);
connect(m_tooltipTimer, &QTimer::timeout, this, &recoUiCallDial::onTooltipTimeout);
}
void recoUiCallDial::setToolip(const QString &message, int millisecondTimeout) {
if (m_tooltip != nullptr) {
m_tooltip->showMsg(message, 64);
m_tooltip->show();
m_tooltip->raise();
m_tooltipTimer->start(millisecondTimeout);
}
}
void recoUiCallDial::setPlatformConnected(bool connected) {
m_platformConnected = connected;
}
void recoUiCallDial::onTooltipTimeout(){
m_tooltip->hide();
}
void recoUiCallDial::reset()
{
m_editDevCode->clear();
m_timer->start(TIMEOUT);
m_backstageIf->stopIdentyState();
if(m_candidate){
delete m_candidate;
m_candidate = nullptr;
}
}
void recoUiCallDial::slotBtnClicked()
{
m_timer->start(TIMEOUT);
const QObject* send = sender();
if (send == m_btnCall) {
if (m_platformConnected) {
auto code = m_editDevCode->text();
if (code.isEmpty()) {
setToolip("号码不能为空", 1500);
} else {
auto iterator = std::find_if(m_devList.cbegin(), m_devList.cend(),
[&code](const stCallDev &device) { return device.code == code.toStdString(); });
if (iterator != m_devList.cend()) {
if (iterator->status == 0) {
setToolip("呼叫设备离线,请稍后重试", 1500);
} else {
m_timer->stop();
slotCall();
emit signalCallBtnPressed(QString::fromStdString(iterator->name));
}
} else {
setToolip("设备不存在", 1500);
}
}
} else {
setToolip("当前设备离线,请稍后重试", 1500);
}
}else if (send == m_btnBackspace) {
QString text = m_editDevCode->text();
if(text.size()){
m_editDevCode->setText(text.left(text.size() - 1));
}
}else if (send == m_btnBack) {
exit();
}else{
if(m_editDevCode->text().length() >= CODE_LEN_MAX){
return;
}
for(int i=0; i<NUM_BTNS_QTY; i++){
if(send == m_btnsNum[i]){
m_editDevCode->setText(m_editDevCode->text() + m_btnsNum[i]->text());
break;
}
}
}
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
}
void recoUiCallDial::slotBtnPressed()
{
dynamic_cast<QPushButton*>(sender())->setStyleSheet(QString("QPushButton {"
"border: 0px;"
"}"
"QPushButton:pressed {"
"border: 0px;"
"background:url(%1);"
"background-repeat:none;"
"background-position:center;"
"}")
.arg(NUM_BTN[UiConfig::GetInstance()->getScreenConfigIndex()]));
}
void recoUiCallDial::slotBtnReleased()
{
dynamic_cast<QPushButton*>(sender())->setStyleSheet("background-color:transparent;border-radius:0px;focus{outline: none;}");
}
void recoUiCallDial::slotTimeout()
{
exit();
}
void recoUiCallDial::slotItemChoosed(int index) {
if (index < m_devList.size()) {
auto event = new AsyncEvent([=]() {
m_timer->start(TIMEOUT);
m_editDevCode->setText(QString::fromStdString(m_devList.at(index).code));
if (UiConfig::GetInstance()->isRkDevice()) {
update();
}
});
QCoreApplication::postEvent(this, event);
}
}
void recoUiCallDial::slotTextChanged(const QString& text)
{
m_devList.clear();
if(m_candidate){
delete m_candidate;
m_candidate = nullptr;
}
if(text.length() < CODE_LEN_MIN){
return;
}
m_backstageIf->queryCallDevList(text.toStdString(), m_devList);
QVector<myListWidget::SetOpnCfg> opns;
for(auto &item : m_devList){
QString dev{item.code.c_str()};
dev += "(";
dev += item.name.c_str();
if(item.status == 0){
dev += tr("-离线");
}
dev += ")";
opns.append(myListWidget::SetOpnCfg(dev));
}
showCandidate(opns);
}
void recoUiCallDial::slotCall() {
auto iterator = std::find_if(m_devList.cbegin(), m_devList.cend(),
[this](const stCallDev &device) { return device.code == m_editDevCode->text().toStdString(); });
if (iterator != m_devList.cend()) {
m_backstageIf->callDev(iterator->devTag, iterator->type);
}
}
void recoUiCallDial::showCandidate(const QVector<myListWidget::SetOpnCfg>& opns)
{
if(opns.size() == 0){
return;
}
m_candidate = new SearchBarCandidate(opns, 0, this);
m_candidate->setFixedSize(m_editDevCode->width(), m_editDevCode->height() * 5);
m_candidate->move(m_editDevCode->x(), m_editDevCode->y() + m_editDevCode->height() + 20);
m_candidate->show();
connect(m_candidate, SIGNAL(signalItemChoosed(int)), this, SLOT(slotItemChoosed(int)));
}
void recoUiCallDial::exit()
{
m_timer->stop();
emit signalShowRecognizePage();
}

View File

@ -0,0 +1,79 @@
#ifndef RECOUICALLDIAL_H
#define RECOUICALLDIAL_H
#include "UiTools.h"
#include "UiConfig.h"
class CenterMsgWidget;
class recoUiCallDial : public WidgetWithBackstageInterface
{
Q_OBJECT
public:
static const int DEV_CODE_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const int NUM_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const int CALL_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const QString DIAL_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString CALL_BTN_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString CALL_BTN_DISABLE_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int CALL_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int CALL_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BACK_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int BACK_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int BACK_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString DEL_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int DEL_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int DEL_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NUM_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit recoUiCallDial(QWidget *parent = nullptr);
void reset();
void setToolip(const QString &message, int millisecondTimeout);
void setPlatformConnected(bool connected);
signals:
void signalShowRecognizePage();
void signalCallBtnPressed(const QString&);
public slots:
void slotBtnClicked();
void slotBtnPressed();
void slotBtnReleased();
void slotTimeout();
void slotItemChoosed(int index);
void slotTextChanged(const QString& text);
void slotCall();
protected:
void onTooltipTimeout();
private:
enum{
NUM_BTNS_QTY = 10,
TIMEOUT = 30000,
CODE_LEN_MIN = 3,
CODE_LEN_MAX = 16,
};
QPushButton* m_btnBack;
QLineEdit* m_editDevCode;
QPushButton* m_btnsNum[NUM_BTNS_QTY];
QPushButton* m_btnBackspace;
QPushButton* m_btnCall;
SearchBarCandidate* m_candidate = nullptr;
CenterMsgWidget *m_tooltip = nullptr;
QTimer *m_tooltipTimer = nullptr;
QTimer* m_timer;
bool m_platformConnected = false;
std::vector<stCallDev> m_devList;
void showCandidate(const QVector<myListWidget::SetOpnCfg>& opns);
void exit();
};
#endif // RECOUICALLDIAL_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,114 @@
#ifndef RECOUIHEALTHCODE_H
#define RECOUIHEALTHCODE_H
#include "UiTools.h"
#include "UiConfig.h"
class recoUiHealthCodePage : public QWidget
{
Q_OBJECT
public:
#if 0
static const int PERSON_NAME_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const int WEL_MSG_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const int PASSWORD_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const int NUM_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const int CONFIRM_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const QString PWD_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString CONFIRM_BTN_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString CONFIRM_BTN_DISABLE_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int CONFIRM_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int CONFIRM_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BACK_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int BACK_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int BACK_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString DEL_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int DEL_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int DEL_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NUM_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
#endif
static const int PIC_WIDGET_H_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit recoUiHealthCodePage(int type, QWidget *parent = nullptr);
void showTemp(float temp);
void showPersonMsg(const QString& name, const QString& idNum, const unsigned char* jpgDate, int len);
void showAntibodyTestingMsg(int num, const QString& testingTime);
void showCovid19TestingMsg(int res, const QString& testingTime);
void showAntiGenTestingMsg(int res, const QString& testingTime);
void showTripMsg(int res, const QString& tripCity);
void showAccResult(bool pass, const QString& failReason, int bgColor);
void setResultShowType(int type);
//void setBgColorByResult(int codeColor, int c19t, int trip, bool pass);
signals:
public slots:
private:
QLabel* m_labelTitle;
QLabel* m_labelCurTime;
QLabel* m_labelTempTip;
QLabel* m_labelTemp;
QWidget* m_labelFacePic;
QLabel* m_labelName;
QLabel* m_labelIdNo;
QLabel* m_labelABTTitle;
QLabel* m_labelABTRes;
QLabel* m_labelABTTime;
QLabel* m_labelC19T;
QLabel* m_labelC19TTitle;
RoundedWidget* m_covid19Testing;
QStackedWidget* m_stackC19T;
QLabel* m_labelC19TTime;
QLabel* m_labelAccRes;
QLabel* m_labelTripRes;
QLabel* m_labelTripResTime;
QLabel* m_labelAcc;
QLabel* m_failReason;
};
class recoUiHealthCode : public WidgetWithBackstageInterface
{
Q_OBJECT
public:
explicit recoUiHealthCode(QWidget *parent = nullptr);
void showHealthMsg(int type, float temp, const QString& msg, bool pass,
const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
void setResultShowType(int type);
signals:
public slots:
private:
QStackedWidget* m_stackPages;
recoUiHealthCodePage* m_pageGreen;
recoUiHealthCodePage* m_pageYellow;
recoUiHealthCodePage* m_pageRed;
recoUiHealthCodePage* m_pageGrey;
int m_resultType = 0;
void _showType0HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
void _showType1HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
void _showType2HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
void _showType3HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
void _showType4HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
void _showType5HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
void _showTypexHealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
void _showType101HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
void _showType6HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
void _showType7HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
void _showType8HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
void _showType9HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor);
};
#endif // RECOUIPASSWORD_H

View File

@ -0,0 +1,422 @@
#include "recoUiPassword.h"
#include <QDebug>
#include <QPainter>
const int recoUiPassword::PERSON_NAME_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY] = {
{24, 20, 14, 15, 12, 15, 14, 13, 9, 12, 10, 13, 13, 9},
{48, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{48, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{16, 16, 10, 12, 10, 12, 11, 10, 8, 10, 9, 10, 10, 8},
{16, 16, 10, 12, 10, 12, 11, 10, 8, 10, 9, 10, 10, 8}
};
const int recoUiPassword::WEL_MSG_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY] = {
{16, 20, 14, 15, 12, 15, 14, 13, 9, 12, 10, 13, 13, 9},
{32, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{32, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{12, 12, 11, 12, 10, 12, 11, 10, 8, 10, 9, 10, 10, 8},
{12, 12, 11, 12, 10, 12, 11, 10, 8, 10, 9, 10, 10, 8}
};
const int recoUiPassword::PASSWORD_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY] = {
{20, 20, 14, 15, 12, 15, 14, 13, 9, 12, 10, 13, 13, 9},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{14, 14, 11, 12, 10, 12, 11, 10, 8, 10, 9, 10, 10, 8},
{14, 14, 11, 12, 10, 12, 11, 10, 8, 10, 9, 10, 10, 8}
};
const int recoUiPassword::NUM_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY] = {
{20, 20, 14, 15, 12, 15, 14, 13, 9, 12, 10, 13, 13, 9},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{16, 16, 11, 12, 10, 12, 11, 10, 8, 10, 9, 10, 10, 8},
{16, 16, 11, 12, 10, 12, 11, 10, 8, 10, 9, 10, 10, 8}
};
const int recoUiPassword::CONFIRM_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY] = {
{20, 20, 14, 15, 12, 15, 14, 13, 9, 12, 10, 13, 13, 9},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{40, 40, 28, 30, 24, 30, 28, 26, 19, 26, 22, 26, 26, 19},
{14, 14, 10, 11, 9, 11, 10, 9, 7, 9, 8, 9, 9, 7},
{14, 14, 10, 11, 9, 11, 10, 9, 7, 9, 8, 9, 9, 7}
};
const QString recoUiPassword::PWD_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/pwd_bg_small.jpg",
":/res/image/pwd_bg_large.jpg",
":/res/image/pwd_bg_middle.jpg",
":/res/image/pwd_bg_large.jpg",
":/res/image/pwd_bg_middle.jpg"
};
const QString recoUiPassword::CONFIRM_BTN_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/pwd_confirm_small.png",
":/res/image/pwd_confirm_large.png",
":/res/image/pwd_confirm_middle.png",
":/res/image/pwd_confirm_large.png",
":/res/image/pwd_confirm_middle.png"
};
const QString recoUiPassword::CONFIRM_BTN_DISABLE_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/pwd_confirm_small_disable.png",
":/res/image/pwd_confirm_large_disable.png",
":/res/image/pwd_confirm_middle_disable.png",
":/res/image/pwd_confirm_large_disable.png",
":/res/image/pwd_confirm_middle_disable.png"
};
const int recoUiPassword::CONFIRM_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {344, 430, 430, 430, 430};
const int recoUiPassword::CONFIRM_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {72, 90, 90, 90, 90};
const QString recoUiPassword::BACK_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/pwd_back_small.png",
":/res/image/pwd_back_large.png",
":/res/image/pwd_back_middle.png",
":/res/image/pwd_back_large.png",
":/res/image/pwd_back_middle.png"
};
const int recoUiPassword::BACK_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {20, 24, 24, 24, 24};
const int recoUiPassword::BACK_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {35, 44, 44, 44, 44};
const QString recoUiPassword::DEL_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/pwd_del_small.png",
":/res/image/pwd_del_large_black.png",
":/res/image/pwd_del_middle.png",
":/res/image/pwd_del_large_black.png",
":/res/image/pwd_del_middle.png"
};
const int recoUiPassword::DEL_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {344, 35, 35, 35, 35};
const int recoUiPassword::DEL_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {344, 24, 24, 24, 24};
const QString recoUiPassword::NUM_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/num_btn_small.png",
":/res/image/num_btn_large.png",
":/res/image/num_btn_middle.png",
":/res/image/num_btn_large.png",
":/res/image/num_btn_middle.png"
};
recoUiPassword::recoUiPassword(QWidget *parent) : WidgetWithBackstageInterface(parent)
{
qDebug() << "recoUiPassword()";
resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
setAutoFillBackground(true);
QPalette palette(this->palette());
palette.setBrush(QPalette::Window,QBrush(QPixmap(PWD_BG[UiConfig::GetInstance()->getScreenConfigIndex()])));
setPalette(palette);
const int btnWidth = UiConfig::GetInstance()->getUiWidth() / 5;
m_btnBack = new QPushButton(this);
setButtonBackImage(m_btnBack, BACK_BTN[UiConfig::GetInstance()->getScreenConfigIndex()],
BACK_BTN_W[UiConfig::GetInstance()->getScreenConfigIndex()],
BACK_BTN_H[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_btnBack->setFixedSize(btnWidth, btnWidth);
//m_btnBack->setStyleSheet("QPushButton:focus{outline: none;}");
m_btnBack->setFocusPolicy(Qt::NoFocus);
connect(m_btnBack, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
QPalette labelPal;
labelPal.setColor(QPalette::Background,QColor(0, 0, 0, 0));
QFont ft;
ft.setWeight(ft.weight() * 2 > 99 ? 99 : ft.weight() * 2);//Weight must be between 0 and 99
//ft.setBold(true);
m_labelName = new QLabel(this);
//m_labelName->setText(tr("某某某"));
m_labelName->setPalette(labelPal);
ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelName->setFont(ft);
m_labelName->hide();
m_labelWelStr = new QLabel(this);
m_labelWelStr->setText(tr("欢迎光临"));
labelPal.setColor(QPalette::WindowText,QColor(203, 242, 252));
m_labelWelStr->setPalette(labelPal);
ft.setPointSize(WEL_MSG_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelWelStr->setFont(ft);
m_labelWelStr->hide();
if(UiConfig::GetInstance()->isRkDevice()){
m_editPwd = new QPasswordLineEdit(this, ".");
}
else{
m_editPwd = new QPasswordLineEdit(this);
}
m_editPwd->setReadOnly(true);
QPalette lineEditPal;
lineEditPal.setColor(QPalette::Text,QColor(255, 255, 255, 255));
m_editPwd->setPalette(lineEditPal);
ft.setPointSize(PASSWORD_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_editPwd->setFont(ft);
m_editPwd->setStyleSheet("background:transparent;border-width:0;border-style:outset");
m_editPwd->setAlignment(Qt::AlignCenter);
QPalette btnPal;
btnPal.setColor(QPalette::ButtonText,QColor(255, 255, 255, 255));
QGridLayout* glayMid = new QGridLayout();
for(int i=0; i<NUM_BTNS_QTY; i++){
m_btnsNum[i] = new QPushButton(this);
m_btnsNum[i]->setText(QString::number(i));
m_btnsNum[i]->setPalette(btnPal);
ft.setPointSize(NUM_BTN_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_btnsNum[i]->setFont(ft);
m_btnsNum[i]->setFlat(true);
m_btnsNum[i]->setCursor(QCursor(Qt::PointingHandCursor));
m_btnsNum[i]->setFocusPolicy(Qt::NoFocus);
m_btnsNum[i]->setFixedSize(btnWidth, btnWidth);
m_btnsNum[i]->setStyleSheet("background-color:transparent;border-radius:0px;focus{outline: none;}");
/*const QString numBtnStyle = QString("QPushButton {"
"border: 0px;"
"background-color:transparent;"
"background:url(%1);"
"}"
"QPushButton:hover { "
"border: 0px;"
"background:url(%2);"
"background-repeat:none;"
"background-position:center;"
"}"
"QPushButton:pressed {"
"border: 0px;"
"background:url(%3);"
"background-repeat:none;"
"background-position:center;"
//"background-origin: content;" // 设置背景图片基于content默认是基于border的
//"padding-left: 8px;" //设置content相对于border的偏移如果此属性要对背景图片生效的话需要设置上面的属性
"}")
.arg(":/res/image/num_btn_large.png")
.arg(":/res/image/num_btn_large.png")
.arg(":/res/image/num_btn_large.png");
m_btnsNum[i]->setStyleSheet(numBtnStyle);
m_btnsNum[i]->setStyleSheet("QPushButton {"
"font-size:100px;"
"color:yellow; "
"border-radius:150px;" //圆角大小因为矩形的一半为150所以圆角大小 设置为150以后将会成为一个原型小于150就是圆角矩形了。
"background-color:rgba(0,255,0,200);" //设置按钮背景为绿色
"}"
"QPushButton:hover { "
"font-size:100px;"
"color:green;"
"border-radius:150px;"
"background-color:rgba(255,255,0,200);" //设置按钮背景为黄色 = 红+绿
"}"
"QPushButton:pressed {"
"color:orange; "
"border-width:3;"
"border-radius:150px;"
"border-color:orange;"
"border-style:solid;"
"background-color:cyan;"
"}");
*/
connect(m_btnsNum[i], SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
if(!UiConfig::GetInstance()->isRkDevice()){
connect(m_btnsNum[i], SIGNAL(pressed()), this, SLOT(slotBtnPressed()));
connect(m_btnsNum[i], SIGNAL(released()), this, SLOT(slotBtnReleased()));
}
if(i > 0){
const int pos = i - 1;
glayMid->addWidget(m_btnsNum[i], pos / 3, pos % 3);
}
}
m_btnBackspace = new QPushButton(this);
setButtonBackImage(m_btnBackspace, DEL_BTN[UiConfig::GetInstance()->getScreenConfigIndex()],
DEL_BTN_W[UiConfig::GetInstance()->getScreenConfigIndex()],
DEL_BTN_H[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_btnBackspace->setFixedSize(btnWidth, btnWidth);
connect(m_btnBackspace, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
//m_btnClear = new QPushButton(this);
//m_btnClear->setText(tr("清空"));
//connect(m_btnClear, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
//glayMid->addWidget(m_btnClear, 3, 0);
glayMid->addWidget(m_btnsNum[0], 3, 1);
glayMid->addWidget(m_btnBackspace, 3, 2);
m_btnConfirm = new QPushButton(this);
m_btnConfirm->setText(tr("确认"));
m_btnConfirm->setPalette(btnPal);
m_btnConfirm->setFlat(true);
m_btnConfirm->setCursor(QCursor(Qt::PointingHandCursor));
m_btnConfirm->setFocusPolicy(Qt::NoFocus);
m_btnConfirm->setFixedSize(CONFIRM_BTN_W[UiConfig::GetInstance()->getScreenConfigIndex()],
UiConfig::GetInstance()->isRkDevice() ?
(CONFIRM_BTN_H[UiConfig::GetInstance()->getScreenConfigIndex()] >> 2 << 2) :
CONFIRM_BTN_H[UiConfig::GetInstance()->getScreenConfigIndex()]);
ft.setWeight(ft.weight() * 2 > 99 ? 99 : ft.weight() * 2);//Weight must be between 0 and 99
ft.setPointSize(CONFIRM_BTN_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_btnConfirm->setFont(ft);
#if 1
const QString confirmBtnStyle = QString("background-color:transparent;"
"color:white;"
"border-image: url(%1);"
)
.arg(CONFIRM_BTN_BG[UiConfig::GetInstance()->getScreenConfigIndex()]);
#else
QString confirmBtnStyle = 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(CONFIRM_BTN_BG[UiConfig::GetInstance()->getScreenConfigIndex()])
.arg(CONFIRM_BTN_DISABLE_BG[UiConfig::GetInstance()->getScreenConfigIndex()])
.arg(CONFIRM_BTN_DISABLE_BG[UiConfig::GetInstance()->getScreenConfigIndex()]);
#endif
//qDebug() << "confirmBtnStyle:" << confirmBtnStyle;
m_btnConfirm->setStyleSheet(confirmBtnStyle);
connect(m_btnConfirm, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
QVBoxLayout* vlay = new QVBoxLayout();
vlay->addWidget(m_btnBack, 1, Qt::AlignLeft | Qt::AlignTop);
vlay->addWidget(m_labelName, 1, Qt::AlignCenter | Qt::AlignTop);
vlay->addWidget(m_labelWelStr, 1, Qt::AlignCenter | Qt::AlignTop);
vlay->addWidget(m_editPwd, 80, Qt::AlignCenter | Qt::AlignBottom);
vlay->addLayout(glayMid);
vlay->addWidget(m_btnConfirm, 1, Qt::AlignCenter | Qt::AlignTop);
vlay->setContentsMargins(0, 10, 0, (UiConfig::GetInstance()->getUiHeight() / 12) >> 1 << 1);
//vlay->setMargin(0);
setLayout(vlay);
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
}
void recoUiPassword::reset(const QString& name)
{
m_editPwd->clear();
m_pwd.clear();
m_timeCnt = 0;
m_tryTime = 0;
m_timer->start(TIMEOUT);
m_btnConfirm->setEnabled(false);
slotShowPwdUiPersonName(name);
//m_backstageIf->pauseDataFlow();
m_backstageIf->stopIdentyState();
m_need2ResetDecisionCenterTimer = !name.isEmpty();
}
void recoUiPassword::slotBtnClicked()
{
qDebug() << "slotBtnClicked";
const QObject* send = sender();
if (send == m_btnConfirm) {
m_timeCnt = 0;
qDebug() << "password:" << m_pwd;
m_backstageIf->sendPassword(m_pwd.toStdString().c_str());
m_editPwd->clear();
m_pwd.clear();
m_btnConfirm->setEnabled(false);
m_timer->stop();
m_tryTime++;
if(m_tryTime >= TRY_TIME){
emit signalShowRecognizePage();
//m_backstageIf->resumeDataFlow();
}
}
else if (send == m_btnBackspace) {
m_timeCnt = 0;
QString text = m_editPwd->text();
if(text.size()){
m_pwd = m_pwd.left(m_pwd.size() - 1);
m_editPwd->setText(text.left(text.size() - 1));
m_btnConfirm->setEnabled(m_editPwd->text().length() >= PWD_LEN_MIN);
}
}
//else if (send == m_btnClear) {
//m_editPwd->clear();
//}
else if (send == m_btnBack) {
emit signalShowRecognizePage();
m_timer->stop();
//m_backstageIf->resumeDataFlow();
m_backstageIf->verifyAbort();
}
else{
m_timeCnt = 0;
if(m_editPwd->text().length() >= PWD_LEN_MAX){
return;
}
for(int i=0; i<NUM_BTNS_QTY; i++){
if(send == m_btnsNum[i]){
if(m_pwd.isEmpty() && m_tryTime){
m_labelName->hide();
m_labelWelStr->hide();
}
m_pwd += m_btnsNum[i]->text();
m_editPwd->setText(m_editPwd->text() + m_btnsNum[i]->text());
m_btnConfirm->setEnabled(m_editPwd->text().length() >= PWD_LEN_MIN);
break;
}
}
}
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
}
void recoUiPassword::slotBtnPressed()
{
const QString numBtnStyle = QString("QPushButton {"
"border: 0px;"//"background-color:transparent;"
"}"
"QPushButton:pressed {"
"border: 0px;"
"background:url(%1);"
"background-repeat:none;"
"background-position:center;"
"}")
.arg(NUM_BTN[UiConfig::GetInstance()->getScreenConfigIndex()]);
dynamic_cast<QPushButton*>(sender())->setStyleSheet(numBtnStyle);
}
void recoUiPassword::slotBtnReleased()
{
qDebug() << "slotBtnReleased";
dynamic_cast<QPushButton*>(sender())->setStyleSheet("background-color:transparent;border-radius:0px;focus{outline: none;}");
}
void recoUiPassword::slotTimeout()
{
m_timeCnt++;
qDebug() << "slotTimeout:" << m_timeCnt;
if(m_need2ResetDecisionCenterTimer && m_timeCnt < (PROC_OVERTIME - BACKSTAGE_PROC_OVERTIME) ){
m_backstageIf->resetDecisionCenterTimer();
}
else if(m_timeCnt >= PROC_OVERTIME){
m_timer->stop();
emit signalShowRecognizePage();
//m_backstageIf->resumeDataFlow();
}
}
void recoUiPassword::slotShowPwdUiPersonName(const QString& name)
{
if(name.isEmpty()){
m_labelName->hide();
m_labelWelStr->hide();
}
else{
m_labelName->setText(name);
m_labelName->setStyleSheet("color:#CBF2FC;");
m_labelName->show();
m_labelWelStr->show();
}
}
void recoUiPassword::slotShowUserPwdError(int type, int color)
{
m_timer->start();
switch(type){
case 0:
m_labelName->setText(tr("密码错误"));
if(0 == color){
m_labelName->setStyleSheet("color:#DB1624;");
}
m_labelWelStr->hide();
m_labelName->show();
break;
default:
break;
}
}

View File

@ -0,0 +1,71 @@
#ifndef RECOUIPASSWORD_H
#define RECOUIPASSWORD_H
#include "UiTools.h"
#include "UiConfig.h"
class recoUiPassword : public WidgetWithBackstageInterface
{
Q_OBJECT
public:
static const int PERSON_NAME_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const int WEL_MSG_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const int PASSWORD_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const int NUM_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const int CONFIRM_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][UiConfig::SUPPORT_LANGUAGE_QUANTITY];
static const QString PWD_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString CONFIRM_BTN_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString CONFIRM_BTN_DISABLE_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int CONFIRM_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int CONFIRM_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BACK_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int BACK_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int BACK_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString DEL_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int DEL_BTN_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int DEL_BTN_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NUM_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit recoUiPassword(QWidget *parent = nullptr);
void reset(const QString& name);
signals:
void signalShowRecognizePage();
public slots:
void slotBtnClicked();
void slotBtnPressed();
void slotBtnReleased();
void slotTimeout();
void slotShowPwdUiPersonName(const QString& name);
void slotShowUserPwdError(int type, int color);
private:
enum{
NUM_BTNS_QTY = 10,
TIMEOUT = 1000,
BACKSTAGE_PROC_OVERTIME = 5, //BACKSTAGE_PROC_OVERTIME * TIMEOUT
PROC_OVERTIME = 10, //PROC_OVERTIME * TIMEOUT
PWD_LEN_MIN = 4,
PWD_LEN_MAX = 16,
TRY_TIME = 5
};
QPushButton* m_btnBack;
QLabel* m_labelName;
QLabel* m_labelWelStr;
QPasswordLineEdit* m_editPwd;
QPushButton* m_btnsNum[NUM_BTNS_QTY];
//QPushButton* m_btnClear;
QPushButton* m_btnBackspace;
QPushButton* m_btnConfirm;
QString m_pwd;
QTimer* m_timer;
int m_timeCnt = 0;
int m_tryTime = 0;
bool m_need2ResetDecisionCenterTimer = false;
};
#endif // RECOUIPASSWORD_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,571 @@
#ifndef RECOUIRECOGNIZE_H
#define RECOUIRECOGNIZE_H
#include <QHBoxLayout>
#include <QLabel>
#include <QPropertyAnimation>
#include <QPushButton>
#include <QTime>
#include <QWidget>
#include "UiTools.h"
#include <QStackedWidget>
#include <QEvent>
#include "UiCommon.h"
#include "UiConfig.h"
#include "UiInterfaceForBackstage.h"
class SceneMsgWidget : public QWidget
{
Q_OBJECT
public:
static const int DATE_TIME_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
SceneMsgWidget(QWidget *parent = nullptr);
void setPersonNum(int source, int personNum);
void setBgTransparent(bool set);
int setType(int type);
public slots:
void slotNewDay();
private:
DateTimeWidgetClassical *m_wgtDateTime = nullptr;
QLabel *m_labelPersonNum = nullptr;
int m_type = 0;
};
typedef enum
{
GLOBAL_RECO_END_OK = 0,
GLOBAL_RECO_END_NO,
GLOBAL_RECO_FACE_CARD_NOT_MATCH,
GLOBAL_RECO_SWIPE_CARD,
GLOBAL_RECO_FACE_CAMERA,
GLOBAL_RECO_NOT_PASS_TIME,
GLOBAL_RECO_NEED_RECHECK,
GLOBAL_RECO_PLATFORM_DISCONNECTED,
GLOBAL_RECO_SWIPE_CARD_HERE,
GLOBAL_RECO_HIDE_NAME_AREA,
GLOBAL_RECO_NOT_LIVING,
GLOBAL_RECO_UNAUTH_CARD,
GLOBAL_RECO_PLS_TAP_ID_CARD,
GLOBAL_RECO_PLS_CHECK_STATIC,
GLOBAL_RECO_STATIC_ABNORMAL,
GLOBAL_RECO_SWIPE_ID_OR_HEALEH_CODE,
GLOBAL_RECO_CHECKING,
GLOBAL_RECO_CHECK_FAILED,
GLOBAL_RECO_QRCODE_OVERDUE,
GLOBAL_RECO_NETWORK_ERROR,
GLOBAL_RECO_PLATFORM_ERROR,
GLOBAL_RECO_REQUEST_OVERTIME,
GLOBAL_RECO_SWIPE_TRIP_CARD,
GLOBAL_RECO_SHOW_HEALTH_CODE,
GLOBAL_RECO_RESWIPE_TRIP_CARD,
GLOBAL_RECO_SWIPE_ID_AND_TRIP_CARD,
GLOBAL_RECO_TRIP_CARD_CHECKING,
GLOBAL_RECO_SCAN_YUEJUMA,
GLOBAL_RECO_SCAN_YUEJUMA_OR_SWIPE_ID,
GLOBAL_RECO_PATROL_OK,
GLOBAL_RECO_PATROL_NOT_RIGHT_TIME,
GLOBAL_RECO_SHOW_QRCODE,
GLOBAL_RECO_ID_FAILED, //身份证核验失败
GLOBAL_RECO_IN, //close to recognize
GLOBAL_RECO_IN_SCANNER,
GLOBAL_RECO_CHECK, //靠近重试
GLOBAL_RECO_BEGIN_AUTH,
GLOBAL_RECO_TEMP_REQ, //请移动额头到测温区
GLOBAL_RECO_READ_TEMP_FAILED, //体温检测失败
GLOBAL_RECO_MASK_REQ, //请戴口罩
GLOBAL_RECO_MASK_OK, //口罩检测正常
GLOBAL_RECO_NO_ENTRY, //禁止通行
GLOBAL_RECO_CLEAR_NO_ENTRY, //清除禁止通行字样
GLOBAL_RECO_CLOSE_SCANLINE, //关闭扫描线
GLOBAL_RECO_SHOW_QRCODE_RECO, //显示识别二维码界面
GLOBAL_RECO_SHOW_FACE_RECO, //显示人脸识别界面,可能是从二维码界面切换过去的
GLOBAL_RECO_SHOW_NOTI_MSG, //显示通知信息
GLOBAL_RECO_SHOW_CENTER_MSG, //显示中央信息块
GLOBAL_RECO_SHOW_CENTER_MSG_BIG,//显示超大中央信息块
GLOBAL_RECO_SHOW_CENTER_MSG_BIG_RED,
GLOBAL_RECO_SHOW_CENTER_MSG_BG_GREEN,
GLOBAL_RECO_SHOW_CENTER_MSG_BG_YELLOW,
GLOBAL_RECO_SHOW_CENTER_MSG_BG_RED,
GLOBAL_RECO_SHOW_CENTER_MSG_BG_PURPLE,
GLOBAL_RECO_SHOW_CENTER_MSG_BG_BLACK,
GLOBAL_RECO_SHOW_CENTER_MSG_FIRE_ALARM,
GLOBAL_RECO_TAKE_OFF_MASK,
GLOBAL_RECO_OTHERS
}GLOBAL_RECO_STATE;
typedef enum
{
WIDGET_BG_COLOR_TRAN,
WIDGET_BG_COLOR_BLUE,
WIDGET_BG_COLOR_GREEN,
WIDGET_BG_COLOR_RED
}WIDGET_BG_COLOR_E;
class TmprWidget : public QWidget
{
Q_OBJECT //多语言需要
public:
static const QString TEMP_BG_GREEN_TOP_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString TEMP_BG_RED_TOP_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int TMPR_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int TMPR_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit TmprWidget(QWidget *parent = nullptr);
~TmprWidget();
void showNormalTemp(const QString& msg, float temp, bool isC);
void showAbnormalTemp(const QString& msg, float temp, bool isHigh, bool isC);
void setBackgroundColor(WIDGET_BG_COLOR_E color);
private:
QLabel* m_label_tem;
//QLabel* m_label_msg;
//记录当前显示温度差值超分辨率0.1才刷新
float m_ForeheadTmpr;
};
class MsgWidget : public QWidget
{
Q_OBJECT
public:
#define STYLE_QUANTITY 2
static const QString NO_NETWORK_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NETWORK_CONNECTED_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NETWORK_LOGGED_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NET_ETH_IP_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NET_WIFI_IP_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NET_4G_IP_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_BLUE_BOM_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_GREEN_BOM_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_RED_BOM_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int TIME_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int MSG_WORD_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY]; //move to uiConfig if want to set font size for each language
static const int NOTI_MSG_WORD_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit MsgWidget(int timeType, int iconType, const QColor& textColor, QWidget *parent = nullptr);
~MsgWidget();
void setMsgTop(const QString&);
void setMsgBtm(const QString&, const bool setRedColor = false);
void setMsgNoti(const QString& msg, int color);
void setLogo(const QString&, const bool scale = false);
bool hasNoMsg();
void setNetworkStatus(const int);
void setBackgroundColor(const WIDGET_BG_COLOR_E color);
void updateIp(const QString& ip, int type = -1);
void showDevInfo(const QString& devId, const QString& ver);
void setStyle(int timeType, int iconType, const QColor& textColor);
void showRecoUiDevIdAndVer(bool show);
private:
//QLabel* m_label_msgTop;
QLabel* m_label_Icon;
QLabel* m_label_msgBtm;
QLabel* m_label_msgNoti;
QLabel* m_label_time = nullptr;
QLabel* m_label_networkStatus;
QLabel* m_label_ip;
QLabel* m_label_ipType; //eth wifi 4g
TimerUpdate* _timerUpdate = nullptr;
QLabel* m_labelDevId;
QLabel* m_labelVer;
int m_style = 0;
};
class DetectResultWidget : public QWidget
{
Q_OBJECT
public:
typedef enum
{
BG_COLOR_BLUE,
BG_COLOR_RED,
BG_COLOR_TRAN,
BG_COLOR_GREEN,
BG_COLOR_YELLOW
}BG_COLOR_E;
static const int DETECT_RESULT_WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int DETECT_RESULT_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int MASK_LOGO_SIZE_7INCH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_BLUE_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_GREEN_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_RED_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int MASK_LOGO_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit DetectResultWidget(QWidget *parent = nullptr);
virtual ~DetectResultWidget();
void updateMsg(const QString& msg);
protected:
void showMsg(const QString& msg, int msgSize, BG_COLOR_E color, const QPixmap* icon = nullptr);
QLabel* m_label_msg;
private:
QLabel* m_label_Icon;
};
#if 1
class MaskWidget_o : public DetectResultWidget
{
Q_OBJECT
public:
explicit MaskWidget_o(QWidget *parent = nullptr);
MaskWidget_o();
void setMaskMsg(bool maskOk, const QString& msg);
void showQRCodeMsg(UiInterfaceForBackstage::QRCode_Msg_E);
QString curMsg() const;
private:
bool m_lastMaskOk;
QPixmap m_iconMaskOk;
QPixmap m_iconMaskNull;
};
class PersonWidget_o : public DetectResultWidget
{
Q_OBJECT
public:
explicit PersonWidget_o(QWidget *parent = nullptr);
PersonWidget_o();
void setPersonMsg(RecoUiTextCfg::enTextType, const QString&, const BG_COLOR_E, const bool);
bool allowToShow();
private:
bool isShowingResultMsg;
};
#endif
class MaskWidget : public QWidget
{
Q_OBJECT
public:
explicit MaskWidget(QWidget *parent = nullptr);
QStackedWidget* m_wgts;
void setMaskMsg(bool maskOk, const QString& msg);
void showQRCodeMsg(UiInterfaceForBackstage::QRCode_Msg_E);
void hideSelf();
private:
bool m_lastMaskOk;
};
class PersonWidget : public QWidget
{
Q_OBJECT
public:
typedef enum
{
BG_COLOR_BLUE,
BG_COLOR_RED,
BG_COLOR_TRAN,
BG_COLOR_GREEN,
BG_COLOR_YELLOW
}BG_COLOR_E;
explicit PersonWidget(QWidget *parent = nullptr);
QStackedWidget* m_wgts;
void setPersonMsg(RecoUiTextCfg::enTextType, const QString&, const BG_COLOR_E, const bool);
bool allowToShow();
private:
bool isShowingResultMsg;
};
class CenterMsgWidget : public QWidget
{
Q_OBJECT
public:
static const int WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit CenterMsgWidget(QWidget *parent = nullptr);
virtual ~CenterMsgWidget();
void showMsg(const QString& msg, int type);
protected:
private:
QLabel* m_label_msg;
int m_centerMsgType = 0;
void paintEvent(QPaintEvent *event);
};
class FinalResultWidget : public QWidget
{
Q_OBJECT
public:
static const QString FINAL_RESULT_OK_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString FINAL_RESULT_FAIL_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int FINAL_RESULT_WIDGET_W_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit FinalResultWidget(QWidget *parent = nullptr);
virtual ~FinalResultWidget();
void showResult(bool pass);
protected:
private:
};
class recoUiRecognize : public PageAcceptMouseAndTouch
{
Q_OBJECT
public:
static const QString BG_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int MSG_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString SCANLINE_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString LOGO_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString TEMP_CALIBOX_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString DARK_FILL_LIGHT_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString PWD_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString PWD_BTN_PRESSED[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int PWD_BTN_W_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int SWIP_CARD_WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int SWIP_CARD_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString SWIP_CARD_DAY_MODE_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString SWIP_CARD_NIGHT_MODE_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString CALL_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
//扫描线运行一次时间,时间越短,运行越快
static const int SCAN_LINE_RUN_TIME = 800;
static constexpr float SCAN_LINE_START_POS_SCALE = 0.2f;
static constexpr float SCAN_LINE_RUN_DISTANCE_SCALE = 0.55f;
static const int SCAN_LINE_LOOP_INTERVAL = 500;
static const int clickNum = UiConfig::MOUSE_CLICK_TIMES_TO_SETTING;
static const int clickGrap = UiConfig::MOUSE_CLICK_INTERVAL_MAX;
static const int QRCODE_SCAN_LINE_RUN_TIME = 1000;
static const int QRCODE_SCAN_LINE_RUN_INTERVAL_TIME = QRCODE_SCAN_LINE_RUN_TIME + 200;
static const int QRCODE_FAILED_MSG_DISPLAY_TIME = 2000; //ms
static constexpr float HIGH_TEMP_VALUE = 42.0f;
static constexpr float LOW_TEMP_VALUE = 35.0f;
typedef enum
{
MSG_BG_COLOR_BOM_NULL,
MSG_BG_COLOR_BOM_BLUE,
MSG_BG_COLOR_BOM_GREEN,
MSG_BG_COLOR_BOM_TOP_GREEN,
MSG_BG_COLOR_BOM_RED,
MSG_BG_COLOR_BOM_TOP_RED,
MSG_BG_COLOR_QRCODE
}MSG_BG_COLOR_E;
typedef enum
{
SCAN_LINE_SWITCH_OFF,
SCAN_LINE_SWITCH_BLUE,
SCAN_LINE_SWITCH_RED
}SCAN_LINE_SWITCH_E;
public:
explicit recoUiRecognize(bool isNightMode, bool hasPwdBtn, bool hasCallBtn, QWidget *parent = nullptr);
~recoUiRecognize();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void timerEvent(QTimerEvent *event);
int setScannerState(const SCAN_LINE_SWITCH_E);
void showRecoScanner();
void showRecoFail(GLOBAL_RECO_STATE failType);
void showRecoIDFail();
void showRetry();
void showNoMaskWarn(); //请戴口罩
void showMaskOk();
void showMaskWarn();
void showNoEntry();
void clearNoEntry();
void setPwdButton(bool visible);
int setCamVideoWind();
void setStyle(int style);
void setSceneUiReco(bool toReco);
void setTicketCheckCount(int source, int count);
void setScenePersonCountType(int type);
signals:
void signalChangePage();
void signalShowPwdPage(const QString& name);
void signalScreenTouch();
void callDialButtonClicked(); // 呼叫设备按钮
void callPlatformButtonClicked(const QString &name); // 呼叫管理处
public slots:
void slotsNoSuccessPage(const int nPage);
void slotsSuccessPage(const int nPage, const QString& name);
void slotsDrawScanner(const int nPage, const bool faceAvailable);
void handleRecoResShowTime();
void slotsInteractionChange(const INTERACION_OPTION& interaction, int nSelectRes);
void slotShowNormalTemp(const float temp, const bool isC);
void slotShowAbnormalTemp(const float temp, const bool isHigh, const bool isC);
void slotUpdateLogo(const int);
void slotUpdatePlatformConnectionStatus(const int);
void slotsResetRecoUi();
void slotShowQRCodeMsg(const int);
void slotChangeRecoUiMode(); //二维码开关时更新识别页面,人脸识别模式/二维码扫描模式
void slotTimerQRCodeScanline();
void slotQRCodeSwitchToStandbyStatusFromOvertimeStatus();
void slotUpdateRecoUiIpDisplay(const bool); //增加识别界面ip显示开关更新信号
void slotShowFeatureUpdateProgress(const unsigned current, const unsigned all);
void slotCloseFeatureUpdateProgress();
void slotShowRecoUiMask(int maskType);
void slotNotiMsg(const int nPage, const QString& msg, int color);
void slotLongPressShowSetting();
void slotCenterMsg(const int nPage, const QString& msg);
void slotPwdBtnClicked();
void slotSetUserPwdButton(bool visible);
void slotShowOrHideFaceFrame(bool show);
void slotShowFinalResult(bool pass);
void slotShowHealthCodeAuthStatus(int status);
void slotShowCallBtn(bool show);
void slotShowRecoUiDevIdAndVer(bool show);
private:
void closeRecoResTime();
private:
QLabel* m_label_back;
QWidget* m_wgtCardUnderScreen;
TmprWidget* m_widget_tmpr;
MaskWidget* m_widget_mask;
CenterMsgWidget* m_widget_cMsg;
PersonWidget* m_widget_person;
MsgWidget* m_widget_msg;
QLabel* _moveScanner;
QPropertyAnimation* _ScanCurorAnimation;
SCAN_LINE_SWITCH_E m_currentScanLine;
int m_clickCount;
QTime _preTime;
bool isTouched;
int _timerId; //扫描动画定时器
QTimer* _pShowResTimer;
QString m_name;
MSG_BG_COLOR_E m_currentBackColor; //当前背景颜色,用于显示“禁止通行”时决定字样的颜色
int m_tempRefresh; //温度刷新标志
int m_maskRefresh; //口罩刷新标志
int m_personRefresh; //人员信息刷新标志
int m_NotiMsgRefresh; //通知信息刷新标志
int m_NoEntryRefresh; //通行结果刷新标志
bool m_msgShowed; //是否有前面4个信息在显示中
bool m_faceAivaliable; //当前画面是否存在人脸
int m_showGreenColor;
int m_showRedColor;
int m_scanLineInterval;
bool runScanLine; //扫描线开关状态
int m_scanLinePos;
bool timerTimeoutOperation; //定时器超时后动作类型,就是超时时做什么事
QTimer* m_timer_QRCodeScanLine;
QLabel* m_label_QRCodeScanLine;
QPropertyAnimation* m_QRCodeAnimation;
QTimer* m_QRCodeTimer;
ProgressWidget* m_widget_progress;
QString m_notimsg;
int m_notiMsgColor;
QWidget* m_btnPwd;
bool m_showFaceFrameByUser = false;
bool m_isNightMode = false;
FinalResultWidget* m_resWgt;
QLabel* m_healthCodeAuthstatus;
QPixmap m_bgPm;
QPixmap m_bgSceneIdle;
SceneMsgWidget* m_wgtSceneMsg = nullptr;
RoundedWidget* m_wgtCallDialDev;
RoundedWidget* m_wgtCallMngCenter;
bool eventFilter(QObject *watched, QEvent *event);
void setBackgroundColor(const MSG_BG_COLOR_E index);
void runQRCodeScanLine();
void showQRCodeReco();
void showFaceReco();
bool showPersonWidgetMsg();
bool showNoEntryMsg();
bool showNotiMsg();
bool showTempMsg();
bool showMaskMsg();
bool event(QEvent *event);
bool multiPressToSettingPage();
bool longPressToSettingPage();
QString recoUiTextCfg(RecoUiTextCfg::enTextType type);
bool showCenterMsg(const QString& msg, int type);
void setCardReaderUnderScreenInstructions(bool isNightMode);
};
#endif // RECOUIRECOGNIZE_H

View File

@ -0,0 +1,811 @@
#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);
}

View File

@ -0,0 +1,129 @@
#ifndef RECOUIRECOGNIZESCENE_H
#define RECOUIRECOGNIZESCENE_H
#include <QWidget>
#include "UiTools.h"
#include "recoUiRecognize.h"
class recoUiRecognizeScene : public PageAcceptMouseAndTouch
{
Q_OBJECT
public:
static const int TOP_MSG_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString TOP_MSG_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int SWIP_CARD_WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int SWIP_CARD_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString SWIP_CARD_DAY_MODE_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString SWIP_CARD_NIGHT_MODE_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString PAGE_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString PAGE_STATUS_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit recoUiRecognizeScene(bool isNightMode, bool hasPwdBtn, QWidget *parent = nullptr);
virtual ~recoUiRecognizeScene();
void setBackstageUiinterface(BackstageInterfaceForUi *interface);
int setCamVideoWind();
void updateBg();
void uiReset();
void setTicketCheckCount(int source, int count);
signals:
void signalChangePage();
void signalShowPwdPage(const QString& name);
void signalScreenTouch();
public slots:
void slotsNoSuccessPage(int nPage);
void slotsSuccessPage(const int nPage, const QString& name);
void slotsDrawScanner(const int nPage, const bool faceAvailable);
//void handleRecoResShowTime();
void slotsInteractionChange(const INTERACION_OPTION& interaction, int nSelectRes);
void slotShowNormalTemp(const float temp, const bool isC);
void slotShowAbnormalTemp(const float temp, const bool isHigh, const bool isC);
void slotUpdateLogo(const int);
void slotUpdatePlatformConnectionStatus(const int);
void slotsResetRecoUi();
//void slotShowQRCodeMsg(const int);
//void slotChangeRecoUiMode();
//void slotTimerQRCodeScanline();
//void slotQRCodeSwitchToStandbyStatusFromOvertimeStatus();
void slotUpdateRecoUiIpDisplay(const bool);
//void slotShowFeatureUpdateProgress(const unsigned current, const unsigned all);
//void slotCloseFeatureUpdateProgress();
void slotShowRecoUiMask(int maskType);
void slotNotiMsg(const int nPage, const QString& msg, int color);
void slotLongPressShowSetting();
void slotCenterMsg(const int nPage, const QString& msg);
void slotPwdBtnClicked();
void slotSetUserPwdButton(bool visible);
//void slotShowOrHideFaceFrame(bool show);
void slotShowFinalResult(bool pass);
private:
//SceneMsgWidget* m_wgtSceneMsg;
MsgWidget* m_wgtDevMsg;
QWidget* m_wgtBack;
QWidget* m_wgtBtnPwd;
QWidget* m_wgtCardUnderScreen = nullptr;
//QLabel* m_wgtStatusTip;
CenterMsgWidget* m_widget_cMsg;
PersonWidget* m_widget_person;
//QBrush m_pageIdle;
//QBrush m_pageStatusTip;
QBrush m_pageReco;
QString m_name;
int m_clickCount;
QTime _preTime;
bool isTouched;
QString recoUiTextCfg(RecoUiTextCfg::enTextType type);
bool eventFilter(QObject *watched, QEvent *event);
bool event(QEvent *event);
bool multiPressToSettingPage();
bool longPressToSettingPage();
void setMsgWidgetBg(int bgType);
void setCardReaderUnderScreenInstructions(bool isNightMode);
void setBg(const QBrush& brush);
void showStatusTip(const QString& tip);
};
class recoUiSceneResult : public QWidget
{
Q_OBJECT
public:
static const QString PAGE_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit recoUiSceneResult(QWidget *parent = nullptr);
void showResult(bool pass, const QString& result, const QString& businessInfo);
bool updatePersonNumAccessed(int personAccess, int personAll);
void setTicketCheckCount(int source, int count);
bool isPassing() const;
void resetPersonCount();
void setPersonCountType(int type);
signals:
public slots:
private:
SceneMsgWidget* m_wgtSceneMsg;
QLabel* m_labelResult;
QLabel* m_labelBussInfo;
QLabel* m_labelBussPersonNum;
QBrush m_bgWhiteList;
QBrush m_bgSceneOk;
QBrush m_bgSceneFailed;
//QWidget* m_accMsg;
//QLabel* m_labelAcc;
//QLabel* m_labelAccRes;
int m_personAccessed;
int m_personAll;
};
#endif // RECOUIRECOGNIZESCENE_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,230 @@
#ifndef RECOUIRECOGNIZETYPEBASE_H
#define RECOUIRECOGNIZETYPEBASE_H
#include <QWidget>
#include "UiTools.h"
#include "recoUiRecognize.h"
#include "recoUiScreensaver.h"
class RecoResultWidget : public QWidget
{
Q_OBJECT
public:
static const int FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString RECO_OK_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString RECO_FAIL_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString RECO_WARN_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString MASK_OK_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString MASK_NULL_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString TEMP_OK_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString TEMP_ABN_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
RecoResultWidget(QWidget *parent = nullptr);
void showIdentityResult(GLOBAL_RECO_STATE state, const QString& msg = QString());
void showMaskResult(bool hasMask, const QString& msg);
void showTempResult(const QString& msg, float temp, bool isNormal, bool isC);
void reset();
private:
QLabel* m_label_identity_icon;
QLabel* m_label_identity_word;
QLabel* m_label_mask_icon;
QLabel* m_label_mask_word;
QLabel* m_label_temp_icon;
QLabel* m_label_temp_word;
};
class DndModeCountDownItem;
class RecoMsgWidget : public QWidget
{
Q_OBJECT
public:
static const int TIME_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int DATE_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int MSG_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int PIC_WIDGET_H_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString PIC_WIDGET_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString IDLE_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString OK_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString FAIL_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString WARN_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString T1_IDLE_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString T1_OK_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString T1_FAIL_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString T1_WARN_BG_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
RecoMsgWidget(bool hasFacePic, bool enTimeType, int bgImgType, QWidget *parent = nullptr);
void showFacePic(const QString& picPath);
void showFacePic(const unsigned char* jpgDate, int len);
void facePicReset();
void showIdentityResult(GLOBAL_RECO_STATE state, const QString& msg = QString());
void showMaskResult(bool hasMask, const QString& msg);
void showTempResult(const QString& msg, float temp, bool isNormal, bool isC);
void setDndMode(bool dndMode, const std::chrono::system_clock::time_point &endTime);
void reset();
void switchBg(int type);
protected:
private:
const int m_bgImgType;
QWidget* m_widget_pic;
QStackedWidget* m_stackWgt_msg;
RecoResultWidget* m_widget_result;
TimeWidget* m_widget_time;
DndModeCountDownItem *m_dndItem = nullptr;
};
class RecoTypeResultWidget : public QWidget
{
Q_OBJECT
public:
static const QString RESULT_OK_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString RESULT_FAIL_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString RESULT_WARN_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit RecoTypeResultWidget(QWidget *parent = nullptr);
void showResult(int type);
protected:
private:
};
class recoUiRecognizeTypeBase : public PageAcceptMouseAndTouch
{
Q_OBJECT
public:
static const int TOP_MSG_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int AD_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString TOP_MSG_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int SWIP_CARD_WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int SWIP_CARD_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString SWIP_CARD_DAY_MODE_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString SWIP_CARD_NIGHT_MODE_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit recoUiRecognizeTypeBase(bool isNightMode, bool hasPwdBtn, bool hasCallBtn, int type, QWidget *parent = nullptr);
virtual ~recoUiRecognizeTypeBase();
virtual int setCamVideoWind() = 0;
signals:
void signalChangePage();
void signalShowPwdPage(const QString& name);
void signalScreenTouch();
void callDialButtonClicked(); // 呼叫设备按钮
void callPlatformButtonClicked(const QString &name); // 呼叫管理处
public slots:
void slotsNoSuccessPage(int nPage);
void slotsSuccessPage(const int nPage, const QString& name);
void slotsDrawScanner(const int nPage, const bool faceAvailable);
//void handleRecoResShowTime();
void slotsInteractionChange(const INTERACION_OPTION& interaction, int nSelectRes);
void slotShowNormalTemp(const float temp, const bool isC);
void slotShowAbnormalTemp(const float temp, const bool isHigh, const bool isC);
void slotUpdateLogo(const int);
void slotUpdatePlatformConnectionStatus(const int);
void slotsResetRecoUi();
//void slotShowQRCodeMsg(const int);
//void slotChangeRecoUiMode();
//void slotTimerQRCodeScanline();
//void slotQRCodeSwitchToStandbyStatusFromOvertimeStatus();
void slotUpdateRecoUiIpDisplay(const bool);
//void slotShowFeatureUpdateProgress(const unsigned current, const unsigned all);
//void slotCloseFeatureUpdateProgress();
void slotShowRecoUiMask(int maskType);
void slotNotiMsg(const int nPage, const QString& msg, int color);
void slotLongPressShowSetting();
void slotCenterMsg(const int nPage, const QString& msg);
void slotPwdBtnClicked();
void slotSetUserPwdButton(bool visible);
//void slotShowOrHideFaceFrame(bool show);
void slotShowFinalResult(bool pass);
void slotShowCallBtn(bool show);
void slotShowRecoUiDevIdAndVer(bool show);
protected:
RecoMsgWidget* m_widget_reco = nullptr;
recoUiScreensaver* m_widget_ad;
MsgWidget* m_widget_msg;
QVBoxLayout *m_vlay = nullptr;
QWidget* m_wgtCardUnderScreen = nullptr;
private:
const int m_uiType;
QWidget* m_wgtBack;
QWidget* m_wgtBtnPwd;
CenterMsgWidget* m_widget_cMsg;
RecoTypeResultWidget* m_widget_result;
//QWidget* m_wgtCallDial;
RoundedWidget* m_wgtCallDialDev;
RoundedWidget* m_wgtCallMngCenter;
QString m_name;
int m_clickCount;
QTime _preTime;
bool isTouched;
QString recoUiTextCfg(RecoUiTextCfg::enTextType type);
bool eventFilter(QObject *watched, QEvent *event);
bool event(QEvent *event);
bool multiPressToSettingPage();
bool longPressToSettingPage();
void uiReset();
void setMsgWidgetBg(int bgType);
void setCardReaderUnderScreenInstructions(bool isNightMode);
};
class recoUiRecognizeTypeColor : public recoUiRecognizeTypeBase
{
Q_OBJECT
public:
explicit recoUiRecognizeTypeColor(bool isNightMode, bool hasPwdBtn, bool hasCallBtn, QWidget *parent = nullptr);
int setCamVideoWind();
void setBackstageUiinterface(BackstageInterfaceForUi *interface);
signals:
public slots:
void slotShowRecoUiColorFaceSnapshot(const QString& path);
void slotShowRecoUiColorFaceSnapshot(const unsigned char* jpgDate, int len);
private:
};
class recoUiRecognizeTypeAd : public recoUiRecognizeTypeBase
{
Q_OBJECT
public:
static const int CAM_WIN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][4];
explicit recoUiRecognizeTypeAd(bool isNightMode, bool hasPwdBtn, bool hasCallBtn, QWidget *parent = nullptr);
int setCamVideoWind();
void setBackstageUiinterface(BackstageInterfaceForUi *interface);
void updateAdWidget();
void setDndMode(bool dndMode, const std::chrono::system_clock::time_point &endTime);
signals:
void signalUpdateScreenSaver();
public slots:
void slotCurrentChange(int index);
};
#endif // RECOUIRECOGNIZETYPEBASE_H

View File

@ -0,0 +1,288 @@
#include "recoUiScreensaver.h"
#include <QDebug>
#include <QPixmap>
#include <QHBoxLayout>
#include "UiTools.h"
BgLoadThread::BgLoadThread(QObject* parent) : QObject (parent)
{
qDebug() << "BgLoadThread";
}
BgLoadThread::~BgLoadThread()
{
qDebug() << "~BgLoadThread";
}
void BgLoadThread::slotloadBGs(const QStringList& pics, const QSize& bgSize)
{
//qDebug() << "BgLoadThread::slotloadBGs";
for (int i=0; i<pics.size(); i++){
QPixmap bg(pics[i]);
if(!bg.isNull()){
//qDebug() << "load one background" << pics[i];
emit signalOneBGReady(ScalePixmap(bg, bgSize));
}
}
emit signalAllBGDone();
}
Screensaver::Screensaver(const QString& pic, QWidget *parent) : QWidget (parent)
{
QLabel* m_label_background = new QLabel(this);
m_label_background->setAlignment(Qt::AlignCenter);
m_label_background->resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
qDebug() << "screensaver:" << pic;
QPixmap bg(pic);
if(!bg.isNull()){
m_label_background->setPixmap(ScalePixmap(bg, QSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight())));
}
QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget(m_label_background, 100, Qt::AlignCenter);
layout->setMargin(0);
setLayout(layout);
resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
}
Screensaver::Screensaver(const QPixmap& pic, QWidget *parent) : QWidget (parent)
{
QLabel* m_label_background = new QLabel(this);
m_label_background->resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
m_label_background->setPixmap(pic);
m_label_background->setAlignment(Qt::AlignCenter);
QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget(m_label_background, 100, Qt::AlignCenter);
layout->setMargin(0);
setLayout(layout);
resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
}
const QString recoUiScreensaver::AD_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/reco_ad_large.png",
":/res/image/reco_ad_large.png",
":/res/image/reco_ad_large.png",
":/res/image/reco_ad_large.png",
":/res/image/reco_ad_large.png"
};
const QString recoUiScreensaver::SCREENSAVER[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][DEFAULT_SCREENSAVER_QUANTITY] = {
{":/res/image/screensaver-600-1024.jpg", ":/res/image/screensaver_720_1280_1.jpg", ":/res/image/screensaver_720_1280_2.jpg"},
{":/res/image/screensaver-800-1280.jpg", ":/res/image/screensaver_800_1280_1.jpg", ":/res/image/screensaver_800_1280_2.jpg"},
{":/res/image/screensaver-720-1280.jpg", ":/res/image/screensaver_720_1280_1.jpg", ":/res/image/screensaver_720_1280_2.jpg"},
{":/res/image/screensaver-800-1280.jpg", ":/res/image/screensaver_800_1280_1.jpg", ":/res/image/screensaver_800_1280_2.jpg"},
{":/res/image/screensaver-720-1280.jpg", ":/res/image/screensaver_720_1280_1.jpg", ":/res/image/screensaver_720_1280_2.jpg"}
};
recoUiScreensaver::recoUiScreensaver(int sourceType, QWidget *parent)
: WidgetWithBackstageInterface(parent), m_sourceType(sourceType)
{
qDebug() << "recoUiScreensaver()";
//setAttribute(Qt::WA_AcceptTouchEvents); //touch
//installEventFilter(this); //mouse click
/*
m_label_logo = new QLabel(this);
QPixmap pm(":/res/image/home_logo.png");
//pm = pm.scaled(50, 50, Qt::KeepAspectRatio);
m_label_logo->setPixmap(pm);
m_label_time = new QLabel(this);
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText,Qt::white);
m_label_time->setPalette(palette);
QFont ft;
ft.setPointSize(30);
m_label_time->setFont(ft);
QHBoxLayout* hbLayout = new QHBoxLayout();
hbLayout->addWidget(m_label_logo, 1, Qt::AlignLeft | Qt::AlignTop);
hbLayout->addWidget(m_label_time, 1, Qt::AlignRight | Qt::AlignTop);
hbLayout->setMargin(40);
setAutoFillBackground(true);
//pm_logo.scaled(469, 700, Qt::IgnoreAspectRatio);
//pm_logo.scaledToHeight(350, Qt::FastTransformation);
palette.setBrush(QPalette::Background,QBrush(QPixmap(":/res/image/screensaver-600-1024.jpg")));
setPalette(palette);
setLayout(hbLayout);
*/
QLabel* blackBg = new QLabel(this);
blackBg->resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
blackBg->setStyleSheet("QLabel{background:#000000;}");
m_stack_scPage = new QStackedWidget(this);
QGridLayout* layout = new QGridLayout();
layout->addWidget(blackBg, 0, 0);
layout->addWidget(m_stack_scPage, 0, 0);
layout->setMargin(0);
setLayout(layout);
resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimer()));
connect(m_stack_scPage, SIGNAL(currentChanged(int)), this, SIGNAL(signalCurrentChange(int)));
}
recoUiScreensaver::~recoUiScreensaver()
{
qDebug() << "~recoUiScreensaver()";
if(m_thLoadBg){
m_thLoadBg->quit();
m_thLoadBg->wait();
}
}
bool recoUiScreensaver::eventFilter(QObject *watched, QEvent *event)
{
if( watched == this){
if(event->type() == QEvent::MouseButtonPress){
qDebug() << "recoUiScreensaver mouse press";
if(m_backstageIf){
qDebug() << "recoUiScreensaver wakeUpFromScreenSaverOrScreenOff";
m_backstageIf->wakeUpFromScreenSaverOrScreenOff();
}
}
}
else{
return QWidget::eventFilter(watched, event);
}
return false;
}
bool recoUiScreensaver::event(QEvent *event)
{
switch( event->type() )
{
case QEvent::TouchBegin:
{
qDebug() << "recoUiScreensaver touch begin";
if(m_backstageIf){
m_backstageIf->wakeUpFromScreenSaverOrScreenOff();
}
event->accept();
return true;
}
case QEvent::TouchUpdate:
{
event->accept();
return true;
}
case QEvent::TouchEnd:
{
qDebug() << "recoUiScreensaver touch end";
event->accept();
return true;
}
default:
break;
}
return QWidget::event(event);
}
void recoUiScreensaver::setBackstageUiinterface(BackstageInterfaceForUi *interface)
{
m_backstageIf = interface;
slotUpdateScreenSaver();
}
void recoUiScreensaver::slotUpdateScreenSaver()
{
qDebug() << "slotUpdateScreenSaver:" << m_sourceType;
if(m_isLoading){
qDebug() << "bg is loading...";
return;
}
stScreensaverCfg cfg;
if(0 == (0 == m_sourceType ? m_backstageIf->getScreenSaverConfig(cfg) : m_backstageIf->getRecoUiAdConfig(cfg))){
m_iTimerInterval = cfg.interval * 1000;
m_timer->start(m_iTimerInterval);
qDebug() << "getScreenSaverConfig successed, time interval:" << m_iTimerInterval;
m_ilastBgQty = m_stack_scPage->count();
qDebug() << "m_ilastBgQty:" << m_ilastBgQty;
qDebug() << "type:" << cfg.type << " qty:" << cfg.picQty;
QStringList pics;
QString picsCmp;
if(0 == cfg.type){
//m_stack_scPage->addWidget(new Screensaver(UiConfig::GetInstance()->getScreenSaver(), this));
if(0 == m_sourceType){
picsCmp = SCREENSAVER[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->defaultScreensaver()];
}
else{
picsCmp = AD_IMG[UiConfig::GetInstance()->getScreenConfigIndex()];
}
pics << picsCmp;
}
else if(1 == cfg.type){
for (int i=0; i<cfg.picQty; i++) {
picsCmp += cfg.pic[i];
pics << cfg.pic[i];
}
}
if(picsCmp == m_lastPics){
qDebug() << "same screensaver";
return;
}
m_isLoading = true;
m_lastPics = picsCmp;
startThread();
emit signalLoadBGs(pics, QSize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight()));
}
}
void recoUiScreensaver::slotTimer()
{
//qDebug() << "slotTimer";
m_stack_scPage->setCurrentIndex(m_stack_scPage->currentIndex() < m_stack_scPage->count() - 1 ? m_stack_scPage->currentIndex() + 1 : 0);
}
void recoUiScreensaver::slotOneBGReady(const QPixmap& pic)
{
//qDebug() << "recoUiScreensaver::slotOneBGReady";
m_stack_scPage->addWidget(new Screensaver(pic, this));
}
void recoUiScreensaver::slotAllBGDone()
{
//qDebug() << "recoUiScreensaver::slotAllBGDone";
if(m_ilastBgQty){
for(int i=0; i<m_ilastBgQty; i++){
QWidget* widget = m_stack_scPage->widget(0);
m_stack_scPage->removeWidget(widget);
widget->deleteLater();
qDebug() << "delete bg:" << i;
}
}
if(m_stack_scPage->count() > 1){
m_timer->start(m_iTimerInterval);
}
else {
m_timer->stop();
}
m_isLoading = false;
}
void recoUiScreensaver::startThread()
{
if(m_thLoadBg){
return;
}
m_thLoadBg= new QThread();
m_oLoadBg = new BgLoadThread();
m_oLoadBg->moveToThread(m_thLoadBg);
connect(m_thLoadBg,&QThread::finished,m_thLoadBg,&QObject::deleteLater);
connect(m_thLoadBg,&QThread::finished,m_oLoadBg,&QObject::deleteLater);
connect(this,&recoUiScreensaver::signalLoadBGs,m_oLoadBg,&BgLoadThread::slotloadBGs);
connect(m_oLoadBg, SIGNAL(signalOneBGReady(const QPixmap&)), this, SLOT(slotOneBGReady(const QPixmap&)));
connect(m_oLoadBg, SIGNAL(signalAllBGDone()), this, SLOT(slotAllBGDone()));
m_thLoadBg->start();
}

View File

@ -0,0 +1,77 @@
#ifndef RECOUISCREENSAVER_H
#define RECOUISCREENSAVER_H
#include <QWidget>
#include <QLabel>
#include "UiConfig.h"
#include "UiTools.h"
#include "QThread"
class BgLoadThread : public QObject
{
Q_OBJECT
public:
BgLoadThread(QObject* parent = nullptr);
~BgLoadThread();
public slots:
void slotloadBGs(const QStringList& pics, const QSize& bgSize);
signals:
void signalOneBGReady(const QPixmap&);
void signalAllBGDone();
};
class Screensaver : public QWidget
{
Q_OBJECT
public:
explicit Screensaver(const QString& pic, QWidget *parent = nullptr);
explicit Screensaver(const QPixmap& pic, QWidget *parent = nullptr);
};
class recoUiScreensaver : public WidgetWithBackstageInterface
{
Q_OBJECT
public:
static const int DEFAULT_SCREENSAVER_QUANTITY = 3;
static const QString SCREENSAVER[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY][DEFAULT_SCREENSAVER_QUANTITY];
static const QString AD_IMG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit recoUiScreensaver(int sourceType, QWidget *parent = nullptr);
~recoUiScreensaver();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
public slots:
void slotUpdateScreenSaver();
void slotTimer();
void slotOneBGReady(const QPixmap&);
void slotAllBGDone();
private:
//QLabel* m_label_background;
//QLabel* m_label_logo;
//QLabel* m_label_time;
QStackedWidget* m_stack_scPage;
QTimer* m_timer;
int m_iTimerInterval;
int m_ilastBgQty;
BgLoadThread* m_oLoadBg = nullptr;
QThread* m_thLoadBg = nullptr;
QString m_lastPics = "default";
const int m_sourceType;
bool m_isLoading = false;
void startThread();
bool eventFilter(QObject *watched, QEvent *event);
bool event(QEvent *event);
signals:
void signalLoadBGs(const QStringList&, const QSize& bgSize);
void signalCurrentChange(int index);
};
#endif // RECOUISCREENSAVER_H

View File

@ -0,0 +1,209 @@
#include "recoUiUnauthorized.h"
#include <QDebug>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QTime>
#include <QBitmap>
#include <QPainter>
recoUiUnauthorized::recoUiUnauthorized(QWidget *parent) : QWidget(parent)
{
qDebug() << "recoUiUnauthorized()";
//title part
titleShow(LOGO_TIME);
_label_Bottom = new QLabel();
_label_Bottom->setObjectName("label_bottom");
_label_Bottom->setStyleSheet("#label_bottom{background-color: #181f33;}");
QFont ft;
QPalette pa;
m_label_msgUnahd = new QLabel();
m_label_msgUnahd->setText(tr("软件未授权"));
ft.setPointSize(72);
m_label_msgUnahd->setFont(ft);
m_label_msgUnahd->setObjectName("label_tip");
m_label_msgUnahd->setStyleSheet("#label_tip{color:#FF9c00;}");
// pa.setColor(QPalette::WindowText,Qt::yellow);
m_label_msgUnahd->setPalette(pa);
m_label_msg = new QLabel();
m_label_msg->setText(tr("请联系平台管理员"));
ft.setPointSize(25);
m_label_msg->setFont(ft);
pa.setColor(QPalette::WindowText,Qt::white);
m_label_msg->setPalette(pa);
m_btn_reCheck = new QPushButton();
m_btn_reCheck->setText(tr("重新检测授权状态"));
m_btn_reCheck->setObjectName("pushButton_reCheck");
m_btn_reCheck->setStyleSheet("#pushButton_reCheck{color:#FFFFFF; background-color:#949eba;}");//font-size:25px;
m_btn_reCheck->setMinimumHeight(30);
m_btn_sysSet = new QPushButton();
m_btn_sysSet->setText(tr("进入系统设置"));
m_btn_sysSet->setObjectName("pushButton_sysSet");
m_btn_sysSet->setStyleSheet("#pushButton_sysSet{color:#FFFFFF; background-color:#949eba;}");//font-size:25px;
m_btn_sysSet->setMinimumHeight(30);
QHBoxLayout* hbLayout_btn = new QHBoxLayout();
hbLayout_btn->addWidget(m_btn_reCheck/*, 1, Qt::AlignBaseline | Qt::AlignTop */);
hbLayout_btn->addSpacing(10);
hbLayout_btn->addWidget(m_btn_sysSet/*, 1, Qt::AlignBaseline | Qt::AlignTop */);
hbLayout_btn->setMargin(34);
QVBoxLayout* vbLayout_msg = new QVBoxLayout();
vbLayout_msg->addSpacing(72);
vbLayout_msg->addWidget(m_label_msgUnahd, 3, /*Qt::AlignBottom |*/ Qt::AlignCenter);
vbLayout_msg->addWidget(m_label_msg, 1, /*Qt::AlignBottom | */Qt::AlignCenter);
vbLayout_msg->addLayout(hbLayout_btn, 3);
vbLayout_msg->addSpacing(16);
_label_Bottom->setLayout(vbLayout_msg);
QHBoxLayout *pHLayoutLabel = new QHBoxLayout();
pHLayoutLabel->addWidget(_label_Bottom);
pHLayoutLabel->setMargin(0);
QLabel *pLabelEmpty = new QLabel();
QVBoxLayout* vbLayout = new QVBoxLayout();
vbLayout->addLayout(_HLayoutTitle, 1);
vbLayout->addWidget(pLabelEmpty, 6);
vbLayout->addLayout(pHLayoutLabel, 3);
vbLayout->setMargin(0);
// vbLayout->addLayout(vbLayout_msg, 6);
// vbLayout->addLayout(hbLayout_btn, 4);
// vbLayout->setSpacing(80);
setLayout(vbLayout);
//floor two
_widgetMainReco = new QWidget(this);
_widgetMainReco->setMinimumSize(476, 800);
m_label_iconUnahd = new QLabel();
m_label_iconUnahd->setObjectName("label_iconUnahd");
m_label_iconUnahd->setStyleSheet("#label_iconUnahd{min-width: 112px;min-height:112px;max-width: 112px;max-height: 112px;border-radius: 56px;\
border-width: 0 0 0 0;background-color:#FF9c00;}");
QPixmap pm(":/res/image/unauthorized.png");
QPixmap fitpixmap_faceIcon=pm.scaled(68, 68, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
fitpixmap_faceIcon = PixmapToRound(fitpixmap_faceIcon,34);
m_label_iconUnahd->setPixmap(fitpixmap_faceIcon);
m_label_iconUnahd->setAlignment(Qt::AlignCenter);
QLabel *pLabelTop = new QLabel();
QLabel *pLabelBottom = new QLabel();
QVBoxLayout* pVLayoutIcon = new QVBoxLayout();
pVLayoutIcon->addWidget(pLabelTop, 5);
pVLayoutIcon->addWidget(m_label_iconUnahd, 1, Qt::AlignHCenter);
pVLayoutIcon->addWidget(pLabelBottom, 2);
_widgetMainReco->setLayout(pVLayoutIcon);
}
recoUiUnauthorized::~recoUiUnauthorized()
{
qDebug() << "~recoUiUnauthorized()";
}
void recoUiUnauthorized::titleShow(recoUiUnauthorized::TITLE_LAYOUT titleIndex)
{
if(titleIndex > LOGO_TIME)
{
return;
}
//show logo
if( titleIndex == LOGO_MID )
{
}
else if(titleIndex == TIME_MID) //show time
{
}
else
{/*show logo and time*/
// _WidgetTitle = new QWidget(_widgetMainReco);
showRWLogo(":/res/image/ProjectSet_Intenet.png", NULL);
showTime();
_HLayoutTitle = new QHBoxLayout();
_HLayoutTitle->addWidget(_labelRWIcon, 1,Qt::AlignCenter);
_HLayoutTitle->addWidget(_labelRWLogo, 10, Qt::AlignLeft);
_HLayoutTitle->addWidget(_labelTime, 1, Qt::AlignCenter);
}
}
void recoUiUnauthorized::showRWLogo(QString icon, QString rw)
{
//ICON
QPixmap pm(icon);
pm = pm.scaled(40, 40, Qt::KeepAspectRatio);
_labelRWIcon = new QLabel();
_labelRWIcon->setPixmap(pm);
_labelRWIcon->setObjectName("label_icon");
//LOGO
_labelRWLogo = new QLabel();
_labelRWLogo->setObjectName("label_logo");
_labelRWLogo->setText(tr("瑞为技术\nRECONOVA"));
_labelRWLogo->setStyleSheet("#label_logo{color:#FFFFFF;}");
}
void recoUiUnauthorized::showTime()
{
QTime time = QTime::currentTime();
QString timeStr = time.toString("hh:mm");
_labelTime = new QLabel();
_labelTime->setObjectName("label_time");
_labelTime->setText(timeStr);
_labelTime->setStyleSheet("#label_time{color:#FFFFFF;font-size:30px}");
}
void recoUiUnauthorized::showRecoInfo(QString name, QString id, QString part)
{
QLabel *pLabelName = new QLabel(_widgetReco);
QLabel *pLabelId = new QLabel(_widgetReco);
QLabel *pLabelPart = new QLabel(_widgetReco);
pLabelName->setObjectName("label_name");
pLabelId->setObjectName("label_id");
pLabelPart->setObjectName("label_part");
pLabelName->setStyleSheet("#label_name{font-size:72px; color:#0ebcf8;}");
pLabelId->setStyleSheet("#label_id{font-size:25px; color:#FFFFFF;}");
pLabelPart->setStyleSheet("#label_part{font-size:25px; color:#FFFFFF;}");
pLabelName->setText(tr(name.toUtf8()));
pLabelId->setText(tr(id.toUtf8()));
pLabelPart->setText(tr(part.toUtf8()));
QVBoxLayout *pVLayoutInfo = new QVBoxLayout(_widgetReco);
pVLayoutInfo->addWidget(pLabelName, 1, Qt::AlignCenter);
pVLayoutInfo->addWidget(pLabelId, 1, Qt::AlignCenter);
pVLayoutInfo->addWidget(pLabelPart, 1, Qt::AlignCenter);
pVLayoutInfo->setMargin(nSpace);
}
QPixmap recoUiUnauthorized::PixmapToRound(QPixmap &src, int radius)
{
if (src.isNull()) {
return QPixmap();
}
QSize size(2*radius, 2*radius);
QBitmap mask(size);
QPainter painter(&mask);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
painter.fillRect(0, 0, size.width(), size.height(), Qt::white);
painter.setBrush(QColor(0, 0, 0));
painter.drawRoundedRect(0, 0, size.width(), size.height(), 99, 99);
QPixmap image = src.scaled(size);
image.setMask(mask);
return image;
}

View File

@ -0,0 +1,59 @@
#ifndef RECOUIUNAUTHORIZED_H
#define RECOUIUNAUTHORIZED_H
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QHBoxLayout>
class recoUiUnauthorized : public QWidget
{
Q_OBJECT
public:
static constexpr int screenWidth = 600;
static constexpr int itemHeight = 41;
static constexpr int nSpace = 14;
enum TITLE_LAYOUT{
LOGO_MID = 0,
TIME_MID,
LOGO_TIME,
MAX
};
public:
explicit recoUiUnauthorized(QWidget *parent = 0);
~recoUiUnauthorized();
void titleShow(TITLE_LAYOUT titleIndex);
signals:
public slots:
private:
void showRWLogo(QString icon, QString rw);
void showTime();
void showRecoInfo(QString name, QString id, QString part);
QPixmap PixmapToRound(QPixmap &src, int radius);
private:
QLabel* _label_Bottom;
QLabel* m_label_iconUnahd;
QLabel* m_label_msgUnahd;
QLabel* m_label_msg;
QPushButton* m_btn_reCheck;
QPushButton* m_btn_sysSet;
QWidget* _widgetMainReco;
QLabel* _labelRWIcon;
QLabel* _labelRWLogo;
QLabel* _labelTime;
QWidget* _widgetReco;
QLabel* _labelRecoRes;
QWidget* _WidgetTitle;
QHBoxLayout* _HLayoutTitle;
};
#endif // RECOUIUNAUTHORIZED_H

View File

@ -0,0 +1,66 @@
#include <QTime>
#include <UiTools.h>
#include <QDebug>
#include "settingUIProjectSet.h"
#include "settingUi.h"
const int settingUIProjectSet::BtnQty = settingUi::PAGE_DEV_TEST - settingUi::PAGE_INFO;
const int settingUIProjectSet::FristPageIndex = settingUi::PAGE_INFO;
settingUIProjectSet::settingUIProjectSet(QWidget *parent) : MyWidgetWithSubStyleColor(parent)
{
qDebug() << "settingUIProjectSet()";
//setStyleSheet(" background:rgb(240, 242, 245);");//border-width:0;border-style:outset;
//setFixedWidth(UiConfig::GetInstance()->getUiWidth());
const int btnWidth = ( UiConfig::GetInstance()->getUiWidth() - 4 * nSpace ) / 3;
const QSize btnSize(btnWidth, btnWidth);
const QString btnsName[BtnQty] = {":/res/image/ProjectSetCheckInfo.png",
":/res/image/ProjectSetDevMng.png",
":/res/image/ProjectSetFaceMng.png",
":/res/image/ProjectSetAccMng.png",
":/res/image/ProjectSetReco.png",
":/res/image/ProjectSetSysMng.png",
":/res/image/ProjectSetFastCfg.png",
":/res/image/ProjectSetNetwork.png"
};
QGridLayout* pLayout = new QGridLayout();
m_pPushBtns = new QPushButton[BtnQty];
int col = 0;
for(int i = 0; i < BtnQty; i ++){
m_pPushBtns[i].setParent(this);
settingUi* setUi = dynamic_cast<settingUi*>(parent);
if(setUi){
setPushButton(&m_pPushBtns[i], (*setUi)[static_cast<unsigned>(FristPageIndex + i)], btnsName[i], btnSize);
pLayout->addWidget(&m_pPushBtns[i], i / 3, col++);
if(3 == col){
col = 0;
}
connect(&m_pPushBtns[i], SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
}
else {
qDebug() << "oooop!";
}
}
pLayout->setSpacing(nSpace);
pLayout->setMargin(0);
QLabel *pEmpty = new QLabel(this);
QVBoxLayout* _VLayout = new QVBoxLayout();
_VLayout->addLayout(pLayout,3);
_VLayout->addWidget(pEmpty, 1);
_VLayout->setMargin(nSpace);
setLayout(_VLayout);
}
void settingUIProjectSet::slotBtnClicked()
{
for(int i = 0; i <= BtnQty; i ++){
if(sender() == &m_pPushBtns[i]){
emit pageSetSignal(i + FristPageIndex);
break;
}
}
}

View File

@ -0,0 +1,31 @@
#ifndef SETTINGUIPROJECTSET_H
#define SETTINGUIPROJECTSET_H
#include <QPushButton>
#include "UiTools.h"
#include "UiConfig.h"
class settingUIProjectSet : public MyWidgetWithSubStyleColor
{
Q_OBJECT
public:
static constexpr int itemHeight = UiConfig::SETTING_PAGE_ITEM_HEIGHT;
static constexpr int nSpace = UiConfig::SETTING_PAGE_WIDGET_TO_FRAME;
public:
explicit settingUIProjectSet(QWidget *parent = nullptr);
signals:
void pageSetSignal(int nIndex, const QString = "");
public slots:
void slotBtnClicked();
private:
static const int BtnQty;
static const int FristPageIndex;
QPushButton *m_pPushBtns;
};
#endif // SETTINGUIPROJECTSET_H

View File

@ -0,0 +1,577 @@
#include "settingUi.h"
#include <QDebug>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPalette>
#include <QPainter>
#include <QGridLayout>
#include <QTimer>
#include <QBitmap>
#include "UiTools.h"
#include "UiConfig.h"
#include "keyboard.h"
settingUiTop::settingUiTop(QWidget *parent) : MyWidgetWithMainStyleColor(parent)
{
qDebug() << "settingUiTop()";
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText,Qt::black);
m_label_ip = new QLabel(this);
//m_label_ip->setText("IP:192.168.10.106");
//m_label_ip->setMinimumSize(60, 30);
m_label_ip->setPalette(palette);
//IP项去掉需求不要求
m_label_ip->hide();
m_label_time = new QLabel(this);
// m_label_time->setText("10:12");
m_label_time->setPalette(palette);
_timerUpdate = new TimerUpdate(m_label_time, this);
m_btn_back = new QPushButton(this);
setButtonBackImage(m_btn_back, ":res/image/ProjectSet_return.png", 20, 40);
m_btn_back->setFixedWidth(UiConfig::GetInstance()->getUiWidth() / 10);
//m_btn_back->setStyleSheet("QPushButton:focus{outline: none;}");
m_btn_back->setFocusPolicy(Qt::NoFocus);
m_label_pageMsg = new QLabel(this);
m_label_pageMsg->setText("this is page title");
m_label_pageMsg->setPalette(palette);
m_label_pageMsg->setAlignment(Qt::AlignCenter);
m_label_pageMsg->setMinimumWidth(UiConfig::GetInstance()->getUiWidth() / 3);
QFont ft;
ft.setPointSize(UiConfig::GetInstance()->getGlobalFontSize());
m_label_pageMsg->setFont(ft);
m_btn_rightSide = new QPushButton(this);
m_btn_rightSide->setFocusPolicy(Qt::NoFocus);
m_btn_rightSide->setStyleSheet("color:blue;"
"background-color: transparent;"
"border:none;");
m_btn_rightSide->hide();
QHBoxLayout* hbLayout_top = new QHBoxLayout();
hbLayout_top->addWidget(m_label_ip, 1, Qt::AlignLeft);
hbLayout_top->addWidget(m_label_time, 1, Qt::AlignRight);
QHBoxLayout* hbLayoutMid = new QHBoxLayout();
hbLayoutMid->addWidget(m_btn_back, 1, Qt::AlignLeft);
//hbLayoutMid->addWidget(m_label_pageMsg, 100, Qt::AlignCenter);
hbLayoutMid->addWidget(m_btn_rightSide, 1, Qt::AlignRight);
QVBoxLayout* vbLayout = new QVBoxLayout();
vbLayout->addLayout(hbLayout_top);
vbLayout->addLayout(hbLayoutMid);
vbLayout->setContentsMargins(20, 10, 0, 10);
setLayout(vbLayout);
//setStyleSheet("border-bottom: 3px solid #DFDDEB;");
connect(m_btn_back, SIGNAL(clicked(bool)), this, SIGNAL(signalReturnBtnClicked()));
connect(m_btn_rightSide, SIGNAL(clicked(bool)), this, SIGNAL(signalRightSideBtnClicked()));
}
settingUiTop::~settingUiTop()
{
qDebug() << "~settingUiTop()";
if(nullptr != _timerUpdate){
delete _timerUpdate;
}
}
void settingUiTop::update_Ip(const QString& str)
{
if(m_label_ip){
m_label_ip->setText(str);
}
}
void settingUiTop::setRightSideBtn(bool isShow, const QString btnName)
{
m_btn_rightSide->setText(btnName);
m_btn_rightSide->setVisible(isShow);
}
void settingUiTop::slotShowPageMsg(const QString& msg)
{
//qDebug() << "slotShowPageMsg:" << msg;
m_label_pageMsg->setText(msg);
m_label_pageMsg->move((UiConfig::GetInstance()->getUiWidth() - m_label_pageMsg->width()) / 2,
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.05));
}
void settingUi::showPage(int nIndex, const QString& title)
{
qDebug() << "showPage:" << nIndex;
if( (PAGE_PROJECT > nIndex ) || ( nIndex >= PAGE_MAX ) )
{
qDebug()<<"page index error : " << nIndex;
return;
}
if(m_stack_setPage->currentIndex() == nIndex){
qDebug() << "same setting page!";
return;
}
//控制条右侧按钮存在与否
if(m_map_rightBtnName.contains(nIndex))
{
m_ctlBar->setRightSideBtn(true, m_map_rightBtnName[nIndex]);
}else
{
m_ctlBar->setRightSideBtn(false);
}
bool needReset = nIndex > m_stack_setPage->currentIndex();
if(nIndex == PAGE_DEV_MNG || nIndex == PAGE_DEV_MNG_BT_SPK || nIndex == PAGE_DEV_MNG_BT_LOCK || nIndex == PAGE_FACE_MNG)
{//设备管理页面和蓝牙页面,回退时也reset
needReset = true;
}
//qDebug() << "needReset:" << needReset << "nIndex:" << nIndex;
m_stack_setPage->setCurrentIndex(nIndex);
QCoreApplication::processEvents();
m_onIndexPage = (PAGE_PROJECT == nIndex);
emit signalShowPageMsg(title);
if(needReset){
switch(nIndex){
case PAGE_INFO:
m_infoPage->reset();
break;
case PAGE_DEV_MNG:
m_devMngPage->reset();
break;
case PAGE_FACE_MNG:
m_faceMngPage->reset();
break;
case PAGE_ACCESS_MNG:
m_accMngPage->reset();
break;
case PAGE_RECO:
m_recoSetPage->reset();
break;
case PAGE_SYS_MNG:
m_sysMngPage->reset();
break;
case PAGE_FAST_CFG_WIRE_NET:
m_fastCfgWireNet->reset();
break;
case PAGE_DEV_TEST:
m_devTestPage->reset();
break;
case PAGE_DEV_MNG_TIME:
m_devMngTimePage->reset();
break;
case PAGE_DEV_MNG_NETWORK:
m_devMngNetworkPage->reset();
break;
case PAGE_DEV_MNG_NET_WIRE:
m_devMngNetWirePage->reset();
break;
case PAGE_DEV_MNG_NET_WIFI:
m_devMngNetWifiPage->reset();
break;
case PAGE_DEV_MNG_NET_WIFI_ACC_POINT:
m_devMngNetWifiAccPointPage->reset();
break;
case PAGE_DEV_MNG_NET_4G:
m_devMngNet4GPage->reset();
break;
case PAGE_DEV_MNG_BT:
m_devMngBtPage->reset();
break;
case PAGE_DEV_MNG_BT_SPK:
m_devMngBtSpkPage->reset();
break;
case PAGE_DEV_MNG_BT_SPK_ACC_POINT:
m_devMngBtSpkAccPointPage->reset();
break;
case PAGE_DEV_MNG_BT_LOCK:
m_devMngBtLockPage->reset();
break;
case PAGE_DEV_MNG_BT_LOCK_ACC_POINT:
m_devMngBtLockAccPointPage->reset();
break;
case PAGE_FACE_MNG_FACE:
m_faceMngFacePage->reset();
break;
case PAGE_FACE_MNG_ACCESS_RECORD:
m_faceMngAccRedPage->reset();
break;
case PAGE_FACE_MNG_ADD_PERSON:
m_addPersonPage->reset();
break;
case PAGE_FACE_MNG_MODIFY_PERSON:
m_modifyPersonPage->reset();
break;
case PAGE_FACE_MNG_SNAP_FACE:
m_snapFacePage->reset();
break;
case PAGE_FAST_CFG_PARK:
m_fastCfgPark->reset();
case PAGE_FAST_CFG_QRCODE:
m_fastCfgQrcode->reset();
break;
default:
break;
}
}
qDebug() << "showPage end";
}
void settingUi::slotShowPage(int nIndex, const QString title)
{
//qDebug() << "push index:" << m_stack_setPage->currentIndex() << "nIndex:" << nIndex;
m_pageIndex.push(m_stack_setPage->currentIndex());
showPage(nIndex, "" != title ? title : SetPageName[nIndex]);
keyboard::close();
}
void settingUi::slotReturnClicked()
{
if(m_syncFlag){
qDebug() << "slotReturnClicked return immediately";
return;
}
m_syncFlag = true;
if(m_stack_setPage->currentIndex() == PAGE_FACE_MNG_ADD_PERSON ||
m_stack_setPage->currentIndex() == PAGE_FACE_MNG_MODIFY_PERSON){
m_backstageIf->stopIdentyState(false, true);
}
else if(m_stack_setPage->currentIndex() == PAGE_FAST_CFG_QRCODE){
UiConfig::GetInstance()->setFastCfgStatus(false);
}
if(m_onIndexPage){
emit signalShowRecoPage();
}
else if(m_stack_setPage->currentIndex() == PAGE_DEV_TEST){
m_stack_setPage->setCurrentIndex(PAGE_PROJECT);
emit signalShowRecoPage();
UiConfig::GetInstance()->setDevTestStatus(false);
}
else{
if(m_pageIndex.size()){
int pageIndex = m_pageIndex.pop();
//qDebug() << "pop index:" << pageIndex;
showPage(pageIndex, SetPageName[pageIndex]);
}
}
keyboard::close();
m_syncFlag = false;
}
void settingUi::slotRightSideBtnClicked()
{
int index = m_stack_setPage->currentIndex();
qDebug() << __PRETTY_FUNCTION__ << "currentIndex=" << index;
switch (index) {
case PAGE_FACE_MNG_FACE:
m_faceMngFacePage->clickBtn_addPerson();
break;
case PAGE_FACE_MNG_MODIFY_PERSON:
m_modifyPersonPage->savePersonInfo();
break;
default:
break;
}
}
settingUi::settingUi(QWidget *parent) : WidgetWithBackstageInterface(parent), m_syncFlag(false)
{
qDebug() << "settingUi()";
QPalette pal = palette();
pal.setColor(QPalette::Background, Qt::transparent);
setPalette(pal);
m_ctlBar = new settingUiTop(this);
m_stack_setPage = new QStackedWidget(this);
m_pProjectSetPage = new settingUIProjectSet(this);
int pageIndex = 1;
m_infoPage = new settingUiInfo(pageIndex++, this);
m_devMngPage = new settingUiDevMng(pageIndex++, this);
m_faceMngPage = new settingUiFaceMng(pageIndex++, this);
m_accMngPage = new settingUiAccMng(pageIndex++, this);
m_recoSetPage = new settingUiRecoSet(pageIndex++, this);
m_sysMngPage = new settingUiSysMng(pageIndex++, this);
m_fastCfgWireNet = new settingUiFastCfgWireNet(pageIndex++, this);
connect(m_fastCfgWireNet, SIGNAL(signalJumpPage(int)), this, SLOT(slotJumpPage(int)));
m_devMngNetworkPage = new settingUiDevMngNetwork(pageIndex++, m_devMngPage);
connect(m_devMngNetworkPage, SIGNAL(signalShowPage(int, const QString)), this, SLOT(slotShowPage(int, const QString)));
m_devTestPage = new settingUiDevTest(pageIndex++, this);
//subPage
m_devMngTimePage = new settingUiDevMngTime(pageIndex++, m_devMngPage);
connect(m_devMngPage, SIGNAL(signalShowPage(int, const QString)), this, SLOT(slotShowPage(int, const QString)));
m_devMngNetWirePage = new settingUiDevMngNetWire(pageIndex++, m_devMngNetworkPage);
m_devMngNetWifiPage = new settingUiDevMngNetWifi(pageIndex++, m_devMngNetworkPage);
m_devMngNetWifiAccPointPage = new settingUiDevMngNetWifiAccPoint(pageIndex++, m_devMngNetWifiPage);
connect(m_devMngNetWifiPage, SIGNAL(signalShowPage(int, const QString)), this, SLOT(slotShowPage(int, const QString)));
connect(m_devMngNetWifiAccPointPage, SIGNAL(signalShowPage(int, const QString)), this, SLOT(slotShowPage(int, const QString)));
connect(m_devMngNetWifiAccPointPage, SIGNAL(signalReturn()), this, SLOT(slotReturnClicked()));
connect(m_devMngNetWifiAccPointPage, SIGNAL(signalUpdateConnectionStatus(QString, bool)), m_devMngNetWifiPage,
SLOT(slotUpdateConnectionStatus(QString, bool)));
m_devMngNet4GPage = new settingUiDevMngNet4G(pageIndex++, m_devMngNetworkPage);
m_devMngBtPage = new settingUiDevMngBt(pageIndex++, m_devMngPage);
connect(m_devMngBtPage, SIGNAL(signalShowPage(int, const QString)), this, SLOT(slotShowPage(int, const QString)));
m_devMngBtSpkPage = new settingUiDevMngBtSpk(pageIndex++, m_devMngPage);
m_devMngBtSpkAccPointPage = new settingUiDevMngBtSpkAccPoint(pageIndex++, m_devMngBtSpkPage);
connect(m_devMngBtSpkPage, SIGNAL(signalShowPage(int, const QString)), this, SLOT(slotShowPage(int, const QString)));
connect(m_devMngBtSpkPage, SIGNAL(signalClickSet(BluetoothDev_t)), m_devMngBtSpkAccPointPage, SLOT(setAccPointInfo(BluetoothDev_t)));
connect(m_devMngBtSpkAccPointPage, SIGNAL(signalReturn()), this, SLOT(slotReturnClicked()));
m_devMngBtLockPage = new settingUiDevMngBtLock(pageIndex++, m_devMngPage);
connect(m_devMngBtLockPage, SIGNAL(signalShowPage(int, const QString)), this, SLOT(slotShowPage(int, const QString)));
m_devMngBtLockAccPointPage = new settingUiDevMngBtLockAccPoint(pageIndex++, m_devMngBtLockPage);
connect(m_devMngBtLockPage, SIGNAL(signalCurrentLock(const QString&)), m_devMngBtLockAccPointPage, SLOT(slotCurrentLock(const QString&)));
connect(m_devMngBtLockAccPointPage, SIGNAL(signalUpdataTitle(const QString)), m_ctlBar, SLOT(slotShowPageMsg(const QString)));
connect(m_devMngBtLockAccPointPage, SIGNAL(signalRefresh()), m_devMngBtLockPage, SLOT(slotRefresh()));
connect(m_devMngBtLockAccPointPage, SIGNAL(signalRefresh()), this, SLOT(slotReturnClicked()));
m_map_rightBtnName[pageIndex] = QString(tr("添加人员"));
m_faceMngFacePage = new FaceDbPage(pageIndex++, m_faceMngPage);
m_faceMngAccRedPage = new AccessRecordPage(pageIndex++, m_faceMngPage);
connect(m_faceMngPage, SIGNAL(signalShowPage(int, const QString)), this, SLOT(slotShowPage(int, const QString)));
connect(m_faceMngFacePage, SIGNAL(signalShowPage(int, const QString)), this, SLOT(slotShowPage(int, const QString)));
connect(m_devTestPage, SIGNAL(signalShowSettingUi()), parent, SLOT(slotShowSettingUi()));
m_addPersonPage = new AddPersonPage(pageIndex++, m_faceMngFacePage);
m_map_rightBtnName[pageIndex] = QString(tr("保存"));
m_modifyPersonPage = new ModifyPersonPage(pageIndex++, m_faceMngFacePage);
m_snapFacePage = new SnapFacePage(pageIndex++, m_faceMngFacePage);
connect(m_addPersonPage, SIGNAL(signalShowPage(int, const QString)), this, SLOT(slotShowPage(int, const QString)));
connect(m_modifyPersonPage, SIGNAL(signalShowPage(int, const QString)), this, SLOT(slotShowPage(int, const QString)));
connect(m_faceMngFacePage, SIGNAL(signalPersonInfo(stQueryPersonInfo &)), m_modifyPersonPage, SLOT(slotSetPersonInfo(stQueryPersonInfo &)));
connect(m_addPersonPage, SIGNAL(signalChangePersonDB()), m_faceMngFacePage, SLOT(slot_freshPage()));
connect(m_modifyPersonPage, SIGNAL(signalChangePersonDB()), m_faceMngFacePage, SLOT(slot_freshPage()));
connect(m_addPersonPage, SIGNAL(signalReturn()), this, SLOT(slotReturnClicked()));
connect(m_modifyPersonPage, SIGNAL(signalReturn()), this, SLOT(slotReturnClicked()));
connect(parent, SIGNAL(signalIcCardResult(const QString&)), m_addPersonPage, SLOT(slotIcCardResult(const QString&)));
connect(parent, SIGNAL(signalIcCardResult(const QString&)), m_modifyPersonPage, SLOT(slotIcCardResult(const QString&)));
connect(m_snapFacePage, SIGNAL(signalReturn()), this, SLOT(slotReturnClicked()));
connect(m_snapFacePage, SIGNAL(signalSnapFace(std::string &, std::string &)), m_addPersonPage, SLOT(slotSnapFace(std::string &, std::string &)));
m_fastCfgPark = new settingUiFastCfgPark(pageIndex++, this);
connect(m_fastCfgPark, SIGNAL(signalJumpPage(int)), this, SLOT(slotJumpPage(int)));
m_fastCfgQrcode = new SettingUiQrcode(pageIndex++, this);
connect(parent, SIGNAL(signalCenterMsg(const int, const QString&)), m_fastCfgQrcode, SLOT(slotCenterMsg(const int, const QString&)));
connect(m_fastCfgQrcode, SIGNAL(signalExitSettingUi()), this, SLOT(slotExitSettingUi()));
connect(parent, SIGNAL(signalQrcodeFastCfgResult(bool)), m_fastCfgQrcode, SLOT(slotQrcodeFastCfgResult(bool)));
m_shadowPage = nullptr;
if(!UiConfig::GetInstance()->isRkDevice()){
m_shadowPage = new PureColorPage(0, 128);
}
#if 0 //rk test
m_la = new QLabel();
QPalette pal = palette();
pal.setColor(QPalette::Background, QColor(128, 128, 128, 128));
m_la->setPalette(pal);
m_la->resize(400, 680);
m_la->setPixmap(QPixmap(":/res/image/msg_box_bg_green.png"));
#endif
//add需要根据枚举定义顺序增加
m_stack_setPage->addWidget(m_pProjectSetPage);
m_stack_setPage->addWidget(m_infoPage);
m_stack_setPage->addWidget(m_devMngPage);
m_stack_setPage->addWidget(m_faceMngPage);
m_stack_setPage->addWidget(m_accMngPage);
m_stack_setPage->addWidget(m_recoSetPage);
m_stack_setPage->addWidget(m_sysMngPage);
m_stack_setPage->addWidget(m_fastCfgWireNet);
m_stack_setPage->addWidget(m_devMngNetworkPage);
m_stack_setPage->addWidget(m_devTestPage);
m_stack_setPage->addWidget(m_devMngTimePage);
m_stack_setPage->addWidget(m_devMngNetWirePage);
m_stack_setPage->addWidget(m_devMngNetWifiPage);
m_stack_setPage->addWidget(m_devMngNetWifiAccPointPage);
m_stack_setPage->addWidget(m_devMngNet4GPage);
m_stack_setPage->addWidget(m_devMngBtPage);
m_stack_setPage->addWidget(m_devMngBtSpkPage);
m_stack_setPage->addWidget(m_devMngBtSpkAccPointPage);
m_stack_setPage->addWidget(m_devMngBtLockPage);
m_stack_setPage->addWidget(m_devMngBtLockAccPointPage);
m_stack_setPage->addWidget(m_faceMngFacePage);
m_stack_setPage->addWidget(m_faceMngAccRedPage);
m_stack_setPage->addWidget(m_addPersonPage);
m_stack_setPage->addWidget(m_modifyPersonPage);
m_stack_setPage->addWidget(m_snapFacePage);
m_stack_setPage->addWidget(m_fastCfgPark);
m_stack_setPage->addWidget(m_fastCfgQrcode);
m_stack_setPage->setCurrentIndex(PAGE_PROJECT);
m_onIndexPage = true;
QVBoxLayout* vbLayout = new QVBoxLayout();
vbLayout->addWidget(m_ctlBar, 1);
vbLayout->addWidget(m_stack_setPage, 99);
vbLayout->setSpacing(0);
vbLayout->setMargin(0);
setLayout(vbLayout);
connect(m_ctlBar, SIGNAL(signalReturnBtnClicked()), this, SLOT(slotReturnClicked()));
connect(this, SIGNAL(signalShowPageMsg(QString)), m_ctlBar, SLOT(slotShowPageMsg(QString)));
connect(m_ctlBar, SIGNAL(signalRightSideBtnClicked()), this, SLOT(slotRightSideBtnClicked()));
connect(m_pProjectSetPage, SIGNAL(pageSetSignal(int, const QString)), this, SLOT(slotShowPage(int, const QString)) );
connect(parent, SIGNAL(signalDevTestMesAddrAndProdNoText(const QString&)), m_devTestPage, SLOT(slotDevTestMesAddrAndProdNoText(const QString&)));
connect(parent, SIGNAL(signalDevTestPcbSeqText(const QString&)), m_devTestPage, SLOT(slotDevTestPcbSeqText(const QString&)));
connect(parent, SIGNAL(signalDevTestConfigInfo(const QString&)), m_devTestPage, SLOT(slotDevTestConfigInfo(const QString&)));
qDebug() << "setting ui created!";
}
settingUi::~settingUi()
{
qDebug() << "~settingUi()";
}
void settingUi::setBackstageUiinterface(BackstageInterfaceForUi* interface)
{
m_backstageIf = interface;
m_infoPage->setBackstageUiinterface(interface);qDebug() << "infoPage reset";
m_devMngPage->setBackstageUiinterface(interface);qDebug() << "devMngPage reset";
m_faceMngPage->setBackstageUiinterface(interface);
m_accMngPage->setBackstageUiinterface(interface);
m_recoSetPage->setBackstageUiinterface(interface);
m_sysMngPage->setBackstageUiinterface(interface);
m_fastCfgWireNet->setBackstageUiinterface(interface);
m_devTestPage->setBackstageUiinterface(interface);
m_devMngTimePage->setBackstageUiinterface(interface);
m_devMngNetworkPage->setBackstageUiinterface(interface);
m_devMngNetWirePage->setBackstageUiinterface(interface);
m_devMngNetWifiPage->setBackstageUiinterface(interface);
m_devMngNetWifiAccPointPage->setBackstageUiinterface(interface);
m_devMngNet4GPage->setBackstageUiinterface(interface);
m_devMngBtPage->setBackstageUiinterface(interface);
m_devMngBtSpkPage->setBackstageUiinterface(interface);
m_devMngBtSpkAccPointPage->setBackstageUiinterface(interface);
m_devMngBtLockPage->setBackstageUiinterface(interface);
m_devMngBtLockAccPointPage->setBackstageUiinterface(interface);
m_faceMngFacePage->setBackstageUiinterface(interface);
m_faceMngAccRedPage->setBackstageUiinterface(interface);
m_addPersonPage->setBackstageUiinterface(interface);
m_modifyPersonPage->setBackstageUiinterface(interface);
m_snapFacePage->setBackstageUiinterface(interface);
m_fastCfgPark->setBackstageUiinterface(interface);
m_fastCfgQrcode->setBackstageUiinterface(interface);
reset();
}
void settingUi::slotShowAddFacePage()
{
//slotShowPage(PAGE_IMAGE);
}
void settingUi::slotRestoreFactory()
{
if(m_backstageIf){
m_backstageIf->recoveryFactorySetting();
}
}
void settingUi::slotShowShadowPage(bool show)
{
if(show){
if(m_shadowPage){
m_shadowPage->show();
}
//m_la->show();
}
else {
if(m_shadowPage){
m_shadowPage->hide();
}
//m_la->hide();
}
}
void settingUi::slotShowDevTestPage()
{
showPage(PAGE_DEV_TEST, SetPageName[PAGE_DEV_TEST]);
}
void settingUi::slotJumpPage(int pageIndex)
{
const QObject* send = sender();
if(send == m_fastCfgWireNet){
qDebug() << "fastCfgWireNet:" << pageIndex;
m_pageIndex.push(m_stack_setPage->currentIndex());
const int index = pageIndex + settingUiFastCfgPark::m_pageIndex;
showPage(index, SetPageName[index]);
}
else if(send == m_fastCfgPark){
qDebug() << "m_fastCfgPark:" << pageIndex;
m_pageIndex.push(m_stack_setPage->currentIndex());
const int index = pageIndex + SettingUiQrcode::m_pageIndex;
showPage(index, SetPageName[index]);
UiConfig::GetInstance()->setFastCfgStatus(true);
}
}
void settingUi::slotExitSettingUi()
{
m_stack_setPage->setCurrentWidget(m_pProjectSetPage);
m_pageIndex.clear();
m_syncFlag = false;
emit signalShowRecoPage();
UiConfig::GetInstance()->setFastCfgStatus(false);
}
void settingUi::update_IpBar()
{
if(nullptr == m_backstageIf){
return;
}
const int nSize = 128;
char buf[nSize] = "";
int type;
m_backstageIf->getIP(buf, nSize, type);
QString ipStr = buf;
m_ctlBar->update_Ip(ipStr);
}
QString settingUi::operator [] (unsigned index) const
{
QString ret;
if(index < (unsigned)SetPageName.size()){
ret = SetPageName[index];
}
return ret;
}
#if 0
void settingUi::showDevTestPage()
{
showPage(PAGE_DEV_TEST, SetPageName[PAGE_DEV_TEST]);
}
#endif
void settingUi::reset()
{
qDebug() << "settingUi::reset()";
update_IpBar();
emit signalShowPageMsg(SetPageName[PAGE_PROJECT]);
}

201
Linguist/setUi/settingUi.h Normal file
View File

@ -0,0 +1,201 @@
#ifndef SETTINGUI_H
#define SETTINGUI_H
#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include <QStackedWidget>
#include <QString>
#include <QDialog>
#include <QLineEdit>
#include <QStack>
#include "UiTools.h"
#include "LineEditWithKeyboard.h"
#include "BackstageInterfaceForUi.h"
#include "UiConfig.h"
#include "settingUIProjectSet.h"
#include "settingUiInfo.h"
#include "settingUiDevMng.h"
#include "settingUiFaceMng.h"
#include "settingUiAccMng.h"
#include "settingUiRecoSet.h"
#include "settingUiSysMng.h"
#include "settingUiDevTest.h"
#include "settingUiFastCfg.h"
class settingUiTop : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
explicit settingUiTop(QWidget *parent = nullptr);
~settingUiTop();
void update_Ip(const QString& str);
void setRightSideBtn(bool isShow, const QString btnName = "");
signals:
void signalReturnBtnClicked();
void signalRightSideBtnClicked();
public slots:
void slotShowPageMsg(const QString&);
private:
QLabel* m_label_ip;
QLabel* m_label_time;
QPushButton* m_btn_back;
QLabel* m_label_pageMsg;
QPushButton* m_btn_rightSide;
TimerUpdate* _timerUpdate;
};
class settingUi : public WidgetWithBackstageInterface
{
Q_OBJECT
public:
enum enPageIndex {
PAGE_PROJECT = 0,
PAGE_INFO,
PAGE_DEV_MNG,
PAGE_FACE_MNG,
PAGE_ACCESS_MNG,
PAGE_RECO,
PAGE_SYS_MNG,
PAGE_FAST_CFG_WIRE_NET,
PAGE_DEV_MNG_NETWORK,
PAGE_DEV_TEST, //hidden page
//subPage
PAGE_DEV_MNG_TIME,
PAGE_DEV_MNG_NET_WIRE,
PAGE_DEV_MNG_NET_WIFI,
PAGE_DEV_MNG_NET_WIFI_ACC_POINT,
PAGE_DEV_MNG_NET_4G,
PAGE_DEV_MNG_BT,
PAGE_DEV_MNG_BT_SPK,
PAGE_DEV_MNG_BT_SPK_ACC_POINT,
PAGE_DEV_MNG_BT_LOCK,
PAGE_DEV_MNG_BT_LOCK_ACC_POINT,
PAGE_FACE_MNG_FACE,
PAGE_FACE_MNG_ACCESS_RECORD,
PAGE_FACE_MNG_ADD_PERSON,
PAGE_FACE_MNG_MODIFY_PERSON,
PAGE_FACE_MNG_SNAP_FACE,
PAGE_FAST_CFG_PARK,
PAGE_FAST_CFG_QRCODE,
PAGE_MAX
};
public:
settingUi(QWidget *parent = nullptr);
~settingUi();
void reset();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void update_IpBar();
QString operator [] (unsigned index) const;
//void showDevTestPage();
signals:
void signalShowRecoPage();
void signalShowPageMsg(const QString&);
void signalSetRecoUiForeheadWidgetVisable(const bool);
void signalChangeRecoUiMode(); //底下的页面开关二维码模式信号
void signalUpdateRecoUiIpDisplay(const bool); //增加识别界面ip显示开关更新信号
public slots:
void slotShowPage(int, const QString title);
void slotReturnClicked();
void slotRightSideBtnClicked();//m_ctlBar 右侧按钮按下
void slotShowAddFacePage();
void slotRestoreFactory();
void slotShowShadowPage(bool show);
void slotShowDevTestPage();
void slotJumpPage(int pageIndex);
void slotExitSettingUi();
private:
const QVector<QString> SetPageName = {tr("操作"),
tr("信息查看"),
tr("设备管理"),
tr("人脸管理"),
tr("门禁管理"),
tr("识别设置"),
tr("系统管理"),
tr("快速配置"),
tr("网络设置"),
tr("设备检测"),
tr("时间设置"),
tr("有线网络"),
tr("无线网络"),
tr("无线网络接入"),
tr("4G网络"),
tr("蓝牙"),
tr("蓝牙音箱"),
tr("已配对蓝牙设置"),
tr("蓝牙门锁"),
tr("蓝牙门锁操作"),
tr("人脸库"),
tr("通行记录"),
tr("添加人员"),
tr("编辑人员"),
tr("拍照"),
tr("设备信息"),
tr("")};
QMap<int, QString> m_map_rightBtnName;
settingUiTop* m_ctlBar;
QStackedWidget* m_stack_setPage;
settingUIProjectSet* m_pProjectSetPage;
settingUiInfo* m_infoPage;
settingUiDevMng* m_devMngPage;
settingUiFaceMng* m_faceMngPage;
settingUiAccMng* m_accMngPage;
settingUiRecoSet* m_recoSetPage;
settingUiSysMng* m_sysMngPage;
settingUiFastCfgWireNet* m_fastCfgWireNet;
settingUiDevTest* m_devTestPage;
settingUiDevMngTime* m_devMngTimePage;
settingUiDevMngNetwork* m_devMngNetworkPage;
settingUiDevMngNetWire* m_devMngNetWirePage;
settingUiDevMngNetWifi* m_devMngNetWifiPage;
settingUiDevMngNetWifiAccPoint* m_devMngNetWifiAccPointPage;
settingUiDevMngNet4G* m_devMngNet4GPage;
settingUiDevMngBt* m_devMngBtPage;
settingUiDevMngBtSpk* m_devMngBtSpkPage;
settingUiDevMngBtSpkAccPoint* m_devMngBtSpkAccPointPage;
settingUiDevMngBtLock* m_devMngBtLockPage;
settingUiDevMngBtLockAccPoint* m_devMngBtLockAccPointPage;
FaceDbPage* m_faceMngFacePage;
AccessRecordPage* m_faceMngAccRedPage;
AddPersonPage *m_addPersonPage;
ModifyPersonPage *m_modifyPersonPage;
SnapFacePage *m_snapFacePage;
settingUiFastCfgPark* m_fastCfgPark;
SettingUiQrcode* m_fastCfgQrcode;
PureColorPage *m_shadowPage;
//是否在设置索引页面,是的话返回便退出设置页面
bool m_onIndexPage;
QStack<int> m_pageIndex;
bool m_syncFlag;
void showPage(int nIndex, const QString& title);
};
#endif // SETTINGUI_H

View File

@ -0,0 +1,355 @@
#include "settingUiAccMng.h"
#include <QDebug>
#include "UiConfig.h"
int settingUiAccMng::m_pageIndex = 0;
settingUiAccMng::settingUiAccMng(int pageIndex, QWidget *parent)
: SettingUiPage(QVector<SettingUiPage::SetOpn>{
SetOpn(tr("开锁延迟(秒)"), "x", myListWidget::enPropertyMoreArrow),
SetOpn(tr("开锁时间(秒)"), "x", myListWidget::enPropertyMoreArrow),
SetOpn(tr("开锁信号"), "xxxxx", myListWidget::enPropertyMoreArrow),
SetOpn(tr("反向通行"), "xxxxx", static_cast<myListWidget::enProperty>(myListWidget::enPropertySwitch| myListWidget::enPropertyIndent1)),
SetOpn(tr("RS485"), "xx", myListWidget::enPropertyMoreArrow),
SetOpn(tr("RS485协议1设备地址(0-255)"), "xx", static_cast<myListWidget::enProperty>(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1)),
SetOpn(tr("静电测试范围"), "xx", static_cast<myListWidget::enProperty>(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1)),
SetOpn(tr("GPIO4接口"), "xx", myListWidget::enPropertyMoreArrow),
SetOpn(tr("GPIO5接口"), "xx", myListWidget::enPropertyMoreArrow),
SetOpn(tr("门超时报警(秒)"), "xx", static_cast<myListWidget::enProperty>(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1)),
SetOpn(tr("防拆报警"), "", myListWidget::enPropertySwitch),
SetOpn(tr("防拆报警信号"), "xx", static_cast<myListWidget::enProperty>(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1)),
}, parent)
{
m_pageIndex = pageIndex;
qDebug() << "settingUiAccMng()";
}
settingUiAccMng::~settingUiAccMng()
{
qDebug() << "~settingUiAccMng()";
}
void settingUiAccMng::setBackstageUiinterface(BackstageInterfaceForUi* interface)
{
m_backstageIf = interface;
reset();
}
void settingUiAccMng::reset()
{
if(nullptr == m_backstageIf){
return;
}
for(int i = 0; i < config.size(); i ++){
QListWidgetItem* pItem = m_listWidget->item(i);
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(pItem));
if(wdt == nullptr){
return;
}
QString str;
switch(i){
case enAccOpenDelay:
str = QString::number(m_backstageIf->getUnlockDelay());
break;
case enAccOpenTime:
str = QString::number(m_backstageIf->getUnlockTime());
break;
case enAccOpenSig:
str = OpenSig[m_backstageIf->getUnlockSig()];
break;
#if 0
case enAccAlmSig:
str = AlarmSig[m_backstageIf->getWarningSig()];
break;
#endif
case enAccRs485:
str = Rs485Cfg[m_backstageIf->getRs485Cfg()];
break;
case enAccRs485Prot1Addr:
str = (m_backstageIf->getRs485Prot1Addr() >= 0 ? QString::number(m_backstageIf->getRs485Prot1Addr()) : tr("(未设置)"));
break;
case enAccGPIO4:
str = GPIOCfg[m_backstageIf->getGpio4Cfg()];
break;
case enAccGPIO5:
str = GPIOCfg[m_backstageIf->getGpio5Cfg()];
break;
case enAccDoorCloseOvertime:
str = QString::number(m_backstageIf->getDoorCloseOvertime());
break;
case enAccAntiDemolitionSw:
wdt->updateIcon(m_backstageIf->getAntiDemolitionSw() ? ":/res/image/on.png" : ":/res/image/off.png");
break;
case enAccAntiDemolitionOutput:
str = AntiDemolitionOutput[m_backstageIf->getAntiDemolitionOutput()];
break;
case enAccRs485ReverseAccessSw: {
wdt->updateIcon(m_backstageIf->getReverseAccessSw() ? ":/res/image/on.png" : ":/res/image/off.png");
break;
}
default:
break;
}
wdt->updateLabel(str);
}
controlListWidgetItemShow(m_backstageIf->getRs485Cfg() == 1, enAccRs485Prot1Addr); //协议1显示设置
controlListWidgetItemShow(m_backstageIf->getRs485Cfg() == 3, enAccRs485Prot3Cfg); //协议3显示设置
controlListWidgetItemShow(m_backstageIf->getAntiDemolitionSw(), enAccAntiDemolitionOutput);
controlListWidgetItemShow(m_backstageIf->getGpio4Cfg() == 1 || m_backstageIf->getGpio5Cfg() == 1, enAccDoorCloseOvertime);
controlListWidgetItemShow(m_backstageIf->getUnlockSig() == UnlockSigRs485, enAccRs485ReverseAccessSw);
}
void settingUiAccMng::slotItemClicked(QListWidgetItem* item)
{
if(nullptr == m_backstageIf){
#ifndef DEBUG_MODE
return;
#endif
}
int row = m_listWidget->currentRow();
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
if(wdt == nullptr){
return;
}
switch(row){
case enAccOpenDelay:
case enAccOpenTime:
case enAccRs485Prot1Addr:
case enAccDoorCloseOvertime:
{
int currentValue = 10;
int min = 0;
int max = 100;
QString tip;
if(enAccOpenDelay == row){
currentValue = m_backstageIf->getUnlockDelay();
min = 0;
max = 10;
}else if(enAccOpenTime == row){
currentValue = m_backstageIf->getUnlockTime();
min = 1;
max = 10;
}else if(enAccRs485Prot1Addr == row){
currentValue = 0;//m_backstageIf->getRs485Prot1Addr();
min = 0;
max = 255;
}else if(enAccDoorCloseOvertime == row){
currentValue = m_backstageIf->getDoorCloseOvertime();
min = 1;
max = 300;
}
SliderDialog dlg(currentValue, min, max, tip, parent()->parent());
if(dlg.exec() == QDialog::Accepted)
{
int valueSet = dlg.getValueSet();
if(enAccOpenDelay == row){
m_backstageIf->setUnlockDelay(valueSet);
}else if(enAccOpenTime == row){
m_backstageIf->setUnlockTime(valueSet);
}else if(enAccRs485Prot1Addr == row){
m_backstageIf->setRs485Prot1Addr(valueSet);
}else if(enAccDoorCloseOvertime == row){
m_backstageIf->setDoorCloseOvertime(valueSet);
}
wdt->updateLabel(QString::number(valueSet));
}
}
break;
case enAccOpenSig:
//case enAccAlmSig:
case enAccRs485:
case enAccGPIO4:
case enAccGPIO5:
case enAccAntiDemolitionOutput:{
int choosed = 0;
QVector<QString> options;
if(enAccOpenSig == row){
options = OpenSig;
if(UiConfig::GetInstance()->isFuncNotSupport(FuncWg42)){
options.remove(4);
}
choosed = static_cast<int>(m_backstageIf->getUnlockSig());
}
#if 0
else if(enAccAlmSig == row){
options = AlarmSig;
choosed = static_cast<int>(m_backstageIf->getWarningSig());
}
#endif
else if(enAccRs485 == row){
options = Rs485Cfg;
choosed = static_cast<int>(m_backstageIf->getRs485Cfg());
}else if(enAccGPIO4 == row){
options = GPIOCfg;
choosed = static_cast<int>(m_backstageIf->getGpio4Cfg());
}else if(enAccGPIO5 == row){
options = GPIOCfg;
choosed = static_cast<int>(m_backstageIf->getGpio5Cfg());
}else if(enAccAntiDemolitionOutput == row){
options = AntiDemolitionOutput;
choosed = static_cast<int>(m_backstageIf->getAntiDemolitionOutput());
}
RadioBtnChooseDialog dlg(options, parent()->parent(), choosed);
if(dlg.exec() == QDialog::Accepted){
int newChoosed = dlg.getChoosedIndex();
if(newChoosed != choosed){
if(enAccOpenSig == row){
if(1 == newChoosed &&
(1 == m_backstageIf->getAntiDemolitionOutput()) ){//1 == m_backstageIf->getWarningSig() ||
InfoDialog(tr("本地继电器已使用"), parent()->parent()).exec();
}else {
m_backstageIf->setUnlockSig(static_cast<enUnlockSignal>(newChoosed));
wdt->updateLabel(options[newChoosed]);
controlListWidgetItemShow(m_backstageIf->getUnlockSig() == UnlockSigRs485, enAccRs485ReverseAccessSw);
}
}
#if 0
else if(enAccAlmSig == row){
if(1 == newChoosed &&
(1 == m_backstageIf->getUnlockSig() || 1 == m_backstageIf->getAntiDemolitionOutput()) ){
InfoDialog(tr("本地继电器已使用"), parent()->parent()).exec();
}else{
m_backstageIf->setWarningSig(newChoosed);
wdt->updateLabel(options[newChoosed]);
}
}
#endif
else if(enAccRs485 == row){
m_backstageIf->setRs485Cfg(newChoosed);
wdt->updateLabel(options[newChoosed]);
QListWidgetItem* pItem = m_listWidget->item(enAccRs485Prot1Addr);
myListWidget* swWidget = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(pItem));
if(swWidget){
swWidget->updateLabel((m_backstageIf->getRs485Prot1Addr() >= 0 ? QString::number(m_backstageIf->getRs485Prot1Addr()) : tr("(未设置)")));
}
controlListWidgetItemShow(1 == newChoosed, enAccRs485Prot1Addr); //协议1显示地址
controlListWidgetItemShow(3 == newChoosed, enAccRs485Prot3Cfg);
if(1 == newChoosed){
InfoDialog(tr("请注意设置RS485协议1设备地址"), parent()->parent()).exec();
}
}else if(enAccGPIO4 == row){
if(0 != newChoosed && m_backstageIf->getAntiDemolitionSw() && 2 == m_backstageIf->getAntiDemolitionOutput()){
InfoDialog(tr("GPIO4已设置为防拆报警输出请重新设置"), parent()->parent()).exec();
}else if(1 == newChoosed && 1 == m_backstageIf->getGpio5Cfg()){
InfoDialog(tr("GPIO5已设置为门磁请重新设置"), parent()->parent()).exec();
}else if(2 == newChoosed && 2 == m_backstageIf->getGpio5Cfg()){
InfoDialog(tr("GPIO5已设置为消防信号请重新设置"), parent()->parent()).exec();
}else{
m_backstageIf->setGpio4Cfg(newChoosed);
wdt->updateLabel(options[newChoosed]);
controlListWidgetItemShow(1 == m_backstageIf->getGpio4Cfg() || 1 == m_backstageIf->getGpio5Cfg(), enAccDoorCloseOvertime);
}
}else if(enAccGPIO5 == row){
if(0 != newChoosed && m_backstageIf->getAntiDemolitionSw() && 3 == m_backstageIf->getAntiDemolitionOutput()){
InfoDialog(tr("GPIO5已设置为防拆报警输出请重新设置"), parent()->parent()).exec();
}else if(1 == newChoosed && 1 == m_backstageIf->getGpio4Cfg()){
InfoDialog(tr("GPIO4已设置为门磁请重新设置"), parent()->parent()).exec();
}else if(2 == newChoosed && 2 == m_backstageIf->getGpio4Cfg()){
InfoDialog(tr("GPIO4已设置为消防信号请重新设置"), parent()->parent()).exec();
}else{
m_backstageIf->setGpio5Cfg(newChoosed);
wdt->updateLabel(options[newChoosed]);
controlListWidgetItemShow(1 == m_backstageIf->getGpio4Cfg() || 1 == m_backstageIf->getGpio5Cfg(), enAccDoorCloseOvertime);
}
}else if(enAccAntiDemolitionOutput == row){
if(1 == newChoosed && 1 == m_backstageIf->getUnlockSig()){//1 == m_backstageIf->getWarningSig() ||
InfoDialog(tr("本地继电器已被使用,请重新设置!"), parent()->parent()).exec();
}else if(2 == newChoosed && 0 != m_backstageIf->getGpio4Cfg()){
InfoDialog(tr("GPIO4已设置为信号输入请重新设置"), parent()->parent()).exec();
}else if(3 == newChoosed && 0 != m_backstageIf->getGpio5Cfg()){
InfoDialog(tr("GPIO5已设置为信号输入请重新设置"), parent()->parent()).exec();
}else {
m_backstageIf->setAntiDemolitionOutput(newChoosed);
wdt->updateLabel(options[newChoosed]);
}
}
}
}
}
break;
#if 0
case enAccRs485Prot1Addr:
{
if(0 == m_backstageIf->getRs485Prot1Addr()){
bool settingFailed = true;
do{
LineEditInputDialog dlg(config[enAccRs485Prot1Addr].m_sOpn, parent()->parent());
if(dlg.exec() == QDialog::Accepted){
const QString strInput = dlg.getRow(0);
do{
bool isDigi = false;
int input = strInput.toInt(&isDigi);
if(!isDigi){
break;
}
if(0 == m_backstageIf->setRs485Prot1Addr(input)){
wdt->updateLabel(strInput);
settingFailed = false;
}
}while(0);
}
else {
settingFailed = false;
}
if(settingFailed){
InfoDialog(tr("设置有误,请重新输入!"), parent()->parent()).exec();
}
}while(settingFailed);
}
}
break;
#endif
case enAccRs485Prot3Cfg:
{
const QStringList titles{tr("手部"), tr("脚部")};
const QVector<QStringList> sels{{"100KΩ-10MΩ", "750KΩ-10MΩ", "750KΩ-35MΩ", tr("不检测")},
{"100KΩ-35MΩ", "750KΩ-100MΩ", "750KΩ-1000MΩ", tr("不检测")}};
ComSelectDialog dlg(titles, sels, parent()->parent());
int handCfg = 0;
int feetCfg = 0;
m_backstageIf->getRs485Prot3Cfg(handCfg, feetCfg);
dlg.setRow(0, handCfg);
dlg.setRow(1, feetCfg);
if(dlg.exec() == QDialog::Accepted){
m_backstageIf->setRs485Prot3Cfg(dlg.getRow(0), dlg.getRow(1));
}
}
break;
case enAccAntiDemolitionSw:
{
bool setting_value = false;
if(enAccAntiDemolitionSw == row){
setting_value = static_cast<bool>(m_backstageIf->getAntiDemolitionSw());
}
setting_value = static_cast<bool>(!setting_value);
wdt->updateIcon(setting_value ? ":/res/image/on.png" : ":/res/image/off.png");
if(enAccAntiDemolitionSw == row){
controlListWidgetItemShow(setting_value, enAccAntiDemolitionOutput);
m_backstageIf->setAntiDemolitionSw(setting_value);
if(!setting_value){
m_backstageIf->setAntiDemolitionOutput(0);//防止在配置输出信号项功能时与防拆输出冲突
}
}
}
break;
case enAccRs485ReverseAccessSw: {
bool setting_value = m_backstageIf->getReverseAccessSw();
setting_value = !setting_value;
wdt->updateIcon(setting_value ? ":/res/image/on.png" : ":/res/image/off.png");
m_backstageIf->setReverseAccessSw(setting_value);
break;
}
default:
break;
}
}

View File

@ -0,0 +1,76 @@
#ifndef SETTINGUIACCMNG_H
#define SETTINGUIACCMNG_H
#include <QListWidget>
#include "UiTools.h"
class settingUiAccMng : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
enAccOpenDelay,
enAccOpenTime,
enAccOpenSig,
enAccRs485ReverseAccessSw, // RS485反向通行
//enAccAlmSig,
enAccRs485,
enAccRs485Prot1Addr,
enAccRs485Prot3Cfg,
enAccGPIO4,
enAccGPIO5,
enAccDoorCloseOvertime,
enAccAntiDemolitionSw,
enAccAntiDemolitionOutput,
}enAcc;
static int m_pageIndex;
explicit settingUiAccMng(int pageIndex, QWidget *parent = nullptr);
~settingUiAccMng();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
public slots:
void slotItemClicked(QListWidgetItem* item);
private:
const QVector<QString> OpenSig{
tr("禁用"),
tr("本地继电器"),
tr("韦根26"),
tr("韦根34"),
tr("韦根42"),
tr("RS485")
};
const QVector<QString> AlarmSig{
tr("禁用"),
tr("本地继电器")
};
const QVector<QString> Rs485Cfg{
tr("禁用"),
tr("协议1"),
tr("协议2"),
tr("协议3")
};
const QVector<QString> GPIOCfg{
tr("禁用"),
tr("门磁"),
tr("消防信号")
};
const QVector<QString> AntiDemolitionOutput{
tr(""),
tr("本地继电器"),
tr("GPIO4"),
tr("GPIO5")
};
};
#endif // SETTINGUIACCMNG_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,470 @@
#ifndef SETTINGUIDEVMNG_H
#define SETTINGUIDEVMNG_H
#include <QListWidget>
#include "UiTools.h"
class settingUiDevMng : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
DEV_MNG_SHOW_IP,
DEV_MNG_SHOW_ID_VER,
DEV_MNG_SET_VOLUMN,
DEV_MNG_SET_BRIGHTNESS,
DEV_MNG_SCREENSAVER,
DEV_MNG_SCREENOFF,
DEV_MNG_SET_TIME,
//DEV_MNG_SET_NETWORK,
DEV_MNG_BLUETOOTH,
DEV_MNG_OPEN_DYNAMICFEATURE,//动态底库
DEV_MNG_PASSWORD,
DEV_MNG_DEV_SETTING_DISABLE
}DEV_MNG_E;
static int m_pageIndex;
explicit settingUiDevMng(int pageIndex, QWidget *parent = nullptr);
~settingUiDevMng();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
public slots:
void slotItemClicked(QListWidgetItem*);
private:
};
class settingUiDevMngTime : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
DEV_MNG_TIME_NTP_SW,
DEV_MNG_TIME_NTP_SERVER,
DEV_MNG_TIME_NTP_INTERVAL,
DEV_MNG_TIME_NTP_TIME_ZONE,
DEV_MNG_TIME_MANUAL
}DEV_MNG_TIME_E;
static int m_pageIndex;
explicit settingUiDevMngTime(int pageIndex, QWidget *parent = nullptr);
~settingUiDevMngTime();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
public slots:
void slotItemClicked(QListWidgetItem*);
void slotShowProcessing();
private:
const QVector<QString> TimeZone = {tr("UTC-11太平洋/中途岛"),
tr("UTC-9:30太平洋/马克萨斯"),
tr("UTC-9美国/安克雷奇"),
tr("UTC-8美国/道森"),
tr("UTC-7美国/博伊西"),
tr("UTC-6美国/巴伊亚州_班德拉斯"),
tr("UTC-5美国/多伦多"),
tr("UTC-4美国/安圭拉"),
tr("UTC-3:30美国/圣约翰斯"),
tr("UTC-3美国/阿拉瓜那"),
tr("UTC-2美国/诺罗尼亚"),
tr("UTC-1美国/斯科比斯松"),
tr("UTC+0欧洲/里斯本/伦敦"),
tr("UTC+1欧洲/阿姆斯特丹"),
tr("UTC+2亚洲/大马士革"),
tr("UTC+3亚洲/科威特"),
tr("UTC+3:30亚洲/德黑兰"),
tr("UTC+4印度/毛里求斯"),
tr("UTC+4:30亚洲/喀布尔"),
tr("UTC+5印度/马尔代夫"),
tr("UTC+5:30亚洲/科伦坡"),
tr("UTC+5:45亚洲/加德满都"),
tr("UTC+6印度/查戈斯"),
tr("UTC+6:30亚洲/仰光"),
tr("UTC+7亚洲/曼谷"),
tr("UTC+8亚洲/北京/台北"),
tr("UTC+8:45澳大利亚/尤克拉"),
tr("UTC+9亚洲/首尔/东京"),
tr("UTC+9:30澳大利亚/达尔文"),
tr("UTC+10澳大利亚/墨尔本"),
tr("UTC+10:30澳大利亚/领主豪"),
tr("UTC+11太平洋/瓜达尔卡纳尔岛"),
tr("UTC+12太平洋/奥克兰"),
tr("UTC+12:45太平洋/查塔姆"),
tr("UTC+13太平洋/阿皮亚"),
tr("UTC+14太平洋/基里蒂马蒂)")
};
const QVector<QString> TimeZoneSet = {"Pacific/Midway",
"Pacific/Marquesas",
"America/Anchorage",
"America/Dawson",
"America/Boise",
"America/Bahia_Banderas",
"America/Toronto",
"America/Anguilla",
"America/St_Johns",
"America/Araguaina",
"America/Noronha",
"America/Scoresbysund",
"right/Europe/London",
"right/Europe/Amsterdam",
"Asia/Damascus",
"Asia/Kuwait",
"Asia/Tehran",
"Indian/Mauritius",
"Asia/Kabul",
"Indian/Maldives",
"Asia/Colombo",
"Asia/Kathmandu",
"Indian/Chagos",
"Asia/Rangoon",
"Asia/Bangkok",
"Asia/Shanghai",
"Australia/Eucla",
"Asia/Tokyo",
"Australia/Darwin",
"Australia/Melbourne",
"Australia/Lord_Howe",
"Pacific/Guadalcanal",
"Pacific/Auckland",
"Pacific/Chatham",
"Pacific/Apia",
"Pacific/Kiritimati"};
MsgDialog* m_msgDlg;
void ntpTimeCorrect();
};
class settingUiDevMngNetwork : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
DEV_MNG_NETWORK_WIRE,
DEV_MNG_NETWORK_WIFI,
DEV_MNG_NETWORK_4G
}DEV_MNG_WIRE_NET_E;
static int m_pageIndex;
explicit settingUiDevMngNetwork(int pageIndex, QWidget *parent = nullptr);
~settingUiDevMngNetwork();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
public slots:
void slotItemClicked(QListWidgetItem*);
private:
};
class settingUiDevMngNetWire : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
DEV_MNG_NET_WIRE_SW,
DEV_MNG_NET_WIRE_DHCP,
DEV_MNG_NET_WIRE_MAN_CFG,
DEV_MNG_NET_WIRE_IP,
DEV_MNG_NET_WIRE_MASK,
DEV_MNG_NET_WIRE_GW,
DEV_MNG_NET_WIRE_DNS
}DEV_MNG_WIRE_NET_E;
static int m_pageIndex;
explicit settingUiDevMngNetWire(int pageIndex, QWidget *parent = nullptr);
~settingUiDevMngNetWire();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
public slots:
void slotItemClicked(QListWidgetItem*);
private:
bool setStaticNetworkPara(const stNetWire& curNetCfg);
};
class settingUiDevMngNetWifi : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
DEV_MNG_NET_WIFI_SW,
DEV_MNG_NET_AP_SW,
DEV_MNG_NET_WIFI_ASSIGN,
DEV_MNG_NET_WIFI_SEARCH,
DEV_MNG_NET_AP_PWD,
DEV_MNG_NET_BUTT
}DEV_MNG_NET_WIFI_E;
static int m_pageIndex;
explicit settingUiDevMngNetWifi(int pageIndex, QWidget *parent = nullptr);
~settingUiDevMngNetWifi();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
public slots:
void slotItemClicked(QListWidgetItem*);
void slotUpdateConnectionStatus(QString ssid, bool connected);
private:
void clearSsidList();
void wifiSearch();
const int m_ssidPosIndex = DEV_MNG_NET_BUTT;
};
class settingUiDevMngNetWifiAccPoint : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
DEV_MNG_NET_WIFI_AP_CONNECT,
DEV_MNG_NET_WIFI_AP_FORGET,
DEV_MNG_NET_WIFI_AP_DHCP,
DEV_MNG_NET_WIFI_AP_MAN_CFG,
DEV_MNG_NET_WIFI_AP_IP,
DEV_MNG_NET_WIFI_AP_MASK,
DEV_MNG_NET_WIFI_AP_GW,
DEV_MNG_NET_WIFI_AP_DNS
}DEV_MNG_NET_WIFI_E;
static int m_pageIndex;
explicit settingUiDevMngNetWifiAccPoint(int pageIndex, QWidget *parent = nullptr);
~settingUiDevMngNetWifiAccPoint();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
void signalUpdateConnectionStatus(QString ssid, bool connected);
void signalReturn();
public slots:
void slotItemClicked(QListWidgetItem*);
private:
bool setStaticNetworkPara(const stNetWifi& curNetCfg);
};
class settingUiDevMngNet4G : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
DEV_MNG_NET_4G_SW,
DEV_MNG_NET_4G_PROVIDER,
DEV_MNG_NET_4G_REBOOT
}DEV_MNG_NET_WIFI_E;
static int m_pageIndex;
explicit settingUiDevMngNet4G(int pageIndex, QWidget *parent = nullptr);
~settingUiDevMngNet4G();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
public slots:
void slotItemClicked(QListWidgetItem*);
private:
const QVector<QString> net4GProvider{
tr("未插卡"),tr("中国移动"),tr("中国电信"),tr("中国联通"),tr("4G启动中...")
};
};
class settingUiDevMngBt : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
DEV_MNG_BT_ENABLE,
DEV_MNG_BT_SPK,
DEV_MNG_BT_LOCK
}DEV_MNG_BT_E;
static int m_pageIndex;
explicit settingUiDevMngBt(int pageIndex, QWidget *parent = nullptr);
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
public slots:
void slotItemClicked(QListWidgetItem*);
private:
};
class settingUiDevMngBtSpk : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
//DEV_MNG_BULETOOTH_ENABLE,
DEV_MNG_BULETOOTH_DEVNAME,
DEV_MNG_BULETOOTH_HISTORY_DEV,
DEV_MNG_BULETOOTH_AVAILABLE_DEV,
}DEV_MNG_BULETOOTH_E;
static int m_pageIndex;
explicit settingUiDevMngBtSpk(int pageIndex, QWidget *parent = nullptr);
~settingUiDevMngBtSpk();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
private:
void clearPaireItem();
void clearAvailItem();
void addPairedItem(BluetoothDev_t &btDev);
void addPairedItem(BtListWidget *pBtListWidget);
void addPairedItem(list<BluetoothDev_t> &btDevList);
void addAvailItem(BluetoothDev_t &btDev);
void addAvailItem(BtListWidget *pBtListWidget);
void addAvailItem(list<BluetoothDev_t> &btDevList);
int deletePairedItem(int row);
int deleteAvaidItem(int row);
void resetPaireItem(list<BluetoothDev_t> &btDevList);
void resetAvailItem(list<BluetoothDev_t> &btDevList);
signals:
void signalClickSet(BluetoothDev_t btDevInfo);
public slots:
void slotItemClicked(QListWidgetItem*);
void slotBtDevSet(BluetoothDev_t btDevInfo);
private:
int m_pairedItemCnt = 0;
int m_availdItemCnt = 0;
#if 1
string m_btDevName;
bool m_btIsEnable;
//list<BluetoothDev_t> m_btPairedList;
//list<BluetoothDev_t> m_btAvailList;
#endif
};
class settingUiDevMngBtSpkAccPoint : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
DEV_MNG_BULETOOTH_ACCPOINTE_RENAME,
DEV_MNG_BULETOOTH_ACCPOINTE_CANCLE
}DEV_MNG_BULETOOTH_ACCPOINTE_E;
static int m_pageIndex;
explicit settingUiDevMngBtSpkAccPoint(int pageIndex, QWidget *parent = nullptr);
~settingUiDevMngBtSpkAccPoint();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
void signalReturn();
public slots:
void slotItemClicked(QListWidgetItem*);
void setAccPointInfo(const BluetoothDev_t &rBlueDev);
private:
BluetoothDev_t m_btDev;
};
class settingUiDevMngBtLock : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
DEV_MNG_BT_LOCK_ENABLE,
DEV_MNG_BT_LOCK_ADD,
DEV_MNG_BT_LOCK_BUTT
}DEV_MNG_BT_LOCK_E;
static int m_pageIndex;
explicit settingUiDevMngBtLock(int pageIndex, QWidget *parent = nullptr);
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
void signalCurrentLock(const QString& lock);
public slots:
void slotItemClicked(QListWidgetItem*);
void slotRefresh();
private:
void clearBtLockList();
void addBtLock(const QString& position);
void showBtLockList(const BtDoorLock& cfg);
};
class settingUiDevMngBtLockAccPoint : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
DEV_MNG_BT_LOCK_INFO,
DEV_MNG_BT_LOCK_BATTERY,
DEV_MNG_BT_LOCK_DELETE,
DEV_MNG_BT_LOCK_BUTT
}DEV_MNG_BT_LOCK_E;
static int m_pageIndex;
explicit settingUiDevMngBtLockAccPoint(int pageIndex, QWidget *parent = nullptr);
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
void signalUpdataTitle(const QString& title);
void signalRefresh();
public slots:
void slotItemClicked(QListWidgetItem*);
void slotCurrentLock(const QString& lock);
private:
int m_manufacturer;
QString m_position;
QString m_mac;
void getRemainingBatPwr();
};
#endif // SETTINGUIDEVMNG_H

View File

@ -0,0 +1,695 @@
#include "settingUiDevTest.h"
#include <QVBoxLayout>
#include <QGridLayout>
#include <QHBoxLayout>
#include <functional>
#include <QDebug>
#include "rw_zlog.h"
#include "common_utils.h"
#include "dev_version.h"
int settingUiDevTest::m_pageIndex = 0;
settingUiDevTest::settingUiDevTest(int pageIndex, QWidget *parent) : MyWidgetWithMainStyleColor(parent)
{
m_pageIndex = pageIndex;
QVBoxLayout* vlayAuto = new QVBoxLayout();
m_gbAuto = new QGroupBox("自动检测", this);
m_gbAuto->setLayout(vlayAuto);
m_btnTest = new QPushButton("立即检测", this);
m_btnTest->setFixedSize(UiConfig::GetInstance()->getUiWidth() / 8, UiConfig::GetInstance()->getUiWidth() / 12);
m_btnTest->setFlat(true);
connect(m_btnTest, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
//m_btnTest->setStyleSheet("background-color:rgb(24, 144, 255);border-radius:50px;focus{padding:-1;}");
m_btnTest->setStyleSheet("QPushButton {"
"border: 0px;"
"border-radius:10px;"
"background-color:rgb(24, 144, 255);"
"focus{outline: none;}"
"}"
"QPushButton:hover { "
"background-color:rgb(24, 144, 255);"
"}"
"QPushButton:pressed {"
"background-color:rgb(222, 222, 222);"
"}");
vlayAuto->addWidget(m_btnTest, 1, Qt::AlignCenter);
QGridLayout* glayAutoTestItems = new QGridLayout();
glayAutoTestItems->setMargin(0);
//glayAutoTestItems->setColumnStretch(0, 98);
//glayAutoTestItems->setColumnStretch(1, 1);
//glayAutoTestItems->setColumnStretch(1, 98);
int row = 0;
int col = 0;
QLabel* testOpn = new QLabel("检测项", this);
glayAutoTestItems->addWidget(testOpn, row, col++, Qt::AlignCenter);
QLabel* testStatus = new QLabel("结果", this);
glayAutoTestItems->addWidget(testStatus, row, col++, Qt::AlignRight);
QLabel* operation = new QLabel("操作", this);
glayAutoTestItems->addWidget(operation, row, col++, Qt::AlignRight);
row++;
col = 0;
const QString style = "QPushButton {"
"border: 0px;"
"border-radius:4px;"
"background-color:rgb(6, 119, 194);"
"focus{outline: none;}"
"}"
"QPushButton:hover { "
"background-color:rgb(6, 119, 194);"
"}"
"QPushButton:pressed {"
"background-color:rgb(222, 222, 222);"
"}";
for(const auto& testItem : m_autoTest){
QLabel* itemName = new QLabel(testItem, this);
itemName->adjustSize();
m_labelsAutoTestItem.push_back(itemName);
glayAutoTestItems->addWidget(itemName, row, col++, Qt::AlignCenter);
QLabel* testRes = new QLabel(this);
m_labelsAutoTestRes.push_back(testRes);
glayAutoTestItems->addWidget(testRes, row, col++);
QPushButton* retest = new QPushButton("复测", this);
connect(retest, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
retest->setStyleSheet(style);
m_btnsAutoTestRetest.push_back(retest);
glayAutoTestItems->addWidget(retest, row, col++, Qt::AlignCenter);
row++;
col = 0;
}
vlayAuto->addLayout(glayAutoTestItems);
vlayAuto->addStretch(5);
QVBoxLayout* vlayMal = new QVBoxLayout();
m_gbMal = new QGroupBox("人工检测", this);
m_gbMal->setLayout(vlayMal);
row = 0;
col = 0;
QGridLayout* glayMalTestItems = new QGridLayout();
glayMalTestItems->setSpacing(5);
for(const auto& testItem : m_malTest){
QLabel* itemName = new QLabel(testItem, this);
m_labelsMalTestItem.push_back(itemName);
glayMalTestItems->addWidget(itemName, row, col++, 1, 2);
QLabel* testRes = new QLabel(this);
m_labelsMalTestRes.push_back(testRes);
glayMalTestItems->addWidget(testRes, row, col++, Qt::AlignRight);
QPushButton* retest = new QPushButton("检测", this);
connect(retest, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
retest->setStyleSheet(style);
m_btnsMalTest.push_back(retest);
glayMalTestItems->addWidget(retest, row, col++, Qt::AlignRight);
row++;
col = 0;
}
vlayMal->addLayout(glayMalTestItems);
QLabel* labelNtp = new QLabel("NTP", this);
glayMalTestItems->addWidget(labelNtp, row, col++);
col++;//放到第三列
m_btnNtp = new QPushButton("校时", this);
m_btnNtp->setStyleSheet(style);
connect(m_btnNtp, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
glayMalTestItems->addWidget(m_btnNtp, row, col++);
row++;
col = 0;
QVBoxLayout* vlayAgeing = new QVBoxLayout();
QGroupBox* m_gbAgeing = new QGroupBox("老化", this);
m_gbAgeing->setLayout(vlayAgeing);
QHBoxLayout* hlayAgeing = new QHBoxLayout();
QLabel* labelAgeing = new QLabel("老化(小时)", this);
hlayAgeing->addWidget(labelAgeing);
m_editAgeing = new LineEditWithKeyboard(this);
m_editAgeing->setStyleSheet("QLineEdit {border : 1px solid blue;}");
hlayAgeing->addWidget(m_editAgeing);
m_btnAgeing = new QPushButton("开始", this);
connect(m_btnAgeing, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
m_btnAgeing->setStyleSheet(style);
hlayAgeing->addWidget(m_btnAgeing);
vlayAgeing->addLayout(hlayAgeing);
QLabel* labelAgeingTip = new QLabel(this);
labelAgeingTip->setWordWrap(true);
labelAgeingTip->setText(QString("<font color = #000000 >%1</font>").arg("提示::") + "<br>" +
QString("<font color = #000000 >%1</font>").arg("1.开始老化后,满足老化时间,手动关掉老""化开关,恢复出厂设置,才可退出老化模式;") + "<br>" +
QString("<font color = #000000 >%1</font>").arg("2.老化时间时断电,之后再次上电,重新开始计时进行老化;") + "<br>" +
QString("<font color = #FF0000 >%1</font>").arg("3.老化测试结束后,功能测试完成,需恢复出厂设置") );
vlayAgeing->addWidget(labelAgeingTip, 1, Qt::AlignLeft);
QVBoxLayout* vlayDev = new QVBoxLayout();
m_gbDev = new QGroupBox("MAC烧录", this);
m_gbDev->setLayout(vlayDev);
QLabel* labelSoftVer = new QLabel("软件版本", this);
vlayDev->addWidget(labelSoftVer, 1, Qt::AlignLeft);
m_editSoftVer = new QLineEdit(this);
m_editSoftVer->setMinimumWidth(UiConfig::GetInstance()->getUiWidth() / 3);
m_editSoftVer->setReadOnly(true);
m_editSoftVer->setStyleSheet("QLineEdit {border : 1px solid blue;}");
vlayDev->addWidget(m_editSoftVer, 1, Qt::AlignLeft);
QLabel* labelDevCfg = new QLabel("设备配置信息", this);
vlayDev->addWidget(labelDevCfg, 1, Qt::AlignLeft);
m_editDevCfg = new QLineEdit(this);
m_editDevCfg->setMinimumWidth(UiConfig::GetInstance()->getUiWidth() / 3);
m_editDevCfg->setReadOnly(true);
m_editDevCfg->setStyleSheet("QLineEdit {border : 1px solid blue;}");
vlayDev->addWidget(m_editDevCfg, 1, Qt::AlignLeft);
QLabel* labelMes = new QLabel("MES服务器地址及工单信息", this);
vlayDev->addWidget(labelMes, 1, Qt::AlignLeft);
m_editMesAddrAndProdNo = new QLineEdit(this);
m_editMesAddrAndProdNo->setMinimumWidth(UiConfig::GetInstance()->getUiWidth() / 3);
m_editMesAddrAndProdNo->setReadOnly(true);
m_editMesAddrAndProdNo->setStyleSheet("QLineEdit {border : 1px solid blue;}");
vlayDev->addWidget(m_editMesAddrAndProdNo, 1, Qt::AlignLeft);
QLabel* labelDevCode = new QLabel("设备条码", this);
vlayDev->addWidget(labelDevCode, 1, Qt::AlignLeft);
m_editPcbSeq = new QLineEdit(this);
m_editPcbSeq->setMinimumWidth(UiConfig::GetInstance()->getUiWidth() / 3);
m_editPcbSeq->setReadOnly(true);
m_editPcbSeq->setStyleSheet("QLineEdit {border : 1px solid blue;}");
vlayDev->addWidget(m_editPcbSeq, 1, Qt::AlignLeft);
QLabel* labelMac = new QLabel("MAC", this);
vlayDev->addWidget(labelMac, 1, Qt::AlignLeft);
m_editMac = new QLineEdit(this);
m_editMac->setMinimumWidth(UiConfig::GetInstance()->getUiWidth() / 3);
m_editMac->setReadOnly(true);
m_editMac->setStyleSheet("QLineEdit {border : 1px solid blue;}");
vlayDev->addWidget(m_editMac, 1, Qt::AlignLeft);
vlayDev->setSpacing(5);
QVBoxLayout* vlayOperation = new QVBoxLayout();
QGroupBox* m_gbOperation = new QGroupBox("操作", this);
m_gbOperation->setLayout(vlayOperation);
m_btnReboot = new QPushButton("手动重启", this);
connect(m_btnReboot, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
m_btnReboot->setStyleSheet(style);
vlayOperation->addWidget(m_btnReboot, 1, Qt::AlignCenter);
m_btnRecover = new QPushButton("恢复出厂设置", this);
connect(m_btnRecover, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
m_btnRecover->setStyleSheet(style);
vlayOperation->addWidget(m_btnRecover, 1, Qt::AlignCenter);
QVBoxLayout* vlayLeft = new QVBoxLayout();
vlayLeft->addWidget(m_gbAuto, 1, Qt::AlignTop);
vlayLeft->addWidget(m_gbDev, 1, Qt::AlignTop);
vlayLeft->addStretch(5);
QVBoxLayout* vlayRight = new QVBoxLayout();
vlayRight->addWidget(m_gbMal, 1, Qt::AlignTop);
vlayRight->addWidget(m_gbAgeing, 1, Qt::AlignTop);
vlayRight->addWidget(m_gbOperation, 1, Qt::AlignTop);
vlayRight->addStretch(5);
QHBoxLayout* hlay = new QHBoxLayout();
hlay->addLayout(vlayLeft);
hlay->addLayout(vlayRight);
setLayout(hlay);
setStyleSheet(QString("font-size:%1px;background-color:rgb(200, 200, 200);"
"border-radius:8px;padding:2px 4px;focus{outline: none;}")
.arg(QString::number(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()])));
m_timer = new QTimer(this);
connect(m_timer, &QTimer::timeout, [this]{delete m_colorScreen;
if(m_colorIndex >= color.size()){
m_colorIndex = 0;
m_timer->stop();
showSelectionWin(enMalTestLcd);
return;
}
m_colorScreen = new PureColorPage(color[m_colorIndex++]);
m_colorScreen->show();});
}
void settingUiDevTest::reset()
{
m_backstageIf->stopIdentyState(true, false);
//const int btnSize = m_btnsMalTest.at(0)->width();
const int btnSize = UiConfig::GetInstance()->getUiWidth() / 15;
m_btnNtp->setFixedSize(btnSize, btnSize);
m_btnAgeing->setFixedSize(btnSize, btnSize);
for(int i=0; i<m_btnsAutoTestRetest.size(); i++){
m_btnsAutoTestRetest.at(i)->setFixedSize(btnSize, btnSize);
}
for(int i=0; i<m_btnsMalTest.size(); i++){
m_btnsMalTest.at(i)->setFixedSize(btnSize, btnSize);
}
std::string mac;
if(m_backstageIf->getKeyDataMac(mac) > 0){
m_editMac->setText(mac.c_str());
}
std::string hours;
if(m_backstageIf->isAgeing(hours)){
m_editAgeing->setText(hours.c_str());
m_btnAgeing->setText("结束");
//m_gbAuto->setEnabled(false);
//m_gbDev->setEnabled(false);
m_btnTest->setEnabled(false);
for(int i=0; i<m_btnsAutoTestRetest.size(); i++){
m_btnsAutoTestRetest.at(i)->setEnabled(false);
}
for(int i=0; i<m_btnsMalTest.size(); i++){
m_btnsMalTest.at(i)->setEnabled(false);
}
m_btnNtp->setEnabled(false);
m_btnRecover->setEnabled(false);
m_btnReboot->setEnabled(false);
}
else{
m_editAgeing->setText("8");
m_btnAgeing->setText("开始");
//m_gbAuto->setEnabled(true);
//m_gbDev->setEnabled(true);
m_btnTest->setEnabled(true);
for(int i=0; i<m_btnsAutoTestRetest.size(); i++){
m_btnsAutoTestRetest.at(i)->setEnabled(true);
}
for(int i=0; i<m_labelsMalTestItem.size(); i++){
m_btnsMalTest.at(i)->setEnabled(true);
}
m_btnNtp->setEnabled(true);
m_btnRecover->setEnabled(true);
m_btnReboot->setEnabled(true);
}
for(auto& item : m_labelsAutoTestRes){
item->clear();
}
const int iBufSize = 64;
char buf[iBufSize] = {'\0'};
if(0 == m_backstageIf->getAppVersion(buf, iBufSize)){
m_editSoftVer->setText(buf);
buf[strlen("FG_B0xx")] = '\0';
if(!QString(buf).contains("B045")){
m_labelsAutoTestItem.at(enAutoTestSerial1)->hide();
m_labelsAutoTestRes.at(enAutoTestSerial1)->hide();
m_btnsAutoTestRetest.at(enAutoTestSerial1)->hide();
}
}
//if(0 == m_backstageIf->getHardwareConfig(buf, iBufSize)){
std::string hardware;
if(m_backstageIf->getKeyDataHardware(hardware) > 0){
refreshUiByHardwareConfig(hardware.c_str());
}
emit signalShowSettingUi();
}
void settingUiDevTest::slotDevTestMesAddrAndProdNoText(const QString& text)
{
m_editMesAddrAndProdNo->setText(text);
if(!m_editPcbSeq->text().isEmpty()){
QTimer::singleShot(100, this, [this]{
std::string mac;
if(0 == m_backstageIf->getMacFromMes(m_editMesAddrAndProdNo->text().toStdString().c_str(),
m_editPcbSeq->text().toStdString().c_str(), mac)){
m_editMac->setText(mac.c_str());
}
else{
InfoDialog("获取mac地址失败请重试").exec();
}});
}
}
void settingUiDevTest::slotDevTestPcbSeqText(const QString& text)
{
m_editPcbSeq->setText(text);
if(!m_editMesAddrAndProdNo->text().isEmpty()){
QTimer::singleShot(100, this, [this]{
std::string mac;
if(0 == m_backstageIf->getMacFromMes(m_editMesAddrAndProdNo->text().toStdString().c_str(),
m_editPcbSeq->text().toStdString().c_str(), mac)){
m_editMac->setText(mac.c_str());
}
else{
InfoDialog("获取mac地址失败请重试").exec();
}});
}
}
void settingUiDevTest::slotDevTestConfigInfo(const QString& text)
{
if(text.isEmpty()){
return;
}
std::string hardware;
if(m_backstageIf->getKeyDataHardware(hardware) < 0){
return;
}
do{
if(hardware.length() && hardware != text.toStdString()){
QString que{"设备已有配置信息:"};
que += hardware.c_str();
que += "\n";
que += "是否更新为:";
que += text;
QuestionDialog dlg(que, nullptr, "是的");
if(QDialog::Rejected == dlg.exec()){
break;
}
QCoreApplication::processEvents();
}
if(hardware == text.toStdString()){
break;
}
m_backstageIf->setKeyDataHardwareAndUpdataFunction(text.toStdString());
refreshUiByHardwareConfig(text);
}while(0);
}
void settingUiDevTest::slotClosed()
{
//m_draw->hide();
showSelectionWin(enMalTestTp);
}
void settingUiDevTest::slotBtnClicked()
{
int index = 0;
const QVector<std::function<bool()>>funcsAuto{std::bind(&BackstageInterfaceForUi::isWiegandIoTestOk, m_backstageIf),
std::bind(&BackstageInterfaceForUi::isRelayAndGpioTestOk, m_backstageIf),
std::bind(&BackstageInterfaceForUi::isRs485TestOk, m_backstageIf),
std::bind(&BackstageInterfaceForUi::isWifiTestOk, m_backstageIf),
std::bind(&BackstageInterfaceForUi::isRtcTestOk, m_backstageIf),
//std::bind(&BackstageInterfaceForUi::isWireEthTestOk, m_backstageIf),
//std::bind(&BackstageInterfaceForUi::is4gTestOk, m_backstageIf),
std::bind(&BackstageInterfaceForUi::isReaderUnderScreenTestOk, m_backstageIf),
std::bind(&BackstageInterfaceForUi::isSerial1TestOk, m_backstageIf)
//std::bind(&BackstageInterfaceForUi::isIdModuleInfoUploaded, m_backstageIf)
};
const QVector<std::function<void()>>funcsMal{std::bind([this]{m_colorScreen = new PureColorPage(color[m_colorIndex++]);
m_colorScreen->show();m_timer->start(2000);}),
std::bind(&settingUiDevTest::doMicrophoneTest, this),
std::bind([this]{m_backstageIf->speakerTest();
showSelectionWin(enMalTestSpeaker);}),
std::bind([this]{if(!m_draw){
m_draw = new DrawPage(UiConfig::GetInstance()->getUiWidth(),
UiConfig::GetInstance()->getUiHeight());
connect(m_draw, SIGNAL(signalClosed()), this, SLOT(slotClosed()));
m_draw->show();}else{m_draw->show();}}),
std::bind([this]{static_cast<QWidget*>(this->parent()->parent())->hide();
QTimer::singleShot(100,this,[this]{
m_backstageIf->irCamTest();
static_cast<QWidget*>(this->parent()->parent())->show();
showSelectionWin(enMalTestIrCam);});}),
std::bind([this]{static_cast<QWidget*>(this->parent()->parent())->hide();
QTimer::singleShot(100,this,[this]{
m_backstageIf->irLedTest();
static_cast<QWidget*>(this->parent()->parent())->show();
showSelectionWin(enMalTestIrLed);});})
};
const int size = m_btnsAutoTestRetest.at(0)->height() * 0.6;
QPixmap pmOk(":/res/image/ok_small.png");
pmOk = pmOk.scaled(size, size);
QPixmap pmFailed(":/res/image/fail2_large.png");
pmFailed = pmFailed.scaled(size, size);
const QObject* send = sender();
if (send == m_btnTest) {
int testItemNum = 0;
for(auto& item : m_labelsAutoTestRes){
if(!item->isHidden()){
item->clear();
testItemNum++;
}
}
ProgressWidget pw("自动检测中...");
pw.setFixedSize(UiConfig::GetInstance()->getUiWidth() / 2, UiConfig::GetInstance()->getUiHeight() / 6);
pw.move((UiConfig::GetInstance()->getUiWidth() - pw.width()) / 2, (UiConfig::GetInstance()->getUiHeight() - pw.height()) / 2);
pw.show();
int curTestItem = 1;
for(auto& item : m_labelsAutoTestRes){
if(!item->isHidden()){
pw.setMsg(curTestItem++, testItemNum);
QCoreApplication::processEvents();
m_labelsAutoTestRes[index]->setPixmap(funcsAuto.at(index)() ? pmOk : pmFailed);
QCoreApplication::processEvents();
}
index++;
}
}
else if (send == m_btnNtp) {
int ret = 0;
{
m_backstageIf->setNtpServerSw(true);
#if 0 //测试代码
QString testText("192.168.100.250/B045220509-40");
std::string ip = getMesSeverIpFromText(testText);
LOGI("expect 1 %d", utils::isValidIp(ip));
QString testText1("");
ip = getMesSeverIpFromText(testText1);
LOGI("expect 0 %d", utils::isValidIp(ip));
QString testText2("abc");
ip = getMesSeverIpFromText(testText2);
LOGI("expect 0 %d", utils::isValidIp(ip));
#endif
std::string mesServerIp = getMesSeverIpFromText(m_editMesAddrAndProdNo->text());
#if 0 //工装ntp校时不依赖mes server ip
if(!utils::isValidIp(mesServerIp))
{
InfoDialog("MES服务器地址无效请重新扫码").exec();
return;
}
#endif
#if 0
ProgressWidget pw("NTP校时中...");
pw.setFixedSize(UiConfig::GetInstance()->getUiWidth() / 2, UiConfig::GetInstance()->getUiHeight() / 6);
pw.move((UiConfig::GetInstance()->getUiWidth() - pw.width()) / 2, (UiConfig::GetInstance()->getUiHeight() - pw.height()) / 2);
pw.show();
#else
MsgDialog msgdlg("NTP校时中...");
msgdlg.show();
#endif
QCoreApplication::processEvents();
ret = m_backstageIf->ntpTimeCorrectForDevTest(mesServerIp);
}
InfoDialog(0 == ret ? "NTP校时成功" : "NTP校时失败请检查网络").exec();
}
else if (send == m_btnAgeing) {
if(m_btnAgeing->text() == "开始"){
unsigned hours = m_editAgeing->text().toUInt();
if(hours > 0){
m_backstageIf->ageingTest(hours);
m_btnAgeing->setText("结束");
m_btnTest->setEnabled(false);
for(int i=0; i<m_btnsAutoTestRetest .size(); i++){
m_btnsAutoTestRetest.at(i)->setEnabled(false);
}
for(int i=0; i<m_btnsMalTest.size(); i++){
m_btnsMalTest.at(i)->setEnabled(false);
}
m_btnNtp->setEnabled(false);
m_btnRecover->setEnabled(false);
m_btnReboot->setEnabled(false);
}
}
else if(m_btnAgeing->text() == "结束"){
m_backstageIf->ageingTest(0);
m_btnAgeing->setText("开始");
m_btnTest->setEnabled(true);
for(int i=0; i<m_btnsAutoTestRetest .size(); i++){
m_btnsAutoTestRetest.at(i)->setEnabled(true);
}
for(int i=0; i<m_labelsMalTestItem.size(); i++){
m_btnsMalTest.at(i)->setEnabled(true);
}
m_btnNtp->setEnabled(true);
m_btnRecover->setEnabled(true);
m_btnReboot->setEnabled(true);
//在工装界面结束老化,会恢复人脸识别,需要重新停止识别,并且延迟一段时间停止保证在恢复之后执行
QTimer::singleShot(200, this, [this]{m_backstageIf->stopIdentyState(true, false);});
}
}
else if (send == m_btnRecover || send == m_btnReboot) {
QString que;
QString btnText;
if(send == m_btnReboot){
que = tr("您确定重新启动FaceTick吗");
btnText = tr("重新启动");
}
else if(send == m_btnRecover){
que = tr("您确定恢复出厂设置吗?");
btnText = tr("恢复");
}
QuestionDialog dlg(que, nullptr, btnText);
if(QDialog::Accepted == dlg.exec()){
if(send == m_btnRecover){
qDebug() << "recoveryFactorySetting";
m_backstageIf->recoveryFactorySetting();
}
PureColorPage* black = new PureColorPage(0);
black->show();
QTimer::singleShot(1000, this, [this]{qDebug() << "devReboot";m_backstageIf->devReboot();});
}
}
else {
index = 0;
for(auto& btn : m_btnsAutoTestRetest){
if(send == btn){
m_labelsAutoTestRes[index]->clear();
MsgDialog msgdlg("检测中...");
msgdlg.show();
QCoreApplication::processEvents();
m_labelsAutoTestRes[index]->setPixmap(funcsAuto.at(index)() ? pmOk : pmFailed);
return;
}
index++;
}
index = 0;
for(auto& btn : m_btnsMalTest){
if(send == btn){
btn->setEnabled(false);
//InfoDialog(QString("通过要求:\n") + m_malTestTips.at(index)).exec();
QCoreApplication::processEvents();
funcsMal.at(index)();
btn->setEnabled(true);
return;
}
index++;
}
}
}
void settingUiDevTest::showSelectionWin(int testIndex) {
const int size = m_btnsMalTest.at(0)->height() * 0.6;
QPixmap pmOk(":/res/image/ok_small.png");
pmOk = pmOk.scaled(size, size);
QPixmap pmFailed(":/res/image/fail2_large.png");
pmFailed = pmFailed.scaled(size, size);
SelectionDialog dlg(m_malTestTips.at(testIndex), "不通过", "通过");
auto manufacturer = DevVersion::getInstance()->getManu();
if (testIndex == enMalTestAuidoSwitch) {
m_labelsMalTestRes.at(enMalTestSpeaker)->setPixmap(dlg.selecion() == 1 ? pmOk : pmFailed);
} else if (testIndex == enMalTestSpeaker &&
(manufacturer == Manu_E::ManuRWRk1109V05)) { // V05以上 板载喇叭测试成功后,再测试外部音频输出
if (dlg.selecion() == 1) {
doAuidoSwitchTest();
} else {
m_labelsMalTestRes.at(testIndex)->setPixmap(pmFailed);
}
} else {
m_labelsMalTestRes.at(testIndex)->setPixmap(dlg.selecion() == 1 ? pmOk : pmFailed);
}
}
void settingUiDevTest::doMicrophoneTest() {
m_backstageIf->microphoneTest(true);
SelectionDialog dlg("录音中,请面对设备屏幕70CM说话", "", "录音结束并播放录音");
if (dlg.selecion() == 1) {
m_backstageIf->microphoneTest(false);
showSelectionWin(enMalTestMicrophone);
} else {
const int size = m_btnsMalTest.at(0)->height() * 0.6;
QPixmap pmFailed(":/res/image/fail2_large.png");
pmFailed = pmFailed.scaled(size, size);
m_labelsMalTestRes.at(enMalTestSpeaker)->setPixmap(pmFailed);
}
}
void settingUiDevTest::doAuidoSwitchTest() {
SelectionDialog dlg("请接入外部音响,并将开关拨至正确位置", "", "已完成");
if (dlg.selecion() == 1) {
m_backstageIf->audioSwitchTest();
showSelectionWin(enMalTestAuidoSwitch);
} else {
const int size = m_btnsMalTest.at(0)->height() * 0.6;
QPixmap pmFailed(":/res/image/fail2_large.png");
pmFailed = pmFailed.scaled(size, size);
m_labelsMalTestRes.at(enMalTestSpeaker)->setPixmap(pmFailed);
}
}
void settingUiDevTest::refreshUiByHardwareConfig(const QString& hardware)
{
m_editDevCfg->setText(hardware);
//HW300102 0 1 C1 1 01H
bool hasReaderUnderScreen = (hardware[8] == '2');
if(hasReaderUnderScreen){//注意测试项索引
m_labelsAutoTestItem.at(enAutoTestReaderUnderScreen)->show();
m_labelsAutoTestRes.at(enAutoTestReaderUnderScreen)->show();
m_btnsAutoTestRetest.at(enAutoTestReaderUnderScreen)->show();
}
else{
m_labelsAutoTestItem.at(enAutoTestReaderUnderScreen)->hide();
m_labelsAutoTestRes.at(enAutoTestReaderUnderScreen)->hide();
m_btnsAutoTestRetest.at(enAutoTestReaderUnderScreen)->hide();
}
bool hasWifi = (hardware[9] == '2');
if(hasWifi){//注意测试项索引
m_labelsAutoTestItem.at(enAutoTestWifi)->show();
m_labelsAutoTestRes.at(enAutoTestWifi)->show();
m_btnsAutoTestRetest.at(enAutoTestWifi)->show();
}
else{
m_labelsAutoTestItem.at(enAutoTestWifi)->hide();
m_labelsAutoTestRes.at(enAutoTestWifi)->hide();
m_btnsAutoTestRetest.at(enAutoTestWifi)->hide();
}
bool hasTp = (hardware[12] == '1');
if(hasTp){//注意测试项索引
m_labelsMalTestItem.at(enMalTestTp)->show();
m_labelsMalTestRes.at(enMalTestTp)->show();
m_btnsMalTest.at(enMalTestTp)->show();
}
else{
m_labelsMalTestItem.at(enMalTestTp)->hide();
m_labelsMalTestRes.at(enMalTestTp)->hide();
m_btnsMalTest.at(enMalTestTp)->hide();
}
auto manufacturer = DevVersion::getInstance()->getManu();
if (manufacturer == Manu_E::ManuRWRk1109V05) {
m_malTest[enMalTestSpeaker] = "喇叭/音频输出";
} else {
m_malTest[enMalTestSpeaker] = "喇叭";
}
m_labelsMalTestItem.at(enMalTestSpeaker)->setText(m_malTest.at(enMalTestSpeaker));
}
std::string settingUiDevTest::getMesSeverIpFromText(const QString& text)
{
//text 例"192.168.100.250:8080/B045220509-40" "192.168.100.250/B045220509-40"
QString mesServerIp("");
if(!text.isEmpty())
{
QStringList list = text.split("/");
QStringList strList = list[0].split(":");
mesServerIp = strList[0];
}
LOGI("mesServerIp %s", mesServerIp.toStdString().c_str());
//qDebug()<<"mesServerIp "<<mesServerIp;
return mesServerIp.toStdString();
}

View File

@ -0,0 +1,103 @@
#ifndef SETTINGUIDEVTEST_H
#define SETTINGUIDEVTEST_H
#include "UiTools.h"
#include "UiConfig.h"
#include <QTimer>
#include <QGroupBox>
class settingUiDevTest : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
enum{
enAutoTestWg,
enAutoTestRelayAndGpio,
enAutoTestRs485,
enAutoTestWifi,
enAutoTestRtc,
enAutoTestReaderUnderScreen,
enAutoTestSerial1,
//enAutoTestIdModuleInfoUpload
};
enum{
enMalTestLcd,
enMalTestMicrophone, // 麦克风测试
enMalTestSpeaker,
enMalTestTp,
enMalTestIrCam,
enMalTestIrLed,
enMalTestAuidoSwitch, // 测试外部 韦根输出、音频输出 GPIO切换功能
};
static int m_pageIndex;
explicit settingUiDevTest(int pageIndex, QWidget *parent = nullptr);
void reset();
signals:
void signalShowSettingUi();
public slots:
void slotBtnClicked();
void slotDevTestMesAddrAndProdNoText(const QString& text);
void slotDevTestPcbSeqText(const QString& text);
void slotDevTestConfigInfo(const QString& text);
void slotClosed();
protected:
void doAuidoSwitchTest();
void doMicrophoneTest();
private:
const QStringList m_autoTest = {"韦根输入输出", "继电器和GPIO", "RS485", "WIFI", "实时时钟", "屏下刷卡", "板载uart3"};//, "NFC模块上报ID", "有线网络", "4G模块"
QStringList m_malTest = {"显示屏", "麦克风", "喇叭", "触摸屏", "红外镜头", "红外补光灯"};
const QStringList m_malTestTips = {"屏幕显示白色、黑色、灰色、\n红色、绿色、蓝色,屏幕无条纹,\n无坏点,无闪烁,无色差",
"播放内容完整,声音清晰,无噪音",
"喇叭播放测试语音,声音清晰、无噪音",
"触摸屏画线无异常",
"红外镜头成像清晰",
"红外镜头画面有明暗交替变化",
"外部喇叭播放测试语音,声音清晰、无噪音",
};
const int FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {30, 35, 35, 23, 23};
const QVector<unsigned> color{0xFFFFFF, 0, 0xDDDDDD, 0xFF0000, 0xFF00, 0xFF};
QGroupBox* m_gbAuto;
QPushButton* m_btnTest;
QVector<QLabel*> m_labelsAutoTestItem;
QVector<QLabel*> m_labelsAutoTestRes;
QVector<QPushButton*> m_btnsAutoTestRetest;
QGroupBox* m_gbMal;
QVector<QLabel*> m_labelsMalTestItem;
QVector<QLabel*> m_labelsMalTestRes;
QVector<QPushButton*> m_btnsMalTest;
QPushButton* m_btnNtp;
QPushButton* m_btnAgeing;
LineEditWithKeyboard* m_editAgeing;
QPushButton* m_btnRecover;
QGroupBox* m_gbDev;
QLineEdit* m_editSoftVer;
QLineEdit* m_editDevCfg;
QLineEdit* m_editMesAddrAndProdNo;
QLineEdit* m_editPcbSeq;
QLineEdit* m_editMac;
QPushButton* m_btnReboot;
QTimer* m_timer = nullptr;
PureColorPage* m_colorScreen = nullptr;
int m_colorIndex = 0;
DrawPage* m_draw = nullptr;
void showSelectionWin(int testIndex);
void refreshUiByHardwareConfig(const QString& hardware);
std::string getMesSeverIpFromText(const QString& text);
};
#endif // SETTINGUIDEVTEST_H

View File

@ -0,0 +1,984 @@
#include "settingUiFaceMng.h"
#include <QDebug>
#include "UiConfig.h"
#include <QButtonGroup>
#include "recoUiRecognize.h"
int settingUiFaceMng::m_pageIndex = 0;
settingUiFaceMng::settingUiFaceMng(int pageIndex, QWidget *parent)
: SettingUiPage(QVector<SettingUiPage::SetOpn>{
SetOpn(tr("人脸库(人)"), "xxxxx", myListWidget::enPropertyMoreArrow),
SetOpn(tr("通行记录(条)"), "xxxxxx", myListWidget::enPropertyMoreArrow)
}, parent)
{
m_pageIndex = pageIndex;
qDebug() << "settingUiFaceMng()";
}
settingUiFaceMng::~settingUiFaceMng()
{
qDebug() << "~settingUiFaceMng()";
}
void settingUiFaceMng::setBackstageUiinterface(BackstageInterfaceForUi* interface)
{
m_backstageIf = interface;
reset();
}
void settingUiFaceMng::reset()
{
if(nullptr == m_backstageIf){
return;
}
for(int i = 0; i < config.size(); i ++)
{
QListWidgetItem* pItem = m_listWidget->item(i);
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(pItem));
if(wdt == nullptr){
return;
}
QString str;
switch(i)
{
case enFaceDb:
str = QString::number(m_backstageIf->getRegisterNum());
break;
case enAccessRecord:
str = QString::number(m_backstageIf->getAccessRecordQty());
break;
default:
break;
}
wdt->updateLabel(str);
}
}
void settingUiFaceMng::slotItemClicked(QListWidgetItem* item)
{
int row = m_listWidget->currentRow();
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
if(wdt == nullptr){
return;
}
switch(row){
case enFaceDb:
emit signalShowPage(FaceDbPage::m_pageIndex);
break;
case enAccessRecord:
emit signalShowPage(AccessRecordPage::m_pageIndex);
break;
default:
break;
}
}
int FaceDbPage::m_pageIndex = 0;
FaceDbPage::FaceDbPage(int pageIndex, QWidget *parent) : PersonMsgUiPage(parent)
{
qDebug() << "FaceDbPage";
m_pageIndex = pageIndex;
QLabel* label = new QLabel(tr("未搜索到相关人员"), m_stackWgt);
label->setAlignment(Qt::AlignHCenter);
m_stackWgt->addWidget(label);
}
void FaceDbPage::reset()
{
slotTextChanged("");
m_editSearch[enSearchOpnName]->clear();
}
void FaceDbPage::clickBtn_addPerson()
{
emit signalShowPage(AddPersonPage::m_pageIndex);
}
void FaceDbPage::slotTextChanged(const QString& text)
{
int searchOpnIndex = 0;
if(sender() == m_editSearch[enSearchOpnName]){
searchOpnIndex = static_cast<int>(enSearchOpnName);
qDebug() << "FaceDbPage text change:" << text;
m_sSearchName = text;
}
else if(sender() == m_editSearch[enSearchOpnTime]){
searchOpnIndex = static_cast<int>(enSearchOpnTime);
m_sSearchtime = text;
}
qDebug() << "m_sSearchName:" << m_sSearchName;
if(m_backstageIf){
unsigned personQty = m_backstageIf->queryPerson(m_sSearchName.toStdString().c_str());
//qDebug() << "queryPerson ret:" << personQty;
if(personQty){
showFaceMsg(0);
m_stackWgt->setCurrentIndex(0);
setPageControlBarHide(personQty <= m_itemQty, 1, static_cast<int>(!!(personQty % m_itemQty) + (personQty / m_itemQty)), 1);
}
else {
m_stackWgt->setCurrentIndex(1);
setPageControlBarHide(true);
}
}
if("" != text){
m_btnClearSearch[searchOpnIndex]->show();
m_labelTip[searchOpnIndex]->hide();
}
else {
m_btnClearSearch[searchOpnIndex]->hide();
m_labelTip[searchOpnIndex]->show();
}
}
void FaceDbPage::showFaceMsg(int pageIndex)
{
if(nullptr == m_backstageIf){
return;
}
stQueryPersonInfo person[m_itemQty];
#if 0
for(unsigned j=0; j<m_itemQty; j++){
person[j].name[0] = '\0';
person[j].imgPath[0] = '\0';
strcpy(person[j].expTime, tr("有效期:").toStdString().c_str());
strcpy(person[j].regTime, tr("注册时间:").toStdString().c_str());
}
#endif
m_lastPageIndex = pageIndex;
unsigned personReadQty = m_backstageIf->queryPerson(m_sSearchName.toStdString().c_str(), pageIndex, person, static_cast<int>(m_itemQty));
QVector<PersonMsgUiPage::MsgSet> msgs;
if(personReadQty){
for(unsigned i=0; i<personReadQty; i++){
if(i < 5)
{
m_person[i] = person[i];
}
const QVector<PersonMsgUiPage::MsgOpn> opns{{person[i].name.c_str(), PersonMsgUiPage::MsgOpnProp::enPropertyBold},
{QString(person[i].expTime.c_str()).lastIndexOf("3000") >= 0 ? tr("有效期:永久有效") : QString(person[i].expTime.c_str()),
PersonMsgUiPage::MsgOpnProp::enPropertyGreyWord},
{person[i].regTime.c_str(), PersonMsgUiPage::MsgOpnProp::enPropertyGreyWord}};
msgs.append(PersonMsgUiPage::MsgSet(person[i].imgPath.c_str(), opns));
}
#if 0
if(personReadQty < m_itemQty){
msgs.append(PersonMsgUiPage::MsgSet("", QVector<PersonMsgUiPage::MsgOpn>()));
}
#endif
}
showMsg(msgs);
}
void FaceDbPage::slotBtnClicked()
{
PersonMsgUiPage::slotBtnClicked();
showFaceMsg(m_toPageNum - 1);
}
void FaceDbPage::slotSliderReleased()
{
PersonMsgUiPage::slotSliderReleased();
showFaceMsg(m_toPageNum - 1);
}
void FaceDbPage::slotItemClicked(QListWidgetItem *item)
{
int row = m_listWidget->currentRow();
qDebug() << __PRETTY_FUNCTION__ << " row=" << row;
if(row < 5)
{
emit signalPersonInfo(m_person[row]);
emit signalShowPage(ModifyPersonPage::m_pageIndex);
}
}
void FaceDbPage::slot_freshPage()
{
qDebug() << __PRETTY_FUNCTION__;
//数据库更新,刷新最后一次的页面
if(nullptr == m_backstageIf){
return;
}
unsigned personQty = m_backstageIf->queryPerson(m_sSearchName.toStdString().c_str());
//qDebug() << "queryPerson ret:" << personQty;
if(personQty){
int maxPageNum = !!(personQty % m_itemQty) + (personQty / m_itemQty);
int showPageIndex = m_lastPageIndex < maxPageNum ? m_lastPageIndex : (maxPageNum-1);
showFaceMsg(showPageIndex);
m_stackWgt->setCurrentIndex(0);
setPageControlBarHide(personQty <= m_itemQty, 1, maxPageNum, showPageIndex+1);
}
else {
m_stackWgt->setCurrentIndex(1);
setPageControlBarHide(true);
}
}
int AccessRecordPage::m_pageIndex = 0;
AccessRecordPage::AccessRecordPage(int pageIndex, QWidget *parent) : PersonMsgUiPage(parent)
{
qDebug() << "AccessRecordPage";
m_pageIndex = pageIndex;
QLabel* label = new QLabel(tr("未搜索到相关通行记录"), m_stackWgt);
label->setAlignment(Qt::AlignHCenter);
m_stackWgt->addWidget(label);
showMoreSearchOpn();
}
void AccessRecordPage::slotTextChanged(const QString& text)
{
int searchOpnIndex = 0;
if(sender() == m_editSearch[enSearchOpnName]){
searchOpnIndex = static_cast<int>(enSearchOpnName);
qDebug() << "AccessRecordPage name text change:" << text;
m_sSearchName = text;
}
else if(sender() == m_editSearch[enSearchOpnTime]){
searchOpnIndex = static_cast<int>(enSearchOpnTime);
qDebug() << "AccessRecordPage time text change:" << text;
m_sSearchtime = text;
}
if(m_backstageIf){
unsigned recordQty = m_backstageIf->queryAccessRecord("" != m_sSearchName.toStdString() ? m_sSearchName.toStdString().c_str() : nullptr,
"" != m_sSearchtime.toStdString() ? m_sSearchtime.toStdString().c_str() : nullptr);
//qDebug() << "recordQty ret:" << recordQty;
if(recordQty){
showAccessRecordMsg(0);
m_stackWgt->setCurrentIndex(0);
setPageControlBarHide(recordQty <= m_itemQty, 1, static_cast<int>(!!(recordQty % m_itemQty) + (recordQty / m_itemQty)), 1);
}
else {
m_stackWgt->setCurrentIndex(1);
setPageControlBarHide(true);
}
}
if("" != text){
m_btnClearSearch[searchOpnIndex]->show();
m_labelTip[searchOpnIndex]->hide();
}
else {
m_btnClearSearch[searchOpnIndex]->hide();
m_labelTip[searchOpnIndex]->show();
}
}
void AccessRecordPage::showAccessRecordMsg(int pageIndex)
{
if(nullptr == m_backstageIf){
return;
}
stQueryAccRedInfo record[m_itemQty];
for(unsigned j=0; j<m_itemQty; j++){
record[j].name[0] = '\0';
record[j].imgPath[0] = '\0';
strcpy(record[j].accessTime, tr("通行时间:").toStdString().c_str());
}
qDebug() << "name:" << m_sSearchName << ", time:" << m_sSearchtime << ", page index:" << pageIndex;
unsigned recordQty = m_backstageIf->queryAccessRecord("" != m_sSearchName.toStdString() ? m_sSearchName.toStdString().c_str() : nullptr,
"" != m_sSearchtime.toStdString() ? m_sSearchtime.toStdString().c_str() : nullptr,
pageIndex, record, static_cast<int>(m_itemQty));
QVector<PersonMsgUiPage::MsgSet> msgs;
for(unsigned i=0; i<recordQty; i++){
const QVector<PersonMsgUiPage::MsgOpn> opns{
{record[i].name, PersonMsgUiPage::MsgOpnProp::enPropertyBold},
{record[i].accessTime, PersonMsgUiPage::MsgOpnProp::enPropertyGreyWord},
{record[i].allowPass ? tr("通过") : tr("不通过"),
record[i].allowPass ? PersonMsgUiPage::MsgOpnProp::enPropertyGreenWord : PersonMsgUiPage::MsgOpnProp::enPropertyRedWord}
};
msgs.append(PersonMsgUiPage::MsgSet(record[i].imgPath, opns));
}
#if 0
if(recordQty < m_itemQty){
msgs.append(PersonMsgUiPage::MsgSet("", QVector<PersonMsgUiPage::MsgOpn>()));
}
#endif
showMsg(msgs);
}
void AccessRecordPage::slotBtnClicked()
{
PersonMsgUiPage::slotBtnClicked();
if(sender() == m_btnPrePage || sender() == m_btnNextPage){
qDebug() << "slotBtnClicked : page num" << m_toPageNum;
showAccessRecordMsg(m_toPageNum - 1);
}
}
void AccessRecordPage::slotSliderReleased()
{
PersonMsgUiPage::slotSliderReleased();
qDebug() << "slotSliderReleased : page num" << m_toPageNum;
showAccessRecordMsg(m_toPageNum - 1);
}
void AccessRecordPage::reset()
{
m_sSearchtime = "";
slotTextChanged("");
m_editSearch[enSearchOpnName]->clear();
m_editSearch[enSearchOpnTime]->clear();
}
RegisterPersonPage::RegisterPersonPage(QWidget *parent) : MyWidgetWithMainStyleColor(parent)
{
m_listWidget = new QListWidget(this);
m_listWidget->setFrameStyle(QFrame::NoFrame);
m_listWidget->setCursor(QCursor(Qt::PointingHandCursor));
m_listWidget->setFocusPolicy(Qt::NoFocus);
m_listWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_listWidget->setSpacing(0);
m_listWidget->setStyleSheet("QListWidget{border-width:0;border-style:outset; background:rgb(255, 255, 255);border-top: 1px solid #DFDDEB;}"
"QListWidget::item{border-bottom: 1px solid #DFDDEB;}"
"QListWidget::Item:hover{background:transparent;}"
"QListWidget::item:selected{background:transparent; }");
m_listWidget->setFixedSize(UiConfig::GetInstance()->getUiWidth(), static_cast<int>(UiConfig::GetInstance()->getUiHeight() / 0.6));
connect(m_listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(slotItemClicked(QListWidgetItem*)));
//图片
m_picWidget = new QWidget(this);
m_picLabel = new QLabel(m_picWidget);
m_picLabel->setFixedSize(static_cast<int>(UiConfig::GetInstance()->getUiWidth() / 4), static_cast<int>(UiConfig::GetInstance()->getUiHeight() / 10));
//m_picLabel->setStyleSheet("background-color: white;");
QLabel *label_pic = new QLabel("*人脸图片", m_picWidget);
QHBoxLayout* picWidgetLayout = new QHBoxLayout();
//QSpacerItem* hSpace1 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
picWidgetLayout->addWidget(label_pic);
picWidgetLayout->addWidget(m_picLabel, 0, Qt::AlignRight);
m_picWidget->setLayout(picWidgetLayout);
//QPixmap faceImg(":/res/image/add.png");
QPixmap faceImg(":/res/image/add.jpg");
m_picLabel->setPixmap(ScalePixmap2Label(faceImg, *m_picLabel));
//m_picLabel->setFixedSize(104, 105);
//m_picLabel->setPixmap(faceImg);
//m_picLabel->setPixmap(ScalePixmap(faceImg, QSize(m_picLabel->width()-1, m_picLabel->height()-1)));
//授权期限选择
m_deadlineChoiceWidget = new QWidget(this);
m_deadlineBtnGrp = new QButtonGroup(m_deadlineChoiceWidget);
QLabel *label_choice = new QLabel("*授权", m_deadlineChoiceWidget);
m_durableBtn = new QRadioButton(m_deadlineChoiceWidget);
m_durableBtn->setText(tr("永久授权"));
m_durableBtn->setStyleSheet(QString("QRadioButton::indicator { width: %1px; height: %2px; }")
.arg(UiConfig::GetInstance()->getUiHeight() / 30)
.arg(UiConfig::GetInstance()->getUiHeight() / 30));
m_durableBtn->setStyleSheet("QRadioButton::indicator:unchecked{image: url(:/res/image/select_1.png);}"
"QRadioButton::indicator:checked{image: url(:/res/image/select_2.png);}");
m_durableBtn->setFocusPolicy(Qt::NoFocus);
m_nondurableBtn = new QRadioButton(m_deadlineChoiceWidget);
m_nondurableBtn->setText(tr("非永久授权"));
m_nondurableBtn->setStyleSheet(QString("QRadioButton::indicator { width: %1px; height: %2px; }")
.arg(UiConfig::GetInstance()->getUiHeight() / 30)
.arg(UiConfig::GetInstance()->getUiHeight() / 30));
m_nondurableBtn->setStyleSheet("QRadioButton::indicator:unchecked{image: url(:/res/image/select_1.png);}"
"QRadioButton::indicator:checked{image: url(:/res/image/select_2.png);}");
m_nondurableBtn->setFocusPolicy(Qt::NoFocus);
m_deadlineBtnGrp->addButton(m_durableBtn, 0);
m_deadlineBtnGrp->addButton(m_nondurableBtn, 1);
m_durableBtn->setChecked(true);
QHBoxLayout* deadlineChoiceLayout = new QHBoxLayout();
deadlineChoiceLayout->addWidget(label_choice);
deadlineChoiceLayout->addWidget(m_durableBtn);
deadlineChoiceLayout->addWidget(m_nondurableBtn);
m_deadlineChoiceWidget->setLayout(deadlineChoiceLayout);
connect(m_deadlineBtnGrp, SIGNAL(buttonClicked(int)), this, SLOT(slotDeadlineBtnClicked(int)));
m_nameWidget = new myListWidget(myListWidget::SetOpnCfg(tr("*姓名"), "", myListWidget::enPropertyMoreArrow));
m_deadlineWidget = new myListWidget(myListWidget::SetOpnCfg(tr("*授权截至日期"), "", myListWidget::enPropertyMoreArrow));
m_jobNumWidget = new myListWidget(myListWidget::SetOpnCfg(tr("工号"), "", myListWidget::enPropertyMoreArrow));
m_phoneNumWidget = new myListWidget(myListWidget::SetOpnCfg(tr("手机号"), "", myListWidget::enPropertyMoreArrow));
m_idCardWidget = new myListWidget(myListWidget::SetOpnCfg(tr("身份证号"), "", myListWidget::enPropertyMoreArrow));
m_icCardWidget = new myListWidget(myListWidget::SetOpnCfg(tr("IC卡/NFC"), "", myListWidget::enPropertyMoreArrow));
QListWidgetItem* pItem;
pItem = new QListWidgetItem(m_listWidget);
pItem->setSizeHint(QSize(UiConfig::GetInstance()->getUiHeight() / 8, UiConfig::GetInstance()->getUiHeight() / 8));
m_listWidget->setItemWidget(pItem, m_picWidget);
pItem = new QListWidgetItem(m_listWidget);
pItem->setSizeHint(QSize(UiConfig::GetInstance()->getUiHeight() / 12, UiConfig::GetInstance()->getUiHeight() / 12));
m_listWidget->setItemWidget(pItem, m_nameWidget);
pItem = new QListWidgetItem(m_listWidget);
pItem->setSizeHint(QSize(UiConfig::GetInstance()->getUiHeight() / 12, UiConfig::GetInstance()->getUiHeight() / 12));
m_listWidget->setItemWidget(pItem, m_deadlineChoiceWidget);
pItem = new QListWidgetItem(m_listWidget);
pItem->setSizeHint(QSize(UiConfig::GetInstance()->getUiHeight() / 12, UiConfig::GetInstance()->getUiHeight() / 12));
m_listWidget->setItemWidget(pItem, m_deadlineWidget);
pItem = new QListWidgetItem(m_listWidget);
pItem->setSizeHint(QSize(UiConfig::GetInstance()->getUiHeight() / 12, UiConfig::GetInstance()->getUiHeight() / 12));
m_listWidget->setItemWidget(pItem, m_jobNumWidget);
pItem = new QListWidgetItem(m_listWidget);
pItem->setSizeHint(QSize(UiConfig::GetInstance()->getUiHeight() / 12, UiConfig::GetInstance()->getUiHeight() / 12));
m_listWidget->setItemWidget(pItem, m_phoneNumWidget);
pItem = new QListWidgetItem(m_listWidget);
pItem->setSizeHint(QSize(UiConfig::GetInstance()->getUiHeight() / 12, UiConfig::GetInstance()->getUiHeight() / 12));
m_listWidget->setItemWidget(pItem, m_idCardWidget);
pItem = new QListWidgetItem(m_listWidget);
pItem->setSizeHint(QSize(UiConfig::GetInstance()->getUiHeight() / 12, UiConfig::GetInstance()->getUiHeight() / 12));
m_listWidget->setItemWidget(pItem, m_icCardWidget);
m_bottomBtn = new QPushButton(this);
m_bottomBtn->setFocusPolicy(Qt::NoFocus);
m_bottomBtn->setMinimumSize(UiConfig::GetInstance()->getUiWidth() / 3, UiConfig::GetInstance()->getUiHeight() / 15);
//m_bottomBtn->setMinimumWidth(UiConfig::GetInstance()->getUiWidth() / 3);
m_bottomBtn->setStyleSheet("color:white;"
"background-color: blue;"
"border:none;"
"border-radius: 3px");
QLabel *tip = new QLabel(this);
tip->setText("<p style='line-height:100%;'><font size='+0' color=blue>可以刷卡写入IC卡</font></p>");
QHBoxLayout* hbLayout = new QHBoxLayout();
QSpacerItem* hSpace1 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
QSpacerItem* hSpace2 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hbLayout->addItem(hSpace1);
hbLayout->addWidget(m_bottomBtn);
hbLayout->addItem(hSpace2);
QVBoxLayout* vbLayout = new QVBoxLayout();
vbLayout->addWidget(m_listWidget, 0, Qt::AlignCenter);
vbLayout->addWidget(tip);
vbLayout->addLayout(hbLayout, 1);
vbLayout->setSpacing(20);
vbLayout->setMargin(10);
setLayout(vbLayout);
m_listWidget->setItemHidden(m_listWidget->item(PERSON_ITEM_DEADLINE), true);
}
void RegisterPersonPage::slotSetPersonInfo(stQueryPersonInfo &personInfo)
{
m_personInfo = personInfo;
m_snapFeature.clear();
m_snapPicPath.clear();
refreshUi();
}
void RegisterPersonPage::slotSnapFace(string &feature, string &picPath)
{
m_snapFeature = feature;
m_snapPicPath = picPath;
m_picLabel->clear();
QPixmap faceImg(m_snapPicPath.c_str());
m_picLabel->setPixmap(ScalePixmap2Label(faceImg, *m_picLabel));
}
void RegisterPersonPage::slotIcCardResult(const QString &icCard)
{
m_icCardWidget->updateLabel(icCard);
}
void RegisterPersonPage::clearPersonInfo()
{
m_personInfo.clear();
m_snapFeature.clear();
m_snapPicPath.clear();
refreshUi();
}
void RegisterPersonPage::refreshUi()
{
m_picLabel->clear();
if(m_personInfo.imgPath.empty())
{
//QPixmap faceImg(":/res/image/add.png");
QPixmap faceImg(":/res/image/add.jpg");
m_picLabel->setPixmap(ScalePixmap2Label(faceImg, *m_picLabel));
}else
{
QPixmap faceImg(m_personInfo.imgPath.c_str());
m_picLabel->setPixmap(ScalePixmap2Label(faceImg, *m_picLabel));
}
bool isDurable = (m_personInfo.expTime.empty() ||
QString(m_personInfo.expTime.c_str()).lastIndexOf("3000") >= 0) ? true : false;
isDurable ? m_durableBtn->setChecked(true) : m_nondurableBtn->setChecked(true);
m_listWidget->setItemHidden(m_listWidget->item(PERSON_ITEM_DEADLINE), isDurable);
m_deadlineWidget->updateLabel(isDurable ? "" : m_personInfo.expTime.c_str());
m_nameWidget->updateLabel(m_personInfo.name.c_str());
m_jobNumWidget->updateLabel(m_personInfo.jobNum.c_str());
m_phoneNumWidget->updateLabel(m_personInfo.phoneNum.c_str());
m_idCardWidget->updateLabel(m_personInfo.idNum.c_str());
m_icCardWidget->updateLabel(m_personInfo.icNum.c_str());
}
#if 0
void RegisterPersonPage::setInfo(dbspace::rwFeatInfo *pFeatInfo, dbspace::rwPersonInfo *pPersonInfo)
{
#if 0
m_featInfo.clear();
m_personInfo.clear();
if(pFeatInfo != nullptr)
{
m_featInfo = *pFeatInfo;
}
if(pFeatInfo != nullptr)
{
m_personInfo = *pPersonInfo;
}
#endif
}
#endif
void RegisterPersonPage::slotItemClicked(QListWidgetItem *item)
{
int row = m_listWidget->currentRow();
//dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
//QWidget* pItemWidget = m_listWidget->itemWidget(item);
qDebug() << __PRETTY_FUNCTION__ << "row=" << row;
switch (row) {
#if 0
case PERSON_ITEM_PIC:
//turn to snap photo page
emit signalShowPage(SnapFacePage::m_pageIndex);
break;
#endif
case PERSON_ITEM_NAME:
{
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
if(wdt == nullptr){
return;
}
LineEditInputDialog dlg(wdt->getOpnLabelString(), parent()->parent());
if(dlg.exec() == QDialog::Accepted)
{
QString setStr = dlg.getRow(0);
#if 0
if(setStr.isEmpty())
{
InfoDialog(tr("设置有误,请重新输入!"), parent()->parent()).exec();
}else
#endif
{
wdt->updateLabel(setStr);
}
}
}
break;
#if 0
case PERSON_ITEM_DEADLINE_CHOICE:
break;
#endif
case PERSON_ITEM_DEADLINE:
{
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
if(wdt == nullptr){
return;
}
//QDateTime::fromString(wdt->getLabelString(), "yyyy-MM-dd hh:mm");
//DateTimeDialog dateTimeDlg(QDateTime::currentDateTime(), parent()->parent());
DateTimeDialog dateTimeDlg(wdt->getLabelString().isEmpty() ? QDateTime::currentDateTime() : QDateTime::fromString(wdt->getLabelString(), "yyyy-MM-dd hh:mm"), parent()->parent());
if(dateTimeDlg.exec() == QDialog::Accepted)
{
wdt->updateLabel(dateTimeDlg.getValueSet().toString("yyyy-MM-dd hh:mm"));
}
}
break;
case PERSON_ITEM_JOB_NUM:
{
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
if(wdt == nullptr){
return;
}
LineEditInputDialog dlg(wdt->getOpnLabelString(), parent()->parent());
if(dlg.exec() == QDialog::Accepted)
{
QString setStr = dlg.getRow(0);
#if 0
if(setStr.isEmpty())
{
InfoDialog(tr("设置有误,请重新输入!"), parent()->parent()).exec();
}else
#endif
{
wdt->updateLabel(setStr);
}
}
}
break;
case PERSON_ITEM_PHONE_NUM:
{
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
if(wdt == nullptr){
return;
}
LineEditInputDialog dlg(wdt->getOpnLabelString(), parent()->parent());
if(dlg.exec() == QDialog::Accepted)
{
QString setStr = dlg.getRow(0);
#if 0
if(setStr.isEmpty())
{
InfoDialog(tr("设置有误,请重新输入!"), parent()->parent()).exec();
}else
#endif
{
wdt->updateLabel(setStr);
}
}
}
break;
case PERSON_ITEM_ID_CARD:
{
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
if(wdt == nullptr){
return;
}
LineEditInputDialog dlg(wdt->getOpnLabelString(), parent()->parent());
if(dlg.exec() == QDialog::Accepted)
{
QString setStr = dlg.getRow(0);
#if 0
if(setStr.isEmpty())
{
InfoDialog(tr("设置有误,请重新输入!"), parent()->parent()).exec();
}else
#endif
{
wdt->updateLabel(setStr);
}
}
}
break;
case PERSON_ITEM_IC_CARD:
{
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
if(wdt == nullptr){
return;
}
LineEditInputDialog dlg(wdt->getOpnLabelString(), parent()->parent());
if(dlg.exec() == QDialog::Accepted)
{
QString setStr = dlg.getRow(0);
#if 0
if(setStr.isEmpty())
{
InfoDialog(tr("设置有误,请重新输入!"), parent()->parent()).exec();
}else
#endif
{
wdt->updateLabel(setStr);
}
}
}
break;
default:
break;
}
}
void RegisterPersonPage::slotDeadlineBtnClicked(int id)
{
qDebug() << __PRETTY_FUNCTION__ << "id=" << id;
if(id == 0)
{
m_listWidget->setItemHidden(m_listWidget->item(PERSON_ITEM_DEADLINE), true);
}else if(id == 1)
{
m_listWidget->setItemHidden(m_listWidget->item(PERSON_ITEM_DEADLINE), false);
}
}
int AddPersonPage::m_pageIndex = 0;
AddPersonPage::AddPersonPage(int pageIndex, QWidget *parent) : RegisterPersonPage(parent)
{
qDebug() << "AddPersonPage";
m_pageIndex = pageIndex;
m_bottomBtn->setText(tr("确认添加"));
connect(m_bottomBtn, SIGNAL(clicked(bool)), this, SLOT(slotAddPerson()));
}
void AddPersonPage::reset()
{
clearPersonInfo();
m_backstageIf->startIdentyState(false, true);
}
void AddPersonPage::slotItemClicked(QListWidgetItem *item)
{
int row = m_listWidget->currentRow();
//dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
//QWidget* pItemWidget = m_listWidget->itemWidget(item);
qDebug() << __PRETTY_FUNCTION__ << "row=" << row;
switch (row) {
case PERSON_ITEM_PIC:
//turn to snap photo page
emit signalShowPage(SnapFacePage::m_pageIndex);
break;
default:
break;
}
RegisterPersonPage::slotItemClicked(item);
}
void AddPersonPage::slotAddPerson()
{
qDebug() << __PRETTY_FUNCTION__;
if(nullptr == m_backstageIf){
return;
}
QString showText = tr("确定新增人员?");
QuestionDialog dlg(showText, parent()->parent(), tr("确定"));
if(QDialog::Accepted != dlg.exec()){
return;
}
stQueryPersonInfo personInfo;
//personInfo.personId = m_personInfo.personId;
personInfo.name = m_nameWidget->getLabelString().toStdString();
personInfo.expTime = m_durableBtn->isChecked() ? std::string("3000-12-31 00:00") : m_deadlineWidget->getLabelString().toStdString();;
personInfo.idNum = m_idCardWidget->getLabelString().toStdString();
personInfo.icNum = m_icCardWidget->getLabelString().toStdString();
personInfo.jobNum = m_jobNumWidget->getLabelString().toStdString();
personInfo.phoneNum = m_phoneNumWidget->getLabelString().toStdString();
personInfo.imgPath = m_snapPicPath;
personInfo.feature = m_snapFeature;
if(personInfo.name.empty() || personInfo.expTime.empty() ||
personInfo.imgPath.empty() || personInfo.feature.empty())
{
InfoDialog(tr("请补全*信息!"), parent()->parent()).exec();
return;
}
int ret = m_backstageIf->addPerson(personInfo);
if(ret == 0)
{
emit signalChangePersonDB();
emit signalReturn();
}else
{
qDebug() << __PRETTY_FUNCTION__ << "addPerson err:" << ret;
if(ret == -99)
{
InfoDialog(tr("注册失败,已达到最大注册人数!"), parent()->parent()).exec();
}else if(ret == -6)
{
InfoDialog(tr("IC卡号重复"), parent()->parent()).exec();
}else if(ret == -5)
{
InfoDialog(tr("注册人员失败,请重新抓拍!"), parent()->parent()).exec();
}else if (ret == -7)
{
InfoDialog(tr("身份证号已存在!"), parent()->parent()).exec();
}else
{
InfoDialog(tr("注册人员失败!"), parent()->parent()).exec();
}
}
}
int ModifyPersonPage::m_pageIndex = 0;
ModifyPersonPage::ModifyPersonPage(int pageIndex, QWidget *parent) : RegisterPersonPage(parent)
{
qDebug() << "ModifyPersonPage";
m_pageIndex = pageIndex;
m_bottomBtn->setText(tr("删除人员"));
connect(m_bottomBtn, SIGNAL(clicked(bool)), this, SLOT(slotDelPerson()));
}
void ModifyPersonPage::reset()
{
m_backstageIf->startIdentyState(false, true);
}
void ModifyPersonPage::savePersonInfo()
{
qDebug() << __PRETTY_FUNCTION__;
if(nullptr == m_backstageIf){
return;
}
QString showText = tr("确定更改人员信息?");
QuestionDialog dlg(showText, parent()->parent(), tr("确定"));
if(QDialog::Accepted != dlg.exec()){
return;
}
stQueryPersonInfo personInfo;
personInfo.personId = m_personInfo.personId;
personInfo.name = m_nameWidget->getLabelString().toStdString();
personInfo.expTime = m_durableBtn->isChecked() ? std::string("3000-12-31 00:00") : m_deadlineWidget->getLabelString().toStdString();;
personInfo.idNum = m_idCardWidget->getLabelString().toStdString();
personInfo.icNum = m_icCardWidget->getLabelString().toStdString();
personInfo.jobNum = m_jobNumWidget->getLabelString().toStdString();
personInfo.phoneNum = m_phoneNumWidget->getLabelString().toStdString();
if(personInfo.name.empty() || personInfo.expTime.empty())
{
InfoDialog(tr("请补全*信息!"), parent()->parent()).exec();
return;
}
int ret = m_backstageIf->modifyPerson(personInfo);
if(ret == 0)
{
emit signalChangePersonDB();
emit signalReturn();
}else
{
qDebug() << __PRETTY_FUNCTION__ << "modifyPerson err:" << ret;
if(ret == -2)
{
InfoDialog(tr("无效的姓名!"), parent()->parent()).exec();
}else if(ret == -3)
{
InfoDialog(tr("IC卡号重复"), parent()->parent()).exec();
}else if(ret == -6)
{
InfoDialog(tr("身份证号已存在!"), parent()->parent()).exec();
}else
{
InfoDialog(tr("更改人员信息失败,人员或已被删除!"), parent()->parent()).exec();
emit signalChangePersonDB();
//emit signalReturn();
}
}
}
void ModifyPersonPage::slotDelPerson()
{
qDebug() << __PRETTY_FUNCTION__;
if(nullptr == m_backstageIf){
return;
}
QString showText = tr("确定删除改人员?");
QuestionDialog dlg(showText, parent()->parent(), tr("确定"));
if(QDialog::Accepted != dlg.exec()){
return;
}
m_backstageIf->delPerson(m_personInfo.personId);
emit signalChangePersonDB();
emit signalReturn();
}
const QString SnapFacePage::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"
};
int SnapFacePage::m_pageIndex = 0;
SnapFacePage::SnapFacePage(int pageIndex, QWidget *parent) : WidgetWithBackstageInterface(parent)
{
qDebug() << "SnapFacePage";
m_pageIndex = pageIndex;
m_btn_snap = new QPushButton(this);
m_btn_snap->setFocusPolicy(Qt::NoFocus);
int radius_w = (UiConfig::GetInstance()->getUiWidth() * 0.2) / 2;
int radius_h = (UiConfig::GetInstance()->getUiHeight() * 0.1) / 2;
int radius = min(radius_w, radius_h);
m_btn_snap->setFixedSize(radius*2, radius*2);
m_btn_snap->setStyleSheet(QString("background-color: white;"
"border-radius: %1px;").arg(radius));
m_btn_snap->setText(tr("拍照"));
connect(m_btn_snap, SIGNAL(clicked(bool)), this, SLOT(slotSnapBtnClicked()));
#if 0
m_btn_snap->move((UiConfig::GetInstance()->getUiWidth() - m_btn_snap->width()) / 2,
UiConfig::GetInstance()->getUiHeight()*0.95 - m_btn_snap->height() );
#endif
QHBoxLayout* hbLayout = new QHBoxLayout();
QSpacerItem* hSpace1 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
QSpacerItem* hSpace2 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hbLayout->addItem(hSpace1);
hbLayout->addWidget(m_btn_snap);
hbLayout->addItem(hSpace2);
QSpacerItem* vSpace1 = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
QVBoxLayout* vbLayout = new QVBoxLayout();
vbLayout->addItem(vSpace1);
vbLayout->addLayout(hbLayout);
//vbLayout->setSpacing(20);
//vbLayout->setMargin(10);
setLayout(vbLayout);
setAutoFillBackground(true);
//setStyleSheet("background-color: transparent;");
#if 0
resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
QPalette pal = palette();
pal.setColor(QPalette::Background, QColor(0x00,0xff,0x00,0x00));
setPalette(pal);
//QPalette palette(this->palette());
//palette.setColor(QPalette::WindowText,Qt::black);
#endif
#if 1
resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText,Qt::white);
//palette.setBrush(QPalette::Window,QBrush(QPixmap(CenterMsgWidget::BG_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
palette.setBrush(QPalette::Window,QBrush(QPixmap(BG_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
setPalette(palette);
#endif
//setWindowOpacity(1);
//setAttribute(Qt::WA_TranslucentBackground, true);
}
void SnapFacePage::reset()
{
//vo显示设置
if(nullptr == m_backstageIf){
return;
}
m_backstageIf->recoUiTypeSwitch(0, 0, UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
}
void SnapFacePage::slotSnapBtnClicked()
{
qDebug() << __PRETTY_FUNCTION__;
if(nullptr == m_backstageIf){
return;
}
#if 0
MsgDialog msgdlg(tr("抓拍人脸中,请稍候..."), parent()->parent());
msgdlg.show();
QCoreApplication::processEvents();//处理qt事件刷新ui
#endif
std::string feature;
std::string savePath("/tmp/test.jpg");
int ret = m_backstageIf->snapFace(feature, savePath);
qDebug() << __PRETTY_FUNCTION__ << "ret=" << ret;
if(ret !=0)
{
InfoDialog(tr("抓拍人脸失败,请重拍!"), parent()->parent()).exec();
}else
{
emit signalSnapFace(feature, savePath);
emit signalReturn();
}
}

View File

@ -0,0 +1,183 @@
#ifndef SETTINGUIFACEMNG_H
#define SETTINGUIFACEMNG_H
#include <QListWidget>
#include "UiTools.h"
#include "UiConfig.h"
class settingUiFaceMng : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
enFaceDb,
enAccessRecord
}enFaceMng;
static int m_pageIndex;
explicit settingUiFaceMng(int pageIndex, QWidget *parent = nullptr);
~settingUiFaceMng();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
public slots:
void slotItemClicked(QListWidgetItem* item);
private:
};
class FaceDbPage : public PersonMsgUiPage
{
Q_OBJECT
public:
static int m_pageIndex;
explicit FaceDbPage(int pageIndex, QWidget *parent = nullptr);
void reset();
void clickBtn_addPerson();
protected:
signals:
void signalShowPage(int, const QString title = "");
void signalPersonInfo(stQueryPersonInfo &personInfo);
protected slots:
void slotTextChanged(const QString& text);
virtual void slotBtnClicked();
virtual void slotSliderReleased();
virtual void slotItemClicked(QListWidgetItem *item);
void slot_freshPage();
private:
void showFaceMsg(int pageIndex);
private:
stQueryPersonInfo m_person[5];
int m_lastPageIndex = 0;
};
class AccessRecordPage : public PersonMsgUiPage
{
Q_OBJECT
public:
static int m_pageIndex;
explicit AccessRecordPage(int pageIndex, QWidget *parent = nullptr);
void reset();
protected:
protected slots:
void slotTextChanged(const QString& text);
virtual void slotBtnClicked();
virtual void slotSliderReleased();
private:
void showAccessRecordMsg(int pageIndex);
};
class RegisterPersonPage : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
typedef enum
{
PERSON_ITEM_PIC = 0,
PERSON_ITEM_NAME,
PERSON_ITEM_DEADLINE_CHOICE,
PERSON_ITEM_DEADLINE,
PERSON_ITEM_JOB_NUM,
PERSON_ITEM_PHONE_NUM,
PERSON_ITEM_ID_CARD,
PERSON_ITEM_IC_CARD,
}PERSON_ITEM_E;
//static int m_pageIndex;
explicit RegisterPersonPage(QWidget *parent = nullptr);
//virtual void reset();
void clearPersonInfo();
void refreshUi();
signals:
void signalShowPage(int, const QString title = "");
void signalReturn();
void signalChangePersonDB();
protected slots:
virtual void slotItemClicked(QListWidgetItem *item);
void slotDeadlineBtnClicked(int id);
void slotSetPersonInfo(stQueryPersonInfo &personInfo);
void slotSnapFace(std::string &feature, std::string &picPath);
void slotIcCardResult(const QString& icCard);
protected:
QListWidget *m_listWidget;
QWidget *m_picWidget;
QLabel *m_picLabel;
QWidget *m_deadlineChoiceWidget;
QButtonGroup *m_deadlineBtnGrp;
QRadioButton *m_durableBtn;
QRadioButton *m_nondurableBtn;
myListWidget *m_nameWidget;
myListWidget *m_deadlineWidget;
myListWidget *m_jobNumWidget;
myListWidget *m_phoneNumWidget;
myListWidget *m_idCardWidget;
myListWidget *m_icCardWidget;
QPushButton *m_bottomBtn;
//bool m_isPicChange = false;
//bool m_isPersonInfoChange = false;
stQueryPersonInfo m_personInfo;
std::string m_snapFeature;
std::string m_snapPicPath;
//dbspace::rwFeatInfo m_featInfo;
//dbspace::rwPersonInfo m_personInfo;
};
class AddPersonPage : public RegisterPersonPage
{
Q_OBJECT
public:
static int m_pageIndex;
explicit AddPersonPage(int pageIndex, QWidget *parent = nullptr);
void reset();
public slots:
virtual void slotItemClicked(QListWidgetItem *item);
void slotAddPerson();
};
class ModifyPersonPage : public RegisterPersonPage
{
Q_OBJECT
public:
static int m_pageIndex;
explicit ModifyPersonPage(int pageIndex, QWidget *parent = nullptr);
void reset();
void savePersonInfo();
public slots:
void slotDelPerson();
};
class SnapFacePage : public WidgetWithBackstageInterface
{
Q_OBJECT
public:
static const QString BG_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static int m_pageIndex;
explicit SnapFacePage(int pageIndex, QWidget *parent = nullptr);
void reset();
signals:
void signalReturn();
void signalSnapFace(std::string &feature, std::string &picPath);
public slots:
void slotSnapBtnClicked();
private:
QPushButton *m_btn_snap;
};
#endif // SETTINGUIFACEMNG_H

View File

@ -0,0 +1,343 @@
#include "settingUiFastCfg.h"
#include "UiConfig.h"
#include <QDebug>
const int NEXT_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {28, 42, 42, 16, 16};
int settingUiFastCfgWireNet::m_pageIndex = 0;
settingUiFastCfgWireNet::settingUiFastCfgWireNet(int pageIndex, QWidget *parent) : MyWidgetWithMainStyleColor(parent)
{
m_pageIndex = pageIndex;
QFont ft;
ft.setPointSize(NEXT_BTN_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
//QLabel* title = new QLabel(tr("有线网络配置"), this);
//title->setFont(ft);
m_wireNet = new settingUiDevMngNetWire(0, this);
m_wireNet->setFixedSize(UiConfig::GetInstance()->getUiWidth(), static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.7));
m_btnNext = new QPushButton(tr("下一步"), this);
m_btnNext->setFixedSize(UiConfig::GetInstance()->getUiWidth() / 3,
UiConfig::GetInstance()->getUiWidth() / 6);
m_btnNext->setFont(ft);
m_btnNext->setStyleSheet("QPushButton {"
"border: 0px;"
"border-radius:10px;"
"background-color:rgb(24, 144, 255);"
"focus{outline: none;}"
"}"
"QPushButton:hover { "
"background-color:rgb(24, 144, 255);"
"}"
"QPushButton:pressed {"
"background-color:rgb(222, 222, 222);"
"}");
connect(m_btnNext, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
QVBoxLayout* bLay = new QVBoxLayout();
//bLay->addWidget(title, 1, Qt::AlignCenter | Qt::AlignTop);
bLay->addWidget(m_wireNet, 1, Qt::AlignCenter | Qt::AlignTop);
bLay->addStretch(1);
bLay->addWidget(m_btnNext, 1, Qt::AlignCenter | Qt::AlignTop);
bLay->addStretch(1);
bLay->setMargin(0);
bLay->setSpacing(0);
setLayout(bLay);
}
void settingUiFastCfgWireNet::setBackstageUiinterface(BackstageInterfaceForUi* interface)
{
m_backstageIf = interface;
m_wireNet->setBackstageUiinterface(interface);
}
void settingUiFastCfgWireNet::reset()
{
m_wireNet->reset();
}
void settingUiFastCfgWireNet::slotBtnClicked()
{
emit signalJumpPage(0); //need page enum
}
int settingUiPark::m_pageIndex = 0;
settingUiPark::settingUiPark(QWidget *parent)
: SettingUiPage(QVector<SettingUiPage::SetOpn>{
SetOpn(tr("设备位置"), "(设备具体安装位置)", myListWidget::enPropertyMoreArrow)
}, parent)
{
}
void settingUiPark::reset()
{
qDebug() << "reset";
for(int i = 0; i < config.size(); i ++)
{
QListWidgetItem* pItem = m_listWidget->item(i);
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(pItem));
if(wdt == nullptr){
return;
}
QString str;
const int iBufSize = 128;
char buf[iBufSize] = {'\0'};
switch(i)
{
case FAST_CFG_DEV_POSI:
{
std::string posiStr;
m_backstageIf->getDevPosi(posiStr);
str = (posiStr.empty() ? tr("(未设置)") : posiStr.c_str());
}
break;
#if 0
case FAST_CFG_PARK_INFO:
{
std::string infoStr;
m_backstageIf->getParkInfo(infoStr);
str = (infoStr.empty() ? tr("(未设置)") : infoStr.c_str());
}
break;
case FAST_CFG_SERVER:
if(0 == m_backstageIf->getServerAddr(buf, iBufSize)){
str = buf;
}
break;
#endif
default:
break;
}
wdt->updateLabel(str);
}
}
void settingUiPark::slotItemClicked(QListWidgetItem* item)
{
const int row = m_listWidget->currentRow();
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
if(wdt == nullptr){
return;
}
switch(row){
//case FAST_CFG_PARK_INFO:
case FAST_CFG_DEV_POSI:
{
bool settingFailed = true;
do{
LineEditInputDialog dlg(config.at(row).m_sOpn, parent()->parent());
if(dlg.exec() == QDialog::Accepted){
const QString strInput = dlg.getRow(0);
do{
#if 0
if(row == FAST_CFG_PARK_INFO){
if(0 == strInput.length()){
InfoDialog(tr("园区信息不能为空"), parent()->parent()).exec();
break;
}
else if(strInput.length() > 32){
InfoDialog(tr("园区信息不能超过32个字符"), parent()->parent()).exec();
break;
}
if(0 == m_backstageIf->setParkInfo(strInput.toStdString())){
wdt->updateLabel(strInput);
settingFailed = false;
}
}
else
#endif
if(row == FAST_CFG_DEV_POSI){
if(strInput.length() > 32){
InfoDialog(tr("设备位置不能超过32个字符"), parent()->parent()).exec();
break;
}
if(0 == m_backstageIf->setDevPosi(strInput.toStdString())){
wdt->updateLabel(strInput.isEmpty() ? tr("(未设置)") : strInput);
settingFailed = false;
}
}
}while(0);
}
else {
settingFailed = false;
}
}while(settingFailed);
}
break;
#if 0
case FAST_CFG_SERVER:
{
bool settingFailed = true;
do{
QList<QString> strs;
if(FAST_CFG_SERVER == row){
strs << tr("服务器地址:") << tr("端口:");
}
LineEditInputDialog dlg(strs, parent()->parent());
if(dlg.exec() == QDialog::Accepted)
{
QString str;
do{
if(FAST_CFG_SERVER == row){
if("" != dlg.getRow(0) && "" != dlg.getRow(1)){
bool isDigi = false;
int valueSet = dlg.getRow(1).toInt(&isDigi);
if( (!isDigi) || (valueSet < 0 || valueSet > 65535)){
break;
}
if(m_backstageIf){
str = dlg.getRow(0) + ":" + dlg.getRow(1);
m_backstageIf->setServerAddr(const_cast<char*>(str.toStdString().c_str()));
wdt->updateLabel(str);
settingFailed = false;
}
}
}
}while(0);
}
else {
settingFailed = false;
}
if(settingFailed)
{
InfoDialog(tr("设置有误,请重新输入!"), parent()->parent()).exec();
}
}while(settingFailed);
}
break;
#endif
default:
break;
}
}
int settingUiFastCfgPark::m_pageIndex = 0;
settingUiFastCfgPark::settingUiFastCfgPark(int pageIndex, QWidget *parent) : MyWidgetWithMainStyleColor(parent)
{
m_pageIndex = pageIndex;
QFont ft;
ft.setPointSize(NEXT_BTN_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_park = new settingUiPark(this);
m_park->setFixedSize(UiConfig::GetInstance()->getUiWidth(), static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.7));
m_btnNext = new QPushButton(tr("下一步"), this);
m_btnNext->setFixedSize(UiConfig::GetInstance()->getUiWidth() / 3,
UiConfig::GetInstance()->getUiWidth() / 6);
m_btnNext->setFont(ft);
m_btnNext->setStyleSheet("QPushButton {"
"border: 0px;"
"border-radius:10px;"
"background-color:rgb(24, 144, 255);"
"focus{outline: none;}"
"}"
"QPushButton:hover { "
"background-color:rgb(24, 144, 255);"
"}"
"QPushButton:pressed {"
"background-color:rgb(222, 222, 222);"
"}");
connect(m_btnNext, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
QVBoxLayout* bLay = new QVBoxLayout();
//bLay->addWidget(title, 1, Qt::AlignCenter | Qt::AlignTop);
bLay->addWidget(m_park, 1, Qt::AlignCenter | Qt::AlignTop);
bLay->addStretch(1);
bLay->addWidget(m_btnNext, 1, Qt::AlignCenter | Qt::AlignTop);
bLay->addStretch(1);
bLay->setMargin(0);
bLay->setSpacing(0);
setLayout(bLay);
}
void settingUiFastCfgPark::setBackstageUiinterface(BackstageInterfaceForUi* interface)
{
m_backstageIf = interface;
m_park->setBackstageUiinterface(interface);
}
void settingUiFastCfgPark::reset()
{
m_park->reset();
}
void settingUiFastCfgPark::slotBtnClicked()
{
emit signalJumpPage(0); //need page enum
}
const int SettingUiQrcode::TIP_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {24, 38, 38, 14, 14};
const QString SettingUiQrcode::BG_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {
":/res/image/qrcode_middle.png",
":/res/image/qrcode_large.png",
":/res/image/qrcode_middle.png",
":/res/image/qrcode_large.png",
":/res/image/qrcode_middle.png"
};
int SettingUiQrcode::m_pageIndex = 0;
SettingUiQrcode::SettingUiQrcode(int pageIndex, QWidget *parent) : WidgetWithBackstageInterface(parent)
{
m_pageIndex = pageIndex;
resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
setAutoFillBackground(true);
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText,Qt::white);
palette.setBrush(QPalette::Window,QBrush(QPixmap(BG_RES_FILE[UiConfig::GetInstance()->getScreenConfigIndex()])));
setPalette(palette);
QLabel* tip = new QLabel(tr("请将配置二维码对准扫码框"), this);
QFont ft;
ft.setPointSize(TIP_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
tip->setFont(ft);
QVBoxLayout* bLay = new QVBoxLayout();
bLay->addWidget(tip, 1, Qt::AlignHCenter);
bLay->addStretch(9);
setLayout(bLay);
m_widget_cMsg = new CenterMsgWidget(this);
m_widget_cMsg->move((UiConfig::GetInstance()->getUiWidth() - CenterMsgWidget::WIDGET_WIDTH[UiConfig::GetInstance()->getScreenConfigIndex()]) / 2,
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.2));
m_widget_cMsg->hide();
}
void SettingUiQrcode::reset()
{
qDebug() << __PRETTY_FUNCTION__;
//vo显示设置
if(nullptr == m_backstageIf){
return;
}
m_backstageIf->recoUiTypeSwitch(0, 0, UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
}
void SettingUiQrcode::slotCenterMsg(const int nPage, const QString& msg)
{
m_widget_cMsg->showMsg(msg, nPage);
if(UiConfig::GetInstance()->isRkDevice()){
update();
}
//qDebug() << "slotCenterMsg:" << msg;
//if(!msg.isEmpty()){
//QTimer::singleShot(10000, this, [this]{qDebug() << "SettingUiQrcode slotQrcodeCfgSuccessed";emit signalExitSettingUi();});
//}
}
void SettingUiQrcode::slotQrcodeFastCfgResult(bool isSuccessed)
{
qDebug() << "slotQrcodeFastCfgResult:" << isSuccessed;
if(isSuccessed){
QTimer::singleShot(10000, this, [this]{qDebug() << "SettingUiQrcode slotQrcodeCfgSuccessed";emit signalExitSettingUi();});
}
}

View File

@ -0,0 +1,91 @@
#ifndef SETTINGUIFASTCFG_H
#define SETTINGUIFASTCFG_H
#include "settingUiDevMng.h"
#include "recoUiRecognize.h"
class settingUiFastCfgWireNet : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
static int m_pageIndex;
explicit settingUiFastCfgWireNet(int pageIndex, QWidget *parent = nullptr);
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
void signalJumpPage(int pageIndex);
public slots:
void slotBtnClicked();
private:
settingUiDevMngNetWire* m_wireNet;
QPushButton* m_btnNext;
};
class settingUiPark : public SettingUiPage
{
Q_OBJECT
public:
enum{
FAST_CFG_DEV_POSI
#if 0
FAST_CFG_PARK_INFO,
FAST_CFG_SERVER
#endif
};
static int m_pageIndex;
explicit settingUiPark(QWidget *parent = nullptr);
void reset();
signals:
public slots:
void slotItemClicked(QListWidgetItem*);
};
class settingUiFastCfgPark : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
static int m_pageIndex;
explicit settingUiFastCfgPark(int pageIndex, QWidget *parent = nullptr);
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
void signalJumpPage(int pageIndex);
public slots:
void slotBtnClicked();
private:
settingUiPark* m_park;
QPushButton* m_btnNext;
};
class SettingUiQrcode : public WidgetWithBackstageInterface
{
Q_OBJECT
public:
static int m_pageIndex;
static const int TIP_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit SettingUiQrcode(int pageIndex, QWidget *parent = nullptr);
void reset();
signals:
void signalExitSettingUi();
public slots:
void slotCenterMsg(const int nPage, const QString& msg);
void slotQrcodeFastCfgResult(bool isSuccessed);
private:
CenterMsgWidget* m_widget_cMsg;
};
#endif // SETTINGUIFASTCFG_H

View File

@ -0,0 +1,120 @@
#include "settingUiInfo.h"
#include <QDebug>
#include "UiConfig.h"
int settingUiInfo::m_pageIndex = 0;
settingUiInfo::settingUiInfo(int pageIndex, QWidget *parent)
: SettingUiPage(QVector<SettingUiPage::SetOpn>{
SetOpn(tr("设备编码"), "FTxxxxxxxxxxxx"),
SetOpn(tr("软件版本"), "FG_B020_V100R001Bxxx"),
SetOpn(tr("硬件配置"), "HWxxxxxxxxxxxxxx"),
SetOpn(tr("MAC地址"), "xx:xx:xx:xx:xx"),
SetOpn(tr("设备IP"), "xxx.xxx.xxx.xxx"),
SetOpn(tr("屏下NFC ID"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
SetOpn(tr("拓展NFC ID"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
SetOpn(tr("总容量GB"), "xx"),
SetOpn(tr("可用容量GB"), "x"),
SetOpn(tr("注册人数"), "xxxxx"),
SetOpn(tr("未上传通行记录"), "xxxxxx")
}, parent)
{
m_pageIndex = pageIndex;
qDebug() << "settingUiInfo()";
}
settingUiInfo::~settingUiInfo()
{
qDebug() << "~settingUiInfo()";
}
void settingUiInfo::setBackstageUiinterface(BackstageInterfaceForUi* interface)
{
m_backstageIf = interface;
reset();
}
void settingUiInfo::reset()
{
if(nullptr == m_backstageIf){
return;
}
for(int i = 0; i < config.size(); i ++)
{
QListWidgetItem* pItem = m_listWidget->item(i);
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(pItem));
if(wdt == nullptr){
return;
}
QString str;
const int iBufSize = 64;
char buf[iBufSize] = {'\0'};
switch(i)
{
case INFO_CHECK_DEV_ID:qDebug() << "INFO_CHECK_DEV_ID";
if(0 == m_backstageIf->getDeviceId(buf, iBufSize)){
str = QString(buf);
}
break;
case INFO_CHECK_SOFT_VERSION:qDebug() << "INFO_CHECK_SOFT_VERSION";
if(0 == m_backstageIf->getAppVersion(buf, iBufSize)){
str = QString(buf);
}
break;
case INFO_CHECK_HARD_VERSION:qDebug() << "INFO_CHECK_HARD_VERSION";
if(0 == m_backstageIf->getHardwareConfig(buf, iBufSize)){
str = QString(buf);
}
break;
case INFO_CHECK_MAC:qDebug() << "INFO_CHECK_MAC";
if(0 == m_backstageIf->getEthMac(buf, iBufSize)){
str = QString(buf);
}
break;
case INFO_CHECK_IP:qDebug() << "INFO_CHECK_IP";
{
int type = 0;
if(0 == m_backstageIf->getIP(buf, iBufSize, type)){
str = QString(buf);
}
}
break;
case INFO_UNDER_SCREEN_NFC_MODULE_ID:qDebug() << "INFO_UNDER_SCREEN_NFC_MODULE_ID";
str = QString::fromStdString(m_backstageIf->getUnderScreenNfcModuleId());
break;
case INFO_EXTEND_NFC_MODULE_ID:qDebug() << "INFO_EXTEND_NFC_MODULE_ID";
str = QString::fromStdString(m_backstageIf->getExtendNfcModuleId());
break;
case INFO_CHECK_SPACE_TOTAL:qDebug() << "INFO_CHECK_SPACE_TOTAL";
{
float free = 0;
int total = 0;
if(0 == m_backstageIf->getStorSpace(total, free)){
str = QString::number(total);
}
}
break;
case INFO_CHECK_SPACE_FREE:qDebug() << "INFO_CHECK_SPACE_FREE";
{
float free = 0;
int total = 0;
if(0 == m_backstageIf->getStorSpace(total, free)){
str.setNum(free, 'f', 1);
}
}
break;
case INFO_CHECK_PERSON_REG:qDebug() << "INFO_CHECK_PERSON_REG";
str = QString::number(m_backstageIf->getRegisterNum());
break;
case INFO_CHECK_NOT_UP_ACC_RED_QTY:qDebug() << "INFO_CHECK_NOT_UP_ACC_RED_QTY";
str = QString::number(m_backstageIf->getAccessRecordNotUpload());
break;
default:
break;
}
wdt->updateLabel(str);
}
}

View File

@ -0,0 +1,42 @@
#ifndef SETTINGUIINFO_H
#define SETTINGUIINFO_H
#include <QListWidget>
#include "UiTools.h"
class settingUiInfo : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
INFO_CHECK_DEV_ID,
INFO_CHECK_SOFT_VERSION,
INFO_CHECK_HARD_VERSION,
INFO_CHECK_MAC,
INFO_CHECK_IP,
INFO_UNDER_SCREEN_NFC_MODULE_ID,
INFO_EXTEND_NFC_MODULE_ID,
INFO_CHECK_SPACE_TOTAL,
INFO_CHECK_SPACE_FREE,
INFO_CHECK_PERSON_REG,
INFO_CHECK_NOT_UP_ACC_RED_QTY
}INFO_CHECK_E;
static int m_pageIndex;
explicit settingUiInfo(int pageIndex, QWidget *parent = nullptr);
~settingUiInfo();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
public slots:
void slotItemClicked(QListWidgetItem* item){Q_UNUSED(item);}
private:
};
#endif // SETTINGUIINFO_H

View File

@ -0,0 +1,296 @@
#include "settingUiRecoSet.h"
#include <QDebug>
#include "UiConfig.h"
int settingUiRecoSet::m_pageIndex = 0;
settingUiRecoSet::settingUiRecoSet(int pageIndex, QWidget *parent)
: SettingUiPage(QVector<SettingUiPage::SetOpn>{
SetOpn(tr("身份核验"), "", myListWidget::enPropertySwitch),
SetOpn(tr("活体检测"), "", static_cast<myListWidget::enProperty>(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1)),
SetOpn(tr("人脸识别阈值"), "xx", static_cast<myListWidget::enProperty>(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1)),
SetOpn(tr("人脸识别自定义阈值0-100"), "xx", static_cast<myListWidget::enProperty>(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1)),
SetOpn(tr("居民二代身份证"), "", static_cast<myListWidget::enProperty>(myListWidget::enPropertySwitch | myListWidget::enPropertyIndent1)),
SetOpn(tr("口罩检测"), "", myListWidget::enPropertySwitch),
SetOpn(tr("未戴口罩禁止通行"), "", static_cast<myListWidget::enProperty>(myListWidget::enPropertySwitch | myListWidget::enPropertyIndent1)),
SetOpn(tr("健康码核验"), "", myListWidget::enPropertySwitch),
SetOpn(tr("允许无人脸核验"), "", static_cast<myListWidget::enProperty>(myListWidget::enPropertySwitch | myListWidget::enPropertyIndent1)),
SetOpn(tr("允许陌生人通行"), "", static_cast<myListWidget::enProperty>(myListWidget::enPropertySwitch | myListWidget::enPropertyIndent1)),
SetOpn(tr("核验通行条件"), "", static_cast<myListWidget::enProperty>(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1))
}, parent)
{
m_pageIndex = pageIndex;
qDebug() << "settingUiRecoSet()";
}
settingUiRecoSet::~settingUiRecoSet()
{
qDebug() << "~settingUiRecoSet()";
}
void settingUiRecoSet::setBackstageUiinterface(BackstageInterfaceForUi* interface)
{
m_backstageIf = interface;
reset();
}
void settingUiRecoSet::reset()
{
if(nullptr == m_backstageIf){
return;
}
for(int i = 0; i < config.size(); i ++)
{
QListWidgetItem* pItem = m_listWidget->item(i);
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(pItem));
if(wdt == nullptr){
return;
}
QString str;
switch(i)
{
case enRecoIdeSw:
case enRecoMaskSw:
case enRecoNoMaskNoPassSw:
case enRecoLiveSw:
case enRecoIDFaceVerify:
case enHealthCodeSw:
case enHealthCodeNoFaceRequiredSw:
case enHealthCodeAllowStrangerSw:
{
bool switch_option = false;
if(enRecoIdeSw == i){
switch_option = m_backstageIf->getIdentificationSw();
}else if(enRecoMaskSw == i){
switch_option = m_backstageIf->getMaskCheckSwitch();
}else if(enRecoNoMaskNoPassSw == i){
switch_option = m_backstageIf->getNoMaskNoPassSwitch();
}else if(enRecoLiveSw == i){
switch_option = m_backstageIf->getLivingBodySw();
}else if(enRecoIDFaceVerify == i){
switch_option = m_backstageIf->getIDFaceVerifySw();
}else if(enHealthCodeSw == i){
switch_option = m_backstageIf->getHealthCodeSw();
}else if(enHealthCodeNoFaceRequiredSw == i){
switch_option = m_backstageIf->getHealthCodeNoFaceRequired();
}else if(enHealthCodeAllowStrangerSw == i){
switch_option = m_backstageIf->getHealthCodeAllowStranger();
}
wdt->updateIcon(switch_option ? ":/res/image/on.png" : ":/res/image/off.png");
}
break;
case enRecoIdeThreCustom:
str = QString::number(m_backstageIf->getCustomSimilarity());
break;
case enRecoIdeThre:
{
enSimilarityTh opt = m_backstageIf->getSimilarityTh();
str = RecoSimThre[static_cast<int>(opt)];
}
break;
// case enRecoLiveThre:
// str = LivingThre[static_cast<int>(m_backstageIf->getLivingBodyTh())];
// break;
default:
break;
}
wdt->updateLabel(str);
}
controlListWidgetItemShow(m_backstageIf->getIdentificationSw(), enRecoLiveSw);
//controlListWidgetItemShow(m_backstageIf->getIdentificationSw(), enRecoLiveThre);
controlListWidgetItemShow(m_backstageIf->getIdentificationSw(), enRecoIdeThre);
controlListWidgetItemShow(m_backstageIf->getIdentificationSw() ? SimilarityThCustom == m_backstageIf->getSimilarityTh() : false, enRecoIdeThreCustom);
controlListWidgetItemShow(m_backstageIf->getIdentificationSw(), enRecoIDFaceVerify);
controlListWidgetItemShow(m_backstageIf->getMaskCheckSwitch(), enRecoNoMaskNoPassSw);
controlListWidgetItemShow(m_backstageIf->getHealthCodeSw(), enHealthCodeNoFaceRequiredSw);
controlListWidgetItemShow(m_backstageIf->getHealthCodeSw(), enHealthCodeAllowStrangerSw);
controlListWidgetItemShow(m_backstageIf->getHealthCodeSw(), enHealthCodePassCfg);
}
void settingUiRecoSet::slotItemClicked(QListWidgetItem* item)
{
int row = m_listWidget->currentRow();
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
if(wdt == nullptr){
return;
}
switch(row){
case enRecoIdeSw:
case enRecoMaskSw:
case enRecoNoMaskNoPassSw:
case enRecoLiveSw:
case enRecoIDFaceVerify:
case enHealthCodeSw:
case enHealthCodeNoFaceRequiredSw:
case enHealthCodeAllowStrangerSw:
{
bool setting_value = false;
if(enRecoIdeSw == row){
setting_value = static_cast<bool>(m_backstageIf->getIdentificationSw());
}
else if(enRecoMaskSw == row){
setting_value = static_cast<bool>(m_backstageIf->getMaskCheckSwitch());
}
else if(enRecoNoMaskNoPassSw == row){
setting_value = static_cast<bool>(m_backstageIf->getNoMaskNoPassSwitch());
}
else if(enRecoLiveSw == row){
setting_value = static_cast<bool>(m_backstageIf->getLivingBodySw());
}
else if(enRecoIDFaceVerify == row){
setting_value = static_cast<bool>(m_backstageIf->getIDFaceVerifySw());
}
else if(enHealthCodeSw == row){
setting_value = m_backstageIf->getHealthCodeSw();
}
else if(enHealthCodeNoFaceRequiredSw == row){
setting_value = m_backstageIf->getHealthCodeNoFaceRequired();
}
else if(enHealthCodeAllowStrangerSw == row){
setting_value = m_backstageIf->getHealthCodeAllowStranger();
}
setting_value = static_cast<bool>(!setting_value);
wdt->updateIcon(setting_value ? ":/res/image/on.png" : ":/res/image/off.png");
if(enRecoIdeSw == row){
m_backstageIf->setIdentificationSw(setting_value);
controlListWidgetItemShow(setting_value, enRecoLiveSw);
//controlListWidgetItemShow(setting_value, enRecoLiveThre);
controlListWidgetItemShow(setting_value, enRecoIdeThre);
controlListWidgetItemShow(setting_value, enRecoIDFaceVerify);
controlListWidgetItemShow(setting_value ? SimilarityThCustom == m_backstageIf->getSimilarityTh() : false, enRecoIdeThreCustom);
}
else if(enRecoMaskSw == row){
m_backstageIf->setMaskCheckSwitch(setting_value);
controlListWidgetItemShow(setting_value, enRecoNoMaskNoPassSw);
}
else if(enRecoNoMaskNoPassSw == row){
m_backstageIf->setNoMaskNoPassSwitch(setting_value);
}
else if(enRecoLiveSw == row){
m_backstageIf->setLivingBodySw(setting_value);
}
else if(enRecoIDFaceVerify == row){
m_backstageIf->setIDFaceVerifySw(setting_value);
}
else if(enHealthCodeSw == row){
m_backstageIf->setHealthCodeSw(setting_value);
controlListWidgetItemShow(setting_value, enHealthCodeNoFaceRequiredSw);
controlListWidgetItemShow(setting_value, enHealthCodeAllowStrangerSw);
controlListWidgetItemShow(setting_value, enHealthCodePassCfg);
if(setting_value){
myListWidget* wdg = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(m_listWidget->item(enRecoIdeSw)));
if(wdg){wdg->updateIcon(":/res/image/on.png");}
wdg = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(m_listWidget->item(enRecoIDFaceVerify)));
if(wdg){wdg->updateIcon(":/res/image/on.png");}
}
}
else if(enHealthCodeNoFaceRequiredSw == row){
m_backstageIf->setHealthCodeNoFaceRequired(setting_value);
}
else if(enHealthCodeAllowStrangerSw == row){
m_backstageIf->setHealthCodeAllowStranger(setting_value);
}
}
break;
case enRecoIdeThreCustom:
{
int currentValue = 10;
int min = 0;
int max = 100;
QString tip("this is a line of prompt text");
#ifndef DEBUG_MODE
if(enRecoIdeThreCustom == row){
currentValue = m_backstageIf->getCustomSimilarity();
min = 0;
max = 100;
tip.clear();
}
#endif
SliderDialog dlg(currentValue, min, max, tip, parent()->parent());
if(dlg.exec() == QDialog::Accepted)
{
QString str("valueSet");
int valueSet = dlg.getValueSet();
#ifndef DEBUG_MODE
if(enRecoIdeThreCustom == row){
m_backstageIf->setCustomSimilarity(valueSet);
str = QString::number(valueSet);
}
#endif
wdt->updateLabel(str);
}
}
break;
case enRecoIdeThre:
{
int choosed = 0;
QVector<QString>& options = const_cast<QVector<QString>&>(RecoSimThre);
if(enRecoIdeThre == row){
choosed = static_cast<int>(m_backstageIf->getSimilarityTh());
}
#if 0
else if(enRecoLiveThre == row){
options = LivingThre;
choosed = static_cast<int>(m_backstageIf->getLivingBodyTh());
}
#endif
RadioBtnChooseDialog dlg(options, parent()->parent(), choosed);
if(dlg.exec() == QDialog::Accepted){
int newChoosed = dlg.getChoosedIndex();
if(newChoosed != choosed){
if(enRecoIdeThre == row){
m_backstageIf->setSimilarityTh(static_cast<enSimilarityTh>(newChoosed));
if(SimilarityThCustom == static_cast<enSimilarityTh>(newChoosed)){
//重新获取当前的阈值显示到条目上,因为当前是从别的档位切换过来的,阈值已经改变,设计的问题:只保存一个当前阈值,没有单独保存自定义的阈值
QListWidgetItem* pItem = m_listWidget->item(enRecoIdeThreCustom);
myListWidget* swWidget = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(pItem));
if(swWidget != nullptr){
swWidget->updateLabel(QString::number(m_backstageIf->getCustomSimilarity()));
}
controlListWidgetItemShow(true, enRecoIdeThreCustom);
}
else{
controlListWidgetItemShow(false, enRecoIdeThreCustom);
}
}
#if 0
else if(enRecoLiveThre == row){
m_backstageIf->setLivingBodyTh(static_cast<enLivingBodyTh>(newChoosed));
}
#endif
wdt->updateLabel(options[newChoosed]);
}
}
}
break;
case enHealthCodePassCfg:
{
const QStringList titles{"健康码色", "核酸检测", "行程信息", "疫苗"};
const QVector<QStringList> sels{{"无限制", "仅绿码可通行", "绿码、黄码可通行", "绿码、黄码、红码可通行"},
{"无限制", "限24小时内阴性", "限48小时内阴性", "限72小时内阴性", "限阴性"},
{"无限制", "限14天内未到过中高风险地区"},
{"无限制", "限至少打了第1针", "限至少打了第2针", "限至少打了第3针"} };
ComSelectDialog dlg(titles, sels, parent()->parent());
int codeColorCfg;
int c19tCfg;
int tripCfg;
int abtCfg;
m_backstageIf->getHealthCodePassCfg(codeColorCfg, c19tCfg, tripCfg, abtCfg);
dlg.setRow(0, codeColorCfg);
dlg.setRow(1, c19tCfg);
dlg.setRow(2, tripCfg);
dlg.setRow(3, abtCfg);
if(dlg.exec() == QDialog::Accepted){
m_backstageIf->setHealthCodePassCfg(dlg.getRow(0), dlg.getRow(1), dlg.getRow(2), dlg.getRow(3));
}
}
break;
default:
break;
}
}

View File

@ -0,0 +1,56 @@
#ifndef SETTINGUIRECOSET_H
#define SETTINGUIRECOSET_H
#include <QListWidget>
#include "UiTools.h"
class settingUiRecoSet : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
enRecoIdeSw,
enRecoLiveSw,
//enRecoLiveThre,
enRecoIdeThre,
enRecoIdeThreCustom,
enRecoIDFaceVerify,
enRecoMaskSw,
enRecoNoMaskNoPassSw,
enHealthCodeSw,
enHealthCodeNoFaceRequiredSw,
enHealthCodeAllowStrangerSw,
enHealthCodePassCfg,
}enRecoSet;
static int m_pageIndex;
explicit settingUiRecoSet(int pageIndex, QWidget *parent = nullptr);
~settingUiRecoSet();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void reset();
signals:
protected slots:
void slotItemClicked(QListWidgetItem* item);
private:
const QVector<QString> RecoSimThre = {
tr("宽松"),
tr("一般"),
tr("适中"),
tr("严格"),
tr("极严格"),
tr("自定义")
};
const QVector<QString> LivingThre = {
tr("宽松"),
tr("一般"),
tr("严格")
};
};
#endif // SETTINGUIRECOSET_H

View File

@ -0,0 +1,308 @@
#include <QDebug>
#include "settingUiSysMng.h"
#include "UiConfig.h"
int settingUiSysMng::m_pageIndex = 0;
settingUiSysMng::settingUiSysMng(int pageIndex, QWidget *parent)
: SettingUiPage(QVector<SettingUiPage::SetOpn>{
SetOpn(tr("设备语言"), "xxxxx", myListWidget::enPropertyMoreArrow),
SetOpn(tr("数据加密"), "", myListWidget::enPropertySwitch),
SetOpn(tr("自动重启"), "", myListWidget::enPropertySwitch),
SetOpn(tr("自动重启时间"), "xx:xx", static_cast<myListWidget::enProperty>(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1)),
SetOpn(tr("自动重启间隔(天)"), "xx", static_cast<myListWidget::enProperty>(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1)),
SetOpn(tr("手动重启"), "", myListWidget::enPropertyMoreArrow),
SetOpn(tr("服务器"), "xxxxxxxxxxxx:xxxx", myListWidget::enPropertyMoreArrow),
SetOpn(tr("数据清空"), "", myListWidget::enPropertyMoreArrow),
SetOpn(tr("恢复出厂设置"), "", static_cast<myListWidget::enProperty>(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyRedWord))
}, parent)
{
m_pageIndex = pageIndex;
qDebug() << "settingUiSysMng()";
}
settingUiSysMng::~settingUiSysMng()
{
qDebug() << "~settingUiSysMng()";
}
void settingUiSysMng::setBackstageUiinterface(BackstageInterfaceForUi *interface)
{
m_backstageIf = interface;
reset();
}
void settingUiSysMng::reset()
{
if(nullptr == m_backstageIf){
return;
}
for(int i = 0; i < config.size(); i ++)
{
QListWidgetItem* pItem = m_listWidget->item(i);
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(pItem));
if(wdt == nullptr){
return;
}
QString str;
const int iBufSize = 64;
char buf[iBufSize] = {'\0'};
switch(i)
{
case SYS_MNG_LANGUAGE:
{
int lang = static_cast<int>(m_backstageIf->getLanguage());
if(lang >= 0 && lang < Language.size()){
str = Language[lang];
}
}
break;
case SYS_MNG_AUTO_REBOOT:
{
bool switch_option = false;
if(SYS_MNG_AUTO_REBOOT == i){
switch_option = m_backstageIf->getAutoRebootSw();
}
wdt->updateIcon(switch_option ? ":/res/image/on.png" : ":/res/image/off.png");
}
break;
case SYS_MNG_AUTO_REBOOT_TIME:
if(0 == m_backstageIf->getAutoRebootTime(buf, iBufSize)){
str = QString(buf);
}
break;
case SYS_MNG_AUTO_REBOOT_INTERVAL:
str = QString::number(m_backstageIf->getAutoRebootInterval());
break;
case SYS_MNG_SERVER_ADDR:
if(0 == m_backstageIf->getServerAddr(buf, iBufSize)){
str = QString(buf);
}
break;
case SYS_MNG_DATA_ENCRYPT:qDebug() << "SYS_MNG_DATA_ENCRYPT";
{
bool switch_option = m_backstageIf->getDataEncryptSw();
wdt->updateIcon(switch_option ? ":/res/image/on.png" : ":/res/image/off.png");
}
break;
default:
break;
}
wdt->updateLabel(str);
}
controlListWidgetItemShow(m_backstageIf->getAutoRebootSw(), SYS_MNG_AUTO_REBOOT_TIME);
controlListWidgetItemShow(m_backstageIf->getAutoRebootSw(), SYS_MNG_AUTO_REBOOT_INTERVAL);
controlListWidgetItemShow(!UiConfig::GetInstance()->isFuncNotSupport(FuncDataEncrypt), SYS_MNG_DATA_ENCRYPT);
}
void settingUiSysMng::slotItemClicked(QListWidgetItem* item)
{
if(nullptr == m_backstageIf){
#ifndef DEBUG_MODE
return;
#endif
}
int row = m_listWidget->currentRow();
myListWidget* wdt = dynamic_cast<myListWidget*>(m_listWidget->itemWidget(item));
if(wdt == nullptr){
return;
}
switch(row){
case SYS_MNG_LANGUAGE:
{
int choosed = 0;
const QVector<QString>& opts = Language;
if(SYS_MNG_LANGUAGE == row){
#ifndef DEBUG_MODE
choosed = static_cast<int>(m_backstageIf->getLanguage());
#endif
}
RadioBtnChooseDialog dlg(opts, parent()->parent(), choosed, &LanguageSup, "");
if(QDialog::Accepted == dlg.exec())
{
int newChoosed = dlg.getChoosedIndex();
qDebug() << "newChoosed:" << newChoosed;
if(newChoosed != choosed){
QuestionDialog queDlg(tr("您需要重新启动设备以设置并切换语言"), parent()->parent(), tr("重新启动"));
if(QDialog::Accepted == queDlg.exec()){
#ifndef DEBUG_MODE
m_backstageIf->setLanguage(newChoosed);
PureColorPage* black = new PureColorPage(0);
black->show();
QTimer::singleShot(1000, this, SLOT(slotSysReboot()));
//m_backstageIf->devReboot();
#endif
wdt->updateLabel(opts[newChoosed]);
}
}
}
}
break;
case SYS_MNG_DATA_ENCRYPT:
{
bool setting_value = !(m_backstageIf->getDataEncryptSw());
QuestionDialog queDlg(setting_value ? tr("您确定要开启数据加密吗?若确定设备将重启!") : tr("您确定要关闭数据加密吗?若确定设备将重启!"), parent()->parent());
if(QDialog::Accepted == queDlg.exec()){
wdt->updateIcon(setting_value ? ":/res/image/on.png" : ":/res/image/off.png");
m_backstageIf->setDataEncryptSw(setting_value);
QTimer::singleShot(1000, this, SLOT(slotSysReboot()));
}
}
break;
case SYS_MNG_AUTO_REBOOT:
{
bool setting_value = false;
#ifndef DEBUG_MODE
if(SYS_MNG_AUTO_REBOOT == row){
setting_value = static_cast<bool>(m_backstageIf->getAutoRebootSw());
}
#endif
setting_value = static_cast<bool>(!setting_value);
wdt->updateIcon(setting_value ? ":/res/image/on.png" : ":/res/image/off.png");
#ifndef DEBUG_MODE
if(SYS_MNG_AUTO_REBOOT == row){
m_backstageIf->setAutoRebootSw(setting_value);
controlListWidgetItemShow(setting_value, SYS_MNG_AUTO_REBOOT_TIME);
controlListWidgetItemShow(setting_value, SYS_MNG_AUTO_REBOOT_INTERVAL);
}
#endif
}
break;
case SYS_MNG_AUTO_REBOOT_TIME:
{
const int iBufSize = 64;
char buf[iBufSize] = {'\0'};
if(0 == m_backstageIf->getAutoRebootTime(buf, iBufSize)){
QDateTime dateTime(QDateTime::currentDateTime());
dateTime.setTime(QTime().fromString(QString(buf), "hh:mm"));
DateTimeDialog timeDlg(dateTime, parent()->parent(), false);
if(timeDlg.exec() == QDialog::Accepted){
m_backstageIf->setAutoRebootTime(timeDlg.getValueSet().toString("hh:mm").toStdString().c_str());
wdt->updateLabel(timeDlg.getValueSet().toString("hh:mm"));
}
}
}
break;
case SYS_MNG_AUTO_REBOOT_INTERVAL:
{
int currentValue = 10;
int min = 0;
int max = 100;
QString tip("this is a line of prompt text");
#ifndef DEBUG_MODE
if(SYS_MNG_AUTO_REBOOT_INTERVAL == row){
currentValue = m_backstageIf->getAutoRebootInterval();
min = 1;
max = 100;
tip.clear();
}
#endif
SliderDialog dlg(currentValue, min, max, tip, parent()->parent());
if(dlg.exec() == QDialog::Accepted)
{
QString str("valueSet");
int valueSet = dlg.getValueSet();
#ifndef DEBUG_MODE
if(SYS_MNG_AUTO_REBOOT_INTERVAL == row){
m_backstageIf->setAutoRebootInterval(valueSet);
str = QString::number(valueSet);
}
#endif
wdt->updateLabel(str);
}
}
break;
case SYS_MNG_SERVER_ADDR:
{
bool settingFailed = true;
do{
QStringList strs;
if(SYS_MNG_SERVER_ADDR == row){
strs << tr("服务器地址:") << tr("端口:");
}
LineEditInputDialog dlg(strs, parent()->parent());
if(dlg.exec() == QDialog::Accepted)
{
QString str;
do{
if(SYS_MNG_SERVER_ADDR == row){
if("" != dlg.getRow(0) && "" != dlg.getRow(1)){
bool isDigi = false;
int valueSet = dlg.getRow(1).toInt(&isDigi);
if( (!isDigi) || (valueSet < 0 || valueSet > 65535)){
break;
}
if(m_backstageIf){
str = dlg.getRow(0) + ":" + dlg.getRow(1);
m_backstageIf->setServerAddr(const_cast<char*>(str.toStdString().c_str()));
wdt->updateLabel(str);
settingFailed = false;
}
}
}
}while(0);
}
else {
settingFailed = false;
}
if(settingFailed)
{
InfoDialog(tr("设置有误,请重新输入!"), parent()->parent()).exec();
}
}while(settingFailed);
}
break;
case SYS_MNG_MAN_REBOOT:
case SYS_MNG_CLEAR_DATA:
case SYS_MNG_RESTORE:
{
QString que;
QString btnText;
if(SYS_MNG_MAN_REBOOT == row){
que = tr("您确定重新启动FaceTick吗");
btnText = tr("重新启动");
}
else if(SYS_MNG_CLEAR_DATA == row){
que = tr("您确定清空数据吗?");
btnText = tr("清空数据");
}
else if(SYS_MNG_RESTORE == row){
que = tr("您确定恢复出厂设置吗?");
btnText = tr("恢复");
}
QuestionDialog dlg(que, parent()->parent(), btnText);
if(QDialog::Accepted == dlg.exec()){
#ifndef DEBUG_MODE
if(SYS_MNG_MAN_REBOOT == row){
PureColorPage* black = new PureColorPage(0);
black->show();
QTimer::singleShot(1000, this, SLOT(slotSysReboot()));
//m_backstageIf->devReboot();
}
else if(SYS_MNG_CLEAR_DATA == row){
m_backstageIf->cleanData();
}
else if(SYS_MNG_RESTORE == row){
m_backstageIf->recoveryFactorySetting();
//create a black page before sys reboot
PureColorPage* black = new PureColorPage(0);
black->show();
QTimer::singleShot(1000, this, SLOT(slotSysReboot()));
}
#endif
}
}
break;
default:
break;
}
}
void settingUiSysMng::slotSysReboot()
{
m_backstageIf->devReboot();
}

View File

@ -0,0 +1,55 @@
#ifndef SETTINGUISYSMNG_H
#define SETTINGUISYSMNG_H
#include <QListWidget>
#include "UiTools.h"
#include "UiConfig.h"
class settingUiSysMng : public SettingUiPage
{
Q_OBJECT
public:
typedef enum
{
SYS_MNG_LANGUAGE,
SYS_MNG_DATA_ENCRYPT,
SYS_MNG_AUTO_REBOOT,
SYS_MNG_AUTO_REBOOT_TIME,
SYS_MNG_AUTO_REBOOT_INTERVAL,
SYS_MNG_MAN_REBOOT,
SYS_MNG_SERVER_ADDR,
SYS_MNG_CLEAR_DATA,
SYS_MNG_RESTORE
}SYS_MNG_E;
static int m_pageIndex;
explicit settingUiSysMng(int pageIndex, QWidget *parent = nullptr);
~settingUiSysMng();
void setBackstageUiinterface(BackstageInterfaceForUi *interface);
void reset();
signals:
public slots:
void slotItemClicked(QListWidgetItem*);
void slotSysReboot();
private:
//简 繁 英 日 韩 西班牙 泰 葡萄牙 意大利 希伯来 法 德 土耳其 匈牙利
const QVector<QString> Language{"简体中文", "繁體中文", "English", "日本語", "한국어.",
"Español", "ภาษาไทย", "Português", "Italiano", "היברית",
"Français", "Deutsch", "Türkçe", "Magyar"};
#ifdef __HIMIX200__
const QVector<bool> LanguageSup = {true, true, true, true, true,
true, true, true, true, true,
true, true, true, true};
#else
const QVector<bool> LanguageSup = {true, true, true, true, true,
false, false, false, true, false,
false, false, false, false};
#endif
};
#endif // SETTINGUISYSMNG_H

View File

@ -0,0 +1,364 @@
#include "SetupUi.h"
#include "UiConfig.h"
#include <QDebug>
#include <QTextEdit>
#include <QScrollBar>
#include <QScroller>
static const int FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {24, 38, 38, 14, 14};
SetupUiProtoDoc::SetupUiProtoDoc(QWidget *parent) : MyWidgetWithMainStyleColor(parent)
{
QLabel* doc = new QLabel(this);
doc->setWordWrap(true);
doc->setText(tr("这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档"
"这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档"
"这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档"
"这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档"
"这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档"
"这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档"
"这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档这是协议文档"));
QVBoxLayout* vlay = new QVBoxLayout();
vlay->addWidget(doc);
setLayout(vlay);
}
SetupUiPrivacyDoc::SetupUiPrivacyDoc(QWidget *parent) : MyWidgetWithMainStyleColor(parent)
{
#if 0
QTextEdit* doc = new QTextEdit(this);
doc->setReadOnly(true);
doc->verticalScrollBar()->hide();
// QScroller::grabGesture(doc, QScroller::LeftMouseButtonGesture);
//doc->setVerticalScrollMode(QListWidget::ScrollPerPixel);
//doc->setWordWrap(true);
#else
QLabel* doc = new QLabel(this);
doc->setWordWrap(true);
#endif
doc->setText(tr("这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档"
"这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档"
"这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档"
"这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档"
"这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档这是隐私文档"));
QVBoxLayout* vlay = new QVBoxLayout();
vlay->addWidget(doc);
setLayout(vlay);
}
const int SetupUiConfig::JUMP_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {17, 27, 27, 10, 10};
SetupUiConfig::SetupUiConfig(QWidget *parent) : MyWidgetWithMainStyleColor(parent)
{
QFont ft;
ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
QPalette palette;
palette.setColor(QPalette::ButtonText,QColor(15, 116, 248, 0xFF));
QLabel* label0 = new QLabel(tr("配置方式"), this);
label0->setFont(ft);
const QString btnStyle{"QPushButton {"
"border: 0px;"
"border-radius:10px;"
"background-color:rgb(24, 144, 255);"
"focus{outline: none;}"
"}"
"QPushButton:hover { "
"background-color:rgb(24, 144, 255);"
"}"
"QPushButton:pressed {"
"background-color:rgb(222, 222, 222);"
"}"};
m_btnQrcode = new QPushButton(tr("二维码配置"), this);
//m_btnQrcode->setIcon(QIcon(":/res/image/setup_qrcode_large.png"));
//m_btnQrcode->setToolButtonStyle(Qt::Qt::ToolButtonTextBesideIcon);
m_btnQrcode->setFixedSize(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.75),
static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.37));
m_btnQrcode->setFocusPolicy(Qt::NoFocus);
m_btnQrcode->setFont(ft);
m_btnQrcode->setStyleSheet(btnStyle);
connect(m_btnQrcode, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
m_btnManual = new QPushButton(tr("手动配置"), this);
//m_btnManual->setIcon(QIcon(":/res/image/setup_manual_large.png"));
m_btnManual->setFixedSize(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.75),
static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.37));
m_btnManual->setFocusPolicy(Qt::NoFocus);
m_btnManual->setFont(ft);
m_btnManual->setStyleSheet(btnStyle);
connect(m_btnManual, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
m_btnSkip = new QPushButton(tr("跳过"), this);
m_btnSkip->setFocusPolicy(Qt::NoFocus);
ft.setPointSize(JUMP_BTN_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_btnSkip->setFont(ft);
m_btnSkip->setFlat(true);
m_btnSkip->setStyleSheet("border: 0px");
//m_btnSkip->setFocusPolicy(Qt::NoFocus);
connect(m_btnSkip, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
QVBoxLayout* bLay = new QVBoxLayout();
bLay->addWidget(label0, 1, Qt::AlignCenter | Qt::AlignTop);
bLay->addWidget(m_btnQrcode, 1, Qt::AlignCenter | Qt::AlignTop);
bLay->addWidget(m_btnManual, 80, Qt::AlignCenter | Qt::AlignTop);
bLay->addWidget(m_btnSkip, 1, Qt::AlignRight | Qt::AlignBottom);
bLay->setSpacing(UiConfig::GetInstance()->getUiHeight() / 30);
bLay->setContentsMargins(UiConfig::GetInstance()->getUiWidth() / 20,
UiConfig::GetInstance()->getUiHeight() / 20,
UiConfig::GetInstance()->getUiWidth() / 20,
UiConfig::GetInstance()->getUiHeight() / 10);
setLayout(bLay);
}
void SetupUiConfig::slotBtnClicked()
{
const QObject* btn = sender();
if(btn == m_btnQrcode){
emit signalJumpPage(0); //need page enum
}
else if(btn == m_btnManual){
emit signalJumpPage(1);
}
else if(btn == m_btnSkip){
emit signalSetupDone();
}
}
SetupUiStart::SetupUiStart(QWidget *parent) : MyWidgetWithMainStyleColor(parent)
{
QFont ft;
ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
QPalette palette;
palette.setColor(QPalette::ButtonText,QColor(15, 116, 248, 0xFF));
QLabel* label0 = new QLabel(tr("请仔细阅读以下内容"), this);
label0->setFont(ft);
m_btnProtocol = new QPushButton(tr("《XXXX协议》"), this);
m_btnProtocol->setPalette(palette);
m_btnProtocol->setFlat(true);
m_btnProtocol->setFont(ft);
m_btnProtocol->setFocusPolicy(Qt::NoFocus);
m_btnProtocol->setStyleSheet("border: 0px");
connect(m_btnProtocol, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
m_btnPrivacy = new QPushButton(tr("《XX隐私声明》"), this);
m_btnPrivacy->setPalette(palette);
m_btnPrivacy->setFlat(true);
m_btnPrivacy->setFont(ft);
m_btnPrivacy->setFocusPolicy(Qt::NoFocus);
m_btnPrivacy->setStyleSheet("border: 0px");
connect(m_btnPrivacy, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
m_rbAgree = new QRadioButton(tr("我已阅读并同意以上协议"), this);
m_rbAgree->setFocusPolicy(Qt::NoFocus);
m_rbAgree->setStyleSheet("QRadioButton::indicator:unchecked{image: url(:/res/image/select_1.png);}"
"QRadioButton::indicator:checked{image: url(:/res/image/select_2.png);}");
connect(m_rbAgree, SIGNAL(pressed()), this, SLOT(slotRadioButtonPressed()));
m_btnStart = new QPushButton(tr("开始使用"), this);
m_btnStart->setFixedSize(UiConfig::GetInstance()->getUiWidth() / 3,
UiConfig::GetInstance()->getUiWidth() / 6);
m_btnStart->setFont(ft);
m_btnStart->setFocusPolicy(Qt::NoFocus);
m_btnStart->setEnabled(false);
m_btnStart->setStyleSheet("QPushButton {"
"border: 0px;"
"border-radius:10px;"
"background-color:rgb(24, 144, 255);"
"focus{outline: none;}"
"}"
"QPushButton:hover { "
"background-color:rgb(24, 144, 255);"
"}"
"QPushButton:pressed {"
"background-color:rgb(222, 222, 222);"
"}");
connect(m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
QVBoxLayout* bLay = new QVBoxLayout();
bLay->addWidget(label0, 1, Qt::AlignCenter | Qt::AlignTop);
bLay->addWidget(m_btnProtocol, 1, Qt::AlignCenter | Qt::AlignTop);
bLay->addWidget(m_btnPrivacy, 80, Qt::AlignCenter | Qt::AlignTop);
bLay->addWidget(m_rbAgree, 1, Qt::AlignCenter | Qt::AlignBottom);
bLay->addWidget(m_btnStart, 1, Qt::AlignCenter | Qt::AlignBottom);
bLay->setSpacing(UiConfig::GetInstance()->getUiHeight() / 30);
bLay->setContentsMargins(UiConfig::GetInstance()->getUiWidth() / 20,
UiConfig::GetInstance()->getUiHeight() / 20,
UiConfig::GetInstance()->getUiWidth() / 20,
UiConfig::GetInstance()->getUiHeight() / 10);
setLayout(bLay);
}
void SetupUiStart::slotRadioButtonPressed()
{
m_btnStart->setEnabled(!m_rbAgree->isChecked());
}
void SetupUiStart::slotBtnClicked()
{
const QObject* btn = sender();
if(btn == m_btnProtocol){
emit signalJumpPage(0); //need page enum
}
else if(btn == m_btnPrivacy){
emit signalJumpPage(1);
}
else if(btn == m_btnStart){
emit signalJumpPage(2);
m_rbAgree->setChecked(false);
m_btnStart->setEnabled(false);
}
}
SetupUiTop::SetupUiTop(QWidget *parent) : MyWidgetWithMainStyleColor(parent)
{
m_btnBack = new QPushButton(this);
setButtonBackImage(m_btnBack, ":res/image/ProjectSet_return.png", 37, 61);
//m_btnBack->setFixedWidth(UiConfig::GetInstance()->getUiWidth() / 10);
m_btnBack->setFocusPolicy(Qt::NoFocus);
m_btnBack->hide();
connect(m_btnBack, SIGNAL(clicked()), this, SIGNAL(signalReturnBtnClicked()));
QHBoxLayout* hLay = new QHBoxLayout();
hLay->addWidget(m_btnBack, 1, Qt::AlignLeft);
hLay->setContentsMargins(UiConfig::GetInstance()->getUiWidth() / 15,
UiConfig::GetInstance()->getUiHeight() / 40, 0,
UiConfig::GetInstance()->getUiHeight() / 80);
setLayout(hLay);
}
void SetupUiTop::hideBackBtn(bool hide)
{
if(hide){
m_btnBack->hide();
}
else{
m_btnBack->show();
}
}
SetupUi::SetupUi(QWidget *parent) : WidgetWithBackstageInterface(parent)
{
QPalette pal = palette();
pal.setColor(QPalette::Background, Qt::transparent);
setPalette(pal);
m_topbar = new SetupUiTop(this);
m_topbar->setAttribute(Qt::WA_TranslucentBackground);
m_topbar->setFixedHeight(UiConfig::GetInstance()->getUiHeight() / 12);
connect(m_topbar, SIGNAL(signalReturnBtnClicked()), this, SLOT(slotBtnClicked()));
QFont ft;
ft.setPointSize(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()]);
m_stackPages = new QStackedWidget(this);
m_pageStart = new SetupUiStart(this);
connect(m_pageStart, SIGNAL(signalJumpPage(int)), this, SLOT(slotJumpPage(int)));
m_stackPages->addWidget(m_pageStart);
m_pageProt = new SetupUiProtoDoc(this);
m_stackPages->addWidget(m_pageProt);
m_pagePriv= new SetupUiPrivacyDoc(this);
m_stackPages->addWidget(m_pagePriv);
m_pageConfig = new SetupUiConfig(this);
connect(m_pageConfig, SIGNAL(signalJumpPage(int)), this, SLOT(slotJumpPage(int)));
connect(m_pageConfig, SIGNAL(signalSetupDone()), this, SLOT(slotSetupDone()));
m_stackPages->addWidget(m_pageConfig);
m_pageQrcode = new SettingUiQrcode(0, this);
m_stackPages->addWidget(m_pageQrcode);
connect(parent, SIGNAL(signalCenterMsg(const int, const QString&)), m_pageQrcode, SLOT(slotCenterMsg(const int, const QString&)));
connect(parent, SIGNAL(signalQrcodeFastCfgResult(bool)), m_pageQrcode, SLOT(slotQrcodeFastCfgResult(bool)));
connect(m_pageQrcode, SIGNAL(signalExitSettingUi()), this, SLOT(slotSetupDone()));
m_pageManualNet = new settingUiFastCfgWireNet(0, this);
connect(m_pageManualNet, SIGNAL(signalJumpPage(int)), this, SLOT(slotJumpPage(int)));
m_stackPages->addWidget(m_pageManualNet);
m_pageManualPark = new settingUiFastCfgPark(0, this);
#if 0
connect(m_pageManualPark, SIGNAL(signalSetupDone()), this, SLOT(slotSetupDone()));
#else
connect(m_pageManualPark, SIGNAL(signalJumpPage(int)), this, SLOT(slotJumpPage(int)));
#endif
m_stackPages->addWidget(m_pageManualPark);
QVBoxLayout* bLay = new QVBoxLayout();
bLay->addWidget(m_topbar);
bLay->addWidget(m_stackPages);
bLay->setSpacing(0);
bLay->setMargin(0);
setLayout(bLay);
//hide protocol page until doc done
m_stackPages->setCurrentIndex(3);
//hide protocol page until doc done end
}
void SetupUi::setBackstageUiinterface(BackstageInterfaceForUi* interface)
{
m_backstageIf = interface;
m_pageStart->setBackstageUiinterface(interface);
m_pageQrcode->setBackstageUiinterface(interface);
m_pageManualNet->setBackstageUiinterface(interface);
m_pageManualPark->setBackstageUiinterface(interface);
}
void SetupUi::slotSetupDone()
{
m_backstageIf->setSetupAlreadyFlag();
emit signalSetupDone();
UiConfig::GetInstance()->setFastCfgStatus(false);
}
void SetupUi::slotBtnClicked()
{
const QObject* btn = sender();
if(m_pagePath.size()){
m_stackPages->setCurrentIndex(m_pagePath.pop());
}
//hide protocol page until doc done
if(3 == m_stackPages->currentIndex()){
m_topbar->hideBackBtn(true);
}
//hide protocol page until doc done end
}
void SetupUi::slotJumpPage(int pageIndex)
{
m_pagePath.push(m_stackPages->currentIndex());
const QObject* page = sender();
if(page == m_pageStart){
m_stackPages->setCurrentIndex(pageIndex + 1);//1:pageIndexOffset for this page
}
else if(page == m_pageConfig){
m_stackPages->setCurrentIndex(pageIndex + 4);//4:pageIndexOffset for this page
qDebug() << "page index:" << pageIndex;
if(pageIndex == 0){ //qrcode config
UiConfig::GetInstance()->setFastCfgStatus(true);
}
else if(pageIndex == 1){//manual cfg, need enum
m_pageManualNet->reset();
}
}
else if(page == m_pageManualNet){
m_stackPages->setCurrentIndex(pageIndex + 6);//6:pageIndexOffset for this page
m_pageManualPark->reset();
}
else if(page == m_pageManualPark){
m_stackPages->setCurrentIndex(4);//to qrcode page, need enum
UiConfig::GetInstance()->setFastCfgStatus(true);
}
m_topbar->hideBackBtn(false);
}

109
Linguist/setupUi/SetupUi.h Normal file
View File

@ -0,0 +1,109 @@
#ifndef SETUPUI_H
#define SETUPUI_H
#include "UiTools.h"
#include <QStack>
#include <QRadioButton>
#include "settingUiFastCfg.h"
class SetupUiProtoDoc : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
explicit SetupUiProtoDoc(QWidget *parent = nullptr);
};
class SetupUiPrivacyDoc : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
explicit SetupUiPrivacyDoc(QWidget *parent = nullptr);
};
class SetupUiStart : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
explicit SetupUiStart(QWidget *parent = nullptr);
signals:
void signalJumpPage(int pageIndex);
public slots:
void slotRadioButtonPressed();
void slotBtnClicked();
private:
QPushButton* m_btnProtocol;
QPushButton* m_btnPrivacy;
QRadioButton* m_rbAgree;
QPushButton* m_btnStart;
};
class SetupUiConfig : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
static const int JUMP_BTN_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit SetupUiConfig(QWidget *parent = nullptr);
signals:
void signalSetupDone();
void signalJumpPage(int pageIndex);
public slots:
void slotBtnClicked();
private:
QPushButton* m_btnQrcode;
QPushButton* m_btnManual;
QPushButton* m_btnSkip;
};
class SetupUiTop : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
explicit SetupUiTop(QWidget *parent = nullptr);
void hideBackBtn(bool hide);
signals:
void signalReturnBtnClicked();
public slots:
private:
QPushButton* m_btnBack;
};
class SetupUi : public WidgetWithBackstageInterface
{
Q_OBJECT
public:
explicit SetupUi(QWidget *parent = nullptr);
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
signals:
void signalSetupDone();
public slots:
void slotBtnClicked();
void slotSetupDone();
void slotJumpPage(int pageIndex);
private:
SetupUiTop* m_topbar;
QStackedWidget* m_stackPages;
QStack<int> m_pagePath;
SetupUiStart* m_pageStart;
SetupUiProtoDoc* m_pageProt;
SetupUiPrivacyDoc* m_pagePriv;
SetupUiConfig* m_pageConfig;
SettingUiQrcode* m_pageQrcode;
settingUiFastCfgWireNet* m_pageManualNet;
settingUiFastCfgPark* m_pageManualPark;
};
#endif // SETUPUI_H

View File

@ -0,0 +1,28 @@
#ifndef __ASYNCEVENT_H__
#define __ASYNCEVENT_H__
#include "rw_zlog.h"
#include <QCoreApplication>
#include <QEvent>
#include <functional>
class AsyncEvent : public QEvent {
public:
using Functor = std::function<void()>;
AsyncEvent(Functor &&functor)
: QEvent(static_cast<QEvent::Type>(QEvent::registerEventType())), m_functor(std::forward<Functor>(functor)) {
}
~AsyncEvent() {
if (QCoreApplication::closingDown()) {
LOGW("QCoreApplication closed,skip handle task.");
return;
}
if (m_functor) m_functor();
}
private:
Functor m_functor;
};
#endif // __ASYNCEVENT_H__

View File

@ -0,0 +1,64 @@
#include "DndModeCountDownItem.h"
#include "rw_zlog.h"
#include <QHBoxLayout>
#include <QLabel>
#include <sstream>
DndModeCountDownItem::DndModeCountDownItem(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) {
m_label = new QLabel(this);
QFont font;
m_label->setMargin(0);
font.setPointSize(20);
m_label->setFont(font);
auto hint = new QLabel(this);
font.setPointSize(12);
hint->setFont(font);
hint->setText("后结束");
hint->setMargin(0);
auto layout = new QHBoxLayout(this);
layout->addWidget(m_label);
layout->addWidget(hint);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
QPalette palette(this->palette());
palette.setColor(QPalette::WindowText, Qt::black);
setPalette(palette);
}
void DndModeCountDownItem::setEndTime(const std::chrono::system_clock::time_point &endTime) {
auto now = std::chrono::system_clock::now();
m_endTime = endTime;
if (m_endTime > now) {
if (m_timerId < 0) m_timerId = startTimer(500);
} else {
if (m_timerId >= 0) {
killTimer(m_timerId);
m_timerId = -1;
}
}
}
void DndModeCountDownItem::timerEvent(QTimerEvent *event) {
constexpr int SencondsOfMinute = 60;
constexpr int SencondsOfHour = SencondsOfMinute * 60;
constexpr int SencondsOfDay = SencondsOfHour * 24;
using namespace std::chrono;
auto now = system_clock::now();
int duration = duration_cast<seconds>(m_endTime - now).count();
if (duration <= 0) {
killTimer(m_timerId);
m_timerId = -1;
}
int days = duration / SencondsOfDay;
int hours = (duration - days * SencondsOfDay) / SencondsOfHour;
int minutes = (duration - days * SencondsOfDay - hours * SencondsOfHour) / SencondsOfMinute;
int sec = (duration - days * SencondsOfDay - hours * SencondsOfHour - minutes * SencondsOfMinute);
m_label->setText(
QString("%1:%2:%3").arg(hours, 2, 10, QLatin1Char('0')).arg(minutes, 2, 10, QLatin1Char('0')).arg(sec, 2, 10, QLatin1Char('0')));
}

View File

@ -0,0 +1,23 @@
#ifndef __DNDMODECOUNTDOWNITEM_H__
#define __DNDMODECOUNTDOWNITEM_H__
#include <QWidget>
#include <chrono>
class QLabel;
class DndModeCountDownItem : public QWidget {
Q_OBJECT
public:
DndModeCountDownItem(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
void setEndTime(const std::chrono::system_clock::time_point &endTime);
protected:
void timerEvent(QTimerEvent *event) final;
private:
QLabel *m_label = nullptr;
std::chrono::system_clock::time_point m_endTime;
int m_timerId = -1;
};
#endif // __DNDMODECOUNTDOWNITEM_H__

View File

@ -0,0 +1,155 @@
#include <QPainter>
#include <QMouseEvent>
#include "SwitchControl.h"
SwitchControl::SwitchControl(QWidget *parent)
: QWidget(parent),
m_bChecked(false),
m_background(Qt::black),
m_checkedColor(0, 150, 136),
m_disabledColor(190, 190, 190),
m_thumbColor(Qt::white),
m_radius(8.0),
m_nHeight(16),
m_nMargin(3)
{
// 鼠标滑过光标形状 - 手型
setCursor(Qt::PointingHandCursor);
// 连接信号槽
connect(&m_timer, SIGNAL(timeout()), this, SLOT(onTimeout()));
}
// 绘制开关
void SwitchControl::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setPen(Qt::NoPen);
painter.setRenderHint(QPainter::Antialiasing);
QPainterPath path;
QColor background;
QColor thumbColor;
qreal dOpacity;
if (isEnabled()) { // 可用状态
if (m_bChecked) { // 打开状态
background = m_checkedColor;
thumbColor = m_checkedColor;
dOpacity = 0.600;
} else { //关闭状态
background = m_background;
thumbColor = m_thumbColor;
dOpacity = 0.800;
}
} else { // 不可用状态
background = m_background;
dOpacity = 0.260;
thumbColor = m_disabledColor;
}
// 绘制大椭圆
painter.setBrush(background);
painter.setOpacity(dOpacity);
path.addRoundedRect(QRectF(m_nMargin, m_nMargin, width() - 2 * m_nMargin, height() - 2 * m_nMargin), m_radius, m_radius);
painter.drawPath(path.simplified());
// 绘制小椭圆
painter.setBrush(thumbColor);
painter.setOpacity(1.0);
painter.drawEllipse(QRectF(m_nX - (m_nHeight / 2), m_nY - (m_nHeight / 2), height(), height()));
}
// 鼠标按下事件
void SwitchControl::mousePressEvent(QMouseEvent *event)
{
if (isEnabled()) {
if (event->buttons() & Qt::LeftButton) {
event->accept();
} else {
event->ignore();
}
}
}
// 鼠标释放事件 - 切换开关状态、发射toggled()信号
void SwitchControl::mouseReleaseEvent(QMouseEvent *event)
{
if (isEnabled()) {
if ((event->type() == QMouseEvent::MouseButtonRelease) && (event->button() == Qt::LeftButton)) {
event->accept();
m_bChecked = !m_bChecked;
emit toggled(m_bChecked);
emit signal_clicked(m_bChecked);
m_timer.start(10);
} else {
event->ignore();
}
}
}
// 大小改变事件
void SwitchControl::resizeEvent(QResizeEvent *event)
{
m_nX = m_nHeight / 2;
m_nY = m_nHeight / 2;
QWidget::resizeEvent(event);
}
// 默认大小
QSize SwitchControl::sizeHint() const
{
return minimumSizeHint();
}
// 最小大小
QSize SwitchControl::minimumSizeHint() const
{
return QSize(2 * (m_nHeight + m_nMargin), m_nHeight + 2 * m_nMargin);
}
// 切换状态 - 滑动
void SwitchControl::onTimeout()
{
if (m_bChecked) {
m_nX += 1;
if (m_nX >= width() - m_nHeight)
m_timer.stop();
} else {
m_nX -= 1;
if (m_nX <= m_nHeight / 2)
m_timer.stop();
}
update();
}
// 返回开关状态 - 打开true 关闭false
bool SwitchControl::isToggled() const
{
return m_bChecked;
}
// 设置开关状态
void SwitchControl::setToggle(bool checked)
{
m_bChecked = checked;
m_timer.start(10);
}
// 设置背景颜色
void SwitchControl::setBackgroundColor(QColor color)
{
m_background = color;
}
// 设置选中颜色
void SwitchControl::setCheckedColor(QColor color)
{
m_checkedColor = color;
}
// 设置不可用颜色
void SwitchControl::setDisbaledColor(QColor color)
{
m_disabledColor = color;
}

View File

@ -0,0 +1,69 @@
#ifndef SWITCH_CONTROL
#define SWITCH_CONTROL
#include <QWidget>
#include <QTimer>
class SwitchControl : public QWidget
{
Q_OBJECT
public:
explicit SwitchControl(QWidget *parent = nullptr);
// 返回开关状态 - 打开true 关闭false
bool isToggled() const;
// 设置开关状态
void setToggle(bool checked);
// 设置背景颜色
void setBackgroundColor(QColor color);
// 设置选中颜色
void setCheckedColor(QColor color);
// 设置不可用颜色
void setDisbaledColor(QColor color);
protected:
// 绘制开关
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
// 鼠标按下事件
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
// 鼠标释放事件 - 切换开关状态、发射toggled()信号
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
// 大小改变事件
void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
// 缺省大小
QSize sizeHint() const Q_DECL_OVERRIDE;
QSize minimumSizeHint() const Q_DECL_OVERRIDE;
signals:
// 状态改变时,发射信号
void toggled(bool checked);
void signal_clicked(bool state);
private slots:
// 状态切换时,用于产生滑动效果
void onTimeout();
private:
bool m_bChecked; // 是否选中
QColor m_background; // 背景颜色
QColor m_checkedColor; // 选中颜色
QColor m_disabledColor; // 不可用颜色
QColor m_thumbColor; // 拇指颜色
qreal m_radius; // 圆角
qreal m_nX; // x点坐标
qreal m_nY; // y点坐标
qint16 m_nHeight; // 高度
qint16 m_nMargin; // 外边距
QTimer m_timer; // 定时器
};
#endif // SWITCH_CONTROL

3146
Linguist/utility/UiTools.cpp Normal file

File diff suppressed because it is too large Load Diff

994
Linguist/utility/UiTools.h Normal file
View File

@ -0,0 +1,994 @@
#ifndef UITOOLS_H
#define UITOOLS_H
#include <QPushButton>
#include <QListWidgetItem>
#include <QLineEdit>
#include <QMessageBox>
#include <QString>
#include <QColor>
#include <QDialog>
#include <QVBoxLayout>
#include <QFormLayout>
#include <QLabel>
#include <QApplication>
#include <QWidget>
#include <QRadioButton>
#include <QDateTimeEdit>
#include <QStackedWidget>
#include <QTimer>
#include <QComboBox>
#include "LineEditWithKeyboard.h"
#include "BackstageInterfaceForUi.h"
class WidgetWithBackstageInterface : public QWidget
{
protected:
BackstageInterfaceForUi* m_backstageIf;
public:
WidgetWithBackstageInterface(QWidget *parent = nullptr);
virtual ~WidgetWithBackstageInterface();
virtual void setBackstageUiinterface(BackstageInterfaceForUi* interface);
//virtual void reset() = 0;
};
class PageAcceptMouseAndTouch : public WidgetWithBackstageInterface
{
public:
explicit PageAcceptMouseAndTouch(QWidget *parent = nullptr);
private:
bool eventFilter(QObject *watched, QEvent *event);
bool event(QEvent *event);
};
class PureColorPage : public PageAcceptMouseAndTouch
{
Q_OBJECT
public:
explicit PureColorPage(unsigned int color, unsigned char tran = 255, bool drawRect = false, QWidget *parent = nullptr);
~PureColorPage();
signals:
public slots:
private:
unsigned m_color;
unsigned char m_tran;
bool m_drawRect;
void paintEvent(QPaintEvent *event);
};
class MyWidgetWithMainStyleColor : public WidgetWithBackstageInterface
{
public:
explicit MyWidgetWithMainStyleColor(QWidget *parent = nullptr);
void paintEvent(QPaintEvent *event);
};
class MyWidgetWithSubStyleColor : public WidgetWithBackstageInterface
{
public:
explicit MyWidgetWithSubStyleColor(QWidget *parent = nullptr);
void paintEvent(QPaintEvent *event);
};
class CustomDialog : public QDialog
{
Q_OBJECT
public:
explicit CustomDialog(const QString& okBtnText, QObject *bgWidget = nullptr, const QString& cancelBtnText = tr("取消"), int timeout = 0);
virtual ~CustomDialog();
signals:
void signalShowShadowPage(bool show);
public slots:
void slotCancleBtnClicked();
virtual void slotConfirmBtnClicked();
protected:
QHBoxLayout* hbtmLayout;
int dialogWidth;
int dialogHeight;
PureColorPage* m_wBg;
QTimer *m_timer = nullptr;
private:
QPushButton* m_btn_ok = nullptr;
QPushButton* m_btn_cancle = nullptr;
const int m_timeout = 0;
void paintEvent(QPaintEvent *event);
bool eventFilter(QObject *watched, QEvent *event);
bool event(QEvent *event);
};
#if 1
class PasswordDialog : public CustomDialog
{
Q_OBJECT
public:
PasswordDialog(const QString& title, const QString& tip1, int timeout, QObject *bgWidget = nullptr, const QString& pwd = "",
const QString& tip0 = QString(), const QString& okBtn = tr("确定"), const QString& cancelBtn = tr("取消"));
virtual ~PasswordDialog();
const QString& getPwd() const;
public slots:
void slotPwdVisableBtnClicked();
void slotRestoreBtnClicked();
void slotConfirmBtnClicked();
signals:
void signalRestoreFactory();
private:
LineEditWithKeyboard* m_lineEdit_pwd;
QPushButton* m_btn_visable;
QPushButton* m_btn_factory;
QObject *m_bgWidget;
QString m_pwd;
int m_mode = 0;
};
class QuestionDialog : public CustomDialog
{
Q_OBJECT
public:
explicit QuestionDialog(const QString& question, QObject *bgWidget = nullptr, const QString& btnText = tr("确定"));
signals:
public slots:
};
class InfoDialog : public CustomDialog
{
Q_OBJECT
public:
explicit InfoDialog(const QString& info, QObject *bgWidget = nullptr, const QString& btnText = tr("知道了"), int timeout = 0);
signals:
public slots:
};
class SliderDialog : public CustomDialog
{
Q_OBJECT
public:
explicit SliderDialog(int current, int min, int max, const QString& tip, QObject *bgWidget = nullptr);
~SliderDialog();
int getValueSet() const;
signals:
public slots:
void slotValueChanged(int value);
private:
QLabel* m_labelCurrent;
QSlider* m_slider;
int m_iCurrent;
};
class DateTimeDialog : public CustomDialog
{
Q_OBJECT
public:
explicit DateTimeDialog(const QDateTime& dateTime, QObject *bgWidget = nullptr, bool needDate = true, bool needTime = true);
QDateTime getValueSet() const;
signals:
public slots:
void slotConfirmBtnClicked();
private:
QDateTimeEdit* m_dateTimeSet;
QDateTime m_dataTimeVal;
};
class RadioBtnChooseDialog : public CustomDialog
{
Q_OBJECT
protected:
QLabel* m_label_title;
QRadioButton* m_rdo;
QVBoxLayout* vLayout;
public:
explicit RadioBtnChooseDialog(const QVector<QString>& labels, QObject *bgWidget = nullptr, const int choose = 0, const QVector<bool> *config = nullptr, const QString& title = "");
virtual ~RadioBtnChooseDialog();
int getChoosedIndex() const;
public slots:
void slotRadioButtonPressed();
private:
int m_option_num;
int m_chooseIndex;
};
class LineEditInputDialog : public CustomDialog
{
Q_OBJECT
protected:
QFormLayout* formLayout;
QVBoxLayout* vLayout;
LineEditWithKeyboard* m_editRow;
QString* m_stringRowInput;
int m_rowNum;
protected slots:
void slotConfirmBtnClicked();
public:
LineEditInputDialog(const QStringList& labels, QObject *bgWidget = nullptr, const QString& confirBtm = tr("确定"));
LineEditInputDialog(const QString& label, QObject *bgWidget = nullptr, const QString& confirBtm = tr("确定"));
virtual ~LineEditInputDialog();
QString getRow(const int) const ;
void fillRow(const int, const QString&, bool readOnly = false);
private:
void init(const QStringList& labels);
};
class MsgDialog : public CustomDialog
{
Q_OBJECT
public:
explicit MsgDialog(const QString& msg, QObject *bgWidget = nullptr);
};
class ComSelectDialog : public CustomDialog
{
Q_OBJECT
protected:
QFormLayout* formLayout;
QVBoxLayout* vLayout;
QVector<QComboBox*> m_cbSels;
int m_rowNum;
protected slots:
public:
ComSelectDialog(const QStringList& titles, const QVector<QStringList>& sels, QObject *bgWidget = nullptr, const QString& confirBtm = tr("确定"));
virtual ~ComSelectDialog();
int getRow(int) const ;
void setRow(int row, int set, bool readOnly = false);
private:
};
class IpInputDialog : public LineEditInputDialog
{
Q_OBJECT
protected:
protected slots:
void slotTextChanged(const QString &);
void slotConfirmBtnClicked();
public:
IpInputDialog(const QStringList& ips, QObject *bgWidget = nullptr, const QString& confirBtm = tr("确定"));
IpInputDialog(const QString& ip, QObject *bgWidget = nullptr, const QString& confirBtm = tr("确定"));
virtual ~IpInputDialog();
private:
};
#endif
class MyMessageBox : public QMessageBox
{
public:
MyMessageBox();
protected:
void showEvent(QShowEvent* event);
void paintEvent(QPaintEvent *event);
};
class myListWidget : public QWidget
{
public:
typedef enum
{
enSwitch,
enMoreArrow,
enRedWord,
enTick,
enIndent1
}_enProp;
typedef enum
{
enPropertyNull,
enPropertySwitch = 1 << enSwitch,
enPropertyMoreArrow = 1 << enMoreArrow,
enPropertyRedWord = 1 << enRedWord,
enPropertyTick = 1 << enTick,
enPropertyIndent1 = 1 << enIndent1
}enProperty;
class SetOpnCfg
{
public:
const QString m_sOpn;
const QString m_sVal;
const enProperty m_prop;
SetOpnCfg(const QString& opn, const QString& val, const enProperty prop) : m_sOpn(opn), m_sVal(val), m_prop(prop){}
SetOpnCfg(const QString& opn, const QString& val) : m_sOpn(opn), m_sVal(val), m_prop(myListWidget::enPropertyNull){}
SetOpnCfg(const QString& opn) : m_sOpn(opn), m_sVal(""), m_prop(myListWidget::enPropertyNull){}
SetOpnCfg() : m_sOpn(""), m_sVal(""), m_prop(myListWidget::enPropertyNull){}
SetOpnCfg& operator= (const SetOpnCfg& obj){Q_UNUSED(obj) return *this;}
};
myListWidget(const SetOpnCfg& cfg, QWidget* parent = nullptr);
~myListWidget();
void updateLabel(const QString& val);
void updateIcon(const QString& icon, int scale_w=0, int scale_h=0);
void setLeftIcon(const QString& icon, int scale_w, int scale_h);
const QString getLabelString() const;
const QString getOpnLabelString() const;
const QString getOptionLabel() const;
private:
QLabel* m_label_leftIcon;
QLabel* m_label_left;
QLabel* m_label_right;
QLabel* m_label_icon;
QHBoxLayout* m_hbLayout;
int m_layoutObjQty = 0;
bool m_hasIndent = false;
};
class SwitchListWidget : public QWidget
{
private:
QLabel* m_label_left;
QLabel* m_label_right;
QLabel* m_label_icon;
bool m_Res;
public:
SwitchListWidget(const QString& left, const QString& right, const QString& icon, QWidget*parent);
~SwitchListWidget();
void updateLabel(const QString& label);
void updateIcon(const QString& icon);
void updateIcon(bool bFlag);
bool getSwitchRes();
const QString getLabelString() const;
};
class FourListWidget : public QWidget
{
private:
QLabel* m_label_left;
QLabel* m_label_right;
QLabel* m_label_icon;
QPushButton* m_btn_mid;
public:
FourListWidget(const QString& left, const QString& right, const QString& btnText, const QString& icon, QWidget*parent);
~FourListWidget();
void updateLabel(const QString& label);
void updateIcon(const QString& icon);
void updateBtnText(const QString& text);
QPushButton* getPushButton();
const QString getLabelString() const;
};
class setPushButton : public QWidget
{
public:
setPushButton(QPushButton* pPushButton, const QString& tip, const QString& icon, const QSize& size);
~setPushButton();
private:
QVBoxLayout* _pVBoxLayoutDevice;
QLabel* _pLabelIcon;
};
void setLanguage(QApplication&, const QString&);
void setFont(QApplication& app, const QString&, const int fontSize, const int);
void setLineEditFontColor(QLineEdit* edit, const QColor& color);
void setLineEditStyle(QLineEdit* edit);
void setButtonBackImage(QPushButton *button, QString image, int sizeW = 0, int sizeH = 0);
QListWidgetItem* setListWidgetItem(QListWidgetItem* item, const QString text = "", const QString image = "");
class TimerUpdate : public QWidget
{
Q_OBJECT
public:
explicit TimerUpdate(QLabel* pLabel, QWidget *parent = nullptr);
TimerUpdate(QLabel* labelTime, QLabel* labelDate, QWidget *parent = nullptr, int timeType = 0, int dateType = 0, int weekType = 0);
~TimerUpdate();
void timerEvent(QTimerEvent *event);
void enableUpdate(bool enable);
signals:
void signalNewDay();
private:
int _timerID;
QLabel* _labelTime;
QLabel* _labelDate;
int m_timeType;
int m_dateType;
int m_weekType;
bool m_enableUpdate = true;
void init();
};
QPixmap PixmapToRound(QPixmap &src, int radius);
QImage ScaleImage(const QImage& image, const QSize& size);
QImage ScaleImage2Label(const QImage& qImage, const QLabel& label);
QPixmap ScalePixmap(const QPixmap& pixmap, const QSize& size);
QPixmap ScalePixmap2Label(const QPixmap& pixmap, const QLabel& label);
class MyLineEdit:public QLineEdit
{
Q_OBJECT
public:
explicit MyLineEdit(QWidget *parent = nullptr);
~MyLineEdit();
protected:
//添加并重写鼠标点击事件函数
virtual void mousePressEvent(QMouseEvent *event);
signals:
//点击信号函数
void clicked();
};
class LocalFourListWidget : public QWidget
{
private:
QLabel* m_label_left;
QLabel* m_label_mid;
QLabel* m_label_right;
QLabel* m_label_icon;
public:
LocalFourListWidget(const QString& left, const QString& mid, const QString& right, const QString& icon, QWidget*parent);
~LocalFourListWidget();
void updateLabel(const QString& label);
void updateRight(const QString& text);
void updateIcon(const QString& icon);
const QString getLabelString() const;
};
bool checkip(const QString& ip);
bool checkMask(const QString& mask);
//判断是否在同一网段
bool isSameNetwork(const QString& ip, const QString& mask, const QString& gateway);
bool getIpFromUserInput(const QString& lineEdit, const QString& initIp, QString& newIp, QObject *bgWidget = nullptr);
bool getMaskFromUserInput(const QString& lineEdit, const QString& initIp, QString& newIp, QObject *bgWidget = nullptr);
bool getNumFromUserInput(const QString& lineEdit, const QString& initNum, QString& newValue, const int min, const int max, QObject *bgWidget = nullptr);
QString GBK2UTF8(const QString &inStr);
QString UTF82GBK(const QString &inStr);
std::string gbk2utf8(const QString &inStr);
QString utf82gbk(const std::string &inStr);
void gbkToUtf8(char *gbkstr);
class ProgressWidget : public QWidget
{
public:
explicit ProgressWidget(const QString& title);
~ProgressWidget();
void setMsg(const unsigned current, const unsigned all);
private:
QLabel* m_label_title;
QLabel* m_label_msg;
QSlider* m_slider_progess;
};
class SettingUiPage : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
typedef myListWidget::SetOpnCfg SetOpn;
explicit SettingUiPage(const QVector<SetOpn>& config, QWidget *parent = nullptr);
protected:
const QVector<SetOpn> config;
QListWidget* m_listWidget;
void controlListWidgetItemShow(const bool sw, int option);
signals:
void signalShowPage(int, const QString title = "");
protected slots:
virtual void slotItemClicked(QListWidgetItem* item) = 0;
};
class MsgListWidgetItem : public QWidget
{
public:
typedef enum
{
enBold,
enGreyWord,
enGreenWord,
enRedWord
}_enProp;
typedef enum
{
enPropertyNull,
enPropertyBold = 1 << enBold,
enPropertyGreyWord = 1 << enGreyWord,
enPropertyGreenWord = 1 << enGreenWord,
enPropertyRedWord = 1 << enRedWord
}enProperty;
typedef struct
{
QString m_sMsg;
enProperty m_eProp;
}stMsgOpn;
class MsgSet
{
public:
const QString m_sPic;
const QVector<stMsgOpn> m_vMsgs;
MsgSet() : m_sPic(""){}
MsgSet(const QString& pic, const QVector<stMsgOpn>& msgs) : m_sPic(pic), m_vMsgs(msgs){}
MsgSet& operator=(const MsgSet& obj){Q_UNUSED(obj) return *this;}
};
MsgListWidgetItem(QWidget* parent);
~MsgListWidgetItem();
void showMsg(const QString& pic, const QVector<stMsgOpn>& msgs);
private:
const int m_msgOpnQty = 4;
QLabel* labelPic;
QVector<QLabel*> labelMsg;
};
class PersonMsgUiPage : public MyWidgetWithMainStyleColor
{
Q_OBJECT
public:
typedef MsgListWidgetItem::stMsgOpn MsgOpn;
typedef MsgListWidgetItem::enProperty MsgOpnProp;
typedef MsgListWidgetItem::MsgSet MsgSet;
const unsigned m_itemQty = 5;
explicit PersonMsgUiPage(QWidget *parent = nullptr);
void showMsg(const QVector<MsgSet>& msgs);
void clearMsg();
void setPageControlBarHide(bool hide, int min = 0, int max = 0, int current = 0);
void showMoreSearchOpn();
protected:
#define SEARCH_OPN_QTY 2
enum{
enSearchOpnName,
enSearchOpnTime
};
QLineEdit* m_editSearch[SEARCH_OPN_QTY];
QPushButton* m_btnClearSearch[SEARCH_OPN_QTY];
QLabel* m_labelTip[SEARCH_OPN_QTY];
QPushButton* m_btnMore;
QStackedWidget* m_stackWgt;
QListWidget* m_listWidget;
QLabel* m_labelPage;
QLabel* m_labelMin;
QLabel* m_labelMax;
QPushButton* m_btnPrePage;
QPushButton* m_btnNextPage;
QSlider* m_sliderPage;
int m_toPageNum;
QString m_sSearchName;
QString m_sSearchtime;
protected slots:
virtual void slotTextChanged(const QString& text) = 0;
virtual void slotBtnClicked();
virtual void slotSliderReleased() = 0;
virtual void slotItemClicked(QListWidgetItem *item);
void slotValueChanged(int value);
};
class ItemChoosePage : public SettingUiPage
{
Q_OBJECT
public:
explicit ItemChoosePage(const QVector<SetOpn>& config, int choose, QWidget *parent = nullptr);
int getChoosedIndex() const;
public slots:
void slotItemClicked(QListWidgetItem*);
private:
int m_chooseIndex;
};
class ItemChooseDialog : public CustomDialog
{
Q_OBJECT
protected:
ItemChoosePage* m_ItemsPage;
QVBoxLayout* vLayout;
public:
explicit ItemChooseDialog(const QVector<QString>& items, const int choose, QObject *bgWidget = nullptr);
virtual ~ItemChooseDialog();
int getChoosedIndex() const;
public slots:
};
class CalendarDialog : public CustomDialog
{
Q_OBJECT
public:
explicit CalendarDialog(bool isEn, QObject *bgWidget = nullptr);
QDate getDateChoose() const;
signals:
public slots:
void slotConfirmBtnClicked();
private:
QCalendarWidget* m_wgtCal;
QDate m_date;
};
class LineEditWithDialog : public QLineEdit
{
Q_OBJECT
public:
LineEditWithDialog(int dialogType, QObject *bgWidget = nullptr, QWidget *parent = nullptr);
~LineEditWithDialog();
protected:
void mousePressEvent(QMouseEvent *event);
signals:
private:
int m_dialogType;
QObject *m_bgWidget;
};
class WifiListWidget : public QWidget
{
public:
WifiListWidget(const QString& ssid, bool connected, bool withLock, int sigLevel, bool isTargetNet, QWidget* parent);
~WifiListWidget();
void updateStatus(bool connected);
QString getSsid() const;
bool isTargetNet() const;
bool isConnected() const;
bool getLockStatus() const;
void clearStatus();
private:
QLabel* m_label_conn;
QLabel* m_label_ssid;
const bool m_isLock;
bool m_isTargetNet;
bool m_isConnected;
};
class WifiAccPointDialog : public LineEditInputDialog
{
Q_OBJECT
private slots:
void slotConfirmBtnClicked();
public:
WifiAccPointDialog(QObject *bgWidget = nullptr);
virtual ~WifiAccPointDialog();
QString getEncType() const;
private:
QComboBox* m_comBox_encType;
QString m_sEncType;
};
int GrabFullScreen(const QString& picName, int rotate = 0);
class DrawPage : public QWidget
{
Q_OBJECT
struct DrawPara
{
QList<QPoint> points;
};
QPushButton* m_btnClear;
QPushButton* m_btnExit;
QList<DrawPara> m_drawList;
DrawPara m_current;
void draw(QPainter& painter, DrawPara& param);
void append(QPoint p);
signals:
void signalClosed();
protected:
void mousePressEvent(QMouseEvent *evt);
void mouseMoveEvent(QMouseEvent *evt);
void mouseReleaseEvent(QMouseEvent *evt);
void paintEvent(QPaintEvent *);
public slots:
void slotClearBtnClicked();
void slotExitBtnClicked();
public:
DrawPage(int w, int h, QWidget *parent = 0);
~DrawPage();
};
class UserPwdDialog : public QDialog
{
Q_OBJECT
public:
QString m_pwd;
explicit UserPwdDialog();
signals:
public slots:
void slotBtnClicked();
private:
enum{NUM_BTNS_QTY = 10};
QLineEdit* m_editPwd;
QPushButton* m_btnsNum[NUM_BTNS_QTY];
QPushButton* m_btnBack;
QPushButton* m_btnClear;
QPushButton* m_btnBackspace;
QPushButton* m_btnConfirm;
};
class QPasswordLineEdit : public QLineEdit
{
Q_OBJECT
public:
QPasswordLineEdit(QWidget *parent, const QString& ch = "", int timeout = 300);
~QPasswordLineEdit();
private slots:
void DisplayPasswordAfterEditSlot(int,int);
void DisplayPasswordSlot();
void GetRealTextSlot(const QString&);
public:
QString GetPassword() const;
void SetTimeout(int msec);
int GetTimeout() const;
private:
QString GetMaskString();
private:
const QString m_ch;
int m_Timeout;
QString m_LineEditText;
int m_LastCharCount = 0;
QTimer* m_timer;
};
class RoundedWidget : public QWidget
{
Q_OBJECT
public:
explicit RoundedWidget(QWidget *parent = nullptr);
private:
void paintEvent(QPaintEvent *event);
};
class StyleItemChooseDialog : public CustomDialog
{
Q_OBJECT
protected:
public:
explicit StyleItemChooseDialog(const QString& title, const QStringList& items, BackstageInterfaceForUi* backstageIf);
virtual ~StyleItemChooseDialog();
int getChoosedIndex() const;
public slots:
void slotItemClicked(QListWidgetItem* item);
void slotTimeout();
private:
enum{
TIMEOUT = 1000,
BACKSTAGE_PROC_OVERTIME = 5,
PROC_OVERTIME = 10
};
BackstageInterfaceForUi* m_backstageIf;
QListWidget* m_listWidget;
int m_chooseIndex = 0;
int m_timeCnt = 0;
void paintEvent(QPaintEvent *event);
};
class SelectionDialog : public CustomDialog
{
Q_OBJECT
public:
explicit SelectionDialog(const QString& tips, const QString& sel0, const QString& sel1, QObject *bgWidget = nullptr);
int selecion() const;
signals:
public slots:
private:
int m_sel = 0;
};
class TimeWidget : public QWidget
{
Q_OBJECT
public:
explicit TimeWidget(bool enType, int timeSize, int dateSize, QWidget *parent = nullptr);
void enableUpdate(bool enable);
public slots:
private:
TimerUpdate* m_timerUpdate;
};
class DateTimeWidgetClassical : public QWidget
{
Q_OBJECT
public:
explicit DateTimeWidgetClassical(int fontSize, QWidget *parent = nullptr);
signals:
void signalNewDay();
};
class BtListWidget : public QWidget
{
Q_OBJECT
public:
//BtListWidget(const QString& devId, const QString& devName, bool isPaired, int devStat);
BtListWidget(BluetoothDev_t &rBtDev/*, bool isPaired = false*/);
~BtListWidget();
void refreshWidget();
void getDevInfo(BluetoothDev_t &dev);
void updateDev(BluetoothDev_t &rBtDev);
signals:
void signalClickSet(BluetoothDev_t btDev);
public slots:
void slotBtnSetClick();
private:
QLabel* m_label_btIcon = nullptr;
QLabel* m_label_dev = nullptr;
//QLabel* m_label_pairedIcon;
//QLabel* m_label_stat;
QPushButton *m_pushButton_set = nullptr;
#if 0
QString m_devId;//设备唯一标识
QString m_devName;
int m_devStat;
#endif
BluetoothDev_t m_btDev;
//bool m_isPaired;//是否已配对的蓝牙设备
};
class IpInputBar : public QWidget {
Q_OBJECT
public:
IpInputBar(bool isMask, QWidget *parent = nullptr);
bool isEmpty() const;
QString getIp() const;
protected slots:
void slotTextChanged(const QString &t);
void slotBackspacePressed();
private:
const bool m_isMask;
QVector<LineEditWithKeyboard *> m_edits;
};
class IpInputBarDialog : public CustomDialog {
Q_OBJECT
public:
IpInputBarDialog(const QStringList &options, const QVector<bool> &required, const QVector<bool> &isMask,
QObject *bgWidget);
QString getRow(int row) const;
protected slots:
void slotConfirmBtnClicked();
private:
QVector<IpInputBar *> m_bars;
const QVector<bool> m_required;
};
class SearchBarCandidate : public ItemChoosePage
{
Q_OBJECT
public:
using ItemChoosePage::ItemChoosePage;
QString getCurrentChooseText();
signals:
void signalItemChoosed(int);
public slots:
void slotItemClicked(QListWidgetItem*);
};
class ImgPlayer : public QWidget
{
Q_OBJECT
public:
ImgPlayer(int width, int height, QWidget *parent = nullptr);
signals:
public slots:
void slotImgLoad(QImage);
private:
QImage m_img;
int m_width;
int m_height;
QRectF m_targetRct;
void paintEvent(QPaintEvent *);
};
#endif // _UITOOLS_H_