Merge master from 9a0 branch

This commit is contained in:
andrew-wuhan-huawei-990-pc 2021-04-20 11:53:00 +08:00
parent 65f6d73c7a
commit 234e12f040
16 changed files with 141 additions and 46 deletions

View File

@ -89,5 +89,15 @@
<file>res/w/wifi6-medium.png</file>
<file>res/w/wifi6-none.png</file>
<file>res/w/wifi6-null-pwd.png</file>
<file>res/w/wifi6+-none.png</file>
<file>res/w/wifi6+-meidum-pwd.png</file>
<file>res/w/wifi6+-medium.png</file>
<file>res/w/wifi6+-medium-pwd.png</file>
<file>res/w/wifi6+-low.png</file>
<file>res/w/wifi6+-low-pwd.png</file>
<file>res/w/wifi6+-high.png</file>
<file>res/w/wifi6+-high-pwd.png</file>
<file>res/w/wifi6+-full.png</file>
<file>res/w/wifi6+-full-pwd.png</file>
</qresource>
</RCC>

BIN
res/w/wifi6+-full-pwd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 B

BIN
res/w/wifi6+-full.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 732 B

BIN
res/w/wifi6+-high-pwd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B

BIN
res/w/wifi6+-high.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

BIN
res/w/wifi6+-low-pwd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 806 B

BIN
res/w/wifi6+-low.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 775 B

BIN
res/w/wifi6+-medium-pwd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 B

BIN
res/w/wifi6+-medium.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

BIN
res/w/wifi6+-meidum-pwd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B

BIN
res/w/wifi6+-none.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 759 B

View File

@ -89,7 +89,7 @@ void KSimpleNM::execGetWifiList(const QString& wname)
if (wname.isEmpty() || wname == "") {
cmd = "nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path device wifi";
} else {
cmd = "nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path device wifi list ifname " + wname;
cmd = "nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path,category device wifi list ifname " + wname;
}
runProcessWifi->start(cmd);
}

View File

