Merge pull request #83 from mammonsama666/0310-dev

fix(wifi): wifi button is closed when connected wifi.
This commit is contained in:
chenlelin 2021-03-11 14:18:51 +08:00 committed by GitHub
commit 1a89fb9fab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 17 deletions

View File

@ -107,7 +107,7 @@ KylinDBus::KylinDBus(MainWindow *mainWindow, QObject *parent) :QObject(parent)
if (mw) {
QObject::connect(this, SIGNAL(updateWiredList(int)), mw, SLOT(onBtnNetListClicked(int)));
QObject::connect(this, SIGNAL(newConnAdded(int)), mw, SLOT(onNewConnAdded(int)));
QObject::connect(this, SIGNAL(updateWirelessList()), mw, SLOT(on_btnWifiList_clicked()));
QObject::connect(this, SIGNAL(updateWirelessList()), mw, SLOT(on_wifi_changed()));
}
mUtils = new Utils();

View File

@ -1373,6 +1373,26 @@ void MainWindow::on_btnWifiList_clicked()
bt->deleteLater();
}
void MainWindow::on_wifi_changed()
{
QString actWifiUuid = objKyDBus->getActiveWifiUuid();
objKyDBus->getConnectNetIp(actWifiUuid);
objKyDBus->getWifiIp(actWifiUuid);
if (oldWifiIpv4Method == "") {
oldWifiIpv4Method = objKyDBus-> dbusWifiIpv4Method;
}
if (objKyDBus->dbusWifiIpv4 != "" && objKyDBus->dbusActiveWifiIpv4 != "" && objKyDBus->dbusWifiIpv4 != objKyDBus->dbusActiveWifiIpv4 &&objKyDBus-> dbusWifiIpv4Method == "manual") {
//在第三方nm-connection-editor进行新的IP配置后重新连接网络
oldWifiIpv4Method = "manual";
qDebug()<<"Ipv4.address of current activated wifi is:"<<objKyDBus->dbusActiveWifiIpv4 << ". Real ipv4.address is:" << objKyDBus->dbusWifiIpv4;
emit this->reConnectWifi(actWifiUuid);
} else if (objKyDBus-> dbusWifiIpv4Method == "auto" && oldWifiIpv4Method == "manual") {
oldWifiIpv4Method = "auto";
qDebug()<<"Ipv4.method is set to auto.";
emit this->reConnectWifi(actWifiUuid);
}
}
/**
* @brief MainWindow::onNewConnAdded
* @param type 0线1线
@ -1641,22 +1661,22 @@ void MainWindow::getWifiListDone(QStringList slist)
return;
}
QString actWifiUuid = objKyDBus->getActiveWifiUuid();
objKyDBus->getConnectNetIp(actWifiUuid);
objKyDBus->getWifiIp(actWifiUuid);
if (oldWifiIpv4Method == "") {
oldWifiIpv4Method = objKyDBus-> dbusWifiIpv4Method;
}
if (objKyDBus->dbusWifiIpv4 != "" && objKyDBus->dbusActiveWifiIpv4 != "" && objKyDBus->dbusWifiIpv4 != objKyDBus->dbusActiveWifiIpv4 &&objKyDBus-> dbusWifiIpv4Method == "manual") {
//在第三方nm-connection-editor进行新的IP配置后重新连接网络
oldWifiIpv4Method = "manual";
qDebug()<<"Ipv4.address of current activated wifi is:"<<objKyDBus->dbusActiveWifiIpv4 << ". Real ipv4.address is:" << objKyDBus->dbusWifiIpv4;
emit this->reConnectWifi(actWifiUuid);
} else if (objKyDBus-> dbusWifiIpv4Method == "auto" && oldWifiIpv4Method == "manual") {
oldWifiIpv4Method = "auto";
qDebug()<<"Ipv4.method is set to auto.";
emit this->reConnectWifi(actWifiUuid);
}
// QString actWifiUuid = objKyDBus->getActiveWifiUuid();
// objKyDBus->getConnectNetIp(actWifiUuid);
// objKyDBus->getWifiIp(actWifiUuid);
// if (oldWifiIpv4Method == "") {
// oldWifiIpv4Method = objKyDBus-> dbusWifiIpv4Method;
// }
// if (objKyDBus->dbusWifiIpv4 != "" && objKyDBus->dbusActiveWifiIpv4 != "" && objKyDBus->dbusWifiIpv4 != objKyDBus->dbusActiveWifiIpv4 &&objKyDBus-> dbusWifiIpv4Method == "manual") {
// //在第三方nm-connection-editor进行新的IP配置后重新连接网络
// oldWifiIpv4Method = "manual";
// qDebug()<<"Ipv4.address of current activated wifi is:"<<objKyDBus->dbusActiveWifiIpv4 << ". Real ipv4.address is:" << objKyDBus->dbusWifiIpv4;
// emit this->reConnectWifi(actWifiUuid);
// } else if (objKyDBus-> dbusWifiIpv4Method == "auto" && oldWifiIpv4Method == "manual") {
// oldWifiIpv4Method = "auto";
// qDebug()<<"Ipv4.method is set to auto.";
// emit this->reConnectWifi(actWifiUuid);
// }
//qDebug()<<"debug: oldWifiSlist.size()="<<oldWifiSlist.size()<<" slist.size()="<<slist.size();
//qDebug()<<"------------";

View File

@ -209,6 +209,7 @@ public slots:
void on_btnHotspot_clicked();
void on_btnHotspotState();
void on_btnWifiList_clicked();
void on_wifi_changed();
void connWifiDone(int connFlag);