Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions net-view/window/netstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ void NetStatus::onStrengthLevelChanged()
if (item && item->status() != NetType::CS_UnConnected) {
updateStatus();
}
updateNetworkIcon();
}

void NetStatus::updateVpnAndProxyStatus()
Expand Down
9 changes: 9 additions & 0 deletions src/impl/networkmanager/accesspointproxynm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ bool AccessPointProxyNM::isWlan6() const
return false;
}

void AccessPointProxyNM::updateStrengthFromActiveAp(int strength)
{
if (strength == m_strength)
return;

m_strength = strength;
Q_EMIT strengthChanged(m_strength);
}

void AccessPointProxyNM::initState()
{
// 获取当前网络的连接状态
Expand Down
1 change: 1 addition & 0 deletions src/impl/networkmanager/accesspointproxynm.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class AccessPointProxyNM : public AccessPointProxy
ConnectionStatus status() const override;
bool hidden() const override;
bool isWlan6() const override;
void updateStrengthFromActiveAp(int strength);

private:
void initState();
Expand Down
38 changes: 38 additions & 0 deletions src/impl/networkmanager/devicemanagerrealize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,36 @@ WirelessDeviceManagerRealize::WirelessDeviceManagerRealize(NetworkManager::Wirel
NetworkManager::WirelessNetwork::List networks = m_device->networks();
for (NetworkManager::WirelessNetwork::Ptr network : networks)
addNetwork(network);

auto updateActiveApStrength = [this](const NetworkManager::AccessPoint::Ptr &activeAp) {
if (activeAp.isNull())
return;
for (AccessPointInfo *apInfo : m_accessPointInfos) {
if (apInfo && apInfo->proxy() && apInfo->proxy()->contains(activeAp->uni())) {
apInfo->proxy()->updateStrengthFromActiveAp(activeAp->signalStrength());
break;
}
}
};

// referenceAccessPoint 信号强度变化不及时,需要监听 activeAccessPointChanged 信号
auto changeActiveAp = [this, updateActiveApStrength] {
if (m_activeApStrengthConn)
disconnect(m_activeApStrengthConn);
NetworkManager::AccessPoint::Ptr activeAp = m_device->activeAccessPoint();
if (activeAp.isNull())
return;

updateActiveApStrength(activeAp);
m_activeApStrengthConn = connect(activeAp.data(), &NetworkManager::AccessPoint::signalStrengthChanged, this, [updateActiveApStrength, activeAp] {
updateActiveApStrength(activeAp);
}, Qt::UniqueConnection);
};

connect(device.data(), &NetworkManager::WirelessDevice::activeAccessPointChanged, this, [changeActiveAp] {
changeActiveAp();
});
changeActiveAp();
}

WirelessDeviceManagerRealize::~WirelessDeviceManagerRealize()
Expand Down Expand Up @@ -1144,11 +1174,19 @@ void WirelessDeviceManagerRealize::addNetwork(const NetworkManager::WirelessNetw
AccessPointInfo *apInfo = new AccessPointInfo(m_device, network);
m_accessPointInfos << apInfo;

NetworkManager::AccessPoint::Ptr activeAp = m_device->activeAccessPoint();
if (!activeAp.isNull() && apInfo->proxy()->contains(activeAp->uni()))
apInfo->proxy()->updateStrengthFromActiveAp(activeAp->signalStrength());

Q_EMIT networkAdded({ apInfo->accessPoint() });
} else {
// 已经存在该无线网络,只需要更新内部的数据即可
AccessPointInfo *apInfo = *itApInfo;
apInfo->proxy()->updateNetwork(network);

NetworkManager::AccessPoint::Ptr activeAp = m_device->activeAccessPoint();
if (!activeAp.isNull() && apInfo->proxy()->contains(activeAp->uni()))
apInfo->proxy()->updateStrengthFromActiveAp(activeAp->signalStrength());
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/impl/networkmanager/devicemanagerrealize.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
#include "netinterface.h"

#include <NetworkManagerQt/WiredDevice>
#include <NetworkManagerQt/WirelessDevice>

Check warning on line 11 in src/impl/networkmanager/devicemanagerrealize.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <NetworkManagerQt/WirelessDevice> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <NetworkManagerQt/WirelessSecuritySetting>

Check warning on line 12 in src/impl/networkmanager/devicemanagerrealize.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <NetworkManagerQt/WirelessSecuritySetting> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QMetaObject>

Check warning on line 14 in src/impl/networkmanager/devicemanagerrealize.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QMetaObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusReply>

Check warning on line 15 in src/impl/networkmanager/devicemanagerrealize.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusReply> not found. Please note: Cppcheck does not need standard library headers to get proper results.

namespace NetworkManager {
class WirelessNetwork;
Expand Down Expand Up @@ -153,6 +154,7 @@
bool m_hotspotEnabled;
ProcesserInterface *m_netProcesser;
bool m_available;
QMetaObject::Connection m_activeApStrengthConn;
};

}
Expand Down