fix(Wifi): Wifilist display incorrectly.

Description: 修复网卡配置中刷新网络列表导致wifi列表显示错误的问题

Log: 修复网卡配置中刷新网络列表导致wifi列表显示错误的问题
Bug: -
This commit is contained in:
zhangjiaping 2021-01-03 10:18:49 +08:00
parent c014e7fe4d
commit bafceffeb8
3 changed files with 31 additions and 7 deletions

View File

@ -96,12 +96,13 @@ IFace* BackThread::execGetIface()
if (istateStr == "unmanaged" || istateStr == "unavailable") { if (istateStr == "unmanaged" || istateStr == "unavailable") {
iface->wstate = 2; //switch of wireless device is off iface->wstate = 2; //switch of wireless device is off
} } else if (istateStr == "disconnected") {
if (istateStr == "disconnected") {
iface->wstate = 1; //wireless network is disconnected iface->wstate = 1; //wireless network is disconnected
} } else if (istateStr == "connected") {
if (istateStr == "connected") {
iface->wstate = 0; //wireless network is connected iface->wstate = 0; //wireless network is connected
} else {
//连接中,正在配置
iface->wstate = 3;
} }
} }
} }

View File

@ -1101,7 +1101,6 @@ void MainWindow::onBtnWifiClicked(int flag)
if (checkWlOn()) { if (checkWlOn()) {
if (flag != 4) { //以防第二张无线网卡插入时断网 if (flag != 4) { //以防第二张无线网卡插入时断网
is_stop_check_net_state = 1; is_stop_check_net_state = 1;
qDebug() << "aaa111";
objKyDBus->setWifiSwitchState(false); objKyDBus->setWifiSwitchState(false);
lbTopWifiList->hide(); lbTopWifiList->hide();
btnAddNet->hide(); btnAddNet->hide();
@ -1287,6 +1286,29 @@ void MainWindow::on_btnWifiList_clicked()
this->startLoading(); this->startLoading();
this->ksnm->execGetWifiList(); this->ksnm->execGetWifiList();
} else if (iface->wstate == 3) { //连接中正在配置wifi设备
btnWireless->setSwitchStatus(true);
lbTopWifiList->show();
btnAddNet->show();
QList<OneConnForm*> topwifis = topWifiListWidget->findChildren<OneConnForm*>();
foreach(OneConnForm* topwifi, topwifis)
{
delete topwifi;
topwifi = NULL;
}
// 当前连接的wifi
OneConnForm *ccf = new OneConnForm(topWifiListWidget, this, confForm, ksnm);
ccf->setName(tr("Not connected"));//"当前未连接任何 Wifi"
ccf->setSignal("0", "--");
ccf->setRate("0");
ccf->setConnedString(1, tr("Disconnected"), "");//"未连接"
ccf->isConnected = false;
ccf->setTopItem(false);
ccf->setAct(true);
ccf->move(L_VERTICAL_LINE_TO_ITEM, 0);
ccf->show();
} else { } else {
btnWireless->setSwitchStatus(false); btnWireless->setSwitchStatus(false);
delete topWifiListWidget; //清空top列表 delete topWifiListWidget; //清空top列表

View File

@ -335,7 +335,8 @@ void WpaWifiDialog::slot_on_connectBtn_clicked() {
appendWifiInfo(nameEditor->text(), eapCombox->currentData().toString(), innerCombox->currentData().toString(), userEditor->text(), askPwdBtn->isChecked()); appendWifiInfo(nameEditor->text(), eapCombox->currentData().toString(), innerCombox->currentData().toString(), userEditor->text(), askPwdBtn->isChecked());
has_config = true; has_config = true;
} }
QString cmdStr = "nmcli connection modify " + nameEditor->text() + " 802-1x.password " + pwdEditor->text(); // QString cmdStr = "nmcli connection modify " + nameEditor->text() + " 802-1x.password " + pwdEditor->text();
QString cmdStr = "nmcli connection modify " + nameEditor->text() + " ipv4.method auto";
int res = Utils::m_system(cmdStr.toUtf8().data()); int res = Utils::m_system(cmdStr.toUtf8().data());
if (res == 0) { if (res == 0) {
//有网络配置文件,密码已修改,接下来修改用户名和其他配置,然后激活连接 //有网络配置文件,密码已修改,接下来修改用户名和其他配置,然后激活连接
@ -410,7 +411,7 @@ void WpaWifiDialog::activateConnection() {
Utils::m_system(cmdStr_2.toUtf8().data()); Utils::m_system(cmdStr_2.toUtf8().data());
syslog(LOG_DEBUG, "execute 'nmcli connection up' in function 'activateConnection' time out"); syslog(LOG_DEBUG, "execute 'nmcli connection up' in function 'activateConnection' time out");
qDebug() << "qDebug: activate time out!"; qDebug() << "qDebug: activate time out!";
qDebug() << "qDebug: 连接超时(12秒超时时间)"; qDebug() << "qDebug: 连接超时(30秒超时时间)";
}); });
//设置超时时间 //设置超时时间
timeout->start(30 * 1000); timeout->start(30 * 1000);