Fix: Password lineedit disappeared when inputing password.

This commit is contained in:
zhangjiaping 2021-06-19 20:24:51 +08:00
parent 00e1642cc8
commit e66b06b49e
5 changed files with 26 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -880,9 +880,13 @@ void OneConnForm::toConnectWirelessNetwork()
//需要密码的wifi连接 //需要密码的wifi连接
void OneConnForm::on_btnConnPWD_clicked() void OneConnForm::on_btnConnPWD_clicked()
{ {
mw->m_is_inputting_wifi_password = false; //点击连接表示密码输入已完成
m_connWithPwd = true; m_connWithPwd = true;
qDebug()<<"A button named btnConnPWD about wifi net is clicked."; qDebug()<<"A button named btnConnPWD about wifi net is clicked.";
if (lbPwdTip->isVisible()) { 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(); lbPwdTip->hide();
mw->m_wifi_list_pwd_changed.removeOne(wifiName); mw->m_wifi_list_pwd_changed.removeOne(wifiName);
} }
@ -1118,7 +1122,7 @@ void OneConnForm::slotConnWifiResult(int connFlag)
} }
if (connFlag == 1 || connFlag == 4) { if (connFlag == 1 || connFlag == 4) {
if (!m_connWithPwd) { if (!m_connWithPwd && hasPwd) {
//用原有配置文件连接失败,显示密码错误 //用原有配置文件连接失败,显示密码错误
qDebug()<<"Connected failed with old configuration. ssid="<<wifiName; qDebug()<<"Connected failed with old configuration. ssid="<<wifiName;
if (mw) if (mw)