Fix bug window of kylin-nm chocked when connect or disconnect wifi
This commit is contained in:
parent
36081fff60
commit
d06ae50117
|
@ -569,15 +569,12 @@ QString BackThread::execChkLanWidth(QString ethName)
|
|||
//disconnected spare ethernet or wifi
|
||||
void BackThread::disConnSparedNetSlot(QString type)
|
||||
{
|
||||
sleep(1);
|
||||
if (type == "wifi") {
|
||||
//disConnLanOrWifi("wifi");
|
||||
} else if(type == "ethernet") {
|
||||
sleep(1);
|
||||
disConnLanOrWifi("ethernet");
|
||||
}
|
||||
|
||||
emit disFinish();
|
||||
emit ttFinish();
|
||||
}
|
||||
|
||||
//disconnected ethernet or wifi according to network type
|
||||
|
|
|
@ -86,8 +86,6 @@ signals:
|
|||
void connDone(int connFlag);
|
||||
|
||||
void btFinish();
|
||||
void disFinish();
|
||||
void ttFinish();
|
||||
};
|
||||
|
||||
#endif // BACKTHREAD_H
|
||||
|
|
|
@ -1578,6 +1578,9 @@ void KylinDBus::toGetWifiList()
|
|||
//网络连接变化时,如有新增或减少的网络,发信号通知更新主界面
|
||||
void KylinDBus::onPropertiesChanged(QVariantMap qvm)
|
||||
{
|
||||
if (mw->is_stop_check_net_state) {
|
||||
return;
|
||||
}
|
||||
for(QString keyStr : qvm.keys()) {
|
||||
//有关已连接网络变化的信号
|
||||
if (keyStr == "ActiveConnections") {
|
||||
|
@ -1709,6 +1712,9 @@ void KylinDBus::onLanIpPropertiesChanged()
|
|||
|
||||
//无线网的Ip属性变化时的响应函数
|
||||
void KylinDBus::onWifiIpPropertiesChanged() {
|
||||
if (mw->is_stop_check_net_state) {
|
||||
return;
|
||||
}
|
||||
emit this->updateWirelessList();
|
||||
}
|
||||
|
||||
|
|
|
@ -2064,7 +2064,7 @@ QList<structWifiProperty> MainWindow::connectableWifiPriorityList(const QStringL
|
|||
if (selectedWifiListStruct.size() > 1) {
|
||||
devListSort(&selectedWifiListStruct);
|
||||
foreach (structWifiProperty wifiPriorityAfterSort, selectedWifiListStruct) {
|
||||
qDebug() << "-----------------------> 排序后" << wifiPriorityAfterSort.priority;
|
||||
qDebug() << wifiPriorityAfterSort.bssid << " 的自动连接优先级是 : " << wifiPriorityAfterSort.priority;
|
||||
}
|
||||
}
|
||||
ocf->deleteLater();
|
||||
|
@ -2339,9 +2339,9 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
|||
ocf->show();
|
||||
|
||||
if (actWifiBssidList.contains(wbssid) && wifiActState == 1) {
|
||||
ocf->startWaiting(true);
|
||||
ocf->startWifiWaiting(true);
|
||||
} else if (actWifiId == wname && wifiActState == 1) {
|
||||
ocf->startWaiting(true);
|
||||
ocf->startWifiWaiting(true);
|
||||
}
|
||||
|
||||
j ++;
|
||||
|
@ -3060,16 +3060,11 @@ void MainWindow::activeLanDisconn()
|
|||
void MainWindow::activeWifiDisconn()
|
||||
{
|
||||
hasWifiConnected = false;
|
||||
|
||||
QThread *tt = new QThread();
|
||||
BackThread *btt = new BackThread();
|
||||
btt->moveToThread(tt);
|
||||
connect(tt, SIGNAL(finished()), tt, SLOT(deleteLater()));
|
||||
connect(tt, SIGNAL(started()), this, SLOT(activeStartLoading()));
|
||||
connect(this, SIGNAL(disConnSparedNet(QString)), btt, SLOT(disConnSparedNetSlot(QString)));
|
||||
connect(btt, SIGNAL(disFinish()), this, SLOT(activeGetWifiList()));
|
||||
connect(btt, SIGNAL(ttFinish()), tt, SLOT(quit()));
|
||||
tt->start();
|
||||
currSelNetName = "";
|
||||
this->ksnm->execGetWifiList(this->wcardname);
|
||||
QtConcurrent::run([=]() {
|
||||
activeStartLoading();
|
||||
});
|
||||
}
|
||||
void MainWindow::activeStartLoading()
|
||||
{
|
||||
|
@ -3077,13 +3072,8 @@ void MainWindow::activeStartLoading()
|
|||
QString txt(tr("Wi-Fi is disconnected"));
|
||||
objKyDBus->showDesktopNotify(txt);
|
||||
|
||||
currSelNetName = "";
|
||||
emit this->disConnSparedNet("wifi");
|
||||
}
|
||||
void MainWindow::activeGetWifiList()
|
||||
{
|
||||
emit this->waitWifiStop();
|
||||
this->ksnm->execGetWifiList(this->wcardname);
|
||||
setTrayLoading(false);
|
||||
getActiveInfoAndSetTrayIcon();
|
||||
}
|
||||
|
||||
//网络开关处理,打开与关闭网络
|
||||
|
|
|
@ -371,7 +371,6 @@ private slots:
|
|||
void activeLanDisconn();
|
||||
void activeWifiDisconn();
|
||||
void activeStartLoading();
|
||||
void activeGetWifiList();
|
||||
void onRequestScanAccesspoint();
|
||||
void toScanWifi(bool isShow);
|
||||
void on_setNetSpeed();
|
||||
|
@ -401,7 +400,6 @@ private slots:
|
|||
signals:
|
||||
void disConnSparedNet(QString type);
|
||||
|
||||
void waitWifiStop();
|
||||
void waitLanStop();
|
||||
void reConnectWifi(const QString& uuid);
|
||||
void actWifiSignalLvChanaged(const int& currentLevel);
|
||||
|
|
|
@ -155,7 +155,6 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
|
|||
this->waitTimer = new QTimer(this);
|
||||
connect(waitTimer, SIGNAL(timeout()), this, SLOT(waitAnimStep()));
|
||||
|
||||
connect(mw, SIGNAL(waitWifiStop()), this, SLOT(stopWaiting()));
|
||||
connect(mw, &MainWindow::reConnectWifi, this, [ = ](const QString& uuid) {
|
||||
if (isActive) {
|
||||
QThread *t = new QThread();
|
||||
|
@ -520,12 +519,12 @@ void OneConnForm::setWifiInfo(QString str1, QString str2, QString str3, int freq
|
|||
|
||||
void OneConnForm::slotConnWifi()
|
||||
{
|
||||
this->startWaiting(true);
|
||||
this->startWifiWaiting(true);
|
||||
emit sigConnWifi(wifiName, wifiIfName);
|
||||
}
|
||||
void OneConnForm::slotConnWifiPWD()
|
||||
{
|
||||
this->startWaiting(true);
|
||||
this->startWifiWaiting(true);
|
||||
emit sigConnWifiPWD(wifiName, ui->lePassword->text(), connType);
|
||||
}
|
||||
|
||||
|
@ -542,10 +541,10 @@ void OneConnForm::on_btnDisConn_clicked()
|
|||
mw->canReconnectWifiList.removeOne(wifiName);
|
||||
}
|
||||
|
||||
this->startWaiting(false);
|
||||
this->startWifiWaiting(false);
|
||||
|
||||
mw->is_stop_check_net_state = 1;
|
||||
mw->on_btnHotspotState();
|
||||
//mw->on_btnHotspotState();
|
||||
//kylin_network_set_con_down(wifiName.toUtf8().data());
|
||||
kylin_network_set_con_down(wifiUuid.toUtf8().data());
|
||||
disconnect(this, SIGNAL(selectedOneWifiForm(QString,int)), mw, SLOT(oneTopWifiFormSelected(QString,int)));
|
||||
|
@ -685,13 +684,13 @@ void OneConnForm::toConnectWirelessNetwork()
|
|||
bt->moveToThread(t);
|
||||
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
|
||||
connect(t, &QThread::started, this, [ = ]() {
|
||||
this->startWaiting(true);
|
||||
this->startWifiWaiting(true);
|
||||
QString cmdStr = "nmcli connection up '" + wifiName + "' passwd-file " + homePath +"/.config/" + wifiName + ".psk";
|
||||
emit this->sigConnWifiPsk(cmdStr);
|
||||
});
|
||||
connect(this, SIGNAL(sigConnWifiPsk(QString)), bt, SLOT(execConnWifiPsk(QString)));
|
||||
connect(bt, &BackThread::connDone, this, [ = ](int res) {
|
||||
this->stopWaiting();
|
||||
this->stopWifiWaiting(true);
|
||||
mw->is_stop_check_net_state = 0;
|
||||
if (res) {
|
||||
QFile::remove(QString("%1/.config/%2.psk").arg(homePath).arg(wifiName).toUtf8());
|
||||
|
@ -743,13 +742,13 @@ void OneConnForm::on_btnConnPWD_clicked()
|
|||
bt->moveToThread(t);
|
||||
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
|
||||
connect(t, &QThread::started, this, [ = ]() {
|
||||
this->startWaiting(true);
|
||||
this->startWifiWaiting(true);
|
||||
QString cmdStr = "nmcli connection up '" + wifiName + "' passwd-file " + homePath +"/.config/" + wifiName + ".psk";
|
||||
emit this->sigConnWifiPsk(cmdStr);
|
||||
});
|
||||
connect(this, SIGNAL(sigConnWifiPsk(QString)), bt, SLOT(execConnWifiPsk(QString)));
|
||||
connect(bt, &BackThread::connDone, this, [ = ](int res) {
|
||||
this->stopWaiting();
|
||||
this->stopWifiWaiting(true);
|
||||
mw->is_stop_check_net_state = 0;
|
||||
if (res) {
|
||||
QFile::remove(QString("%1/.config/%2.psk").arg(homePath).arg(wifiName).toUtf8());
|
||||
|
@ -994,7 +993,7 @@ void OneConnForm::slotConnWifiResult(int connFlag)
|
|||
// 设置全局变量,当前连接Wifi的信号强度
|
||||
currentActWifiSignalLv = signalLv;
|
||||
|
||||
this->stopWaiting();
|
||||
this->stopWifiWaiting(true);
|
||||
|
||||
mw->is_stop_check_net_state = 0;
|
||||
}
|
||||
|
@ -1020,13 +1019,13 @@ void OneConnForm::waitAnimStep()
|
|||
syslog(LOG_ERR, "execute 'kill -9 $(pidof nmcli)' in function 'waitAnimStep' failed");
|
||||
}
|
||||
|
||||
this->stopWaiting(); //动画超出时间限制,强制停止动画
|
||||
this->stopWifiWaiting(true); //动画超出时间限制,强制停止动画
|
||||
|
||||
mw->is_stop_check_net_state = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void OneConnForm::startWaiting(bool isToConnect)
|
||||
void OneConnForm::startWifiWaiting(bool isToConnect)
|
||||
{
|
||||
this->isWaiting = true;
|
||||
if (isToConnect) {
|
||||
|
@ -1046,7 +1045,7 @@ void OneConnForm::startWaiting(bool isToConnect)
|
|||
mw->setTrayLoading(true);
|
||||
}
|
||||
|
||||
void OneConnForm::stopWaiting()
|
||||
void OneConnForm::stopWifiWaiting(bool isUpdateTrayIcon)
|
||||
{
|
||||
ui->lbWaitingIcon->move(380, 20);
|
||||
ui->btnCancel->hide();
|
||||
|
@ -1055,8 +1054,10 @@ void OneConnForm::stopWaiting()
|
|||
ui->lbWaiting->hide();
|
||||
ui->lbWaitingIcon->hide();
|
||||
|
||||
mw->setTrayLoading(false);
|
||||
mw->getActiveInfoAndSetTrayIcon();
|
||||
if (isUpdateTrayIcon) {
|
||||
mw->setTrayLoading(false);
|
||||
mw->getActiveInfoAndSetTrayIcon();
|
||||
}
|
||||
}
|
||||
|
||||
void OneConnForm::on_btnCancel_clicked()
|
||||
|
@ -1075,7 +1076,7 @@ void OneConnForm::on_btnCancel_clicked()
|
|||
QString currentConnectWifiUuid = wifiSsidAndUuid.at(0);
|
||||
kylin_network_set_con_down(currentConnectWifiUuid.toUtf8().data());
|
||||
}
|
||||
this->stopWaiting();
|
||||
this->stopWifiWaiting(true);
|
||||
}
|
||||
|
||||
int OneConnForm::getPskFlag()
|
||||
|
|
|
@ -98,8 +98,8 @@ public:
|
|||
|
||||
public slots:
|
||||
void waitAnimStep();
|
||||
void startWaiting(bool isToConnect);
|
||||
void stopWaiting();
|
||||
void startWifiWaiting(bool isToConnect);
|
||||
void stopWifiWaiting(bool isUpdateTrayIcon);
|
||||
void onBtnPropertyClicked();
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue