change sleep to qeventloop

This commit is contained in:
jzxc95 2021-10-21 16:36:58 +08:00
parent 3b786d9131
commit b2411b918b
2 changed files with 12 additions and 4 deletions

View File

@ -71,9 +71,9 @@ void DetailPage::setAutoConnect(bool flag)
void DetailPage::getSsid(QString &ssid) void DetailPage::getSsid(QString &ssid)
{ {
if (isCreate) { if (isCreate) {
ssid = mSSIDLabel->text();
} else {
ssid = mSSIDEdit->text(); ssid = mSSIDEdit->text();
} else {
ssid = mSSIDLabel->text();
} }
} }

View File

@ -581,17 +581,21 @@ void NetDetail::initTtlsInfo(ConInfo &conInfo)
//点击了保存更改网络设置的按钮 //点击了保存更改网络设置的按钮
void NetDetail::on_btnConfirm_clicked() void NetDetail::on_btnConfirm_clicked()
{ {
qDebug() << "on_btnConfirm_clicked";
setEnabled(false);
if (m_isCreateNet) { if (m_isCreateNet) {
if (!isWlan) { if (!isWlan) {
//新建有线连接 //新建有线连接
qDebug() << "Confirm create wired connect"; qDebug() << "Confirm create wired connect";
if (!createWiredConnect()) { if (!createWiredConnect()) {
setEnabled(true);
return; return;
} }
} else { } else {
//新建无线连接 //新建无线连接
qDebug() << "Confirm create wireless connect"; qDebug() << "Confirm create wireless connect";
if (!createWirelessConnect()) { if (!createWirelessConnect()) {
setEnabled(true);
return; return;
} }
} }
@ -599,6 +603,7 @@ void NetDetail::on_btnConfirm_clicked()
//更新连接 //更新连接
qDebug() << "Confirm update connect"; qDebug() << "Confirm update connect";
if (!updateConnect()) { if (!updateConnect()) {
setEnabled(true);
return; return;
} }
} }
@ -853,8 +858,11 @@ bool NetDetail::updateConnect()
if (ipv4Change || ipv6Change || securityChange) { if (ipv4Change || ipv6Change || securityChange) {
if (isActive) { if (isActive) {
//信息变化 断开-重连 更新需要時間 不可以立即重連 //信息变化 断开-重连 更新需要時間 不可以立即重連
sleep(1); // sleep(1);
m_wirelessConnOpration->activateConnection(m_uuid, m_deviceName); QEventLoop eventloop;
QTimer::singleShot(1000, &eventloop, SLOT(quit()));
eventloop.exec();
m_wirelessConnOpration->activateConnection(m_uuid, m_deviceName);
} }
} }
return true; return true;