Merge pull request #63 from mammonsama666/0103-dev
fix(activateWifi): Activated wifi is empty when wifi name is not same with ssid.
This commit is contained in:
commit
0d190f3c53
|
@ -1610,6 +1610,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
|
|
||||||
// 获取当前连接的wifi name
|
// 获取当前连接的wifi name
|
||||||
QString actWifiName = "--";
|
QString actWifiName = "--";
|
||||||
|
actWifissid = "--";
|
||||||
activecon *act = kylin_network_get_activecon_info();
|
activecon *act = kylin_network_get_activecon_info();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (act[index].con_name != NULL) {
|
while (act[index].con_name != NULL) {
|
||||||
|
@ -1634,6 +1635,22 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
lbLoadDownImg->hide();
|
lbLoadDownImg->hide();
|
||||||
lbLoadUpImg->hide();
|
lbLoadUpImg->hide();
|
||||||
ccf->setTopItem(false);
|
ccf->setTopItem(false);
|
||||||
|
} else {
|
||||||
|
QProcess * process = new QProcess;
|
||||||
|
QString name = actWifiName;
|
||||||
|
if (name.contains(" ")) {
|
||||||
|
name.replace(QRegExp("[\\s]"), "\\\ "); //防止名字包含空格导致指令识别错误,需要转义
|
||||||
|
}
|
||||||
|
process->start(QString("nmcli -f 802-11-wireless.ssid connection show %1").arg(name));
|
||||||
|
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
|
||||||
|
process->deleteLater();
|
||||||
|
});
|
||||||
|
connect(process, &QProcess::readyReadStandardOutput, this, [ = ]() {
|
||||||
|
QString str = process->readAllStandardOutput();
|
||||||
|
actWifissid = str.mid(str.lastIndexOf(" ") + 1, str.length() - str.lastIndexOf(" ") - 2);
|
||||||
|
qDebug()<<actWifissid;
|
||||||
|
});
|
||||||
|
process->waitForFinished();
|
||||||
}
|
}
|
||||||
ccf->setAct(true);
|
ccf->setAct(true);
|
||||||
ccf->move(L_VERTICAL_LINE_TO_ITEM, 0);
|
ccf->move(L_VERTICAL_LINE_TO_ITEM, 0);
|
||||||
|
@ -1656,6 +1673,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
}
|
}
|
||||||
QStringList wnames;
|
QStringList wnames;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (int i = 1, j = 0; i < slist.size(); i ++) {
|
for (int i = 1, j = 0; i < slist.size(); i ++) {
|
||||||
QString line = slist.at(i);
|
QString line = slist.at(i);
|
||||||
QString wsignal = line.mid(0, indexSecu).trimmed();
|
QString wsignal = line.mid(0, indexSecu).trimmed();
|
||||||
|
@ -1690,7 +1708,8 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
}
|
}
|
||||||
if (wname != "" && wname != "--") {
|
if (wname != "" && wname != "--") {
|
||||||
// 当前连接的wifi
|
// 当前连接的wifi
|
||||||
if (wname == actWifiName) {
|
// if (wname == actWifiName) {
|
||||||
|
if (wname == actWifissid) {
|
||||||
connect(ccf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneTopWifiFormSelected(QString,int)));
|
connect(ccf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneTopWifiFormSelected(QString,int)));
|
||||||
connect(ccf, SIGNAL(disconnActiveWifi()), this, SLOT(activeWifiDisconn()));
|
connect(ccf, SIGNAL(disconnActiveWifi()), this, SLOT(activeWifiDisconn()));
|
||||||
ccf->setName(wname);
|
ccf->setName(wname);
|
||||||
|
|
|
@ -280,6 +280,7 @@ private:
|
||||||
long int end_rcv_rates = 0; //保存结束时的流量计数
|
long int end_rcv_rates = 0; //保存结束时的流量计数
|
||||||
long int start_tx_rates = 0; //保存开始时的流量计数
|
long int start_tx_rates = 0; //保存开始时的流量计数
|
||||||
long int end_tx_rates = 0; //保存结束时的流量计数
|
long int end_tx_rates = 0; //保存结束时的流量计数
|
||||||
|
QString actWifissid = "--"; //当前连接wifi的ssid
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void iconActivated(QSystemTrayIcon::ActivationReason reason);
|
void iconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||||
|
|
Loading…
Reference in New Issue