diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9ee8f3c5..79d78ec0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1576,7 +1576,7 @@ void MainWindow::loadWifiListDone(QStringList slist) for (int i = 1, j = 0; i < slist.size(); i ++) { QString line = slist.at(i); QString wsignal = line.mid(0, indexSecu).trimmed(); - QString wsecu = line.mid(indexSecu, indexName - indexSecu).trimmed(); + QString wsecu = line.mid(indexSecu, indexFreq - indexSecu).trimmed(); QString wname = line.mid(indexName).trimmed(); QString wfreq = line.mid(indexFreq, 4).trimmed(); bool isContinue = false; @@ -1597,6 +1597,14 @@ void MainWindow::loadWifiListDone(QStringList slist) } } } + int freqState = 0; + if (max_freq < 3000) { + //只有2.4GHZ + freqState = 1; + } else if (min_freq >= 5000) { + //只有5GHZ + freqState = 2; + } if (wname != "" && wname != "--") { // 当前连接的wifi if (wname == actWifiName) { @@ -1607,7 +1615,7 @@ void MainWindow::loadWifiListDone(QStringList slist) ccf->setSignal(wsignal, wsecu); activeWifiSignalLv = wsignal.toInt(); objKyDBus->getWifiMac(wname); - ccf->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac, ((max_freq > 5000) && (min_freq < 3000))); + ccf->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac, freqState); ccf->setConnedString(1, tr("NetOn,"), wsecu);//"已连接" ccf->isConnected = true; ifWLanConnected = true; @@ -1629,7 +1637,7 @@ void MainWindow::loadWifiListDone(QStringList slist) ocf->setLine(true); ocf->setSignal(wsignal, wsecu); objKyDBus->getWifiMac(wname); - ocf->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac, ((max_freq > 5000) && (min_freq < 3000))); + ocf->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac, freqState); ocf->setConnedString(0, tr("Disconnected"), wsecu); ocf->move(L_VERTICAL_LINE_TO_ITEM, j * H_NORMAL_ITEM); ocf->setSelected(false, false); @@ -1738,7 +1746,7 @@ void MainWindow::updateWifiListDone(QStringList slist) for(int i = 1; i < slist.size(); i++){ QString line = slist.at(i); QString wsignal = line.mid(0, indexSecu).trimmed(); - QString wsecu = line.mid(indexSecu, indexName - indexSecu).trimmed(); + QString wsecu = line.mid(indexSecu, indexFreq - indexSecu).trimmed(); QString wname = line.mid(indexName).trimmed(); QString wfreq = line.mid(indexFreq, 4).trimmed(); @@ -1763,6 +1771,15 @@ void MainWindow::updateWifiListDone(QStringList slist) } } + int freqState = 0; + if (max_freq < 3000) { + //只有2.4GHZ + freqState = 1; + } else if (min_freq >= 5000) { + //只有5GHZ + freqState = 2; + } + wnames.append(wname); for (int j=1; j < oldWifiSlist.size(); j++) { @@ -1792,7 +1809,7 @@ void MainWindow::updateWifiListDone(QStringList slist) addItem->setLine(false); addItem->setSignal(wsignal, wsecu); objKyDBus->getWifiMac(wname); - addItem->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac, ((max_freq > 5000) && (min_freq < 3000))); + addItem->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac, freqState); addItem->setConnedString(0, tr("Disconnected"), wsecu);//"未连接" addItem->move(L_VERTICAL_LINE_TO_ITEM, posY); addItem->setSelected(false, false); diff --git a/src/oneconnform.cpp b/src/oneconnform.cpp index 7dc2b1a4..f6137a38 100644 --- a/src/oneconnform.cpp +++ b/src/oneconnform.cpp @@ -136,9 +136,19 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf connect(mw, SIGNAL(waitWifiStop()), this, SLOT(stopWaiting())); connType = ""; - - ui->fiveGlabel->hide(); - ui->fiveGlabel->setStyleSheet("QLabel{background-color: palette(button); border-radius: 4px;}"); + lbNameLyt = new QHBoxLayout(ui->lbName); + lbFreq = new QLabel(ui->lbName); + lbFreq->setAlignment(Qt::AlignCenter); + lbFreq->setEnabled(false); + lbFreq->setStyleSheet("QLabel{border: 1px solid rgba(0, 0, 0, 0.5); background: transparent; color: rgba(0, 0, 0, 0.5); border-radius: 4px; font-size: 12px;}"); + lbFreq->hide(); + lbNameText = new QLabel(ui->lbName); + lbNameLyt->setContentsMargins(0, 0, 0, 0); + lbNameLyt->setSpacing(4); + lbNameLyt->addWidget(lbNameText); + lbNameLyt->addWidget(lbFreq); + lbNameLyt->addStretch(); + ui->lbName->setLayout(lbNameLyt); } OneConnForm::~OneConnForm() @@ -345,18 +355,18 @@ void OneConnForm::setConnedString(bool showLable, QString str, QString str1) void OneConnForm::setName(QString name) { - ui->lbName->setText(name); + lbNameText->setText(name); wifiName = name; } void OneConnForm::setSpecialName(QString name) { - ui->lbName->setText(tr("Connect to Hidden Wi-Fi Network")); //连接到隐藏的 Wi-Fi 网络 + lbNameText->setText(tr("Connect to Hidden Wi-Fi Network")); //连接到隐藏的 Wi-Fi 网络 wifiName = name; } QString OneConnForm::getName() { - return ui->lbName->text(); + return lbNameText->text(); } void OneConnForm::setRate(QString rate) @@ -426,10 +436,19 @@ void OneConnForm::setSignal(QString lv, QString secu) } } -void OneConnForm::setWifiInfo(QString str1, QString str2, QString str3, bool is_double_freq) +void OneConnForm::setWifiInfo(QString str1, QString str2, QString str3, int freq) { - if (is_double_freq) { - ui->fiveGlabel->show(); + //freq 0:含2.4G和5G, 1:只有2.4G, 2:只有5G + lbFreq->show(); + if (freq == 1) { + //freq ~ 2.4G + lbFreq->setText("2.4G"); + } else if (freq == 2) { + //freq ~ 5G + lbFreq->setText("5G"); + } else { + //freq ~ 5G&2.4G + lbFreq->setText("2.4/5G"); } if (str1 == "--" || str1 == ""){ str1 = tr("None"); }; @@ -446,25 +465,25 @@ void OneConnForm::setWifiInfo(QString str1, QString str2, QString str3, bool is_ void OneConnForm::slotConnWifi() { this->startWaiting(true); - emit sigConnWifi(ui->lbName->text()); + emit sigConnWifi(lbNameText->text()); } void OneConnForm::slotConnWifiPWD() { this->startWaiting(true); - emit sigConnWifiPWD(ui->lbName->text(), ui->lePassword->text(), connType); + emit sigConnWifiPWD(lbNameText->text(), ui->lePassword->text(), connType); } //点击后断开wifi网络 void OneConnForm::on_btnDisConn_clicked() { - syslog(LOG_DEBUG, "DisConnect button about wifi net is clicked, current wifi name is %s .", ui->lbName->text().toUtf8().data()); - qDebug()<<"DisConnect button about wifi net is clicked, current wifi name is "<lbName->text(); + syslog(LOG_DEBUG, "DisConnect button about wifi net is clicked, current wifi name is %s .", lbNameText->text().toUtf8().data()); + qDebug()<<"DisConnect button about wifi net is clicked, current wifi name is "<text(); this->startWaiting(false); mw->is_stop_check_net_state = 1; mw->on_btnHotspotState(); - kylin_network_set_con_down(ui->lbName->text().toUtf8().data()); + kylin_network_set_con_down(lbNameText->text().toUtf8().data()); disconnect(this, SIGNAL(selectedOneWifiForm(QString,int)), mw, SLOT(oneWifiFormSelected(QString,int))); emit disconnActiveWifi(); } @@ -521,7 +540,7 @@ void OneConnForm::toConnectWirelessNetwork() return; } if (ui->lbConned->text() == "--" || ui->lbConned->text() == " ") { - if (!isWifiConfExist(ui->lbName->text())) { + if (!isWifiConfExist(lbNameText->text())) { //没有配置文件,使用有密码的wifi连接 on_btnConnPWD_clicked(); return; @@ -654,7 +673,7 @@ void OneConnForm::on_btnInfo_clicked() } BackThread *bt = new BackThread(); - QString connProp = bt->getConnProp(ui->lbName->text()); + QString connProp = bt->getConnProp(lbNameText->text()); QStringList propList = connProp.split("|"); QString v4method, addr, mask, gateway, dns; foreach (QString line, propList) { @@ -676,7 +695,7 @@ void OneConnForm::on_btnInfo_clicked() } // qDebug()<<"v4method:"<setProp(ui->lbName->text(), "--", v4method, addr, mask, gateway, dns, this->isActive, true); + cf->setProp(lbNameText->text(), "--", v4method, addr, mask, gateway, dns, this->isActive, true); cf->move(primaryGeometry.width() / 2 - cf->width() / 2, primaryGeometry.height() / 2 - cf->height() / 2); cf->exec(); cf->raise(); @@ -690,14 +709,14 @@ void OneConnForm::slotConnWifiResult(int connFlag) qDebug()<<"Function slotConnWifiResult receives a number: "<lbName->text() + " wifi-sec.psk-flags 2"; + QString strConntype = "nmcli connection modify " + lbNameText->text() + " wifi-sec.psk-flags 2"; system(strConntype.toUtf8().data()); } connType = ""; if (connFlag == 2 || connFlag == 4) { mw->currSelNetName = ""; - emit selectedOneWifiForm(ui->lbName->text(), H_WIFI_ITEM_SMALL_EXTEND); + emit selectedOneWifiForm(lbNameText->text(), H_WIFI_ITEM_SMALL_EXTEND); resize(W_ITEM, H_ITEM_MIDDLE); ui->wbg->hide(); @@ -732,12 +751,12 @@ void OneConnForm::slotConnWifiResult(int connFlag) if (connFlag == 1) { // 使用配置文件连接失败,需要删除该配置文件 QString txt(tr("Conn Wifi Failed"));//"连接 Wifi 失败" - syslog(LOG_DEBUG, "Try to connect wifi named %s, but failed, will delete it's configuration file", ui->lbName->text().toUtf8().data()); + syslog(LOG_DEBUG, "Try to connect wifi named %s, but failed, will delete it's configuration file", lbNameText->text().toUtf8().data()); KylinDBus kylindbus; kylindbus.showDesktopNotify(txt); //QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + ui->lbName->text() + "';notify-send '" + txt + "...' -t 3800"; - QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + ui->lbName->text() + "'"; + QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + lbNameText->text() + "'"; int status = system(cmd.toUtf8().data()); if (status != 0) { syslog(LOG_ERR, "execute 'nmcli connection delete' in function 'slotConnWifiResult' failed"); diff --git a/src/oneconnform.h b/src/oneconnform.h index ccf1a140..a33947ca 100644 --- a/src/oneconnform.h +++ b/src/oneconnform.h @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "confform.h" #include "backthread.h" @@ -68,7 +70,7 @@ public: QString getName(); void setRate(QString rate); void setLine(bool isShow); - void setWifiInfo(QString str1, QString str2, QString str3, bool is_double_freq); + void setWifiInfo(QString str1, QString str2, QString str3, int freq); void setSelected(bool isSelected, bool isCurrName); void setHideItem(bool isHideItem, bool isShowHideBtn); @@ -131,6 +133,9 @@ private: bool hasPwd; QString leQssLow, leQssHigh; + QLabel * lbFreq = nullptr; + QLabel * lbNameText = nullptr; + QHBoxLayout * lbNameLyt = nullptr; signals: void selectedOneWifiForm(QString wifiName, int extendLength); diff --git a/src/oneconnform.ui b/src/oneconnform.ui index 0ab736cf..ea23a959 100644 --- a/src/oneconnform.ui +++ b/src/oneconnform.ui @@ -18,7 +18,7 @@ 63 8 - 190 + 200 20 @@ -259,22 +259,6 @@ - - - - 255 - 17 - 50 - 20 - - - - 2.4/5G - - - Qt::AlignCenter - - wbg_3 wbg_2 lbName @@ -289,7 +273,6 @@ btnHideConn lbWaiting lbWaitingIcon - fiveGlabel diff --git a/src/wpawifidialog.cpp b/src/wpawifidialog.cpp index ceba0988..c21c88b4 100644 --- a/src/wpawifidialog.cpp +++ b/src/wpawifidialog.cpp @@ -26,6 +26,7 @@ #include #include #include +#include const QString CONFIG_FILE = "/tmp/wpaconf.ini"; @@ -395,7 +396,7 @@ void WpaWifiDialog::activateConnection() { qDebug() << "qDebug: activate time out!"; }); //设置超时时间 - timeout->start(5000); + timeout->start(12 * 1000); }); connect(upThread, &UpConnThread::connRes, this, [ = ](int res) { qDebug()<<"qDebug: Connect result is: "<0 0 360 - 504 + 530 360 - 504 + 530 360 - 504 + 530 diff --git a/translations/kylin-nm_bo.ts b/translations/kylin-nm_bo.ts index 783d4b45..a8131781 100644 --- a/translations/kylin-nm_bo.ts +++ b/translations/kylin-nm_bo.ts @@ -74,38 +74,38 @@ - - + + Can not create new wired network for without wired card - + New network already created - + New network settings already finished - + Will check the IP address conflict - + IP address conflict, Please change IP - + Edit Network - + Add Wired Network @@ -1190,20 +1190,20 @@ MainWindow - + kylin-nm - + Advanced - - + + Ethernet @@ -1219,7 +1219,7 @@ - + Wifi @@ -1234,29 +1234,29 @@ - + No wireless card detected - - - - - + + + + + Not connected - - - - - - - - - + + + + + + + + + Disconnected @@ -1276,69 +1276,69 @@ - + Show MainWindow - + No Other Wired Network Scheme - + No Other Wireless Network Scheme - - - - + + + + Wired connection - - - - + + + + Ethernet connection - + Confirm your Wi-Fi password or usable of wireless card - - + + NetOn, - + Wired net is disconnected - + Wi-Fi is disconnected - + Conn Ethernet Success - + Conn Ethernet Fail - + Conn Wifi Success @@ -1350,11 +1350,6 @@ Form - - - 2.4/5G - - @@ -1369,47 +1364,47 @@ - + Connect to Hidden Wi-Fi Network - + Rate - + None - + WiFi Security: - + Signal: - + MAC: - + Conn Wifi Success - + Confirm your Wi-Fi password or usable of wireless card - + Conn Wifi Failed @@ -1482,57 +1477,62 @@ - + Connect Wifi - + Connection name - + Security - + EAP type - + inner authentication - + Username - + Password - + Show password - + + Ask pwd each query + + + + Cancel - + Connect - + WPA & WPA2 diff --git a/translations/kylin-nm_tr.ts b/translations/kylin-nm_tr.ts index 83f77ce0..094e40e1 100644 --- a/translations/kylin-nm_tr.ts +++ b/translations/kylin-nm_tr.ts @@ -81,38 +81,38 @@ Tamam - - + + Can not create new wired network for without wired card Kablolu kart olmadan yeni kablolu ağ oluşturulamıyor - + New network already created Yeni ağ zaten oluşturuldu - + New network settings already finished Yeni ağ ayarları zaten tamamlandı - + Will check the IP address conflict - + IP address conflict, Please change IP - + Edit Network Ağı Düzenle - + Add Wired Network Kablolu Ağ Ekle @@ -1348,7 +1348,7 @@ MainWindow - + kylin-nm @@ -1358,14 +1358,14 @@ - + Advanced Gelişmiş - - + + Ethernet Kablolu Ağ @@ -1375,7 +1375,7 @@ - + Wifi Wi-Fi @@ -1398,75 +1398,75 @@ - + Show MainWindow Ana Pencereyi Göster - + No wireless card detected - - - - - + + + + + Not connected Bağlanamadı - - - - - - - - - + + + + + + + + + Disconnected Bağlantı Kesildi - + No Other Wired Network Scheme Başka Kablolu Ağ Düzeni Yok - + No Other Wireless Network Scheme Başka Kablosuz Ağ Düzeni Yok - - - - + + + + Wired connection - - - - + + + + Ethernet connection - + Wired net is disconnected Kablolu ağ bağlantısı kesildi - + Wi-Fi is disconnected Kablosuz bağlantı kesildi - + Confirm your Wi-Fi password or usable of wireless card Kablosuz şifrenizi veya kablosuz kart kullanılabilirliğini onaylayın @@ -1491,8 +1491,8 @@ Listede kullanılabilir ağ yok - - + + NetOn, @@ -1526,17 +1526,17 @@ Kablosuz listesini şimdi güncelle - + Conn Ethernet Success Ethernet Bağlantısı Başarılı - + Conn Ethernet Fail Ethernet Bağlantısı Hatası - + Conn Wifi Success Wi-Fi Bağlantısı Başarılı @@ -1555,11 +1555,6 @@ Form -- - - - 2.4/5G - - Input password Parola gir @@ -1586,12 +1581,12 @@ Parola gir... - + Connect to Hidden Wi-Fi Network Gizli Wi-Fi Ağına Bağlan - + Signal: @@ -1604,17 +1599,17 @@ Güvenli - + Rate Oran - + None Yok - + WiFi Security: WiFi güvenliği: @@ -1623,22 +1618,22 @@ Sinyal gücü: - + MAC: Fiziksel adres: - + Conn Wifi Success Wi-Fi Bağlantısı Başarılı - + Confirm your Wi-Fi password or usable of wireless card Kablosuz şifrenizi veya kablosuz kart kullanılabilirliğini onaylayın - + Conn Wifi Failed Wifi Bağlantısı Başarısız @@ -1719,57 +1714,62 @@ - + Connect Wifi - + Connection name - + Security - + EAP type - + inner authentication - + Username - + Password - + Show password - + + Ask pwd each query + + + + Cancel - + Connect - + WPA & WPA2 diff --git a/translations/kylin-nm_zh_CN.qm b/translations/kylin-nm_zh_CN.qm index 6ae44ebb..1ed3aca0 100644 Binary files a/translations/kylin-nm_zh_CN.qm and b/translations/kylin-nm_zh_CN.qm differ diff --git a/translations/kylin-nm_zh_CN.ts b/translations/kylin-nm_zh_CN.ts index 8b46cdda..24b89c78 100644 --- a/translations/kylin-nm_zh_CN.ts +++ b/translations/kylin-nm_zh_CN.ts @@ -81,38 +81,38 @@ 确定 - - + + Can not create new wired network for without wired card 缺少有线网卡 无法新建网络 - + New network already created 已创建新的有线网络 - + New network settings already finished 新的网络配置已经完成 - + Will check the IP address conflict 即将检测IP地址冲突 - + IP address conflict, Please change IP IP地址冲突,请更换IP - + Edit Network 编辑网络设置 - + Add Wired Network 新建有线网络 @@ -1308,7 +1308,7 @@ MainWindow - + kylin-nm 网络工具 @@ -1318,14 +1318,14 @@ - + Advanced 设置网络 - - + + Ethernet 有线网络 @@ -1335,7 +1335,7 @@ - + Wifi 无线网络 @@ -1358,75 +1358,75 @@ 飞行模式 - + Show MainWindow 显示网络连接界面 - + No wireless card detected 未检测到无线网卡 - - - - - + + + + + Not connected 当前未连接任何网络 - - - - - - - - - + + + + + + + + + Disconnected 未连接 - + No Other Wired Network Scheme 列表中无其他有线网络 - + No Other Wireless Network Scheme 未检测到其他无线网络 - - - - + + + + Wired connection 有线连接 - - - - + + + + Ethernet connection 以太网连接 - + Wired net is disconnected 断开有线网络 - + Wi-Fi is disconnected 断开无线网络 - + Confirm your Wi-Fi password or usable of wireless card 请确认Wi-Fi密码或无线设备 @@ -1451,8 +1451,8 @@ 列表暂无可连接网络 - - + + NetOn, 已连接, @@ -1486,17 +1486,17 @@ 正在更新 Wi-Fi列表 - + Conn Ethernet Success 连接有线网络成功 - + Conn Ethernet Fail 连接有线网络失败 - + Conn Wifi Success 连接无线网络成功 @@ -1515,11 +1515,6 @@ Form -- - - - 2.4/5G - - Input password 输入密码 @@ -1546,12 +1541,12 @@ 输入密码... - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 - + Signal: 信号强度: @@ -1564,37 +1559,37 @@ 安全 - + Rate 速率 - + None - + WiFi Security: WiFi安全性: - + MAC: 物理地址: - + Conn Wifi Success 连接无线网络成功 - + Confirm your Wi-Fi password or usable of wireless card 请确认Wi-Fi密码或无线设备 - + Conn Wifi Failed 连接无线网络失败 @@ -1675,57 +1670,62 @@ - + Connect Wifi 连接网络 - + Connection name 连接名称 - + Security 安全性 - + EAP type EAP方法 - + inner authentication 阶段2身份验证 - + Username 用户名: - + Password 密码: - + Show password 显示密码 - + + Ask pwd each query + 每次询问密码 + + + Cancel 取消 - + Connect 连接 - + WPA & WPA2 WPA 及 WPA2企业