Fix: Password lineedit disappeared when inputing password.
This commit is contained in:
parent
00e1642cc8
commit
e66b06b49e
|
@ -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",
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
#include <QTimer>
|
||||
#include <QThread>
|
||||
|
||||
#define WIFI_CONNECTING 1
|
||||
#define WIFI_CONNECTED 2
|
||||
#define WIFI_DISCONNECTED 3
|
||||
|
||||
class MainWindow;
|
||||
class Utils;
|
||||
|
||||
|
|
|
@ -814,6 +814,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;
|
||||
}
|
||||
|
@ -2051,7 +2052,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;
|
||||
|
@ -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连接状态发生了改变,需要刷新整个列表,否则只需要比对新旧列表更新即可
|
||||
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的列表";
|
||||
|
@ -2577,7 +2578,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;
|
||||
|
@ -2678,7 +2679,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");
|
||||
activeWifiSignalLv = 0;
|
||||
|
@ -2797,7 +2798,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);
|
||||
|
@ -2899,7 +2900,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);
|
||||
}
|
||||
|
||||
|
@ -3515,6 +3516,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 *>();
|
||||
|
@ -4372,6 +4378,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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -880,9 +880,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);
|
||||
}
|
||||
|
@ -1118,7 +1122,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)
|
||||
|
|
Loading…
Reference in New Issue