Fix bug show abnormal connected WiFi after sleep and wake-up

This commit is contained in:
chenlelin 2021-01-29 17:19:32 +08:00
parent b77d8de876
commit 0eb0f8a65a
4 changed files with 31 additions and 2 deletions

View File

@ -78,6 +78,7 @@ void KSimpleNM::execGetWifiList()
isUseOldWifiSlist = true;
QStringList slistmEmpty;
slistmEmpty.append("Empty");
//emit requestRevalueUpdateWifi();
emit getWifiListFinished(slistmEmpty);
return;
}

View File

@ -52,6 +52,7 @@ signals:
void getLanListFinished(QStringList slist);
void getWifiListFinished(QStringList slist);
void getConnListFinished(QStringList slist);
void requestRevalueUpdateWifi();
public slots:
void readProcessLan();

View File

@ -92,6 +92,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ksnm, SIGNAL(getLanListFinished(QStringList)), this, SLOT(getLanListDone(QStringList)));
connect(ksnm, SIGNAL(getWifiListFinished(QStringList)), this, SLOT(getWifiListDone(QStringList)));
connect(ksnm, SIGNAL(getConnListFinished(QStringList)), this, SLOT(getConnListDone(QStringList)));
connect(ksnm, SIGNAL(requestRevalueUpdateWifi()), this, SLOT(onRequestRevalueUpdateWifi()));
loading = new LoadingDiv(this);
loading->move(40,0);
@ -651,8 +652,10 @@ void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
IFace *loop_iface = loop_bt->execGetIface();
if (loop_iface->wstate != 2) {
is_update_wifi_list = 1;
this->ksnm->execGetWifiList(); //更新wifi列表
//is_update_wifi_list = 1;
//checkIfConnectedWifiExist();
//this->ksnm->execGetWifiList(); //更新wifi列表
this->on_btnWifiList_clicked(); //加载wifi列表
}
delete loop_iface;
@ -1245,6 +1248,8 @@ void MainWindow::onBtnNetListClicked(int flag)
void MainWindow::on_btnWifiList_clicked()
{
is_stop_check_net_state = 1;
is_update_wifi_list = 0;
this->is_btnWifiList_clicked = 1;
this->is_btnLanList_clicked = 0;
if (this->is_btnLanList_clicked == 1) {
@ -1291,6 +1296,7 @@ void MainWindow::on_btnWifiList_clicked()
btnWireless->setSwitchStatus(true);
lbTopWifiList->show();
btnAddNet->show();
is_stop_check_net_state = 0;
} else {
qDebug()<<"debug: WiFi的开关已经关闭";
btnWireless->setSwitchStatus(false);
@ -1568,6 +1574,13 @@ void MainWindow::getLanListDone(QStringList slist)
is_stop_check_net_state = 0;
}
// 获取wifi列表回调
void MainWindow::onRequestRevalueUpdateWifi()
{
is_stop_check_net_state = 1;
is_update_wifi_list = 0;
}
// 获取wifi列表回调
void MainWindow::getWifiListDone(QStringList slist)
{
@ -2103,6 +2116,17 @@ QString MainWindow::getMacByUuid(QString uuidName)
return resultMac;
}
void MainWindow::checkIfConnectedWifiExist()
{
//在点击托盘图标时判读有无wifi的连接若wstate不为0但是有wifi连接就断开
BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface();
if (iface->wstate != 0) {
QString toDisConnWifi = "nmcli connection down '" + actWifiUuid + "'";
system(toDisConnWifi.toUtf8().data());
}
}
///////////////////////////////////////////////////////////////////////////////
//主窗口其他按钮点击响应

View File

@ -199,6 +199,8 @@ public slots:
void on_showWindowAction();
void checkIfConnectedWifiExist();
protected:
bool eventFilter(QObject *obj, QEvent *event);
void paintEvent(QPaintEvent *event);
@ -306,6 +308,7 @@ private slots:
void onBtnNetListClicked(int flag=0);
void onNewConnAdded(int type);
void onRequestRevalueUpdateWifi();
void getLanListDone(QStringList slist);
void getWifiListDone(QStringList slist);
void getConnListDone(QStringList slist);