Blob Blame History Raw
Index: applet/nmpopup.h
===================================================================
--- applet/nmpopup.h	(revision 1128863)
+++ applet/nmpopup.h	(working copy)
@@ -30,6 +30,7 @@
 #include <Plasma/PushButton>
 #include <Plasma/TabBar>
 
+#include <solid/networking.h>
 #include <solid/control/networkinterface.h>
 
 #include "activatable.h"
@@ -65,6 +66,7 @@
     void managerWirelessHardwareEnabledChanged(bool);
     void wirelessEnabledToggled(bool checked);
     void networkingEnabledToggled(bool checked);
+    void managerNetworkingEnabledChanged(bool);
     void manageConnections();
     void showMore();
     void showMore(bool);
Index: applet/nmpopup.cpp
===================================================================
--- applet/nmpopup.cpp	(revision 1128863)
+++ applet/nmpopup.cpp	(working copy)
@@ -118,6 +118,8 @@
     m_leftLayout->addItem(m_networkingCheckBox);
     connect(m_networkingCheckBox, SIGNAL(toggled(bool)),
             this, SLOT(networkingEnabledToggled(bool)));
+    connect(Solid::Control::NetworkManager::notifier(), SIGNAL(networkingEnabledChanged(bool)),
+            this, SLOT(managerNetworkingEnabledChanged(bool)));
 
     // flight-mode checkbox
     m_rfCheckBox = new Plasma::CheckBox(m_leftWidget);
@@ -384,6 +386,12 @@
     m_rfCheckBox->setEnabled(!enabled);
 }
 
+void NMPopup::managerNetworkingEnabledChanged(bool enabled)
+{
+    kDebug() << "NM daemon changed networking enable state" << enabled;
+    m_networkingCheckBox->setChecked(Solid::Control::NetworkManager::isNetworkingEnabled());
+}
+
 void NMPopup::showMore()
 {
     showMore(m_showMoreButton->isChecked());
Index: monolithic/knetworkmanagertrayicon.h
===================================================================
--- monolithic/knetworkmanagertrayicon.h	(revision 1128863)
+++ monolithic/knetworkmanagertrayicon.h	(working copy)
@@ -91,6 +91,11 @@
     void networkingStatusChanged(Solid::Networking::Status);
 
     /**
+     * Enable networking in response to user action
+     */
+    void enableNetworking(bool);
+
+    /**
      * Enable wireless in response to user action
      */
     void enableWireless(bool);
@@ -101,6 +106,11 @@
     void wirelessEnabledChanged();
 
     /**
+     * Update UI in response to system network management networkong state changes
+     */
+    void networkingEnabledChanged();
+
+    /**
      * Starts monitoring new network interfaces' state changes
      */
     void networkInterfaceAdded(const QString&);
Index: monolithic/knetworkmanagertrayicon.cpp
===================================================================
--- monolithic/knetworkmanagertrayicon.cpp	(revision 1128863)
+++ monolithic/knetworkmanagertrayicon.cpp	(working copy)
@@ -66,6 +66,7 @@
     KNetworkManagerTrayIconPrivate()
         : list(0),
         iconName(QLatin1String("networkmanager")),
+        networkingEnableAction(0),
         flightModeAction(0),
         prefsAction(0),
         copyIpAddrAction(0),
@@ -77,6 +78,7 @@
     QHash<Knm::Activatable *, QWidgetAction *> actions;
     QStringList deviceUnis;
     QString iconName;
+    KAction * networkingEnableAction;
     KAction * flightModeAction;
     KAction * prefsAction;
     KAction * copyIpAddrAction;
@@ -112,6 +114,13 @@
     setAssociatedWidget(contextMenu());
     setStatus( (!d->active || Solid::Control::NetworkManager::status() == Solid::Networking::Unknown )? PARENT_ICON_CLASS::Passive : PARENT_ICON_CLASS::Active);
 
+    d->networkingEnableAction = new KAction(i18nc("@action:inmenu turns off networking", "Enable networking"), this);
+    d->networkingEnableAction->setCheckable(true);
+    d->networkingEnableAction->setChecked(Solid::Control::NetworkManager::isNetworkingEnabled());
+    connect(d->networkingEnableAction, SIGNAL(toggled(bool)), this, SLOT(enableNetworking(bool)));
+    connect(Solid::Control::NetworkManager::notifier(), SIGNAL(networkingEnabledChanged(bool)),
+            this, SLOT(networkingEnabledChanged()));
+
     if (types.testFlag(Solid::Control::NetworkInterface::Ieee80211)) {
         d->flightModeAction = new KAction(i18nc("@action:inmenu turns off wireless networking", "Enable wireless"), this);
         d->flightModeAction->setCheckable(true);
@@ -202,7 +211,7 @@
         }
     }
 
-    // if not active, add a warning notice and stop
+    // if not active, add a warning notice, show Networking and Wireless check buttons and stop
     if (Solid::Control::NetworkManager::status() == Solid::Networking::Unknown) {
         QString passiveText = i18nc("@action:inmenu Disable action text used when the NetworkManager daemon is not running", "Network Management disabled");
         QString passiveTooltip = i18nc("@info:tooltip NetworkManager is not running, this client cannot do anything", "The system Network Management service is not running");
@@ -211,6 +220,12 @@
         passiveAction->setToolTip(passiveTooltip);
         passiveAction->setEnabled(false);
         contextMenu()->addAction(passiveAction);
+
+        // show "Enable" check buttons
+        contextMenu()->addAction(d->networkingEnableAction);
+        if (!wirelessDeviceUnis.isEmpty() /*TODO Bluetooth too */ && d->interfaceTypes.testFlag(Solid::Control::NetworkInterface::Ieee80211)) {
+            contextMenu()->addAction(d->flightModeAction);
+        }
         return;
     }
 
@@ -311,9 +326,11 @@
     // add the housekeeping actions
     contextMenu()->addSeparator();
 
+    contextMenu()->addAction(d->networkingEnableAction);
     if (!wirelessDeviceUnis.isEmpty() /*TODO Bluetooth too */ && d->interfaceTypes.testFlag(Solid::Control::NetworkInterface::Ieee80211)) {
         contextMenu()->addAction(d->flightModeAction);
     }
+    contextMenu()->addSeparator();
     contextMenu()->addAction(d->prefsAction);
 }
 
@@ -533,6 +550,12 @@
     }
 }
 
+void KNetworkManagerTrayIcon::enableNetworking(bool enabled)
+{
+    kDebug() << enabled;
+    Solid::Control::NetworkManager::setNetworkingEnabled(enabled);
+}
+
 void KNetworkManagerTrayIcon::enableWireless(bool enabled)
 {
     kDebug() << enabled;
@@ -550,6 +573,12 @@
     }
 }
 
+void KNetworkManagerTrayIcon::networkingEnabledChanged()
+{
+    Q_D(KNetworkManagerTrayIcon);
+    d->networkingEnableAction->setChecked(Solid::Control::NetworkManager::isNetworkingEnabled());
+}
+
 void KNetworkManagerTrayIcon::setActive(bool active)
 {
     Q_D(KNetworkManagerTrayIcon);