@ -1675,12 +1675,6 @@ void MainWindow::onRequestRevalueUpdateWifi()
// 获取wifi列表回调
void MainWindow::getWifiListDone(QStringList slist)
{
//qDebug()<<"------------";
//foreach (QString str, slist) {
// qDebug()<<str;
//}
//qDebug()<<"------------";
//要求使用上一次获取到的列表
if (this->ksnm->isUseOldWifiSlist) {
slist = oldWifiSlist;
@ -1696,19 +1690,12 @@ void MainWindow::getWifiListDone(QStringList slist)
}
}
//若slist为空则使用上一次获取到的列表
//if (slist.size() == 1 && slist.at(0) == "") {
// if (oldWifiSlist.size() == 1 && oldWifiSlist.at(0) == "") {
// return;
// } else {
// slist = oldWifiSlist;
// }
//}
slist = priorityList(slist);
if (isHuaWeiPC) {
if (slist.size() >= 2) {
wifiListOptimize(slist);
getFinalWifiList(slist);
// getFinalWifiList(slist);
}
}
@ -1732,7 +1719,6 @@ void MainWindow::getWifiListDone(QStringList slist)
if (this->is_btnLanList_clicked == 1) {
return;
}
if (current_wifi_list_state == LOAD_WIFI_LIST) {
//qDebug() << "loadwifi的列表";
loadWifiListDone(slist);
@ -1752,11 +1738,9 @@ void MainWindow::getWifiListDone(QStringList slist)
void MainWindow::getConnListDone(QStringList slist)
{
if (isInitConnList) {
// oldConnSlist = slist;
for (int i = 1; i < slist.length() - 1; i++) {
oldConnSlist << slist.at(i).trimmed();
}
// qDebug()<<oldConnSlist;
isInitConnList = false;
return;
} else {
@ -1785,11 +1769,96 @@ void MainWindow::getConnListDone(QStringList slist)
return;
}
}
QStringList MainWindow::priorityList(QStringList slist){
QStringList ret;
ret.append(slist[0]);
QString headLine = slist.at(0);
int indexSignal,indexSecu, indexFreq, indexBSsid, indexName,indexPath,indexCate;
headLine = headLine.trimmed();
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
if (isChineseExist) {
indexSignal = headLine.indexOf("SIGNAL");
indexSecu = headLine.indexOf("安全性");
indexFreq = headLine.indexOf("频率") + 4;
indexBSsid = headLine.indexOf("BSSID") + 6;
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
indexCate = headLine.indexOf("CATEGORY");
} else {
indexSignal = headLine.indexOf("SIGNAL");
indexSecu = headLine.indexOf("SECURITY");
indexFreq = headLine.indexOf("FREQ");
indexBSsid = headLine.indexOf("BSSID");
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
indexCate = headLine.indexOf("CATEGORY");
}
QStringList p1,p2,p3,p4,p5,p6,p7;//按照信号与频段划分为6个列表
for(int i=1;i<slist.size();i++){
QString line = slist.at(i);
int conSignal = line.mid(indexSignal,3).trimmed().toInt();
int conFreq = line.mid(indexFreq,4).trimmed().toInt();
if(conSignal > 75 && conFreq >= 5000){
p1.append(line);
continue;
}else if(conSignal > 55 && conFreq >= 5000){
p2.append(line);
continue;
}else if(conSignal > 75){
p3.append(line);
continue;
}else if(conSignal > 55){
p4.append(line);
continue;
}else if(conSignal > 35){
p5.append(line);
continue;
}else if(conSignal > 15){
p6.append(line);
continue;
}else{
p7.append(line);
}
}
QVector<QStringList> listVec;
listVec<<p1<<p2<<p3<<p4<<p5<<p6<<p7;
for(auto list:listVec){
list = sortApByCategory(list,indexCate);
ret += list;
}
return ret;
}
QVector<QStringList> MainWindow::repetitionFilter(QVector<QStringList>){
QVector<QStringList> ret;
return ret;
}
QStringList MainWindow::sortApByCategory(QStringList list,int cateIndex){
QStringList ret;
for(auto line:list){
int conCate = line.mid(cateIndex).trimmed().toInt();
if(conCate == 2){
ret.append(line);
}
}
for(auto line:list){
int conCate = line.mid(cateIndex).trimmed().toInt();
if(conCate == 1){
ret.append(line);
}
}
for(auto line:list){
int conCate = line.mid(cateIndex).trimmed().toInt();
if(conCate == 0){
ret.append(line);
}
}
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;
@ -1811,7 +1880,6 @@ void MainWindow::wifiListOptimize(QStringList& slist)
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
}
QStringList targetList; //slist优化同名同频AP中只留信号最强
targetList<<slist.at(0); //把第一行加进去
for(int it = 1;it < slist.size();it++){
@ -1850,11 +1918,9 @@ void MainWindow::wifiListOptimize(QStringList& slist)
void MainWindow::getFinalWifiList(QStringList &slist)
{
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");
@ -1909,7 +1975,6 @@ void MainWindow::getFinalWifiList(QStringList &slist)
}
}
}
foreach (QString deleteStr, deleteWifiStr) {
slist.removeOne(deleteStr);
}
@ -1921,7 +1986,7 @@ QList<structWifiProperty> MainWindow::connectableWifiPriorityList(const QStringL
if(slist.size()<2) return selectedWifiListStruct;
OneConnForm *ocf = new OneConnForm();
QString headLine = slist.at(0);
int indexSignal,indexSecu, indexFreq, indexBSsid, indexName, indexPath;
int indexSignal,indexSecu, indexFreq, indexBSsid, indexName, indexPath,indexCate;
headLine = headLine.trimmed();
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
@ -1932,6 +1997,7 @@ QList<structWifiProperty> MainWindow::connectableWifiPriorityList(const QStringL
indexBSsid = headLine.indexOf("BSSID") + 6;
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
indexCate = headLine.indexOf("CATEGORY");
} else {
indexSignal = headLine.indexOf("SIGNAL");
indexSecu = headLine.indexOf("SECURITY");
@ -1939,6 +2005,7 @@ QList<structWifiProperty> MainWindow::connectableWifiPriorityList(const QStringL
indexBSsid = headLine.indexOf("BSSID");
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
indexCate = headLine.indexOf("CATEGORY");
}
QStringList tmp = slist;
@ -1946,7 +2013,7 @@ QList<structWifiProperty> MainWindow::connectableWifiPriorityList(const QStringL
QString line = tmp.at(iter);
QString wifiname = line.mid(indexName,indexPath - indexName).trimmed();
QString wifibssid = line.mid(indexBSsid, indexName-indexBSsid).trimmed();
QString wifiObjectPath = line.mid(indexPath).trimmed();
QString wifiObjectPath = line.mid(indexPath,indexCate-indexPath).trimmed();
QString wifiAutoConnection;
QString wifiPriority;
@ -1989,7 +2056,6 @@ QList<structWifiProperty> MainWindow::connectableWifiPriorityList(const QStringL
qDebug() << "-----------------------> 排序后" << wifiPriorityAfterSort.priority;
}
}
ocf->deleteLater();
return selectedWifiListStruct;
}
@ -2009,7 +2075,6 @@ void MainWindow::loadWifiListDone(QStringList slist)
{
delete topWifiListWidget; //清空top列表
createTopWifiUI(); //创建topWifiListWidget
// 清空wifi列表
wifiListWidget = new QWidget(scrollAreaw);
wifiListWidget->resize(W_LIST_WIDGET, H_WIFI_ITEM_BIG_EXTEND);
@ -2097,7 +2162,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
// 填充可用网络列表
QString headLine = slist.at(0);
int indexSignal,indexSecu, indexFreq, indexBSsid, indexName, indexPath;
int indexSignal,indexSecu, indexFreq, indexBSsid, indexName, indexPath, indexCate;
headLine = headLine.trimmed();
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
@ -2108,6 +2173,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
indexBSsid = headLine.indexOf("BSSID") + 6;
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
indexCate = headLine.indexOf("CATEGORY");
} else {
indexSignal = headLine.indexOf("SIGNAL");
indexSecu = headLine.indexOf("SECURITY");
@ -2115,6 +2181,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
indexBSsid = headLine.indexOf("BSSID");
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
indexCate = headLine.indexOf("CATEGORY");
}
QStringList wnames;
int count = 0;
@ -2128,7 +2195,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
actWifiName = wname;
}
if ("*" == line.mid(0,indexSignal).trimmed()) {
//在华为的电脑中,因为前面的优选工作,及时有已经连接的wifi也可能会被筛选出去
//在华为的电脑中,因为前面的优选工作,即使有已经连接的wifi也可能会被筛选出去
actWifiBssid = wbssid;
}
}
@ -2144,6 +2211,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
QString wbssid = line.mid(indexBSsid, 17).trimmed();
QString wname = line.mid(indexName, indexPath - indexName).trimmed();
QString wfreq = line.mid(indexFreq, 4).trimmed();
QString wcate = line.mid(indexCate).trimmed();
if (!isHuaWeiPC) {
//如果不是华为的电脑选择wifi在这里执行
@ -2161,6 +2229,9 @@ void MainWindow::loadWifiListDone(QStringList slist)
wbssid = actWifiBssidList.at(0);
actWifiBssid = actWifiBssidList.at(0);
}
if ((wnames.contains(wname) && wbssid != actWifiBssid)) {
continue; //过滤相同名称的wifi
}
}
int max_freq = wfreq.toInt();
@ -2248,7 +2319,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
}
//ocf->setRate(wrate);
ocf->setLine(true);
ocf->setSignal(wsignal, wsecu);
ocf->setSignal(wsignal, wsecu, wcate);
//objKyDBus->getWifiMac(wname);
ocf->setWifiInfo(wsecu, wsignal, wbssid, freqState);
ocf->setConnedString(0, tr("Disconnected"), wsecu);
@ -2326,7 +2397,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
}
QString headLine = slist.at(0);
int indexSecu, indexFreq, indexBSsid, indexName, indexPath;
int indexSecu, indexFreq, indexBSsid, indexName, indexPath, indexCate;
headLine = headLine.trimmed();
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
if (isChineseExist) {
@ -2336,6 +2407,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
//indexName = headLine.indexOf("SSID") + 6;
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
indexCate= headLine.indexOf("CATEGORY");
} else {
indexSecu = headLine.indexOf("SECURITY");
indexFreq = headLine.indexOf("FREQ");
@ -2343,6 +2415,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
//indexName = headLine.indexOf("SSID");
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
indexCate = headLine.indexOf("CATEGORY");
}
//列表中去除已经减少的wifi
@ -2388,6 +2461,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
QString wbssid = line.mid(indexBSsid, 17).trimmed();
QString wname = line.mid(indexName, indexPath - indexName).trimmed();
QString wfreq = line.mid(indexFreq, 4).trimmed();
QString wcate =line.mid(indexCate).trimmed();
if(wname == "" || wname == "--"){continue;}
@ -2454,7 +2528,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
}
//addItem->setRate(wrate);
addItem->setLine(false);
addItem->setSignal(wsignal, wsecu);
addItem->setSignal(wsignal, wsecu, wcate);
//objKyDBus->getWifiMac(wname);
addItem->setWifiInfo(wsecu, wsignal, wbssid, freqState);
addItem->setConnedString(0, tr("Disconnected"), wsecu);//"未连接"

