[PC-BSD Commits] r5789 - pcbsd/trunk/pcbsd-netmanager/src/NetworkTray

svn at pcbsd.org svn at pcbsd.org
Tue Jan 5 12:42:19 PST 2010


Author: kris
Date: 2010-01-05 12:42:19 -0800 (Tue, 05 Jan 2010)
New Revision: 5789

Modified:
   pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/NetworkTray.cpp
Log:

Updated net tray further, really cleaned it up now, should perform better



Modified: pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/NetworkTray.cpp
===================================================================
--- pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/NetworkTray.cpp	2010-01-05 20:24:44 UTC (rev 5788)
+++ pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/NetworkTray.cpp	2010-01-05 20:42:19 UTC (rev 5789)
@@ -124,7 +124,6 @@
   displayTooltip();
 
   // Start the monitor service
-  //QTimer::singleShot(UPDATE_MSEC,  this,  SLOT(monitorStatus()));
   monitorStatus();
 
 }
@@ -329,7 +328,6 @@
   // Start checking to see if the device has changed, and if it has inform the user
   QString tmp;  
   int updateTooltip = 0;
-  int displayPassivePopup = 0;
   QIcon Icon;
   QIcon Icon2;
   QString NotifyText = "";
@@ -338,196 +336,101 @@
   // First run a check to see if this applet has been disabled in the network manager
   QFile testFile(filename);
   if ( ! testFile.exists() )
-  {
     exit(0);
-  }
 
   // Update the ifconfig output of this device
   updateIfStatus(DeviceName);
 
   // Check the media status of this device
-  tmp = getMediaForIdent( DeviceName );
-  if ( DeviceMedia != tmp )
-  {
-     // Save the status as the new status now
-     DeviceMedia = tmp;
-     updateTooltip = 1;
-  }
+  DeviceMedia = getMediaForIdent( DeviceName );
 
   // Check for IPv6 Changes
-  tmp = getIPv6ForIdent( DeviceName);
-  if ( DeviceIPv6 != tmp )
-  {
-     NotifyText+="IPv6 changed to: " + tmp + "<br>";
-     displayPassivePopup = 1;
-     // Save the status as the new status now
-     DeviceIPv6 = tmp;
-     updateTooltip = 1;
-  }
+  DeviceIPv6 = getIPv6ForIdent( DeviceName);
 
   // Get the device up status
