mmplugin: Cleanup signals

This commit is contained in:
Devin Lin 2022-10-23 15:33:47 -04:00
parent a219c59a1f
commit ca671e1992
2 changed files with 11 additions and 20 deletions

View file

@ -19,19 +19,10 @@ SignalIndicator::SignalIndicator(QObject *parent)
connect(ModemManager::notifier(), &ModemManager::Notifier::modemAdded, this, &SignalIndicator::updateModemManagerModem);
connect(ModemManager::notifier(), &ModemManager::Notifier::modemRemoved, this, &SignalIndicator::updateModemManagerModem);
connect(NetworkManager::settingsNotifier(), &NetworkManager::SettingsNotifier::connectionAdded, this, [this]() {
Q_EMIT mobileDataEnabledChanged();
});
connect(NetworkManager::settingsNotifier(), &NetworkManager::SettingsNotifier::connectionRemoved, this, [this]() {
Q_EMIT mobileDataEnabledChanged();
});
connect(NetworkManager::notifier(), &NetworkManager::Notifier::activeConnectionAdded, this, [this]() {
Q_EMIT mobileDataEnabledChanged();
});
connect(NetworkManager::notifier(), &NetworkManager::Notifier::activeConnectionRemoved, this, [this]() {
Q_EMIT mobileDataEnabledChanged();
});
connect(NetworkManager::settingsNotifier(), &NetworkManager::SettingsNotifier::connectionAdded, this, &SignalIndicator::mobileDataEnabledChanged);
connect(NetworkManager::settingsNotifier(), &NetworkManager::SettingsNotifier::connectionRemoved, this, &SignalIndicator::mobileDataEnabledChanged);
connect(NetworkManager::notifier(), &NetworkManager::Notifier::activeConnectionAdded, this, &SignalIndicator::mobileDataEnabledChanged);
connect(NetworkManager::notifier(), &NetworkManager::Notifier::activeConnectionRemoved, this, &SignalIndicator::mobileDataEnabledChanged);
connect(NetworkManager::notifier(), &NetworkManager::Notifier::deviceAdded, this, &SignalIndicator::updateNetworkManagerModem);
connect(NetworkManager::notifier(), &NetworkManager::Notifier::deviceRemoved, this, &SignalIndicator::updateNetworkManagerModem);
@ -191,12 +182,10 @@ void SignalIndicator::updateNetworkManagerModem()
if (nmDevice->udi() == m_modemDevice->uni()) {
m_nmModem = nmDevice.objectCast<NetworkManager::ModemDevice>();
connect(m_nmModem.get(), &NetworkManager::Device::autoconnectChanged, this, [this]() {
Q_EMIT mobileDataEnabledChanged();
});
connect(m_nmModem.get(), &NetworkManager::Device::stateChanged, this, [this](auto, auto, auto) {
Q_EMIT mobileDataEnabledChanged();
});
connect(m_nmModem.get(), &NetworkManager::Device::autoconnectChanged, this, &SignalIndicator::mobileDataEnabledChanged);
connect(m_nmModem.get(), &NetworkManager::Device::stateChanged, this, &SignalIndicator::mobileDataEnabledChanged);
connect(m_nmModem.get(), &NetworkManager::Device::availableConnectionAppeared, this, &SignalIndicator::mobileDataEnabledChanged);
connect(m_nmModem.get(), &NetworkManager::Device::availableConnectionDisappeared, this, &SignalIndicator::mobileDataEnabledChanged);
}
}

View file

@ -10,7 +10,9 @@ MobileShell.QuickSetting {
text: i18n("Mobile Data")
icon: "network-modem"
status: {
if (PlasmaMM.SignalIndicator.needsAPNAdded) {
if (!PlasmaMM.SignalIndicator.modemAvailable) {
return i18n("Not Available");
} else if (PlasmaMM.SignalIndicator.needsAPNAdded) {
return i18n("APN needs to be configured in the settings");
} else if (PlasmaMM.SignalIndicator.mobileDataSupported) {
return enabled ? i18n("On") : i18n("Off");