mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
mmplugin: Ensure variables are reset properly
This commit is contained in:
parent
867dc32df2
commit
bca3fb3626
2 changed files with 14 additions and 4 deletions
|
|
@ -9,7 +9,12 @@
|
||||||
|
|
||||||
#include "signalindicator.h"
|
#include "signalindicator.h"
|
||||||
|
|
||||||
SignalIndicator::SignalIndicator()
|
SignalIndicator::SignalIndicator(QObject *parent)
|
||||||
|
: QObject{parent}
|
||||||
|
, m_nmModem{nullptr}
|
||||||
|
, m_modemDevice{nullptr}
|
||||||
|
, m_modem{nullptr}
|
||||||
|
, m_3gppModem{nullptr}
|
||||||
{
|
{
|
||||||
connect(ModemManager::notifier(), &ModemManager::Notifier::modemAdded, this, &SignalIndicator::updateModemManagerModem);
|
connect(ModemManager::notifier(), &ModemManager::Notifier::modemAdded, this, &SignalIndicator::updateModemManagerModem);
|
||||||
connect(ModemManager::notifier(), &ModemManager::Notifier::modemRemoved, this, &SignalIndicator::updateModemManagerModem);
|
connect(ModemManager::notifier(), &ModemManager::Notifier::modemRemoved, this, &SignalIndicator::updateModemManagerModem);
|
||||||
|
|
@ -48,7 +53,7 @@ QString SignalIndicator::name() const
|
||||||
|
|
||||||
bool SignalIndicator::modemAvailable() const
|
bool SignalIndicator::modemAvailable() const
|
||||||
{
|
{
|
||||||
return m_modem;
|
return !m_modem.isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SignalIndicator::simLocked() const
|
bool SignalIndicator::simLocked() const
|
||||||
|
|
@ -61,7 +66,7 @@ bool SignalIndicator::simLocked() const
|
||||||
|
|
||||||
bool SignalIndicator::simEmpty() const
|
bool SignalIndicator::simEmpty() const
|
||||||
{
|
{
|
||||||
if (!m_modem) {
|
if (!m_modemDevice) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return m_modemDevice && m_modemDevice->sim() && m_modemDevice->sim()->uni() == QStringLiteral("/");
|
return m_modemDevice && m_modemDevice->sim() && m_modemDevice->sim()->uni() == QStringLiteral("/");
|
||||||
|
|
@ -146,6 +151,10 @@ void SignalIndicator::setMobileDataEnabled(bool enabled)
|
||||||
|
|
||||||
void SignalIndicator::updateModemManagerModem()
|
void SignalIndicator::updateModemManagerModem()
|
||||||
{
|
{
|
||||||
|
m_modemDevice = nullptr;
|
||||||
|
m_modem = nullptr;
|
||||||
|
m_3gppModem = nullptr;
|
||||||
|
|
||||||
if (ModemManager::modemDevices().isEmpty()) {
|
if (ModemManager::modemDevices().isEmpty()) {
|
||||||
qWarning() << "No modems available";
|
qWarning() << "No modems available";
|
||||||
return;
|
return;
|
||||||
|
|
@ -175,6 +184,7 @@ void SignalIndicator::updateModemManagerModem()
|
||||||
|
|
||||||
void SignalIndicator::updateNetworkManagerModem()
|
void SignalIndicator::updateNetworkManagerModem()
|
||||||
{
|
{
|
||||||
|
m_nmModem = nullptr;
|
||||||
if (!m_modemDevice) {
|
if (!m_modemDevice) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class SignalIndicator : public QObject
|
||||||
Q_PROPERTY(bool needsAPNAdded READ needsAPNAdded NOTIFY mobileDataEnabledChanged)
|
Q_PROPERTY(bool needsAPNAdded READ needsAPNAdded NOTIFY mobileDataEnabledChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SignalIndicator();
|
SignalIndicator(QObject *parent = nullptr);
|
||||||
|
|
||||||
int strength() const;
|
int strength() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue