# Conflicts:
#	src/confform.cpp
This commit is contained in:
lvhan 2021-03-23 19:02:17 +08:00
commit df0bc4bdb3
23 changed files with 162 additions and 63 deletions

View File

@ -79,5 +79,15 @@
<file>res/s/conning-s/12.png</file>
<file>res/x/setup.png</file>
<file>res/x/control.svg</file>
<file>res/w/wifi6-full-pwd.png</file>
<file>res/w/wifi6-full.png</file>
<file>res/w/wifi6-high-pwd.png</file>
<file>res/w/wifi6-high.png</file>
<file>res/w/wifi6-low-pwd.png</file>
<file>res/w/wifi6-low.png</file>
<file>res/w/wifi6-medium-pwd.png</file>
<file>res/w/wifi6-medium.png</file>
<file>res/w/wifi6-none.png</file>
<file>res/w/wifi6-null-pwd.png</file>
</qresource>
</RCC>

BIN
res/w/wifi6-full-pwd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

BIN
res/w/wifi6-full.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 B

BIN
res/w/wifi6-high-pwd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 812 B

BIN
res/w/wifi6-high.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

BIN
res/w/wifi6-low-pwd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 804 B

BIN
res/w/wifi6-low.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

BIN
res/w/wifi6-medium-pwd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 814 B

BIN
res/w/wifi6-medium.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

BIN
res/w/wifi6-none.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 738 B

BIN
res/w/wifi6-null-pwd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

View File

