From 0fd8171d3f7a277bb6f331127757fa233d377105 Mon Sep 17 00:00:00 2001 From: chenlelin Date: Tue, 22 Jun 2021 10:52:43 +0800 Subject: [PATCH] ix bug-58766 show zero value of wifi signal strength --- src/mainwindow.cpp | 17 +++++++---------- src/oneconnform.cpp | 30 +++++++++--------------------- src/oneconnform.h | 2 +- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7a98e83c..3b024498 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -34,7 +34,6 @@ #include QString llname, lwname, hideWiFiConn; -int currentActWifiSignalLv, count_loop; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -87,8 +86,6 @@ void MainWindow::firstlyStart() llname = "-1"; lwname = "-1"; hideWiFiConn = "Connect to Hidden WLAN Network"; - currentActWifiSignalLv = -1; - count_loop = 0; createTrayIcon(); connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::iconActivated); @@ -1613,7 +1610,7 @@ void MainWindow::on_btnWifiList_clicked() // 当前连接的wifi OneConnForm *ccf = new OneConnForm(topWifiListWidget, this, confForm, ksnm); ccf->setWifiName(tr("Not connected"), "--", "--", "--", isHuaWeiPC, isHuaWei9006C);//"当前未连接任何 Wifi" - ccf->setSignal("0", "--", "0"); + ccf->setSignal("0", "--", "0", false); ccf->setRate("0"); ccf->setConnedString(1, tr("Disconnected"), "");//"未连接" ccf->isConnected = false; @@ -2681,7 +2678,7 @@ void MainWindow::loadWifiListDone(QStringList slist) OneConnForm *ccf = new OneConnForm(topWifiListWidget, this, confForm, ksnm); if (actWifiName == "--" || wifiActState == 1 || actWifiBssidList.at(0) == "--" || actWifiBssid == " ") { ccf->setWifiName(tr("Not connected"), "--", "--", "--", isHuaWeiPC, isHuaWei9006C);//"当前未连接任何 Wifi" - ccf->setSignal("0", "--" , "0"); + ccf->setSignal("0", "--" , "0", false); activeWifiSignalLv = 0; ccf->setConnedString(1, tr("Disconnected"), "");//"未连接" ccf->isConnected = false; @@ -2801,7 +2798,7 @@ void MainWindow::loadWifiListDone(QStringList slist) if (actWifiBssid == wbssid && wifiActState == 2) { //对于已经连接的wifi connect(this, &MainWindow::actWifiSignalLvChanaged, ccf, [ = ](const int &signalLv) { - ccf->setSignal(QString::number(signalLv), wsecu, wcate); + ccf->setSignal(QString::number(signalLv), wsecu, wcate, true); }); connect(ccf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneTopWifiFormSelected(QString,int))); connect(ccf, SIGNAL(requestHandleWifiDisconn()), this, SLOT(handleWifiDisconn())); @@ -2837,7 +2834,7 @@ void MainWindow::loadWifiListDone(QStringList slist) signal = ccf->getSignal(); else signal = wsignal.toInt() + 11; - ccf->setSignal(QString::number(signal), wsecu, wcate); + ccf->setSignal(QString::number(signal), wsecu, wcate, true); setTrayIconOfWifi(wsignal.toInt()); activeWifiSignalLv = wsignal.toInt(); //objKyDBus->getWifiMac(wname); @@ -2892,7 +2889,7 @@ void MainWindow::loadWifiListDone(QStringList slist) } //ocf->setRate(wrate); ocf->setLine(true); - ocf->setSignal(wsignal, wsecu, wcate); + ocf->setSignal(wsignal, wsecu, wcate, true); //objKyDBus->getWifiMac(wname); ocf->setWifiInfo(wsecu, wsignal, wbssid, freqState); ocf->setConnedString(0, tr("Disconnected"), wsecu); @@ -3126,7 +3123,7 @@ void MainWindow::updateWifiListDone(QStringList slist) } //addItem->setRate(wrate); addItem->setLine(false); - addItem->setSignal(wsignal, wsecu, wcate); + addItem->setSignal(wsignal, wsecu, wcate, true); //objKyDBus->getWifiMac(wname); addItem->setWifiInfo(wsecu, wsignal, wbssid, freqState); addItem->setConnedString(0, tr("Disconnected"), wsecu);//"未连接" @@ -3808,7 +3805,7 @@ void MainWindow::disWifiDoneChangeUI() if (ocf->isActive == true) { ocf->setSelected(false, false); ocf->setWifiName(tr("Not connected"), "--", "--", "--", isHuaWeiPC, isHuaWei9006C);//"当前未连接任何 Wifi" - ocf->setSignal("0", "--", "0"); + ocf->setSignal("0", "--", "0", false); ocf->setConnedString(1, tr("Disconnected"), "");//"未连接" ocf->lbFreq->hide(); lbLoadDown->hide(); diff --git a/src/oneconnform.cpp b/src/oneconnform.cpp index a8b82acc..3b81caaf 100644 --- a/src/oneconnform.cpp +++ b/src/oneconnform.cpp @@ -34,8 +34,6 @@ #include #include -extern int currentActWifiSignalLv; - OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *confForm, KSimpleNM *ksnm) : QWidget(parent), ui(new Ui::OneConnForm) @@ -531,7 +529,7 @@ void OneConnForm::setLine(bool isShow) } } -void OneConnForm::setSignal(QString lv, QString secu, QString category) +void OneConnForm::setSignal(QString lv, QString secu, QString category, bool hasSignalStrength) { this->m_signal = lv.toInt(); int signal = lv.toInt(); @@ -562,7 +560,6 @@ void OneConnForm::setSignal(QString lv, QString secu, QString category) } else { signalStyle += "-full.png);}"; } - signalLv = 1; } if (signal > 55 && signal <= 75) { if (hasPwd) { @@ -570,7 +567,6 @@ void OneConnForm::setSignal(QString lv, QString secu, QString category) } else { signalStyle += "-high.png);}"; } - signalLv = 2; } if (signal > 35 && signal <= 55) { if (hasPwd) { @@ -578,24 +574,19 @@ void OneConnForm::setSignal(QString lv, QString secu, QString category) } else { signalStyle += "-medium.png);}"; } - signalLv = 3; } - if (signal > 15 && signal <= 35) { - if (hasPwd) { - signalStyle += "-low-pwd.png);}"; - } else { - signalStyle += "-low.png);}"; - } - signalLv = 4; - } - if (signal <= 15) { - if (hasPwd) { - signalStyle += "-none-pwd.png);}"; + if (signal <= 35) { + if (hasSignalStrength) { + if (hasPwd) { + signalStyle += "-low-pwd.png);}"; + } else { + signalStyle += "-low.png);}"; + } } else { signalStyle += "-none.png);}"; } - signalLv = 4; } + ui->lbSignal->setStyleSheet(signalStyle); } @@ -1171,9 +1162,6 @@ void OneConnForm::slotConnWifiResult(int connFlag) ui->checkBoxPwd->setChecked(false); } - // 设置全局变量,当前连接Wifi的信号强度 - currentActWifiSignalLv = signalLv; - this->stopWifiWaiting(true); mw->is_stop_check_net_state = 0; diff --git a/src/oneconnform.h b/src/oneconnform.h index 047b3c3d..0aa4569c 100644 --- a/src/oneconnform.h +++ b/src/oneconnform.h @@ -66,7 +66,7 @@ public: ~OneConnForm(); // category:1->normal protocol 1->wifi 6 2->wifi 6+ - void setSignal(QString lv, QString secu,QString category = "0"); + void setSignal(QString lv, QString secu, QString category = "0", bool hasSignalStrength = true); int getSignal(); void setWifiName(QString name, QString bssid, QString uuid, QString isname, bool isHW, bool is9006C); QString getName();