mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
mmplugin: Add support for checking if a SIM is missing
This commit is contained in:
parent
c6feac9ce0
commit
31cb248a8a
3 changed files with 18 additions and 3 deletions
|
|
@ -35,6 +35,14 @@ bool SignalIndicator::simLocked() const
|
|||
return m_modem->unlockRequired() == MM_MODEM_LOCK_SIM_PIN;
|
||||
}
|
||||
|
||||
bool SignalIndicator::simEmpty() const
|
||||
{
|
||||
if (!m_modem) {
|
||||
return false;
|
||||
}
|
||||
return m_modemDevice && m_modemDevice->sim() && m_modemDevice->sim()->uni() == QStringLiteral("/");
|
||||
}
|
||||
|
||||
bool SignalIndicator::available() const
|
||||
{
|
||||
return !ModemManager::modemDevices().isEmpty();
|
||||
|
|
@ -42,7 +50,7 @@ bool SignalIndicator::available() const
|
|||
|
||||
bool SignalIndicator::mobileDataSupported() const
|
||||
{
|
||||
return m_nmModem && m_modemDevice->sim();
|
||||
return m_nmModem && m_modemDevice->sim() && !simEmpty();
|
||||
}
|
||||
|
||||
bool SignalIndicator::mobileDataEnabled() const
|
||||
|
|
@ -143,6 +151,8 @@ void SignalIndicator::updateModem()
|
|||
}
|
||||
}
|
||||
|
||||
connect(m_modemDevice->sim().get(), &ModemManager::Sim::simIdentifierChanged, this, &SignalIndicator::simEmptyChanged);
|
||||
|
||||
if (m_modem) {
|
||||
connect(m_modem.get(), &ModemManager::Modem::signalQualityChanged, this, &SignalIndicator::strengthChanged);
|
||||
connect(m_modem.get(), &ModemManager::Modem::unlockRequiredChanged, this, &SignalIndicator::simLockedChanged);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class SignalIndicator : public QObject
|
|||
Q_PROPERTY(int strength READ strength NOTIFY strengthChanged)
|
||||
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
||||
Q_PROPERTY(bool simLocked READ simLocked NOTIFY simLockedChanged)
|
||||
Q_PROPERTY(bool simEmpty READ simEmpty NOTIFY simEmptyChanged)
|
||||
Q_PROPERTY(bool available READ available NOTIFY availableChanged)
|
||||
Q_PROPERTY(bool mobileDataSupported READ mobileDataSupported NOTIFY mobileDataSupportedChanged)
|
||||
Q_PROPERTY(bool mobileDataEnabled READ mobileDataEnabled WRITE setMobileDataEnabled NOTIFY mobileDataEnabledChanged)
|
||||
|
|
@ -31,6 +32,7 @@ public:
|
|||
int strength() const;
|
||||
QString name() const;
|
||||
bool simLocked() const;
|
||||
bool simEmpty() const;
|
||||
bool available() const;
|
||||
bool mobileDataSupported() const;
|
||||
bool mobileDataEnabled() const;
|
||||
|
|
@ -42,6 +44,7 @@ Q_SIGNALS:
|
|||
void strengthChanged();
|
||||
void nameChanged();
|
||||
void simLockedChanged();
|
||||
void simEmptyChanged();
|
||||
void availableChanged();
|
||||
void mobileDataSupportedChanged();
|
||||
void mobileDataEnabledChanged();
|
||||
|
|
|
|||
|
|
@ -14,18 +14,20 @@ MobileShell.QuickSetting {
|
|||
return i18n("APN needs to be configured in the settings");
|
||||
} else if (PlasmaMM.SignalIndicator.mobileDataSupported) {
|
||||
return enabled ? i18n("On") : i18n("Off");
|
||||
} else if (PlasmaMM.SignalIndicator.simEmpty) {
|
||||
return i18n("No SIM inserted");
|
||||
} else {
|
||||
return i18n("Not Available");
|
||||
}
|
||||
}
|
||||
|
||||
settingsCommand: "plasma-open-settings kcm_mobile_broadband"
|
||||
settingsCommand: "plasma-open-settings kcm_cellular_network"
|
||||
enabled: PlasmaMM.SignalIndicator.mobileDataEnabled
|
||||
|
||||
function toggle() {
|
||||
if (PlasmaMM.SignalIndicator.needsAPNAdded || !PlasmaMM.SignalIndicator.mobileDataSupported) {
|
||||
// open settings if unable to toggle mobile data
|
||||
MobileShell.ShellUtil.executeCommand("plasma-open-settings kcm_mobile_broadband");
|
||||
MobileShell.ShellUtil.executeCommand("plasma-open-settings kcm_cellular_network");
|
||||
} else {
|
||||
PlasmaMM.SignalIndicator.mobileDataEnabled = !PlasmaMM.SignalIndicator.mobileDataEnabled;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue