Commit 83790dac authored by Devin Lin's avatar Devin Lin 🎨
Browse files

quicksettings/mobiledata: Add warning if APN is not configured

parent b51a575b
Pipeline #229862 passed with stage
in 1 minute and 5 seconds
......@@ -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;
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment