qt/LedOK/wDevicesManager/specialdlg.cpp
2022-01-04 18:11:48 +08:00

83 lines
2.9 KiB
C++

#include "specialdlg.h"
#include "ui_specialdlg.h"
#include "LoUIClass/loemptydialog.h"
#include <globaldefine.h>
#include <LoUIClass/x_uimsgboxok.h>
SpecialDlg::SpecialDlg(QWidget *parent,NetComm *p) :
LoQDialog(parent),
ui(new Ui::SpecialDlg)
{
ui->setupUi(this);
pNetComm = p;
m_pStackedW = new QStackedWidget;
m_pSubSpecifyIp = new SubSpecifyIp(this);
m_pSubSpecifyIpRange = new SubSpecifyIpRange(this);
m_pStackedW->addWidget(m_pSubSpecifyIp);
m_pStackedW->addWidget(m_pSubSpecifyIpRange);
// ui->HLayout_IP_widget->addStretch(1);
ui->HLayout_IP_widget->addWidget(m_pStackedW);
// ui->HLayout_IP_widget->addStretch();
ui->RadioButtonGroup->setId(ui->radioSpecifyIpButton, 0);
ui->RadioButtonGroup->setId(ui->radioSpecifyIpRangeButton, 1);
ui->radioSpecifyIpButton->setVisible(false);
ui->radioSpecifyIpRangeButton->setVisible(false);
//绑定信号和槽函数
connect(ui->RadioButtonGroup,SIGNAL(buttonClicked(int)),m_pStackedW, SLOT(setCurrentIndex(int)));
connect( ui->bnSearch,SIGNAL(clicked()),this,SLOT(OnSearch()));
}
SpecialDlg::~SpecialDlg()
{
delete m_pSubSpecifyIp;
delete m_pSubSpecifyIpRange;
delete ui;
}
void SpecialDlg::OnSearch()
{
int iIndex= ui->RadioButtonGroup->checkedId();
if(iIndex==0)//获取到的
{
QString strTempIp=m_pSubSpecifyIp->getIp();
if(strTempIp=="...")
{
X_UIMsgBoxOk *dlg = new X_UIMsgBoxOk(tr("Attention"), tr("Please input IP address!"), this,0);
dlg->exec();
return;
}
else
{
if (!isTextValid(strTempIp))
{
//QMessageBox::warning(this, tr("Attention"), tr("Your IP Address is Invalid!"), QMessageBox::StandardButton::Ok);
X_UIMsgBoxOk *dlg = new X_UIMsgBoxOk(tr("Attention"), tr("Your IP Address is Invalid!"), this,0);
dlg->exec();
return;
}
}
pNetComm->CheckSpecifyIp(strTempIp);
LoEmptyDialog * pDlg = new LoEmptyDialog(this);
pDlg->lock(tr("Search")+"...",tr("Success"),tr("Can't find this device IP"));
connect(pNetComm, SIGNAL(sigGetSpecifyIpResponse(LedCard *)), pDlg, SLOT(close()));//显示正在保存提示对话框
// connect(pNetComm, SIGNAL(sigGetSpecifyIpResponse(LedCard *)), pDlg, SLOT(unlock()));//显示正在保存提示对话框
connect(pNetComm, SIGNAL(sigGetSpecifyIpTimerOut()), pDlg, SLOT(TimerOutUnlock()));//显示正在保存提示对话框
connect(pNetComm, SIGNAL(sigGetSpecifyIpResponse(LedCard *)), this, SLOT(OnGetSpecialIp(LedCard *)));//收到指定ip应答立即关闭本对话框
pDlg->exec();
}
else if(iIndex==1)
{
pNetComm->CheckSpecifyIpRange("","");
}
}
void SpecialDlg::OnGetSpecialIp(LedCard *p)
{
emit sigGetSpecialIp(p);
close();
}