mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
quicksettings/mobiledata: Add warning if APN is not configured
This commit is contained in:
parent
b51a575bc6
commit
83790daccd
3 changed files with 24 additions and 4 deletions
|
|
@ -73,6 +73,11 @@ bool SignalIndicator::mobileDataEnabled() const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool SignalIndicator::needsAPNAdded() const
|
||||
{
|
||||
return m_nmModem && m_nmModem->availableConnections().count() == 0;
|
||||
}
|
||||
|
||||
void SignalIndicator::setMobileDataEnabled(bool enabled)
|
||||
{
|
||||
if (!m_nmModem) {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class SignalIndicator : public QObject
|
|||
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)
|
||||
Q_PROPERTY(bool needsAPNAdded READ needsAPNAdded NOTIFY mobileDataEnabledChanged)
|
||||
|
||||
public:
|
||||
SignalIndicator();
|
||||
|
|
@ -33,6 +34,7 @@ public:
|
|||
bool available() const;
|
||||
bool mobileDataSupported() const;
|
||||
bool mobileDataEnabled() const;
|
||||
bool needsAPNAdded() const;
|
||||
|
||||
void setMobileDataEnabled(bool enabled);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,25 @@ import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
|||
MobileShell.QuickSetting {
|
||||
text: i18n("Mobile Data")
|
||||
icon: "network-modem"
|
||||
status: PlasmaMM.SignalIndicator.mobileDataSupported
|
||||
? (enabled ? i18n("On") : i18n("Off"))
|
||||
: i18n("Not Available")
|
||||
status: {
|
||||
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");
|
||||
} else {
|
||||
return i18n("Not Available");
|
||||
}
|
||||
}
|
||||
|
||||
settingsCommand: "plasma-open-settings kcm_mobile_broadband"
|
||||
enabled: PlasmaMM.SignalIndicator.mobileDataEnabled
|
||||
|
||||
function toggle() {
|
||||
PlasmaMM.SignalIndicator.mobileDataEnabled = !PlasmaMM.SignalIndicator.mobileDataEnabled
|
||||
if (PlasmaMM.SignalIndicator.needsAPNAdded || !PlasmaMM.SignalIndicator.mobileDataSupported) {
|
||||
// open settings if unable to toggle mobile data
|
||||
MobileShell.ShellUtil.executeCommand("plasma-open-settings kcm_mobile_broadband");
|
||||
} else {
|
||||
PlasmaMM.SignalIndicator.mobileDataEnabled = !PlasmaMM.SignalIndicator.mobileDataEnabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue