Fix bug can not switch to wired interface when refresh wireless list

This commit is contained in:
chenlelin 2021-01-12 13:56:39 +08:00
parent 0c9f34d8d5
commit 964f337045
3 changed files with 23 additions and 27 deletions

View File

@ -169,6 +169,8 @@ void BackThread::execEnWifi()
{ {
char *chr1 = "nmcli radio wifi on"; char *chr1 = "nmcli radio wifi on";
Utils::m_system(chr1); Utils::m_system(chr1);
emit btFinish();
while (1) { while (1) {
if (execGetIface()->wstate != 2) { if (execGetIface()->wstate != 2) {
KylinDBus objKyDbus; KylinDBus objKyDbus;

View File

@ -29,7 +29,7 @@ LoadingDiv::LoadingDiv(QWidget *parent) : QWidget(parent)
this->loadingGif = new QLabel(this); this->loadingGif = new QLabel(this);
this->loadingGif->resize(96, 96); this->loadingGif->resize(96, 96);
this->loadingGif->move(this->width()/2 - 96/2 + 41/2, this->height()/2 + 20); this->loadingGif->move(this->width()/2 - 96/2 + 41/2 - 40, this->height()/2 + 20);
this->loadingGif->show(); this->loadingGif->show();
this->switchTimer = new QTimer(this); //QTimer对象控制等待动画播放 this->switchTimer = new QTimer(this); //QTimer对象控制等待动画播放

View File

@ -92,6 +92,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ksnm, SIGNAL(getWifiListFinished(QStringList)), this, SLOT(getWifiListDone(QStringList))); connect(ksnm, SIGNAL(getWifiListFinished(QStringList)), this, SLOT(getWifiListDone(QStringList)));
loading = new LoadingDiv(this); loading = new LoadingDiv(this);
loading->move(40,0);
connect(loading, SIGNAL(toStopLoading() ), this, SLOT(on_checkOverTime() )); connect(loading, SIGNAL(toStopLoading() ), this, SLOT(on_checkOverTime() ));
checkIsWirelessDeviceOn(); //检测无线网卡是否插入 checkIsWirelessDeviceOn(); //检测无线网卡是否插入
@ -1243,6 +1244,9 @@ void MainWindow::on_btnWifiList_clicked()
{ {
this->is_btnWifiList_clicked = 1; this->is_btnWifiList_clicked = 1;
this->is_btnLanList_clicked = 0; this->is_btnLanList_clicked = 0;
if (this->is_btnLanList_clicked == 1) {
return;
}
BackThread *bt = new BackThread(); BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface(); IFace *iface = bt->execGetIface();
@ -1266,38 +1270,26 @@ void MainWindow::on_btnWifiList_clicked()
btnWireless->show(); btnWireless->show();
if (iface->wstate == 0 || iface->wstate == 1) { if (iface->wstate == 0 || iface->wstate == 1) {
//qDebug() << "wifi开关在打开状态";
btnWireless->setSwitchStatus(true); btnWireless->setSwitchStatus(true);
lbTopWifiList->show(); lbTopWifiList->show();
btnAddNet->show(); btnAddNet->show();
this->startLoading(); this->startLoading();
this->ksnm->execGetWifiList(); this->ksnm->execGetWifiList();
} else if (iface->wstate == 3) { //连接中正在配置wifi设备 } else if (iface->wstate == 3) {
//qDebug() << "连接中正在配置wifi设备";
this->ksnm->isUseOldWifiSlist = true;
QStringList slistWifi;
slistWifi.append("empty");
getWifiListDone(slistWifi);
btnWireless->setSwitchStatus(true); btnWireless->setSwitchStatus(true);
lbTopWifiList->show(); lbTopWifiList->show();
btnAddNet->show(); btnAddNet->show();
QList<OneConnForm*> topwifis = topWifiListWidget->findChildren<OneConnForm*>();
foreach(OneConnForm* topwifi, topwifis)
{
delete topwifi;
topwifi = NULL;
}
// 当前连接的wifi
OneConnForm *ccf = new OneConnForm(topWifiListWidget, this, confForm, ksnm);
ccf->setName(tr("Not connected"));//"当前未连接任何 Wifi"
ccf->setSignal("0", "--");
ccf->setRate("0");
ccf->setConnedString(1, tr("Disconnected"), "");//"未连接"
ccf->isConnected = false;
ccf->setTopItem(false);
ccf->setAct(true);
ccf->move(L_VERTICAL_LINE_TO_ITEM, 0);
ccf->show();
is_stop_check_net_state = 0;
} else { } else {
qDebug()<<"debug: WiFi的开关已经关闭"; //qDebug()<<"debug: WiFi的开关已经关闭";
btnWireless->setSwitchStatus(false); btnWireless->setSwitchStatus(false);
delete topWifiListWidget; //清空top列表 delete topWifiListWidget; //清空top列表
createTopWifiUI(); //创建顶部无线网item createTopWifiUI(); //创建顶部无线网item
@ -1338,7 +1330,6 @@ void MainWindow::on_btnWifiList_clicked()
bt->deleteLater(); bt->deleteLater();
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
//网络列表加载与更新 //网络列表加载与更新
@ -1655,7 +1646,6 @@ void MainWindow::loadWifiListDone(QStringList slist)
connect(process, &QProcess::readyReadStandardOutput, this, [ = ]() { connect(process, &QProcess::readyReadStandardOutput, this, [ = ]() {
QString str = process->readAllStandardOutput(); QString str = process->readAllStandardOutput();
actWifissid = str.mid(str.lastIndexOf(" ") + 1, str.length() - str.lastIndexOf(" ") - 2); actWifissid = str.mid(str.lastIndexOf(" ") + 1, str.length() - str.lastIndexOf(" ") - 2);
qDebug()<<actWifissid;
}); });
process->waitForFinished(); process->waitForFinished();
} }
@ -2497,7 +2487,7 @@ void MainWindow::enWifiDone()
if (is_btnWifiList_clicked) { if (is_btnWifiList_clicked) {
this->ksnm->execGetWifiList(); this->ksnm->execGetWifiList();
} else { } else {
on_btnWifiList_clicked(); //on_btnWifiList_clicked();
} }
objKyDBus->getWirelessCardName(); objKyDBus->getWirelessCardName();
@ -2606,7 +2596,11 @@ void MainWindow::onExternalLanChange()
void MainWindow::onExternalWifiChange() void MainWindow::onExternalWifiChange()
{ {
on_btnWifiList_clicked(); if (is_btnWifiList_clicked) {
this->ksnm->execGetWifiList();
} else {
//on_btnWifiList_clicked();
}
} }
//处理外界对wifi开关的打开与关闭 //处理外界对wifi开关的打开与关闭