Merge branch '180344' into 'yhkylin/v101'

fix bug 180344 wifi托盘图标显示切换

See merge request kylinos-src/kylin-nm!212
This commit is contained in:
赵世旭 2023-07-11 09:26:51 +00:00
commit 951acf2b3d
5 changed files with 33 additions and 29 deletions

View File

@ -748,9 +748,9 @@ QString KyActiveConnectResourse::getAcitveConnectionPathByUuid(QString connectUu
return activeAonnectPtr->path();
}
int KyActiveConnectResourse::getAcivateWifiSignal()
int KyActiveConnectResourse::getActivateWifiSignal(QString devName)
{
int signalStrength = 0;
int signalStrength = -1;
KyNetworkDeviceResourse devResource;
QStringList devList;
devResource.getNetworkDeviceList(NetworkManager::Device::Type::Wifi, devList);
@ -766,14 +766,17 @@ int KyActiveConnectResourse::getAcivateWifiSignal()
}
if (connectDevice->type() == NetworkManager::Device::Wifi) {
NetworkManager::WirelessDevice *wirelessDevicePtr =
qobject_cast<NetworkManager::WirelessDevice *>(connectDevice.data());
NetworkManager::AccessPoint::Ptr apPtr = wirelessDevicePtr->activeAccessPoint();
if (apPtr.isNull()) {
continue;
if ((!devName.isEmpty() && connectDevice->interfaceName() == devName)
|| devName.isEmpty()) {
NetworkManager::WirelessDevice *wirelessDevicePtr =
qobject_cast<NetworkManager::WirelessDevice *>(connectDevice.data());
NetworkManager::AccessPoint::Ptr apPtr = wirelessDevicePtr->activeAccessPoint();
if (apPtr.isNull()) {
continue;
}
signalStrength = apPtr->signalStrength();
break;
}
signalStrength = apPtr->signalStrength();
break;
}
}

View File

@ -60,7 +60,7 @@ public:
bool wiredConnectIsActived();
bool checkWirelessStatus(NetworkManager::ActiveConnection::State state);
QString getAcitveConnectionPathByUuid(QString uuid);
int getAcivateWifiSignal();
int getActivateWifiSignal(QString devName = "");
private:
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,

View File

@ -644,7 +644,10 @@ void MainWindow::onRefreshTrayIcon()
iconStatus = IconActiveType::LAN_CONNECTED;
} else if (m_wlanWidget->checkWlanStatus(NetworkManager::ActiveConnection::State::Activated)){
// m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-connected-symbolic"));
signalStrength = m_wlanWidget->getAcivateWifiSignal();
signalStrength = m_wlanWidget->getActivateWifiSignal(m_wlanWidget->getCurrentDisplayDevice());
if (signalStrength == -1) {
signalStrength = m_wlanWidget->getActivateWifiSignal();
}
iconStatus = IconActiveType::WLAN_CONNECTED;
} else {
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-disconnected-symbolic"));
@ -690,6 +693,10 @@ void MainWindow::onRefreshTrayIcon()
m_trayIcon->setIcon(QIcon::fromTheme(NONE_SIGNAL_LIMIT_ICON));
}
}
if (signalStrength == -1) {
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-disconnected-symbolic"));
}
onRefreshTrayIconTooltip();
}

View File

@ -1138,6 +1138,8 @@ void WlanPage::onDeviceComboxIndexChanged(int currentIndex)
initWlanArea();
Q_EMIT timeToUpdate();
return;
}
@ -1661,9 +1663,9 @@ void WlanPage::addWlanMoreItem()
return;
}
int WlanPage::getAcivateWifiSignal()
int WlanPage::getActivateWifiSignal(QString devName)
{
return m_activatedConnectResource->getAcivateWifiSignal();
return m_activatedConnectResource->getActivateWifiSignal(devName);
}
void WlanPage::getWirelssDeviceConnectState(QMap<QString, QString> &map)
@ -1674,26 +1676,14 @@ void WlanPage::getWirelssDeviceConnectState(QMap<QString, QString> &map)
}
for (const auto devname : m_devList) {
NetworkManager::Connectivity state;
KyWirelessNetItem wirelessNetItem;
if (!m_netDeviceResource->getDeviceManaged(devname)) {
continue;
}
m_netDeviceResource->getDeviceConnectivity(devname, state);
if (state < NetworkManager::Connectivity::Full) {
if (m_wirelessNetResource->getActiveWirelessNetItem(devname, wirelessNetItem)) {
map.insert(devname, QString(tr("Connected: ")) + wirelessNetItem.m_connName + " " + QString(tr("(Limited)")));
} else {
map.insert(devname, tr("Not Connected"));
}
} else if (state == NetworkManager::Connectivity::Full) {
if (m_wirelessNetResource->getActiveWirelessNetItem(devname, wirelessNetItem)) {
map.insert(devname, QString(tr("Connected: ")) + wirelessNetItem.m_connName);
}
if (m_wirelessNetResource->getActiveWirelessNetItem(devname, wirelessNetItem)) {
map.insert(devname, QString(tr("Connected: ")) + wirelessNetItem.m_NetSsid);
} else {
qDebug() << devname << " Network connectivity is unknown.";
map.insert(devname, tr("Not Connected"));
}
}
}

View File

@ -79,11 +79,15 @@ public:
bool getWirelessSwitchBtnState();
int getAcivateWifiSignal();
int getActivateWifiSignal(QString devName = "");
//无线网卡连通性
void getWirelssDeviceConnectState(QMap<QString, QString> &map);
QString getCurrentDisplayDevice() {
return m_currentDevice;
}
Q_SIGNALS:
void oneItemExpanded(const QString &ssid);
void wlanAdd(QString devName, QStringList info);