#include "sysset_page.h" #include "ui_SysSetPage.h" #include "qprocess.h" #include "Common/classxml.h" #include "IMEKeyBoard/keyboard_num.h" #include "IMEKeyBoard/syszuxpinyin.h" #include "Common/mymessagebox.h" SysSet_Page::SysSet_Page(QWidget *parent, Work_Thread *thread, SlaveCtrl *slavectrl) : customDialog(parent), ui(new Ui::SysSet_Page) { ui->setupUi(this); work_thread = thread; connect(work_thread,SIGNAL(SentInterface(int)),this,SLOT(UpdateInterface(int))); work_thread->localData.Interface = FACE_SET; QString version = dateVersion; if(PRO) version += "pro"; ui->label_softinfo->setText(tr("软件版本:")+appVersion+ClassXML::readCoreVersion()+QString::number(work_thread->localData.SoftVersion)+version); //ui->label_softinfo->setText("test1.1."+ClassXML::readCoreVersion()+QString::number(work_thread->localData.SoftVersion)+version); Tcp = slavectrl; tcp_mode = work_thread->localData.tcp_ctrl.mode; sysParam = work_thread->sysParam; sysParam.monomer_addrset = 1; tmpaddr = sysParam.monomer_addrset; tmpfre = sysParam.monomer_fre; wifi_show_cnt = 0; tcp_connect_cnt = 0; one_sub_window_exist = false; edit = false; get_date_time(); ui->SysSet_tab->setCurrentIndex(0); #ifdef DZBBH ui->label_dz->setText(DZBBH); #endif set_btn_beep(ui->pushButton_Exit,SIGNAL(pressed())); set_btn_beep(ui->SysSet_tab,SIGNAL(currentChanged(int))); set_btn_beep(ui->ledit_date,SIGNAL(custom_click())); set_btn_beep(ui->ledit_time,SIGNAL(custom_click())); set_btn_beep(ui->ledit_dsave,SIGNAL(custom_click())); set_btn_beep(ui->ledit_mlow,SIGNAL(custom_click())); set_btn_beep(ui->ledit_morder,SIGNAL(custom_click())); set_btn_beep(ui->ledit_mfreq,SIGNAL(custom_click())); set_btn_beep(ui->ledit_loadplus,SIGNAL(custom_click())); set_btn_beep(ui->ledit_maddr,SIGNAL(custom_click())); set_btn_beep(ui->ledit_password,SIGNAL(custom_click())); set_btn_beep(ui->btn_to_adj,SIGNAL(pressed())); set_btn_beep(ui->btn_to_config,SIGNAL(pressed())); set_btn_beep(ui->btn_to_welcome,SIGNAL(pressed())); set_btn_beep(ui->btn_to_reboot,SIGNAL(pressed())); set_btn_beep(ui->btn_to_8kwio,SIGNAL(pressed())); set_btn_beep(ui->btn_to_module,SIGNAL(pressed())); set_btn_beep(ui->btn_language,SIGNAL(pressed())); set_btn_beep(ui->btn_set_addr,SIGNAL(pressed())); connect(ui->pushButton_Exit,SIGNAL(released()),this,SLOT(BtnReleased())); connect(ui->SysSet_tab,SIGNAL(currentChanged(int)),this,SLOT(TabChanged(int))); ui->ledit_password->setEchoMode(QLineEdit::Password); //tab0 connect(ui->ledit_date,SIGNAL(custom_click()),this,SLOT(leditAction())); connect(ui->ledit_time,SIGNAL(custom_click()),this,SLOT(leditAction())); connect(ui->btn_set_time,SIGNAL(released()),this,SLOT(BtnReleased())); //tab1 connect(ui->ledit_dsave,SIGNAL(custom_click()),this,SLOT(leditAction())); connect(ui->ledit_mlow,SIGNAL(custom_click()),this,SLOT(leditAction())); connect(ui->ledit_morder,SIGNAL(custom_click()),this,SLOT(leditAction())); connect(ui->ledit_mfreq,SIGNAL(custom_click()),this,SLOT(leditAction())); connect(ui->ledit_loadplus,SIGNAL(custom_click()),this,SLOT(leditAction())); connect(ui->ledit_maddr,SIGNAL(custom_click()),this,SLOT(leditAction())); connect(ui->btn_set_addr,SIGNAL(released()),this,SLOT(BtnReleased())); //tab2 set_btn_beep(ui->ledit_ssid,SIGNAL(custom_click())); connect(ui->ledit_ssid,SIGNAL(custom_click()),this,SLOT(leditAction())); set_btn_beep(ui->ledit_pwd,SIGNAL(custom_click())); connect(ui->ledit_pwd,SIGNAL(custom_click()),this,SLOT(leditAction())); set_btn_beep(ui->ledit_tcp_type,SIGNAL(custom_click())); connect(ui->ledit_tcp_type,SIGNAL(custom_click()),this,SLOT(leditAction())); set_btn_beep(ui->ledit_tcp_ip,SIGNAL(custom_click())); connect(ui->ledit_tcp_ip,SIGNAL(custom_click()),this,SLOT(leditAction())); set_btn_beep(ui->ledit_tcp_port,SIGNAL(custom_click())); connect(ui->ledit_tcp_port,SIGNAL(custom_click()),this,SLOT(leditAction())); set_btn_beep(ui->btn_connect,SIGNAL(pressed())); connect(ui->btn_connect,SIGNAL(released()),this,SLOT(BtnReleased())); set_btn_beep(ui->btn_tcp_start,SIGNAL(pressed())); connect(ui->btn_tcp_start,SIGNAL(released()),this,SLOT(BtnReleased())); //tab3 connect(ui->btn_to_config,SIGNAL(released()),this,SLOT(BtnReleased())); connect(ui->btn_to_welcome,SIGNAL(released()),this,SLOT(BtnReleased())); connect(ui->btn_to_adj,SIGNAL(released()),this,SLOT(BtnReleased())); connect(ui->btn_to_reboot,SIGNAL(released()),this,SLOT(BtnReleased())); connect(ui->ledit_password,SIGNAL(custom_click()),this,SLOT(leditAction())); connect(ui->btn_to_8kwio,SIGNAL(released()),this,SLOT(BtnReleased())); connect(ui->btn_to_module,SIGNAL(released()),this,SLOT(BtnReleased())); connect(ui->btn_language,SIGNAL(released()),this,SLOT(BtnReleased())); t_timer = new QTimer(this); connect(t_timer,SIGNAL(timeout()),this,SLOT(get_date_time())); t_timer->setInterval(500); t_timer->start(); qRegisterMetaType("SYS_PARAM"); connect(this,SIGNAL(SendSysParam(SYS_PARAM)),work_thread,SLOT(RecvSysParam(SYS_PARAM))); connect(work_thread,SIGNAL(SendThreadState(int,int)),this,SLOT(RecvThreadState(int,int))); connect(this,SIGNAL(SendSysAddrFre(int,int)),work_thread,SLOT(RecvSysAddrFre(int,int))); get_wifi_ssid_pwd(); sys_param_show(); // if(ENCNTURN){ // ui->btn_language->setVisible(true); // } // else // ui->btn_language->setVisible(false); if(CONTROL_BJ){ ui->ledit_loadplus->setEnabled(true); } else ui->ledit_loadplus->setEnabled(false); ui->btn_to_config_log->setVisible(false); ui->btn_to_config->setVisible(false); ui->btn_to_welcome->setVisible(false); ui->btn_to_8kwio->setVisible(false); ui->btn_to_module->setVisible(false); ui->btn_language->setVisible(false); ui->label_dz->setVisible(false); } SysSet_Page::~SysSet_Page() { work_thread->localData.Interface = FACE_HOME; delete ui; delete t_timer; } void SysSet_Page::sys_param_show(void) { ui->ledit_dsave->setText(QString::number(sysParam.save_interval)); if(MONOMER_LOW_STOP == sysParam.monomerlow_act) ui->ledit_mlow->setText(tr("停止")); else ui->ledit_mlow->setText(tr("暂停")); if(MONOMER_ORDER_POS == sysParam.monomer_order) ui->ledit_morder->setText(tr("从组端正级递增")); else ui->ledit_morder->setText(tr("从组端负级递增")); ui->ledit_mfreq->setText(QString::number(sysParam.monomer_fre+1)); ui->ledit_maddr->setText(QString::number(sysParam.monomer_addrset)); if(LOADER_PLUS_DISEN == sysParam.loader_plusEn) ui->ledit_loadplus->setText(tr("停用")); else ui->ledit_loadplus->setText(tr("启用")); ui->ledit_ssid->setText(wifi_ssid); ui->ledit_pwd->setText(wifi_pwd); if(tcp_mode) { ui->ledit_tcp_type->setText(tr("客户端")); ui->ledit_tcp_ip->setEnabled(true); ui->ledit_tcp_port->setEnabled(true); //ui->btn_tcp_start->setEnabled(true); } else { ui->ledit_tcp_type->setText(tr("服务端")); ui->ledit_tcp_ip->setEnabled(false); ui->ledit_tcp_port->setEnabled(false); //ui->btn_tcp_start->setEnabled(false); } QString temp; temp.sprintf("%d.%d.%d.%d",sysParam.tcp_ip[0],sysParam.tcp_ip[1],sysParam.tcp_ip[2],sysParam.tcp_ip[3]); ui->ledit_tcp_ip->setText(temp); ui->ledit_tcp_port->setText(QString::number(sysParam.tcp_port)); } void SysSet_Page::BtnReleased() { QPushButton *pb = dynamic_cast(sender()); if(pb == ui->pushButton_Exit) { sysParam.OnlineOffVol = work_thread->sysParam.OnlineOffVol; sysParam.GroupOffVol = work_thread->sysParam.GroupOffVol; sysParam.monomer_fre = work_thread->sysParam.monomer_fre; emit SendSysParam(sysParam); closeCustom(false); } else if(pb == ui->btn_set_time) { set_date_time(ctDT); } else if(pb == ui->btn_set_addr) { emit SendSysAddrFre(work_thread->CMD_SetMonomerAddr,tmpaddr); } else if(pb == ui->btn_to_config) { if((!work_thread->IF_J9Close)&&JT_VALUE) { QString msg = tr("设备处于紧急停止状态,请检查并断电重启!"); popBox(msg); return; } if(true == one_sub_window_exist) { return; } work_thread->localData.Interface = FACE_CONFIGPAGE; conf = new Sysconf_Page(this,work_thread); one_sub_window_exist = true; conf->execCustom(); work_thread->localData.Interface = FACE_SET; one_sub_window_exist = false; } else if(pb == ui->btn_to_welcome) { if(true == one_sub_window_exist) { return; } work_thread->localData.Interface = FACE_WELCOMPAGE; welcomeconf = new Welcome_Page(this,work_thread); one_sub_window_exist = true; welcomeconf->execCustom(); work_thread->localData.Interface = FACE_SET; one_sub_window_exist = false; } else if(pb == ui->btn_to_adj) { if(true == one_sub_window_exist) { return; } work_thread->localData.Interface = FACE_ADJ; adjconf = new Adjust_Page(this,work_thread); one_sub_window_exist = true; adjconf->execCustom(); work_thread->localData.Interface = FACE_SET; one_sub_window_exist = false; } else if(pb == ui->btn_to_reboot) { QDir dir; if(false == dir.exists("/mnt/usb/BatterTester.SM5") && false == dir.exists("/mnt/usb/BatterTester") && false == dir.exists("/mnt/usb/welcome.png") && false == dir.exists("/mnt/usb/Language_CN.qm")) { popBox(tr("升级文件不存在!")); return; } MessageBox box( this, QMessageBox::Question, MB_Caption, tr("确定要升级吗?"), QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Ok, work_thread ); if(box.exec() != QMessageBox::Ok) { return; } if(dir.exists("/app/run_updateSM5.sh")) system("/app/run_updateSM5.sh &"); else system("/app/run_appupdate.sh &"); return; } else if(pb == ui->btn_connect) { if(IP.isEmpty()) { QString cmd = "/app/wifi_connect.sh "; cmd += "\""+wifi_ssid+"\""; cmd += " "; cmd += "\""+wifi_pwd+"\""; QProcess::startDetached(cmd.toStdString().data()); wifi_show_cnt = 120; } else { system("/app/wifi_disconnect.sh"); } pb->setEnabled(false); ui->ledit_ssid->setStyleSheet("color:black"); ui->ledit_pwd->setStyleSheet("color:black"); } else if(pb == ui->btn_tcp_start) { work_thread->localData.tcp_ctrl.mode = tcp_mode; if(tcp_mode) { QString ip; ip.sprintf("%d.%d.%d.%d",sysParam.tcp_ip[0],sysParam.tcp_ip[1], sysParam.tcp_ip[2],sysParam.tcp_ip[3]); Tcp->sentClientConnect(ip,sysParam.tcp_port); tcp_connect_cnt = 6; } else { Tcp->Restartlisten(); } emit SendSysParam(sysParam); ClassXML::ModifySysParamXml(sysParam); pb->setEnabled(false); ui->ledit_tcp_type->setStyleSheet("color:black"); ui->ledit_tcp_ip->setStyleSheet("color:black"); ui->ledit_tcp_port->setStyleSheet("color:black"); } else if(pb == ui->btn_to_8kwio)//升级8KW或I/O接口板 { QDir dir; if(true == dir.exists("/mnt/usb/update.bin"))//升级8KW { MessageBox box( this, QMessageBox::Question, MB_Caption, tr("确定要升级吗?"), QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes,work_thread ); if(box.exec()!=QMessageBox::Yes) return; system("/app/run_update8kw.sh &"); return; } else//升级I/O接口板 { if(false == dir.exists(F1223P_File)) { MessageBox box( this, QMessageBox::Critical, MB_Caption, tr("升级文件不存在!"), QMessageBox::Ok, QMessageBox::Ok,work_thread ); box.exec(); return; } if(false == dir.exists(update_cfg)) { MessageBox box( this, QMessageBox::Critical, MB_Caption, tr("配置文件不存在!"), QMessageBox::Ok, QMessageBox::Ok,work_thread ); box.exec(); return; } MessageBox box( this, QMessageBox::Question, MB_Caption, tr("确定要升级吗?"), QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes,work_thread ); if(box.exec()!=QMessageBox::Yes) return; system("/app/run_update8kw.sh &"); return; } } else if(pb == ui->btn_to_module)//升级软件升级 { QDir dir; if(false == dir.exists("/mnt/usb/Update8kw")) { MessageBox box( this, QMessageBox::Critical, MB_Caption, tr("升级文件不存在!"), QMessageBox::Ok,QMessageBox::Ok,work_thread ); box.exec(); return; } MessageBox box( this, QMessageBox::Question, MB_Caption, tr("确定要升级吗?"), QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes,work_thread ); if(box.exec()!=QMessageBox::Yes) return; system("cp /mnt/usb/Update8kw /app"); if(true == dir.exists("/mnt/usb/Update8kw")) { MessageBox box( this, QMessageBox::Information, MB_Caption, tr("升级成功!"), QMessageBox::Ok,QMessageBox::Ok,work_thread ); box.exec(); return; } else { MessageBox box( this, QMessageBox::Critical, MB_Caption, tr("升级失败!"), QMessageBox::Ok,QMessageBox::Ok,work_thread ); box.exec(); return; } return; } else if(pb == ui->btn_language){ QDir dir; if(false == dir.exists("/app/Language_CN.qm")) { MessageBox box( this, QMessageBox::Critical,MB_Caption, tr("语言文件不存在,请先升级语言文件!"), QMessageBox::Ok,QMessageBox::Ok,work_thread ); box.exec(); return; } MessageBox box( this, QMessageBox::Question,MB_Caption, tr("确定要切换吗?"), QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes,work_thread ); if(box.exec()!=QMessageBox::Yes) return; if(false==dir.exists("/app/china")) system("touch /app/china"); else system("rm /app/china"); system("/app/restart_app.sh &"); return; } } void SysSet_Page::TabChanged(int index) { switch(index) { case 0: break; case 1: break; case 2: break; default:break; } } void SysSet_Page::setIcon() { if(work_thread->iconState.monomerState){ if(work_thread->get_mon_source()==MONO_TYPE_WIRED) { ui->label_MON->setStyleSheet("image: url(:/new/prefix1/1.png);"); } else { if(mon_use_type == 2) ui->label_MON->setStyleSheet("border-image: url(:/new/prefix1/lora_mon.png);"); else ui->label_MON->setStyleSheet("border-image: url(:/new/prefix1/mon.png);"); } } else ui->label_MON->setStyleSheet(""); if(work_thread->iconState.usbState) ui->label_USB->setPixmap(QPixmap(":new/prefix1/usb.png")); else ui->label_USB->setPixmap(QPixmap("")); if(work_thread->iconState.wifiState) ui->label_WIFI->setStyleSheet("border-image: url(:/new/prefix1/wificonnect.png);"); else ui->label_WIFI->setStyleSheet(""); } void SysSet_Page::get_date_time() { qDT = QDateTime::currentDateTime(); if(!edit) { ctDT.year = qDT.date().year()-2000; ctDT.month = qDT.date().month(); ctDT.day = qDT.date().day(); ctDT.hour = qDT.time().hour(); ctDT.minute = qDT.time().minute(); ctDT.second = qDT.time().second(); ui->btn_set_time->setEnabled(false); } else ui->btn_set_time->setEnabled(true); QString dt; dt.sprintf("%04d-%02d-%02d",ctDT.year+2000,ctDT.month,ctDT.day); ui->ledit_date->setText(dt); QString tt; tt.sprintf("%02d:%02d",ctDT.hour,ctDT.minute); ui->ledit_time->setText(tt); QString time; time.sprintf("%04d-%02d-%02d %02d:%02d:%02d",qDT.date().year(),qDT.date().month(),qDT.date().day(), qDT.time().hour(),qDT.time().minute(),qDT.time().second()); ui->label_Time->setText(time); setIcon(); ShowIP(); if(tcp_connect_cnt) --tcp_connect_cnt; if(work_thread->localData.tcp_ctrl.mode) { if(work_thread->localData.tcp_ctrl.Enter_ctrl == 0) { if(!ui->btn_tcp_start->isEnabled() && tcp_connect_cnt == 0) { ui->btn_tcp_start->setEnabled(true); } } } if(Tcp->isConnect()) ui->label_tcp_status->setText(tr("状态:已连接")); else ui->label_tcp_status->setText(tr("状态:未连接")); } void SysSet_Page::set_date_time(CT_DATE_TIME &dt) { QString set_dt; //month/day/hour/minute/year set_dt.sprintf("date %02d%02d%02d%02d%04d.%02d",dt.month,dt.day,dt.hour,dt.minute,(dt.year+2000),dt.second); MessageBox box( this, QMessageBox::Question,MB_Caption, tr("时间设置需重启后生效,确定?"), QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Ok, work_thread); if(box.exec() == QMessageBox::Ok) { customDialog::buzzer_beep(50); system(set_dt.toLocal8Bit().data());//月日时分年.秒 system("hwclock -w"); system("/app/restart_app.sh &"); return; } edit = false; ui->ledit_date->setStyleSheet("color:black"); ui->ledit_time->setStyleSheet("color:black"); } bool SysSet_Page::checkDateText(QString &Chked,CT_DATE_TIME &datetime) { if(Chked.length()<5) return false; if(Chked.contains(QRegExp("[.:]"))) return false; QString year = Chked.section("-",0,0).trimmed(); QString month = Chked.section("-",1,1).trimmed(); QString day = Chked.section("-",2,2).trimmed(); int iy = year.toInt(); int im = month.toInt(); int id = day.toInt(); if(iy<2000 || iy>2200) return false; if(im<1 || im>12) return false; if(id<1 || id>31) return false; datetime.year = iy-2000; datetime.month = im; datetime.day = id; return true; } bool SysSet_Page::checkTimeText(QString &Chked,CT_DATE_TIME &datetime) { if(Chked.length()<3) return false; if(Chked.contains(QRegExp("[.-]"))) return false; QString hour = Chked.section(":",0,0).trimmed(); QString minute = Chked.section(":",1,1).trimmed(); int ih = hour.toInt(); int im = minute.toInt(); if(ih<0 || ih>23) return false; if(im<0 || im>59) return false; datetime.hour = ih; datetime.minute = im; return true; } void SysSet_Page::RecvThreadState(int cmd,int state) { if(work_thread->CMD_SetMonomerAddr == cmd) { if(0 == state) //succeed { qDebug("set addr succeed!"); sysParam.monomer_addrset = tmpaddr; ClassXML::ModifySysParamXml(sysParam); popBox(tr("地址配置成功!")); } else //failed { qDebug("set addr failed"); popBox(tr("地址配置失败!")); } } else if(work_thread->CMD_SetMonomerFre == cmd) { if(0 == state) //succeed { sysParam.monomer_fre = tmpfre; ClassXML::ModifySysParamXml(sysParam); work_thread->sysParam.monomer_fre = tmpfre; // qDebug("tmpfre = %d",tmpfre); // qDebug("set fre succeed!"); } else //failed { qDebug("set fre failed"); ui->ledit_mfreq->setText(QString::number(sysParam.monomer_fre+1)); } } } void SysSet_Page::leditAction() { Custom_LineEdit *le = dynamic_cast(sender()); if(le == ui->ledit_date) { KeyBoard_Num keyboard(this,INPUT_DATE,work_thread); keyboard.setGeometry(430,100,300,350); keyboard.execKeyboard(); DATA_KB_RTN kbdata = keyboard.get_kb_data(); if(kbdata.If_OK) { if(checkDateText(kbdata.set_text,ctDT)) { edit = true; le->setStyleSheet("color:red"); } else { //格式错误 qDebug("format error"); } } } else if(le == ui->ledit_time) { KeyBoard_Num keyboard(this,INPUT_TIME,work_thread); keyboard.setGeometry(430,100,300,350); keyboard.execKeyboard(); DATA_KB_RTN kbdata = keyboard.get_kb_data(); if(kbdata.If_OK) { if(checkTimeText(kbdata.set_text,ctDT)) { edit = true; le->setStyleSheet("color:red"); } else { //格式错误 qDebug("format error"); } } } else if(le == ui->ledit_dsave) { le->setStyleSheet("color:red"); KeyBoard_Num keyboard(this,INPUT_ALLNO,work_thread); keyboard.setGeometry(480,100,300,350); keyboard.execKeyboard(); le->setStyleSheet("color:black"); DATA_KB_RTN kbdata = keyboard.get_kb_data(); if(kbdata.If_OK) { int saveinterval = kbdata.set_text.toInt(); if(saveinterval<1) saveinterval = 1; else if(saveinterval>99) saveinterval = 99; sysParam.save_interval = saveinterval; ui->ledit_dsave->setText(QString::number(sysParam.save_interval)); } } else if(le == ui->ledit_mlow) { if(MONOMER_LOW_STOP == sysParam.monomerlow_act) sysParam.monomerlow_act = MONOMER_LOW_PAUSE; else sysParam.monomerlow_act = MONOMER_LOW_STOP; if(MONOMER_LOW_STOP == sysParam.monomerlow_act) ui->ledit_mlow->setText(tr("停止")); else ui->ledit_mlow->setText(tr("暂停")); } else if(le == ui->ledit_morder) { if(MONOMER_ORDER_POS == sysParam.monomer_order) sysParam.monomer_order = MONOMER_ORDER_NEG; else sysParam.monomer_order = MONOMER_ORDER_POS; if(MONOMER_ORDER_POS == sysParam.monomer_order) ui->ledit_morder->setText(tr("从组端正级递增")); else ui->ledit_morder->setText(tr("从组端负级递增")); } else if(le == ui->ledit_mfreq) { le->setStyleSheet("color:red"); KeyBoard_Num keyboard(this,INPUT_ALLNO,work_thread); keyboard.setGeometry(480,100,300,350); keyboard.execKeyboard(); le->setStyleSheet("color:black"); DATA_KB_RTN kbdata = keyboard.get_kb_data(); if(kbdata.If_OK) { int setfreq = kbdata.set_text.toInt(); if(setfreq<1) setfreq = 1; else if(setfreq>16) setfreq = 16; tmpfre = setfreq-1; // qDebug()<<"修改频段"<setText(QString::number(setfreq)); emit SendSysAddrFre(work_thread->CMD_SetMonomerFre,tmpfre); } } else if(le == ui->ledit_loadplus) { if(LOADER_PLUS_DISEN == sysParam.loader_plusEn) sysParam.loader_plusEn = LOADER_PLUS_ENABLE; else sysParam.loader_plusEn = LOADER_PLUS_DISEN; if(LOADER_PLUS_DISEN == sysParam.loader_plusEn) ui->ledit_loadplus->setText(tr("停用")); else ui->ledit_loadplus->setText(tr("启用")); } else if(le == ui->ledit_maddr) { le->setStyleSheet("color:red"); KeyBoard_Num keyboard(this,INPUT_ALLNO,work_thread); keyboard.setGeometry(480,100,300,350); keyboard.execKeyboard(); le->setStyleSheet("color:black"); DATA_KB_RTN kbdata = keyboard.get_kb_data(); if(kbdata.If_OK) { int setaddr = kbdata.set_text.toInt(); if(setaddr<1) setaddr = 1; else if(setaddr>99) setaddr = 99; tmpaddr = setaddr; le->setText(QString::number(tmpaddr)); } } else if(le == ui->ledit_password) { le->setStyleSheet("color:red"); KeyBoard_Num keyboard(this,INPUT_PW,work_thread); keyboard.setGeometry(500,110,300,350); keyboard.execKeyboard(); le->setStyleSheet("color:black"); DATA_KB_RTN kbdata = keyboard.get_kb_data(); if(kbdata.If_OK) { if("991231" == kbdata.set_text) { this->WidgetHorizontalScroll(ui->widget,1); } else if("881231" == kbdata.set_text) { ui->btn_to_config->setVisible(true); ui->btn_to_welcome->setVisible(true); ui->btn_to_8kwio->setVisible(true); ui->btn_to_module->setVisible(true); ui->btn_language->setVisible(false); ui->label_dz->setVisible(true); this->WidgetHorizontalScroll(ui->widget,1); } // else if("771231" == kbdata.set_text) // { // ui->btn_to_config_log->setVisible(true); // ui->btn_to_config->setVisible(true); // ui->btn_to_welcome->setVisible(true); // ui->btn_to_8kwio->setVisible(true); // ui->btn_to_module->setVisible(true); // ui->btn_language->setVisible(false); // ui->label_dz->setVisible(true); // this->WidgetHorizontalScroll(ui->widget,1); // } else { popBox(tr("密码输入有误,请重新输入!")); } } } else if(le == ui->ledit_ssid || le == ui->ledit_pwd) { QString tmpBName = le->text(); QString origcolor = le->styleSheet(); le->setStyleSheet("color:red"); SyszuxPinyin keyboard(this,le,work_thread); keyboard.exec(); if(le->text() != tmpBName) { if(le == ui->ledit_ssid) wifi_ssid = le->text(); else wifi_pwd = le->text(); } else le->setStyleSheet(origcolor); } else if(le == ui->ledit_tcp_port || le == ui->ledit_tcp_ip) { QString tmpBName = le->text(); QString origcolor = le->styleSheet(); le->setStyleSheet("color:red"); SyszuxPinyin keyboard(this,le,work_thread); keyboard.exec(); if(le->text() != tmpBName) { if(le == ui->ledit_tcp_ip) { sysParam.tcp_ip[0] = le->text().section(".",0,0).toUInt(); sysParam.tcp_ip[1] = le->text().section(".",1,1).toUInt(); sysParam.tcp_ip[2] = le->text().section(".",2,2).toUInt(); sysParam.tcp_ip[3] = le->text().section(".",3,3).toUInt(); } else sysParam.tcp_port = le->text().toUInt(); ui->btn_tcp_start->setEnabled(true); } else le->setStyleSheet(origcolor); } else if(le == ui->ledit_tcp_type) { if(tcp_mode) tcp_mode = 0; else tcp_mode = 1; if(tcp_mode) { ui->ledit_tcp_type->setText(tr("客户端")); ui->ledit_tcp_ip->setEnabled(true); ui->ledit_tcp_port->setEnabled(true); } else { ui->ledit_tcp_type->setText(tr("服务端")); ui->ledit_tcp_ip->setEnabled(false); ui->ledit_tcp_port->setEnabled(false); } ui->ledit_tcp_ip->setStyleSheet("color:black"); ui->ledit_tcp_port->setStyleSheet("color:black"); le->setStyleSheet("color:red"); ui->btn_tcp_start->setEnabled(true); } } //************告警窗口*****************// void SysSet_Page::popBox(QString msg) { MessageBox box( this, QMessageBox::Warning,MB_Caption, msg, QMessageBox::Ok, QMessageBox::Ok, work_thread); box.exec(); } void SysSet_Page::get_wifi_ssid_pwd(void) { int i=0; QFile file("/etc/wpa_supplicant.conf"); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QString str; while (!file.atEnd()) { str = file.readLine(); ++i; if(i == 4) wifi_ssid = str.section("\"",1,1); else if(i == 9) wifi_pwd = str.section("\"",1,1); } file.close(); } } void SysSet_Page::ShowIP(void) { QList entryList; /*if(QNetworkInterface::interfaceFromName("eth0").flags().testFlag(QNetworkInterface::IsRunning)) { if(IP.isEmpty()) { entryList = QNetworkInterface::interfaceFromName("eth0").addressEntries(); } } else if(QNetworkInterface::interfaceFromName("eth1").flags().testFlag(QNetworkInterface::IsRunning)) { if(IP.isEmpty()) { entryList = QNetworkInterface::interfaceFromName("eth1").addressEntries(); } } else */if(QNetworkInterface::interfaceFromName("wlan0").flags().testFlag(QNetworkInterface::IsRunning)) { if(IP.isEmpty()) { entryList = QNetworkInterface::interfaceFromName("wlan0").addressEntries(); } } else { if(!IP.isEmpty()) { IP.clear(); } if(wifi_show_cnt == 0) { ui->btn_connect->setText(tr("连 接")); ui->btn_connect->setEnabled(true); ui->label_IP->setText(tr("网络未连接")); } else { ui->label_IP->setText(tr("网络正在连接...")); if(--wifi_show_cnt == 0) { system("/app/wifi_disconnect.sh"); } } return; } if(IP.isEmpty()) { foreach (QNetworkAddressEntry entry, entryList) { if (entry.ip() != QHostAddress::LocalHost && entry.ip().toIPv4Address()) { IP = entry.ip().toString(); } } } if(IP.isEmpty()) { ui->label_IP->setText(tr("网络正在连接...")); if(wifi_show_cnt) { if(--wifi_show_cnt == 0) { system("/app/wifi_disconnect.sh"); } } } else { ui->btn_connect->setText(tr("断 开")); ui->btn_connect->setEnabled(true); ui->label_IP->setText(tr("IP:")+IP); wifi_show_cnt = 0; } } void SysSet_Page::UpdateInterface(int interface) { if(work_thread->localData.Interface == FACE_ADJ) { adjconf->closeCustom(false); } if(work_thread->localData.Interface == FACE_WELCOMPAGE) { welcomeconf->closeCustom(false); } if(work_thread->localData.Interface == FACE_CONFIGPAGE) { conf->closeCustom(false); } this->closeCustom(false); } void SysSet_Page::on_btn_to_config_log_pressed() { bool SD_Ok = false; SD_Ok = work_thread->CheckDiskState(usbDir); if(false == SD_Ok) { popBox(tr("U盘不存在!")); return; } QDir dir; if(!(dir.exists(usbDir+File_Dir))) { if(false == dir.mkdir(usbDir+File_Dir)) { popBox(tr("创建数据文件夹失败!")); return; } } if (QFile::exists(usbDir+File_Dir+"/"+configFile)) { QFile::remove(usbDir+File_Dir+"/"+configFile); } if (!QFile::copy(dataDir+configFile,usbDir+File_Dir+"/"+configFile)) { popBox(tr("日志导出失败")); } else popBox(tr("日志导出成功")); }