View File

@ -313,7 +313,10 @@ private:
QString lastAddedConn = "";
QString oldActLanName = ""; //上一次获取的已连接有线网名称
int oldDbusActLanDNS = 0; //上一次获取的已连接有线网的DNS代号
void wifiListOptimize(QStringList& slist); //只保留同名同频信号最强AP
void wifiListOptimize(QStringList& slist); //只保留同名同频信号最优AP
QVector<QStringList> repetitionFilter(QVector<QStringList>);
QStringList priorityList(QStringList);
QStringList sortApByCategory(QStringList,int);
void getFinalWifiList(QStringList& slist); //获取应该显示在wifi列表中的最优列表参数
QList<structWifiProperty> connectableWifiPriorityList(const QStringList slist); //可连接wifi优先级列表
void devListSort(QList<structWifiProperty> *list);

View File

@ -434,7 +434,7 @@ void OneConnForm::setLine(bool isShow)
}
}
void OneConnForm::setSignal(QString lv, QString secu)
void OneConnForm::setSignal(QString lv, QString secu, QString category)
{
int signal = lv.toInt();
if (secu == "--" || secu == "") {
@ -442,47 +442,54 @@ void OneConnForm::setSignal(QString lv, QString secu)
} else {
hasPwd = true;
}
QString signalStyle = "QLabel{border-radius:0px;background:url(:/res/w/wifi";
if("1" == category){
signalStyle += "6";
}else if("2" == category){
signalStyle += "6+";
}
if (signal > 75) {
if (hasPwd) {
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-full-pwd.png);}");
signalStyle += "-full-pwd.png);}";
} else {
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-full.png);}");
signalStyle += "-full.png);}";
}
signalLv = 1;
}
if (signal > 55 && signal <= 75) {
if (hasPwd) {
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-high-pwd.png);}");
signalStyle += "-high-pwd.png);}";
} else {
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-high.png);}");
signalStyle += "-high.png);}";
}
signalLv = 2;
}
if (signal > 35 && signal <= 55) {
if (hasPwd) {
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-medium-pwd.png);}");
signalStyle += "-medium-pwd.png);}";
} else {
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-medium.png);}");
signalStyle += "-medium.png);}";
}
signalLv = 3;
}
if (signal > 15 && signal <= 35) {
if (hasPwd) {
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-low-pwd.png);}");
signalStyle += "-low-pwd.png);}";
} else {
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-low.png);}");
signalStyle += "-low.png);}";
}
signalLv = 4;
}
if (signal <= 15) {
if (hasPwd) {
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-none-pwd.png);}");
signalStyle += "-none-pwd.png);}";
} else {
ui->lbSignal->setStyleSheet("QLabel{border-radius:0px;background:url(:/res/w/wifi-none.png);}");
signalStyle += "-none.png);}";
}
signalLv = 4;
}
ui->lbSignal->setStyleSheet(signalStyle);
}
void OneConnForm::setWifiInfo(QString str1, QString str2, QString str3, int freq)

View File

@ -64,7 +64,8 @@ public:
explicit OneConnForm(QWidget *parent = 0, MainWindow *mw = 0, ConfForm *confForm = 0, KSimpleNM *ksnm = 0);
~OneConnForm();
void setSignal(QString lv, QString secu);
// category:1->normal protocol 1->wifi 6 2->wifi 6+
void setSignal(QString lv, QString secu,QString category = "0");
void setName(QString name, QString bssid, QString uuid, QString isname);
QString getName();
void setRate(QString rate);