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;
|
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
|
bool SignalIndicator::available() const
|
||||||
{
|
{
|
||||||
return !ModemManager::modemDevices().isEmpty();
|
return !ModemManager::modemDevices().isEmpty();
|
||||||
|
|
@ -42,7 +50,7 @@ bool SignalIndicator::available() const
|
||||||
|
|
||||||
bool SignalIndicator::mobileDataSupported() const
|
bool SignalIndicator::mobileDataSupported() const
|
||||||
{
|
{
|
||||||
return m_nmModem && m_modemDevice->sim();
|
return m_nmModem && m_modemDevice->sim() && !simEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SignalIndicator::mobileDataEnabled() const
|
bool SignalIndicator::mobileDataEnabled() const
|
||||||
|
|
@ -142,6 +150,8 @@ void SignalIndicator::updateModem()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(m_modemDevice->sim().get(), &ModemManager::Sim::simIdentifierChanged, this, &SignalIndicator::simEmptyChanged);
|
||||||
|
|
||||||
if (m_modem) {
|
if (m_modem) {
|
||||||
connect(m_modem.get(), &ModemManager::Modem::signalQualityChanged, this, &SignalIndicator::strengthChanged);
|
connect(m_modem.get(), &ModemManager::Modem::signalQualityChanged, this, &SignalIndicator::strengthChanged);
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ class SignalIndicator : public QObject
|
||||||
Q_PROPERTY(int strength READ strength NOTIFY strengthChanged)
|
Q_PROPERTY(int strength READ strength NOTIFY strengthChanged)
|
||||||
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
||||||
Q_PROPERTY(bool simLocked READ simLocked NOTIFY simLockedChanged)
|
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 available READ available NOTIFY availableChanged)
|
||||||
Q_PROPERTY(bool mobileDataSupported READ mobileDataSupported NOTIFY mobileDataSupportedChanged)
|
Q_PROPERTY(bool mobileDataSupported READ mobileDataSupported NOTIFY mobileDataSupportedChanged)
|
||||||
Q_PROPERTY(bool mobileDataEnabled READ mobileDataEnabled WRITE setMobileDataEnabled NOTIFY mobileDataEnabledChanged)
|
Q_PROPERTY(bool mobileDataEnabled READ mobileDataEnabled WRITE setMobileDataEnabled NOTIFY mobileDataEnabledChanged)
|
||||||
|
|
@ -31,6 +32,7 @@ public:
|
||||||
int strength() const;
|
int strength() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
bool simLocked() const;
|
bool simLocked() const;
|
||||||
|
bool simEmpty() const;
|
||||||
bool available() const;
|
bool available() const;
|
||||||
bool mobileDataSupported() const;
|
bool mobileDataSupported() const;
|
||||||
bool mobileDataEnabled() const;
|
bool mobileDataEnabled() const;
|
||||||
|
|
@ -42,6 +44,7 @@ Q_SIGNALS:
|
||||||
void strengthChanged();
|
void strengthChanged();
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
void simLockedChanged();
|
void simLockedChanged();
|
||||||
|
void simEmptyChanged();
|
||||||
void availableChanged();
|
void availableChanged();
|
||||||
void mobileDataSupportedChanged();
|
void mobileDataSupportedChanged();
|
||||||
void mobileDataEnabledChanged();
|
void mobileDataEnabledChanged();
|
||||||
|
|
|
||||||
|
|
@ -14,18 +14,20 @@ MobileShell.QuickSetting {
|
||||||
return i18n("APN needs to be configured in the settings");
|
return i18n("APN needs to be configured in the settings");
|
||||||
} else if (PlasmaMM.SignalIndicator.mobileDataSupported) {
|
} else if (PlasmaMM.SignalIndicator.mobileDataSupported) {
|
||||||
return enabled ? i18n("On") : i18n("Off");
|
return enabled ? i18n("On") : i18n("Off");
|
||||||
|
} else if (PlasmaMM.SignalIndicator.simEmpty) {
|
||||||
|
return i18n("No SIM inserted");
|
||||||
} else {
|
} else {
|
||||||
return i18n("Not Available");
|
return i18n("Not Available");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsCommand: "plasma-open-settings kcm_mobile_broadband"
|
settingsCommand: "plasma-open-settings kcm_cellular_network"
|
||||||
enabled: PlasmaMM.SignalIndicator.mobileDataEnabled
|
enabled: PlasmaMM.SignalIndicator.mobileDataEnabled
|
||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
if (PlasmaMM.SignalIndicator.needsAPNAdded || !PlasmaMM.SignalIndicator.mobileDataSupported) {
|
if (PlasmaMM.SignalIndicator.needsAPNAdded || !PlasmaMM.SignalIndicator.mobileDataSupported) {
|
||||||
// open settings if unable to toggle mobile data
|
// 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 {
|
} else {
|
||||||
PlasmaMM.SignalIndicator.mobileDataEnabled = !PlasmaMM.SignalIndicator.mobileDataEnabled;
|
PlasmaMM.SignalIndicator.mobileDataEnabled = !PlasmaMM.SignalIndicator.mobileDataEnabled;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue