[Kde-hardware-devel] extragear/base/networkmanagement/monolithic

Lamarque Vieira Souza lamarque at gmail.com
Mon Oct 11 15:19:26 CEST 2010


SVN commit 1184819 by lvsouza:

Patch from Jirka Klimes against monolithic KNM to reflect a change in Solid Network Manager backend.

CCBUG: 238325
CCMAIL: kde-networkmanager at kde.org
CCMAIL: kde-hardware-devel at kde.org


 M  +30 -1     knetworkmanagertrayicon.cpp  
 M  +10 -0     knetworkmanagertrayicon.h  


--- trunk/extragear/base/networkmanagement/monolithic/knetworkmanagertrayicon.cpp #1184818:1184819
@@ -64,6 +64,7 @@
     KNetworkManagerTrayIconPrivate()
         : list(0),
         iconName(QLatin1String("networkmanager")),
+        networkingEnableAction(0),
         flightModeAction(0),
         prefsAction(0),
         copyIpAddrAction(0),
@@ -75,6 +76,7 @@
     QHash<Knm::Activatable *, QWidgetAction *> actions;
     QStringList deviceUnis;
     QString iconName;
+    KAction * networkingEnableAction;
     KAction * flightModeAction;
     KAction * prefsAction;
     KAction * copyIpAddrAction;
@@ -110,6 +112,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);
@@ -200,7 +209,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");
@@ -209,6 +218,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;
     }
 
@@ -309,9 +324,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);
 }
 
@@ -531,6 +548,12 @@
     }
 }
 
+void KNetworkManagerTrayIcon::enableNetworking(bool enabled)
+{
+    kDebug() << enabled;
+    Solid::Control::NetworkManager::setNetworkingEnabled(enabled);
+}
+
 void KNetworkManagerTrayIcon::enableWireless(bool enabled)
 {
     kDebug() << enabled;
@@ -548,6 +571,12 @@
     }
 }
 
+void KNetworkManagerTrayIcon::networkingEnabledChanged()
+{
+    Q_D(KNetworkManagerTrayIcon);
+    d->networkingEnableAction->setChecked(Solid::Control::NetworkManager::isNetworkingEnabled());
+}
+
 void KNetworkManagerTrayIcon::setActive(bool active)
 {
     Q_D(KNetworkManagerTrayIcon);
--- trunk/extragear/base/networkmanagement/monolithic/knetworkmanagertrayicon.h #1184818:1184819
@@ -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 networking state changes
+     */
+    void networkingEnabledChanged();
+
+    /**
      * Starts monitoring new network interfaces' state changes
      */
     void networkInterfaceAdded(const QString&);


More information about the Kde-hardware-devel mailing list