Fix bug wifi need connect twice wihthout compare bssid

This commit is contained in:
chenlelin 2021-04-07 20:22:52 +08:00
parent 51ef115902
commit 15d2f30f66
4 changed files with 28 additions and 6 deletions

View File

@ -3630,6 +3630,11 @@ void MainWindow::connWifiDone(int connFlag)
is_stop_check_net_state = 0; is_stop_check_net_state = 0;
} }
void MainWindow::onRequestRefreshWifiList()
{
this->ksnm->execGetWifiList(this->wcardname);
}
//重新绘制背景色 //重新绘制背景色
void MainWindow::paintEvent(QPaintEvent *event) void MainWindow::paintEvent(QPaintEvent *event)
{ {

View File

@ -225,6 +225,7 @@ public slots:
void on_wifi_changed(); void on_wifi_changed();
void connWifiDone(int connFlag); void connWifiDone(int connFlag);
void onRequestRefreshWifiList();
//flag =0或1为普通点击、2为收到打开信息、3为收到关闭信息、4为无线网卡插入、5为无线网卡拔出 //flag =0或1为普通点击、2为收到打开信息、3为收到关闭信息、4为无线网卡插入、5为无线网卡拔出
void onBtnWifiClicked(int flag = 0); void onBtnWifiClicked(int flag = 0);

View File

@ -189,6 +189,8 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
lbNameLyt->addWidget(lbFreq); lbNameLyt->addWidget(lbFreq);
lbNameLyt->addStretch(); lbNameLyt->addStretch();
ui->lbName->setLayout(lbNameLyt); ui->lbName->setLayout(lbNameLyt);
connect(this, SIGNAL(requestRefreshWifiList()), mw, SLOT(onRequestRefreshWifiList()));
} }
OneConnForm::~OneConnForm() OneConnForm::~OneConnForm()
@ -908,13 +910,26 @@ void OneConnForm::slotConnWifiResult(int connFlag)
if (connFlag == 0) { if (connFlag == 0) {
if (mw->isHuaWeiPC) { if (mw->isHuaWeiPC) {
//network-manager可能回连接到其他bssid对应的网络改成我们想要连接的那个网络 //network-manager可能会连接到其他bssid对应的网络改成我们想要连接的那个网络
QFuture < void > future1 = QtConcurrent::run([=]() { QtConcurrent::run([=]() {
QString currConnWifiBssid;
KylinDBus myKylinDbus;
QStringList wifiListInfo;
QList<QString> wifiSsidAndUuid = myKylinDbus.getAtiveWifiBSsidUuid(wifiListInfo);
if (wifiSsidAndUuid.size() > 1 && wifiSsidAndUuid.at(1).length() == 17) {
qDebug() << "想要连接的wifi的bssid是 " << wifiSsidAndUuid.at(1);
currConnWifiBssid = wifiSsidAndUuid.at(1);
}
qDebug() << "实际连接的wifi的bssid是 " << wifiBSsid; qDebug() << "实际连接的wifi的bssid是 " << wifiBSsid;
QString modityCmd = "nmcli connection modify \""+ wifiName + "\" " + "802-11-wireless.bssid " + wifiBSsid; if (currConnWifiBssid != wifiBSsid && !currConnWifiBssid.isEmpty()) {
system(modityCmd.toUtf8().data()); QString modityCmd = "nmcli connection modify \""+ wifiName + "\" " + "802-11-wireless.bssid " + wifiBSsid;
QString reconnectWifiCmd = "nmcli connection up \"" + wifiName + "\""; system(modityCmd.toUtf8().data());
system(reconnectWifiCmd.toUtf8().data()); QString reconnectWifiCmd = "nmcli connection up \"" + wifiName + "\"";
system(reconnectWifiCmd.toUtf8().data());
} else {
emit requestRefreshWifiList();
}
}); });
} }

View File

@ -150,6 +150,7 @@ signals:
void selectedOneWifiForm(QString wifiName, int extendLength); void selectedOneWifiForm(QString wifiName, int extendLength);
void connDone(int connFlag); void connDone(int connFlag);
void disconnActiveWifi(); void disconnActiveWifi();
void requestRefreshWifiList();
void sigConnWifi(QString); void sigConnWifi(QString);
void sigConnWifiPWD(QString, QString, QString); void sigConnWifiPWD(QString, QString, QString);