diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1c803ca1..0cab3e11 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1381,7 +1381,7 @@ void MainWindow::on_btnWifiList_clicked() // 当前连接的wifi OneConnForm *ccf = new OneConnForm(topWifiListWidget, this, confForm, ksnm); ccf->setWifiName(tr("Not connected"), "--", "--", "--", isHuaWeiPC);//"当前未连接任何 Wifi" - ccf->setSignal("0", "--"); + ccf->setSignal("0", "--", "0"); ccf->setRate("0"); ccf->setConnedString(1, tr("Disconnected"), "");//"未连接" ccf->isConnected = false; @@ -1710,12 +1710,14 @@ void MainWindow::getWifiListDone(QStringList slist) slist = priorityList(slist); + if (isHuaWeiPC) { if (slist.size() >= 2) { wifiListOptimize(slist); -// getFinalWifiList(slist); + //getFinalWifiList(slist); } } + if (current_wifi_list_state == RECONNECT_WIFI) { QVector targetWifiStructList = connectableWifiPriorityList(slist); if (!targetWifiStructList.isEmpty()) { @@ -1850,7 +1852,7 @@ QStringList MainWindow::priorityList(QStringList slist){ QStringList ret; ret.append(slist[0]); QString headLine = slist.at(0); - int indexSignal,indexSecu, indexFreq, indexBSsid, indexName,indexPath,indexCate; + int indexSignal,indexSecu, indexFreq, indexBSsid, indexName, indexPath, indexCate; headLine = headLine.trimmed(); bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+")); if (isChineseExist) { @@ -1892,9 +1894,7 @@ QStringList MainWindow::priorityList(QStringList slist){ list = sortApByFreq(list,indexFreq, indexSignal); ret += list; } - foreach (QString s, ret) { - qDebug()< MainWindow::repetitionFilter(QVector){ QVector ret; return ret; } + QStringList MainWindow::sortApByCategory(QStringList list,int cateIndex){ QStringList ret; for(auto line:list){ @@ -1957,16 +1958,16 @@ QStringList MainWindow::sortApByCategory(QStringList list,int cateIndex){ } return ret; } + //进行wifi列表优化选择,分为2.4G和5G进行选择,先每种频率形成一个列表 //同一个列表中同名wifi只有一个,再按信号强度由大到小合并列表 void MainWindow::wifiListOptimize(QStringList& slist) { - if(slist.size() < 2) return ; - //这个函数可能会把已经连接的那个wifi给筛选出去 - QString headLine = slist.at(0); - int indexSignal,indexSecu, indexFreq, indexBSsid, indexName,indexPath; - headLine = headLine.trimmed(); + if (slist.size() < 2) return ; + QString headLine = slist.at(0); + int indexSignal, indexSecu, indexFreq, indexBSsid, indexName, indexPath; + headLine = headLine.trimmed(); bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+")); if (isChineseExist) { indexSignal = headLine.indexOf("SIGNAL"); @@ -1983,37 +1984,68 @@ void MainWindow::wifiListOptimize(QStringList& slist) indexName = indexBSsid + 19; indexPath = headLine.indexOf("DBUS-PATH"); } + QStringList targetList; //slist优化,同名同频AP中只留信号最强 targetList<= 5000 && freq >= 5000){ - if(conSignal < signal){ + if (conFreq >= 5000 && freq >= 5000) { + if (conSignal < signal) { ifContinue = true; break; } } } } - if(ifContinue) continue; - targetList<setWifiName(tr("Not connected"), "--", "--", "--", isHuaWeiPC);//"当前未连接任何 Wifi" - ccf->setSignal("0", "--"); + ccf->setSignal("0", "--" , "0"); activeWifiSignalLv = 0; ccf->setConnedString(1, tr("Disconnected"), "");//"未连接" ccf->isConnected = false; @@ -2344,11 +2383,11 @@ void MainWindow::loadWifiListDone(QStringList slist) continue; //过滤相同名称的wifi } } else { - if ((actWifiName == wname) && actWifiBssidList.size()>=1) { - //防止列表中没有已经连接的那个wifi - wbssid = actWifiBssidList.at(0); - actWifiBssid = actWifiBssidList.at(0); - } +// if ((actWifiName == wname) && actWifiBssidList.size()>=1) { +// //防止列表中没有已经连接的那个wifi +// wbssid = actWifiBssidList.at(0); +// actWifiBssid = actWifiBssidList.at(0); +// } if ((wnames.contains(wname) && wbssid != actWifiBssid)) { continue; //过滤相同名称的wifi } @@ -2384,8 +2423,9 @@ void MainWindow::loadWifiListDone(QStringList slist) freqState = 2; } if (wname != "" && wname != "--") { + //qDebug() << "wifi的 actWifiBssid: " << actWifiBssid << " wcate = " << wcate; //qDebug() << "wifi的 bssid: " << wbssid << "当前连接的wifi的bssid: " << actWifiBssidList; - if(actWifiBssid == wbssid && wifiActState == 2){ + if(actWifiBssid == wbssid && wifiActState == 2) { //对于已经连接的wifi connect(this, &MainWindow::actWifiSignalLvChanaged, ccf, [ = ](const int &signalLv) { ccf->setSignal(QString::number(signalLv), wsecu, wcate); @@ -2419,7 +2459,7 @@ void MainWindow::loadWifiListDone(QStringList slist) signal = ccf->getSignal(); else signal = wsignal.toInt() + 11; - ccf->setSignal(QString::number(signal), wsecu); + ccf->setSignal(QString::number(signal), wsecu, wcate); setTrayIconOfWifi(wsignal.toInt()); activeWifiSignalLv = wsignal.toInt(); //objKyDBus->getWifiMac(wname); @@ -3338,7 +3378,7 @@ void MainWindow::disWifiDoneChangeUI() if (ocf->isActive == true) { ocf->setSelected(false, false); ocf->setWifiName(tr("Not connected"), "--", "--", "--", isHuaWeiPC);//"当前未连接任何 Wifi" - ocf->setSignal("0", "--"); + ocf->setSignal("0", "--", "0"); ocf->setConnedString(1, tr("Disconnected"), "");//"未连接" ocf->lbFreq->hide(); lbLoadDown->hide(); diff --git a/src/mainwindow.h b/src/mainwindow.h index dccdee1a..b903cb93 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -347,6 +347,8 @@ private: QString actWifiSsid = "--"; //当前连接wifi的ssid QStringList actWifiBssidList; //当前连接wifi的bssid QString actWifiUuid = "--"; //当前连接wifi的uuid + QString hasStarWifiInfo; //nmcli命令获取的wifi列表中已经连接的wifi in-use熟悉会有一个* + QString hasStarWifiName; bool hasWifiConnected;//当前是否有wifi连接 QDBusInterface *mDbusXrandInter;