#include "settingUiFaceMng.h" #include #include "UiConfig.h" #include #include "recoUiRecognize.h" int settingUiFaceMng::m_pageIndex = 0; settingUiFaceMng::settingUiFaceMng(int pageIndex, QWidget *parent) : SettingUiPage(QVector{ 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(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(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(enSearchOpnName); qDebug() << "FaceDbPage text change:" << text; m_sSearchName = text; } else if(sender() == m_editSearch[enSearchOpnTime]){ searchOpnIndex = static_cast(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(!!(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; jqueryPerson(m_sSearchName.toStdString().c_str(), pageIndex, person, static_cast(m_itemQty)); QVector msgs; if(personReadQty){ for(unsigned i=0; i 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())); } #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(enSearchOpnName); qDebug() << "AccessRecordPage name text change:" << text; m_sSearchName = text; } else if(sender() == m_editSearch[enSearchOpnTime]){ searchOpnIndex = static_cast(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(!!(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; jqueryAccessRecord("" != m_sSearchName.toStdString() ? m_sSearchName.toStdString().c_str() : nullptr, "" != m_sSearchtime.toStdString() ? m_sSearchtime.toStdString().c_str() : nullptr, pageIndex, record, static_cast(m_itemQty)); QVector msgs; for(unsigned i=0; i 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())); } #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(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(UiConfig::GetInstance()->getUiWidth() / 4), static_cast(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("

可以刷卡写入IC卡

"); 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(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(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(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(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(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(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(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(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(); } }