-  tmp = getUpStatusForIdent( DeviceName );
-  if ( DeviceUpStatus != tmp )
-  {
-     NotifyText+="Link status changed to: " + tmp + "<br>";
+  DeviceUpStatus = getUpStatusForIdent( DeviceName );
 
-     if ( DeviceType == "Ethernet" )
-     {
-         if ( (DeviceStatus == "active" || DeviceStatus == "")  && tmp == "UP") {
-            Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_local.png"));
-         } else {
-            Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_local_dis.png"));
-	 }
-
-     } else {
-         if ( DeviceStatus == "associated" && tmp == "UP" ) {
-          Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi.png"));
-	 } else {
-          Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi_dis.png"));
-
-         }
-     }
-
-     
-     setIcon(Icon);
-
-
-     // Save the status as the new status now
-     DeviceUpStatus = tmp;
-     updateTooltip = 1;
-     displayPassivePopup = 1;
+  if ( DeviceType == "Ethernet" )
+  {
+    if ( (DeviceStatus == "active" || DeviceStatus == "")  && tmp == "UP")
+      Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_local.png"));
+    else
+      Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_local_dis.png"));
+  } else {
+    if ( DeviceStatus == "associated" && tmp == "UP" )
+      Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi.png"));
+    else
+      Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi_dis.png"));
   }
 
 
   // First check the status of the device
-  tmp = getStatusForIdent(DeviceName);
-  if ( DeviceStatus != tmp )
+  DeviceStatus = getStatusForIdent(DeviceName);
+  if ( DeviceType == "Ethernet" )
   {
-       
+    if ( (tmp == "active" || tmp == "")  && DeviceUpStatus == "UP")
+      Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_local.png"));
+    else
+      Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_local_dis.png"));
 
-       if ( DeviceType == "Ethernet" )
-       {
-            if ( (tmp == "active" || tmp == "")  && DeviceUpStatus == "UP") {
-             Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_local.png"));
-	    } else {
-             Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_local_dis.png"));
-	    }
-
-       } else {
-            if ( tmp == "associated" && DeviceUpStatus == "UP" ) {
-             Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi.png"));
-	    } else {
-             Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi_dis.png"));
-	     DeviceSavedStrength = 0;
-	    }
-       }
-
-     // Set the tray icon now
-     setIcon(Icon);
-
-     NotifyText+="Link status changed to: " + tmp + "<br>";
-
-     // Save the status as the new status now
-     DeviceStatus = tmp;
-     updateTooltip = 1;
-     displayPassivePopup = 1;
+  } else {
+    if ( tmp == "associated" && DeviceUpStatus == "UP" )
+      Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi.png"));
+    else
+      Icon.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi_dis.png"));
   }
 
   // Now check the IP Address for changes
-  tmp = getIpForIdent(DeviceName);
-  if ( DeviceIP != tmp )
-  {
-     NotifyText+="IP address changed to: " + tmp + "<br>";
-     // Save the IP as the new IP now
-     DeviceIP = tmp;
-     updateTooltip = 1;
-     displayPassivePopup = 1;
-  }
+  DeviceIP = getIpForIdent(DeviceName);
 
-  tmp = getNetmaskForIdent( DeviceName );
-  if ( DeviceNetmask != tmp )
+  DeviceNetmask = getNetmaskForIdent( DeviceName );
+
+  if ( DeviceType == "Wireless" && DeviceStatus == "associated" )
   {
-     NotifyText+="Netmask changed to: " + tmp + "<br>";
-     // Save the IP as the new IP now
-     DeviceNetmask = tmp;
-     updateTooltip = 1;
-     displayPassivePopup = 0;
-  }
+    // Now check the SSID Address for changes
+    DeviceSSID = getSSIDForIdent(DeviceName);
 
-
-   if ( DeviceType == "Wireless" && DeviceStatus == "associated" )
-   {
-        // Now check the SSID Address for changes
-        tmp = getSSIDForIdent(DeviceName);
-        if ( DeviceSSID != tmp )
-        {
-             NotifyText+="SSID changed to: " + tmp + "<br>";
-             // Save the SSID as the new SSID now
-             DeviceSSID = tmp;
-             updateTooltip = 1;
-             displayPassivePopup = 1;
+    if (! DeviceSSID.isEmpty() )
+    {
+       int newStrength = 0;
+       int iconStrength = 0;
+       QString FileLoad;
+       bool ok;
+       // Get the strength of the signal
+       tmp = getSignalStrengthForIdent( DeviceName );
+       // Figure out if we need to change the strength icon
+       tmp.toInt(&ok);
+       if ( ok ) {
+         newStrength = tmp.toInt(&ok);
+	 if ( newStrength < 5 )
+         {	
+	   iconStrength = 0;
+	   FileLoad=KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi.png");
+         } else if ( newStrength < 50 ) {
+	   iconStrength = 30;
+	   FileLoad=KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi30.png");
+	 } else if ( newStrength < 75 ) {
+	   iconStrength = 60;
+	   FileLoad=KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi60.png");
+         } else {
+	   iconStrength = 85;
+	   FileLoad=KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi85.png");
+	 }
+           Icon.addFile(FileLoad);
         }
-
-	if (! DeviceSSID.isEmpty() )
-	{
-	  int newStrength = 0;
-          int iconStrength = 0;
-          QString FileLoad;
-	  bool ok;
-	  // Get the strength of the signal
-	  tmp = getSignalStrengthForIdent( DeviceName );
-
-	  // Figure out if we need to change the strength icon
-	  tmp.toInt(&ok);
-          if ( ok ) {
-	  newStrength = tmp.toInt(&ok);
-	  if ( newStrength < 5 )
-          {	
-		iconStrength = 0;
-		FileLoad=KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi.png");
-          } else if ( newStrength < 50 ) {
-		iconStrength = 30;
-		FileLoad=KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi30.png");
-	  }  else if ( newStrength < 75 ) {
-		iconStrength = 60;
-		FileLoad=KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi60.png");
-	  } else {
-		iconStrength = 85;
-		FileLoad=KStandardDirs::locate("data", "pc-netmanager/pics/tray_wifi85.png");
-	  }
-
-	 // If the strength has changed enough, change the loaded icon
-  	 if ( DeviceSavedStrength != iconStrength  )
-	 {
-	  QIcon Icon3;
-	  DeviceSavedStrength = iconStrength;
-          Icon3.addFile(FileLoad);
-          setIcon(Icon3);
-         }
-
-        }
-        DeviceSignalStrength = tmp; 
-        updateTooltip = 1;
-
         // Get the connection speed being used
         DeviceWirelessSpeed = getWirelessSpeedForIdent( DeviceName );
-        updateTooltip = 1;
-    }
+     }
 
   }
 
+  // Set the tray icon now
+  setIcon(Icon);
 
-  if ( updateTooltip == 1)
-  {
-    // Show the notification that something important changed
-    if ( displayPassivePopup == 1) {
-      Icon2.addFile(KStandardDirs::locate("data", "pc-netmanager/pics/info.png"));
-      KPassivePopup::message("Device " + DeviceName + ":", NotifyText,  Icon2.pixmap(22,22),  this);
-    }
-    displayTooltip();
-  }
 
+  displayTooltip();
 
+
   // First run a check to see if this applet has been disabled in the network manager
   if ( ! QFile::exists( filename ) )
     close(0);



More information about the Commits mailing list