Merge branch 'sp1-0710' into 'main'

Merge 0710 to main.

See merge request kylin-desktop/kylin-nm!55
This commit is contained in:
chen lelin 2021-06-25 06:13:50 +00:00
commit a1d4f7ab55
5 changed files with 26 additions and 10 deletions

View File

@ -1330,7 +1330,7 @@ QString KylinDBus::getWifiSsid(QString accessPointPath)
//检查wifi连接状态
int KylinDBus::checkWifiConnectivity()
{
int wifiState = 3;
int wifiState = WIFI_DISCONNECTED;
QDBusInterface interface( "org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager",

View File

@ -33,6 +33,10 @@
#include <QTimer>
#include <QThread>
#define WIFI_CONNECTING 1
#define WIFI_CONNECTED 2
#define WIFI_DISCONNECTED 3
class MainWindow;
class Utils;

View File

@ -812,6 +812,7 @@ void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
is_stop_check_net_state = 0;
}
} else {
this->m_is_inputting_wifi_password = false;
this->hide();
numberForWifiScan = 0;
}
@ -2052,7 +2053,7 @@ void MainWindow::getWifiListDone(QStringList slist)
return;
}
if (current_wifi_list_state == LOAD_WIFI_LIST || current_wifi_list_state == REFRESH_WIFI) {
if ((current_wifi_list_state == LOAD_WIFI_LIST || current_wifi_list_state == REFRESH_WIFI) && !this->m_is_inputting_wifi_password) {
if (!isReconnectingWifi) {
loadWifiListDone(slist);
is_init_wifi_list = 0;
@ -2063,12 +2064,12 @@ void MainWindow::getWifiListDone(QStringList slist)
}
}
if (current_wifi_list_state == UPDATE_WIFI_LIST) {
if (current_wifi_list_state == UPDATE_WIFI_LIST || this->m_is_inputting_wifi_password) {
//如果WiFi连接状态发生了改变需要刷新整个列表否则只需要比对新旧列表更新即可
if (m_isWifiConnected && objKyDBus->checkWifiConnectivity() != 2) {
if (m_isWifiConnected && objKyDBus->checkWifiConnectivity() != WIFI_CONNECTED) {
//qDebug() << "loadwifi的列表";
loadWifiListDone(slist);
} else if (!m_isWifiConnected && objKyDBus->checkWifiConnectivity() == 2) {
} else if (!m_isWifiConnected && objKyDBus->checkWifiConnectivity() == WIFI_CONNECTED) {
loadWifiListDone(slist);
} else {
//qDebug() << "updatewifi的列表";
@ -2582,7 +2583,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
// 获取当前无线网的连接状态正在连接wifiActState==1已经连接wifiActState==2, 未连接wifiActState==3
int wifiActState = objKyDBus->checkWifiConnectivity(); //检查wifi的连接状态
if (wifiActState == 2) {
if (wifiActState == WIFI_CONNECTED) {
m_isWifiConnected = true;
} else {
m_isWifiConnected = false;
@ -2683,7 +2684,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
// 根据当前连接的wifi 设置OneConnForm
OneConnForm *ccf = new OneConnForm(topWifiListWidget, this, confForm, ksnm);
if (actWifiName == "--" || wifiActState == 1 || actWifiBssidList.at(0) == "--" || actWifiBssid == " ") {
if (actWifiName == "--" || wifiActState == WIFI_CONNECTING || actWifiBssidList.at(0) == "--" || actWifiBssid == " ") {
ccf->setWifiName(tr("Not connected"), "--", "--", "--", isHuaWeiPC, isHuaWei9006C);//"当前未连接任何 Wifi"
ccf->setSignal("0", "--" , "0", false);
activeWifiSignalLv = 0;
@ -2802,7 +2803,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
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 == WIFI_CONNECTED) {
//对于已经连接的wifi
connect(this, &MainWindow::actWifiSignalLvChanaged, ccf, [ = ](const int &signalLv) {
ccf->setSignal(QString::number(signalLv), wsecu, wcate, true);
@ -2904,7 +2905,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
ocf->setSelected(false, false);
ocf->show();
if ((actWifiBssidList.contains(wbssid) && wifiActState == 1) || (actWifiId == wname && wifiActState == 1)) {
if ((actWifiBssidList.contains(wbssid) && wifiActState == WIFI_CONNECTING) || (actWifiId == wname && wifiActState == WIFI_CONNECTING)) {
ocf->startWifiWaiting(true);
}
@ -3520,6 +3521,11 @@ void MainWindow::oneWifiFormSelected(QString wifibssid, int extendLength)
//与win逻辑一致点击同一选项不再缩小选项卡
return;
}
if (extendLength == H_WIFI_ITEM_SMALL_EXTEND) {
this->m_is_inputting_wifi_password = true;
} else {
this->m_is_inputting_wifi_password = false;
}
QList<OneConnForm *>topWifiList = topWifiListWidget->findChildren<OneConnForm *>();
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
@ -4378,6 +4384,7 @@ bool MainWindow::event(QEvent *event)
{
if (event->type() == QEvent::ActivationChange) {
if (QApplication::activeWindow() != this) {
this->m_is_inputting_wifi_password = false;
this->hide();
numberForWifiScan = 0;
}

View File

@ -184,6 +184,7 @@ public:
bool isToSetWifiValue = true; //本次执行是否进行赋值
bool isReconnectingWifi = false; //是否正在执行wifi的回连
bool isReconnectingLan = false; //是否正在执行lan的回连
bool m_is_inputting_wifi_password = false; //是否正在输入密码
int addNumberForWifi = 0; //短时间内收到关于wifi连接信号的次数
bool isHuaWeiPC;
bool isHuaWei9006C;

View File

@ -871,9 +871,13 @@ void OneConnForm::toConnectWirelessNetwork()
//需要密码的wifi连接
void OneConnForm::on_btnConnPWD_clicked()
{
mw->m_is_inputting_wifi_password = false; //点击连接表示密码输入已完成
m_connWithPwd = true;
qDebug()<<"A button named btnConnPWD about wifi net is clicked.";
if (lbPwdTip->isVisible()) {
QString modifyCmd = "nmcli connection modify \""+ wifiName + "\" " + "802-11-wireless-security.psk " + ui->lePassword->text();
int mdf_res = system(modifyCmd.toUtf8().data());
qDebug()<<"Modified wifi password, cmd="<<modifyCmd<<";res="<<mdf_res;
lbPwdTip->hide();
mw->m_wifi_list_pwd_changed.removeOne(wifiName);
}
@ -1115,7 +1119,7 @@ void OneConnForm::slotConnWifiResult(int connFlag)
}
if (connFlag == 1 || connFlag == 4) {
if (!m_connWithPwd) {
if (!m_connWithPwd && hasPwd) {
//用原有配置文件连接失败,显示密码错误
qDebug()<<"Connected failed with old configuration. ssid="<<wifiName;
if (mw)