LanLinkProvider: Restore previous network change behavior

This commit is contained in:
Alexander Lohnau 2023-07-20 12:58:50 +03:00
parent 8ea717b363
commit e9063d168d

View file

@ -71,13 +71,17 @@ LanLinkProvider::LanLinkProvider(bool testMode, quint16 udpBroadcastPort, quint1
}
});
#else
// Detect when a network interface changes status, so we announce ourselves in the new network
QNetworkInformation::instance()->loadBackendByFeatures(QNetworkInformation::Feature::Reachability);
connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged, this, [this]() {
const auto checkNetworkChange = [this]() {
if (QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online) {
onNetworkChange();
}
});
};
// Detect when a network interface changes status, so we announce ourselves in the new network
QNetworkInformation::instance()->loadBackendByFeatures(QNetworkInformation::Feature::Reachability);
// We want to know if our current network reachability has changed, or if we change from one network to another
connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged, this, checkNetworkChange);
connect(QNetworkInformation::instance(), &QNetworkInformation::transportMediumChanged, this, checkNetworkChange);
#endif
}
@ -187,7 +191,6 @@ void LanLinkProvider::broadcastUdpIdentityPacket()
#endif
}
QList<QHostAddress> LanLinkProvider::getBroadcastAddresses()
{
const QStringList customDevices = KdeConnectConfig::instance().customDevices();