@ -96,7 +96,7 @@ IFace* BackThread::execGetIface()
iface->lstate = 3;
}
}
if (type == "wifi") {
if (type == "wifi" && iface->wname.isEmpty()) { //仅统计第一个无线网卡,后续无线网卡状态必然等于或差与第一个获取到的无线网卡
// if type is wireless network
iface->wname = iname;

View File

@ -70,7 +70,7 @@ void KSimpleNM::execGetLanList()
}
//获取无线网络列表数据
void KSimpleNM::execGetWifiList()
void KSimpleNM::execGetWifiList(const QString& wname)
{
if (isExecutingGetWifiList) {
syslog(LOG_DEBUG, "It is running getting wifi list when getting wifi list");
@ -85,7 +85,13 @@ void KSimpleNM::execGetWifiList()
isExecutingGetWifiList = true;
shellOutputWifi = "";
runProcessWifi->start("nmcli -f in-use,signal,security,freq,bssid,ssid device wifi");
QString cmd;
if (wname.isEmpty() || wname == "") {
cmd = "nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path device wifi";
} else {
cmd = "nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path device wifi list ifname " + wname;
}
runProcessWifi->start(cmd);
}
//获取保存的网络列表数据

View File

@ -45,7 +45,7 @@ public:
bool isUseOldWifiSlist = false; //是否应该要用上一次获取的有线列表
void execGetLanList();
void execGetWifiList();
void execGetWifiList(const QString& wname);
void execGetConnList();
signals:

View File

@ -1188,6 +1188,18 @@ int KylinDBus::getActiveWifiSignal()
return wifistrength;
}
//根据Dbus路径获取wifi的ssid排除空格干扰
QString KylinDBus::getWifiSsid(QString accessPointPath)
{
QDBusInterface interface( "org.freedesktop.NetworkManager",
accessPointPath,
"org.freedesktop.DBus.Properties",
QDBusConnection::systemBus() );
QDBusMessage result = interface.call("Get", "org.freedesktop.NetworkManager.AccessPoint", "Ssid");
if (result.arguments().isEmpty()) return "";
return result.arguments().at(0).value<QDBusVariant>().variant().toString();
}
//检查wifi连接状态
int KylinDBus::checkWifiConnectivity()
{

View File

@ -76,6 +76,7 @@ public:
int checkWifiConnectivity();
bool checkNetworkConnectivity();
int getActiveWifiSignal();
QString getWifiSsid(QString accessPointPath);
void toGetWifiList();

View File

@ -55,7 +55,6 @@ void LoadingDiv::switchAnimStep()
if (this->currentPage > 12) {
this->currentPage = 1; //循环播放
}
this->countCurrentTime += FRAMESPEED;
if (this->countCurrentTime >= ALLTIME) {
emit this->toStopLoading(); //发出信号停止主界面和托盘区的等待动画

View File

@ -21,7 +21,6 @@
#include "kylin-network-interface.h"
#include "wireless-security/dlghidewifi.h"
#include "dbusadaptor.h"
#include <QTranslator>
#include <QLocale>
#include <QApplication>
@ -31,7 +30,6 @@
#define LOG_IDENT "ukui_kylin_nm"
int main(int argc, char *argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

View File

@ -67,8 +67,8 @@ MainWindow::MainWindow(QWidget *parent) :
createListAreaUI(); //创建列表区域的控件
createLeftAreaUI(); //创建左侧区域控件
lname = "-1";
wname = "-1";
lcardname = "-1";
wcardname = "-1";
llname = "-1";
lwname = "-1";
hideWiFiConn = "Connect to Hidden Wi-Fi Network";
@ -453,12 +453,12 @@ void MainWindow::initNetwork()
BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface();
wname = iface->wname;
wcardname = iface->wname;
lwname = iface->wname;
lname = iface->lname;
lcardname = iface->lname;
llname = iface->lname;
mwBandWidth = bt->execChkLanWidth(lname);
mwBandWidth = bt->execChkLanWidth(lcardname);
// 开关状态
qDebug()<<"===";
@ -536,7 +536,7 @@ void MainWindow::initTimer()
checkWifiListChanged = new QTimer(this);
checkWifiListChanged->setTimerType(Qt::PreciseTimer);
QObject::connect(checkWifiListChanged, SIGNAL(timeout()), this, SLOT(on_checkWifiListChanged()));
checkWifiListChanged->start(7000);
checkWifiListChanged->start(10*1000);
//网线插入时定时执行
wiredCableUpTimer = new QTimer(this);
@ -1066,9 +1066,9 @@ void MainWindow::getLanBandWidth()
BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface();
lname = iface->lname;
lcardname = iface->lname;
mwBandWidth = bt->execChkLanWidth(lname);
mwBandWidth = bt->execChkLanWidth(lcardname);
}
//检测网络设备状态
@ -1076,30 +1076,26 @@ bool MainWindow::checkLanOn()
{
BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface();
if (iface->lstate == 2) {
bt->deleteLater();
int state = iface->lstate;
if (state == 2) {
return false;
} else {
return true;
}
delete iface;
bt->deleteLater();
}
bool MainWindow::checkWlOn()
{
BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface();
if (iface->wstate == 2) {
bt->deleteLater();
int state = iface->wstate;
if (state == 2) {
return false;
} else {
return true;
}
delete iface;
bt->deleteLater();
}
@ -1327,7 +1323,7 @@ void MainWindow::on_btnWifiList_clicked()
this->startLoading();
//this->objKyDBus->toGetWifiList();
this->ksnm->execGetWifiList();
this->ksnm->execGetWifiList(this->wcardname);
} else if (iface->wstate == 3) {
qDebug() << "debug: 连接中正在配置wifi设备";
@ -1710,7 +1706,7 @@ void MainWindow::getWifiListDone(QStringList slist)
}
if (is_update_wifi_list == 0) {
//qDebug() << "loadwifi的列表";
qDebug() << "loadwifi的列表";
loadWifiListDone(slist);
is_init_wifi_list = 0;
} else {
@ -1778,18 +1774,19 @@ void MainWindow::wifiListOptimize(QStringList& slist)
indexBSsid = headLine.indexOf("BSSID");
indexName = indexBSsid + 19;
}
int indexPath = headLine.indexOf("DBUS-PATH");
QStringList targetList; //slist优化同名同频AP中只留信号最强
targetList<<slist.at(0); //把第一行加进去
for(int it = 1;it < slist.size();it++){
QString i = slist.at(it);
bool ifContinue = false;
QString conName = i.mid(indexName).trimmed();
QString conName = i.mid(indexName, indexPath - indexName).trimmed();
int conSignal = i.mid(indexSignal,3).trimmed().toInt();
int conFreq = i.mid(indexFreq,4).trimmed().toInt();
for(int i=0;i<slist.size();i++){
QString str = slist.at(i);
QString name = str.mid(indexName).trimmed();
QString name = str.mid(indexName, indexPath - indexName).trimmed();
int signal = str.mid(indexSignal,3).trimmed().toInt();
int freq = str.mid(indexFreq,4).trimmed().toInt();
if(conName == name){
@ -1808,16 +1805,51 @@ void MainWindow::wifiListOptimize(QStringList& slist)
}
}
if(ifContinue) continue;
// if(conFreq < 5000)
// apSignalSet[conName+"2.4"] = conSignal;
// else
// apSignalSet[conName+"5"] = conSignal;
targetList<<i;
}
slist = targetList;
return ;
}
QStringList MainWindow::connectableWifiPriorityList(const QStringList slist){
QStringList target;
if(!slist.size()) return target;
OneConnForm *ocf = new OneConnForm();
QString headLine = slist.at(0);
int indexSignal,indexSecu, indexFreq, indexBSsid, indexName;
headLine = headLine.trimmed();
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
if (isChineseExist) {
indexSignal = headLine.indexOf("SIGNAL");
indexSecu = headLine.indexOf("安全性");
indexFreq = headLine.indexOf("频率") + 4;
indexBSsid = headLine.indexOf("BSSID") + 6;
indexName = indexBSsid + 19;
} else {
indexSignal = headLine.indexOf("SIGNAL");
indexSecu = headLine.indexOf("SECURITY");
indexFreq = headLine.indexOf("FREQ");
indexBSsid = headLine.indexOf("BSSID");
indexName = indexBSsid + 19;
}
QStringList tmp = slist;
for(int i=1;i<tmp.size();i++){
QString line = tmp.at(i);
QString name = line.mid(indexName).trimmed();
int freq = line.mid(indexFreq,4).trimmed().toInt();
int signal = line.mid(indexSignal,3).trimmed().toInt();
if(freq >= 5000 && ocf->isWifiConfExist(name) && signal > 55){ //两格以上有配置的5Gwifi中选择信号最佳的
target << line;
tmp.removeAt(i);
}
}
for(QString i:tmp){
QString name = i.mid(indexName).trimmed();
if(ocf->isWifiConfExist(name)){
target<<i;
}
}
return target;
}
// 加载wifi列表
void MainWindow::loadWifiListDone(QStringList slist)
{
@ -1892,7 +1924,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
} else {
QProcess * process = new QProcess;
QString name = actWifiName;
process->start(QString("nmcli -f 802-11-wireless.ssid connection show '%1'").arg(name));
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();
});
@ -1911,7 +1943,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
// 填充可用网络列表
QString headLine = slist.at(0);
int indexSignal,indexSecu, indexFreq, indexBSsid, indexName;
int indexSignal,indexSecu, indexFreq, indexBSsid, indexName, indexPath;
headLine = headLine.trimmed();
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
@ -1921,12 +1953,14 @@ void MainWindow::loadWifiListDone(QStringList slist)
indexFreq = headLine.indexOf("频率") + 4;
indexBSsid = headLine.indexOf("BSSID") + 6;
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
} else {
indexSignal = headLine.indexOf("SIGNAL");
indexSecu = headLine.indexOf("SECURITY");
indexFreq = headLine.indexOf("FREQ");
indexBSsid = headLine.indexOf("BSSID");
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
}
QStringList wnames;
int count = 0;
@ -1934,7 +1968,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
for (int i = 1; i < slist.size(); i ++) {
QString line = slist.at(i);
QString wbssid = line.mid(indexBSsid, 17).trimmed();
QString wname = line.mid(indexName).trimmed();
QString wname = line.mid(indexName, indexPath - indexName).trimmed();
if (actWifiBssidList.contains(wbssid)) {
actWifiName = wname;
@ -1948,13 +1982,12 @@ void MainWindow::loadWifiListDone(QStringList slist)
actWifiId = actWifiName;
actWifiName = "--";
}
for (int i = 1, j = 0; i < slist.size(); i ++) {
QString line = slist.at(i);
QString wsignal = line.mid(indexSignal, 3).trimmed();
QString wsecu = line.mid(indexSecu, indexFreq - indexSecu).trimmed();
QString wbssid = line.mid(indexBSsid, 17).trimmed();
QString wname = line.mid(indexName).trimmed();
QString wname = line.mid(indexName, indexPath - indexName).trimmed();
QString wfreq = line.mid(indexFreq, 4).trimmed();
if (actWifiName != "--" && actWifiName == wname) {
@ -1962,14 +1995,15 @@ void MainWindow::loadWifiListDone(QStringList slist)
continue; //若当前热点ssid名称和已经连接的wifi的ssid名称相同但bssid不同则跳过
}
}
if (wnames.contains(wname) && wbssid != actWifiBssid) {
if ((wnames.contains(wname) && wbssid != actWifiBssid)) {
continue; //过滤相同名称的wifi
}
int max_freq = wfreq.toInt();
int min_freq = wfreq.toInt();
for (int k = i; k < slist.size(); k ++) {
if (wname == slist.at(k).mid(indexName).trimmed()) {
QString m_name = slist.at(k).mid(indexName, indexPath - indexName).trimmed();
if (wname == m_name) {
if (slist.at(k).mid(indexFreq, 4).trimmed().toInt() > max_freq) {
max_freq = slist.at(k).mid(indexFreq, 4).trimmed().toInt();
} else if (slist.at(k).mid(indexFreq, 4).trimmed().toInt() < min_freq) {
@ -1977,6 +2011,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
}
}
}
int freqState = 0;
if (max_freq < 3000) {
//只有2.4GHZ
@ -1991,7 +2026,14 @@ void MainWindow::loadWifiListDone(QStringList slist)
//对于已经连接的wifi
connect(ccf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneTopWifiFormSelected(QString,int)));
connect(ccf, SIGNAL(disconnActiveWifi()), this, SLOT(activeWifiDisconn()));
ccf->setName(wname, wbssid, actWifiUuid);
QString path = line.mid(indexPath).trimmed();
QString m_name;
if (path != "" && !path.isEmpty()) m_name= this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(path.mid(path.lastIndexOf("/") + 1)));
if (m_name.isEmpty() || m_name == "") {
ccf->setName(wname, wbssid, actWifiUuid);
} else {
ccf->setName(m_name, wbssid, actWifiUuid);
}
//ccf->setRate(wrate);
int signal = wsignal.toInt() + 11;
ccf->setSignal(QString::number(signal), wsecu);
@ -2014,7 +2056,15 @@ void MainWindow::loadWifiListDone(QStringList slist)
OneConnForm *ocf = new OneConnForm(wifiListWidget, this, confForm, ksnm);
connect(ocf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneWifiFormSelected(QString,int)));
ocf->setName(wname, wbssid, "--");
// ocf->setName(wname, wbssid, "--");
QString path = line.mid(indexPath).trimmed();
QString m_name;
if (path != "" && !path.isEmpty()) m_name= this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(path.mid(path.lastIndexOf("/") + 1)));
if (m_name.isEmpty() || m_name == "") {
ocf->setName(wname, wbssid, actWifiUuid);
} else {
ocf->setName(m_name, wbssid, actWifiUuid);
}
//ocf->setRate(wrate);
ocf->setLine(true);
ocf->setSignal(wsignal, wsecu);
@ -2093,7 +2143,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
}
QString headLine = slist.at(0);
int indexSecu, indexFreq, indexBSsid, indexName;
int indexSecu, indexFreq, indexBSsid, indexName, indexPath;
headLine = headLine.trimmed();
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
if (isChineseExist) {
@ -2102,21 +2152,23 @@ void MainWindow::updateWifiListDone(QStringList slist)
indexBSsid = headLine.indexOf("BSSID") + 6;
//indexName = headLine.indexOf("SSID") + 6;
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
} else {
indexSecu = headLine.indexOf("SECURITY");
indexFreq = headLine.indexOf("FREQ");
indexBSsid = headLine.indexOf("BSSID");
//indexName = headLine.indexOf("SSID");
indexName = indexBSsid + 19;
indexPath = headLine.indexOf("DBUS-PATH");
}
//列表中去除已经减少的wifi
for (int i=1; i<oldWifiSlist.size(); i++){
QString line = oldWifiSlist.at(i);
QString lastWname = line.mid(lastIndexName).trimmed();
QString lastWname = line.mid(lastIndexName, indexPath - lastIndexName).trimmed();
for (int j=1; j<slist.size(); j++){
QString line = slist.at(j);
QString wname = line.mid(indexName).trimmed();
QString wname = line.mid(indexName, indexPath - indexName).trimmed();
if (lastWname == wname){break;} //在slist最后之前找到了lastWname则停止
if (j == slist.size()-1) {
@ -2151,7 +2203,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
QString wsignal = line.mid(0, indexSecu).trimmed();
QString wsecu = line.mid(indexSecu, indexFreq - indexSecu).trimmed();
QString wbssid = line.mid(indexBSsid, 17).trimmed();
QString wname = line.mid(indexName).trimmed();
QString wname = line.mid(indexName, indexPath - indexName).trimmed();
QString wfreq = line.mid(indexFreq, 4).trimmed();
if(wname == "" || wname == "--"){continue;}
@ -2165,8 +2217,10 @@ void MainWindow::updateWifiListDone(QStringList slist)
int max_freq = wfreq.toInt();
int min_freq = wfreq.toInt();
for (int k = i; k < slist.size(); k ++) {
if (wname == slist.at(k).mid(indexName).trimmed()) {
for (int k = 0; k < slist.size(); k ++) {
QString m_name = slist.at(k).mid(indexName, indexPath - indexName).trimmed();
// QString m_name = this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(slist.at(k).mid(slist.at(k).lastIndexOf("/") + 1).trimmed()));
if (wname == m_name) {
if (slist.at(k).mid(indexFreq, 4).trimmed().toInt() > max_freq) {
max_freq = slist.at(k).mid(indexFreq, 4).trimmed().toInt();
} else if (slist.at(k).mid(indexFreq, 4).trimmed().toInt() < min_freq) {
@ -2188,8 +2242,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
for (int j=1; j < oldWifiSlist.size(); j++) {
QString line = oldWifiSlist.at(j);
QString lastWname = line.mid(lastIndexName).trimmed();
QString lastWname = line.mid(lastIndexName, indexPath - lastIndexName).trimmed();
if (lastWname == wname){break;} //上一次的wifi列表已经有名为wname的wifi则停止
if (j == oldWifiSlist.size()-1) { //到lastSlist最后一个都没找到执行下面流程
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
@ -2208,7 +2261,15 @@ void MainWindow::updateWifiListDone(QStringList slist)
wifiListWidget->resize(W_LIST_WIDGET, wifiListWidget->height() + H_NORMAL_ITEM);
OneConnForm *addItem = new OneConnForm(wifiListWidget, this, confForm, ksnm);
connect(addItem, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneWifiFormSelected(QString,int)));
addItem->setName(wname, wbssid, "--");
// addItem->setName(wname, wbssid, "--");
QString path = line.mid(indexPath).trimmed();
QString m_name;
if (path != "" && !path.isEmpty()) m_name= this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(path.mid(path.lastIndexOf("/") + 1)));
if (m_name.isEmpty() || m_name == "") {
addItem->setName(wname, wbssid, actWifiUuid);
} else {
addItem->setName(m_name, wbssid, actWifiUuid);
}
//addItem->setRate(wrate);
addItem->setLine(false);
addItem->setSignal(wsignal, wsecu);
@ -2754,14 +2815,14 @@ void MainWindow::activeStartLoading()
void MainWindow::activeGetWifiList()
{
emit this->waitWifiStop();
this->ksnm->execGetWifiList();
this->ksnm->execGetWifiList(this->wcardname);
}
//网络开关处理,打开与关闭网络
void MainWindow::enNetDone()
{
BackThread *bt = new BackThread();
mwBandWidth = bt->execChkLanWidth(lname);
mwBandWidth = bt->execChkLanWidth(lcardname);
// 打开网络开关时如果Wifi开关是打开的设置其样式
if (checkWlOn()) {
@ -2824,7 +2885,7 @@ void MainWindow::enWifiDone()
{
is_update_wifi_list = 0;
if (is_btnWifiList_clicked) {
this->ksnm->execGetWifiList();
this->ksnm->execGetWifiList(this->wcardname);
} else {
//on_btnWifiList_clicked();
}
@ -3069,7 +3130,7 @@ void MainWindow::on_checkWifiListChanged()
if (loop_iface->wstate != 2) {
is_update_wifi_list = 1;
this->ksnm->execGetWifiList(); //更新wifi列表
this->ksnm->execGetWifiList(this->wcardname); //更新wifi列表
}
delete loop_iface;
@ -3235,7 +3296,7 @@ void MainWindow::connWifiDone(int connFlag)
WifiAuthThread *wifi_auth_thread=new WifiAuthThread();
wifi_auth_thread->start();
syslog(LOG_DEBUG, "Wi-Fi already connected by clicking button");
this->ksnm->execGetWifiList();
this->ksnm->execGetWifiList(this->wcardname);
QString txt(tr("Conn Wifi Success"));
objKyDBus->showDesktopNotify(txt);

View File

@ -170,8 +170,8 @@ public:
int is_fly_mode_on = 0; //是否已经打开飞行模式
int is_hot_sopt_on = 0; //是否已经打开热点
int is_connect_hide_wifi = 0; //是否正在连接隐藏wifi
QString currSelNetName = ""; //当前ScrollArea中选中的网络名称
QString currConnIfname = ""; //当前连接的有线网对应网卡名称,只有一个有线网连接的情况
QString oldWifiIpv4Method = ""; //原来的wifi的ipv4地址获取方式,自动还是手动
int currSelNetNum = 0; //当前选中的item序号
@ -282,7 +282,7 @@ private:
QWidget *widShowWindow = nullptr;
QWidget *widAdvConf = nullptr;
QString lname, wname; // 以太网卡和无线网卡名称
QString lcardname, wcardname; // 以太网卡和无线网卡名称
QString btnOffQss, btnOnQss, btnBgOffQss, btnBgOnQss, btnBgHoverQss, btnBgLeaveQss; // 主界面按钮底色
QString scrollBarQss, leftBtnQss, funcBtnQss;
@ -296,6 +296,7 @@ private:
QString oldActLanName = ""; //上一次获取的已连接有线网名称
int oldDbusActLanDNS = 0; //上一次获取的已连接有线网的DNS代号
void wifiListOptimize(QStringList& slist); //只保留同名同频信号最强AP
QStringList connectableWifiPriorityList(const QStringList slist); //可连接wifi优先级列表
//循环检测网络连接状态
QTimer *iconTimer = nullptr;
QTimer *wiredCableUpTimer = nullptr;

View File

@ -605,7 +605,7 @@ void OneConnForm::toConnectWirelessNetwork()
if (isWifiConfExist(wifiName)) {
//有配置文件,获取密码存储策略
QProcess * process = new QProcess(this);
process->start(QString("nmcli -f 802-11-wireless-security.psk-flags connection show '%1'").arg(wifiName));
process->start(QString("nmcli -f 802-11-wireless-security.psk-flags connection show \"%1\"").arg(wifiName));
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
process->deleteLater();
});
@ -845,7 +845,7 @@ void OneConnForm::on_btnInfo_clicked()
if (line.startsWith("method:")) {
v4method = line.split(":").at(1);
}
if (line.startsWith("addr:")) {
if (line.startsWith("v4addr:")) {
addr = line.split(":").at(1);
}
if (line.startsWith("mask:")) {
@ -1023,7 +1023,7 @@ void OneConnForm::on_btnCancel_clicked()
int OneConnForm::getPskFlag()
{
QProcess * process = new QProcess(this);
process->start(QString("nmcli -f 802-11-wireless-security.psk-flags connection show '%1'").arg(wifiName));
process->start(QString("nmcli -f 802-11-wireless-security.psk-flags connection show \"%1\"").arg(wifiName));
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
process->deleteLater();
});

View File

@ -225,7 +225,14 @@ void OneLancForm::setTopItem(bool isSelected)
//设置网络名称
void OneLancForm::setName(QString ssid, QString transSsid, QString uuid, QString interface)
{
ui->lbName->setText(ssid);
//处理过长SSID
QString displayName;
if(ssid.length() > 23){
displayName = ssid.mid(0, 20) + "...";
}else{
displayName = ssid;
}
ui->lbName->setText(displayName);
ssidName = ssid;
m_sConnectType = transSsid;
uuidName = uuid;

View File

@ -44,6 +44,10 @@ WiFiConfigDialog::WiFiConfigDialog(QWidget *parent) :
ui->checkBoxPwd->setStyleSheet(checkBoxQss);
ui->checkBoxPwd->setFocusPolicy(Qt::NoFocus);
ui->leWifiId->setContextMenuPolicy(Qt::NoContextMenu); //禁止LineEdit的右键菜单
ui->leWiFiName->setContextMenuPolicy(Qt::NoContextMenu);
ui->leWifiPassword->setContextMenuPolicy(Qt::NoContextMenu);
this->setEnableOfBtn();
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));