#include "settingUi.h" #include #include #include #include #include #include #include #include #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(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]); }