[Connectivity Report] Only emit signal when it has actually changed
Avoids pointless DBus traffic
This commit is contained in:
parent
034e5fb03c
commit
2a3ab4104e
1 changed files with 7 additions and 1 deletions
|
@ -43,11 +43,17 @@ bool ConnectivityReportPlugin::receivePacket(const NetworkPacket& np)
|
|||
auto subscriptions = np.get<QVariantMap>(QStringLiteral("signalStrengths"), QVariantMap());
|
||||
auto networkInfo = subscriptions.first().toMap();
|
||||
|
||||
const auto oldCellularNetworkType = m_cellularNetworkType;
|
||||
const auto oldNetworkStrength = m_cellularNetworkStrength;
|
||||
|
||||
m_cellularNetworkType = networkInfo.value(QStringLiteral("networkType")).toString();
|
||||
m_cellularNetworkStrength = networkInfo.value(QStringLiteral("signalStrength")).toInt();
|
||||
|
||||
if (oldCellularNetworkType != m_cellularNetworkType ||
|
||||
oldNetworkStrength != m_cellularNetworkStrength) {
|
||||
Q_EMIT refreshed(m_cellularNetworkType, m_cellularNetworkStrength);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue