From a6498fc568bb17d24b3218404f82f620ead8481b Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Wed, 12 Apr 2023 17:45:13 +0800 Subject: [PATCH] =?UTF-8?q?WiFi=E5=88=97=E8=A1=A8=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=98=BE=E7=A4=BAWiFi6/WiFi6+=E5=9B=BE=E6=A0=87=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/list-items/wlanlistitem.cpp | 10 ++++-- src/frontend/list-items/wlanlistitem.h | 5 +-- src/frontend/tab-pages/wlanpage.cpp | 44 ++++++++++++++++++++---- src/frontend/tab-pages/wlanpage.h | 3 ++ 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp index 4b5ef274..f7d9563e 100644 --- a/src/frontend/list-items/wlanlistitem.cpp +++ b/src/frontend/list-items/wlanlistitem.cpp @@ -35,17 +35,19 @@ const QString ENTERPRICE_TYPE = "802.1X"; const QString WPA1_AND_WPA2 = "WPA"; const QString WPA3 = "WPA3"; -WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, bool isApMode, QWidget *parent) +WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, bool isApMode, bool isShowWifi6, QWidget *parent) : WlanListItem(wirelessNetItem, device, parent) { m_isApMode = isApMode; + m_isShowWifi6 = isShowWifi6; refreshIcon(false); // 额外刷新一次图标,因为WlanListItem执行时,m_isApMode尚未赋值 } -WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, QWidget *parent) : ListItem(parent) +WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, bool isShowWifi6, QWidget *parent) : ListItem(parent) { m_wlanDevice = device; m_wirelessNetItem = wirelessNetItem; + m_isShowWifi6 = isShowWifi6; qDebug()<<"[WlanPage] wlan list item is created." << m_wirelessNetItem.m_NetSsid; @@ -454,7 +456,9 @@ void WlanListItem::refreshIcon(bool isActivated) int signalStrength = 0; QString uni = ""; QString secuType = ""; - category = m_wirelessNetItem.getCategory(m_wirelessNetItem.m_uni); + if (m_isShowWifi6) { + category = m_wirelessNetItem.getCategory(m_wirelessNetItem.m_uni); + } signalStrength = m_wirelessNetItem.m_signalStrength; if (isActivated) { diff --git a/src/frontend/list-items/wlanlistitem.h b/src/frontend/list-items/wlanlistitem.h index 5325d3e1..0d6b3e89 100644 --- a/src/frontend/list-items/wlanlistitem.h +++ b/src/frontend/list-items/wlanlistitem.h @@ -54,8 +54,8 @@ class WlanListItem : public ListItem { Q_OBJECT public: - WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, bool isApMode, QWidget *parent = nullptr); - WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, QWidget *parent = nullptr); + WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, bool isApMode, bool isShowWifi6, QWidget *parent = nullptr); + WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, bool isShowWifi6, QWidget *parent = nullptr); WlanListItem(QWidget *parent = nullptr); ~WlanListItem(); @@ -127,6 +127,7 @@ private: bool m_forgetConnection = false; bool m_isApMode = false; + bool m_isShowWifi6 = true; protected Q_SLOTS: void onInfoButtonClicked(); diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index bb1ea1f5..310ee05c 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -45,6 +45,7 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent) m_connectResource = new KyConnectResourse(this); m_wirelessConnectOpreation = new KyWirelessConnectOperation(this); + checkShowWifi6(); initDevice(); initWlanUI(); initWlanSwitchState(); @@ -192,6 +193,22 @@ bool WlanPage::getWirelessEnable() return m_wirelessConnectOpreation->getWirelessEnabled(); } +void WlanPage::checkShowWifi6() +{ + //990下不显示wifi6 wifi6+图标 + QProcess * processCpuinfo = new QProcess(this); + processCpuinfo->start(QString("cat /proc/cpuinfo")); + connect(processCpuinfo, static_cast(&QProcess::finished), this, [ = ]() { + processCpuinfo->deleteLater(); + }); + processCpuinfo->waitForFinished(); + QString ctrCpuinfo = processCpuinfo->readAll(); + if (ctrCpuinfo.indexOf("HUAWEI Kirin 990") != -1) { + //HW990上不显示wifi6/6+ + m_showWifi6 = false; + } +} + void WlanPage::initWlanSwitchState() { if (m_devList.isEmpty()) { @@ -292,7 +309,8 @@ QListWidgetItem *WlanPage::addNewItem(KyWirelessNetItem &wirelessNetItem, WlanListItem *p_wlanItem = new WlanListItem( wirelessNetItem, m_currentDevice, - m_connectResource->isApConnection(wirelessNetItem.m_connectUuid)); + m_connectResource->isApConnection(wirelessNetItem.m_connectUuid), + m_showWifi6); connect(p_wlanItem, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged); connect(p_wlanItem, &WlanListItem::detailShow, this, &WlanPage::showDetailPage); @@ -309,7 +327,7 @@ QListWidgetItem *WlanPage::insertNewItem(KyWirelessNetItem &wirelessNetItem, QListWidget *wirelessListWidget, int row) { - WlanListItem *p_wlanItem = new WlanListItem(wirelessNetItem, m_currentDevice); + WlanListItem *p_wlanItem = new WlanListItem(wirelessNetItem, m_currentDevice, m_showWifi6); connect(p_wlanItem, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged); connect(p_wlanItem, &WlanListItem::detailShow, this, &WlanPage::showDetailPage); @@ -330,7 +348,7 @@ QListWidgetItem *WlanPage::insertNewItemWithSort(KyWirelessNetItem &wirelessNetI // qDebug()<< "insertNewItemWithSort" << wirelessNetItem.m_NetSsid // <<"sort item config" << wirelessNetItem.m_isConfigured // << "signal strength" << wirelessNetItem.m_signalStrength; - WlanListItem *p_sortWlanItem = new WlanListItem(wirelessNetItem, m_currentDevice); + WlanListItem *p_sortWlanItem = new WlanListItem(wirelessNetItem, m_currentDevice, m_showWifi6); connect(p_sortWlanItem, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged); connect(p_sortWlanItem, &WlanListItem::detailShow, this, &WlanPage::showDetailPage); @@ -527,12 +545,17 @@ void WlanPage::initWlanArea() void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item) { //for dbus + int category = 0; + if (m_showWifi6) { + category = item.getCategory(item.m_uni); + } + QStringList info; info << item.m_NetSsid << QString::number(item.m_signalStrength) << item.m_secuType << (m_connectResource->isApConnection(item.m_connectUuid) ? IsApConnection : NotApConnection) - << QString::number(item.getCategory(item.m_uni)); + << QString::number(category); Q_EMIT wlanAdd(interface, info); if (interface != m_currentDevice) { @@ -1204,7 +1227,7 @@ void WlanPage::onRefreshIconTimer() int takeRow = m_inactivatedNetListWidget->row(p_sortListWidgetItem); m_inactivatedNetListWidget->takeItem(takeRow); - WlanListItem *p_sortWlanItem = new WlanListItem(sortItem, m_currentDevice); + WlanListItem *p_sortWlanItem = new WlanListItem(sortItem, m_currentDevice, m_showWifi6); connect(p_sortWlanItem, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged); connect(p_sortWlanItem, &WlanListItem::detailShow, this, &WlanPage::showDetailPage); m_inactivatedNetListWidget->insertItem(sortRow, p_sortListWidgetItem); @@ -1255,7 +1278,10 @@ void WlanPage::getWirelessList(QMap > &map) QString uni,secuType; if (m_netDeviceResource->getActiveConnectionInfo(iter.key(), signalStrength, uni, secuType)) { - category = data.getCategory(uni); + if (m_showWifi6) { + category = data.getCategory(uni); + } + } vector.append(QStringList() << data.m_NetSsid << QString::number(signalStrength) @@ -1275,11 +1301,15 @@ void WlanPage::getWirelessList(QMap > &map) if (itemData.m_NetSsid == activeSsid) { continue; } + int category = 0; + if (m_showWifi6) { + category = itemData.getCategory(itemData.m_uni); + } vector.append(QStringList()<isApConnection(itemData.m_connectUuid) ? IsApConnection : NotApConnection) - << QString::number(itemData.getCategory(itemData.m_uni))); + << QString::number(category)); } map.insert(iter.key(), vector); diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index d7453722..31257368 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -210,6 +210,9 @@ private: } } + void checkShowWifi6(); + bool m_showWifi6 = true; + private: QMap m_wirelessNetItemMap; QMap m_activateConnectionItemMap;