#include "settingUiAccMng.h" #include #include "UiConfig.h" int settingUiAccMng::m_pageIndex = 0; settingUiAccMng::settingUiAccMng(int pageIndex, QWidget *parent) : SettingUiPage(QVector{ SetOpn(tr("开锁延迟(秒)"), "x", myListWidget::enPropertyMoreArrow), SetOpn(tr("开锁时间(秒)"), "x", myListWidget::enPropertyMoreArrow), SetOpn(tr("开锁信号"), "xxxxx", myListWidget::enPropertyMoreArrow), SetOpn(tr("反向通行"), "xxxxx", static_cast(myListWidget::enPropertySwitch| myListWidget::enPropertyIndent1)), SetOpn(tr("RS485"), "xx", myListWidget::enPropertyMoreArrow), SetOpn(tr("RS485协议1设备地址(0-255)"), "xx", static_cast(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1)), SetOpn(tr("静电测试范围"), "xx", static_cast(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1)), SetOpn(tr("GPIO4接口"), "xx", myListWidget::enPropertyMoreArrow), SetOpn(tr("GPIO5接口"), "xx", myListWidget::enPropertyMoreArrow), SetOpn(tr("门超时报警(秒)"), "xx", static_cast(myListWidget::enPropertyMoreArrow | myListWidget::enPropertyIndent1)), SetOpn(tr("防拆报警"), "", myListWidget::enPropertySwitch), SetOpn(tr("防拆报警信号"), "xx", static_cast(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(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(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 options; if(enAccOpenSig == row){ options = OpenSig; if(UiConfig::GetInstance()->isFuncNotSupport(FuncWg42)){ options.remove(4); } choosed = static_cast(m_backstageIf->getUnlockSig()); } #if 0 else if(enAccAlmSig == row){ options = AlarmSig; choosed = static_cast(m_backstageIf->getWarningSig()); } #endif else if(enAccRs485 == row){ options = Rs485Cfg; choosed = static_cast(m_backstageIf->getRs485Cfg()); }else if(enAccGPIO4 == row){ options = GPIOCfg; choosed = static_cast(m_backstageIf->getGpio4Cfg()); }else if(enAccGPIO5 == row){ options = GPIOCfg; choosed = static_cast(m_backstageIf->getGpio5Cfg()); }else if(enAccAntiDemolitionOutput == row){ options = AntiDemolitionOutput; choosed = static_cast(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(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(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 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(m_backstageIf->getAntiDemolitionSw()); } setting_value = static_cast(!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; } }