[PC-BSD Commits] r16419 - pcbsd/current/src-qt4/pc-netmanager/src/NetworkTray

svn at pcbsd.org svn at pcbsd.org
Sun Apr 15 11:40:58 PDT 2012


Author: kenmoore
Date: 2012-04-15 18:40:58 +0000 (Sun, 15 Apr 2012)
New Revision: 16419

Modified:
   pcbsd/current/src-qt4/pc-netmanager/src/NetworkTray/NetworkTray.cpp
Log:
Fix the wireless network tray to not show identical SSID signals



Modified: pcbsd/current/src-qt4/pc-netmanager/src/NetworkTray/NetworkTray.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-netmanager/src/NetworkTray/NetworkTray.cpp	2012-04-15 18:39:23 UTC (rev 16418)
+++ pcbsd/current/src-qt4/pc-netmanager/src/NetworkTray/NetworkTray.cpp	2012-04-15 18:40:58 UTC (rev 16419)
@@ -637,22 +637,47 @@
   for(int i=1; i<wifinet.length(); i++){ //skip the first line (labels)
     //Get the ssid and Security for this network
     QStringList wdata = NetworkInterface::parseWifiScanLine(wifinet[i],false);
+    QString ssid = wdata[0];
+    QString strength = wdata[4];
     //Add this network to the list
-    QString entry = wdata[0]+" ("+wdata[4]+")"; // SSID (%Strength)
+    QString entry = ssid+" ("+strength+")"; // SSID (%Strength)
     //Get the proper "locked" or "unlocked" icon for the network
     if(wdata[6].contains("None")){
       ssidIcon = iconUnlocked;
     }else{
       ssidIcon = iconLocked;
     }
-    //Create the action
-    QAction* tempAct = new QAction(entry, this); //set the label for the action on creation
-    tempAct->setObjectName(wdata[0]); //set the action name as the SSID
-    tempAct->setIcon(ssidIcon); //set the action icon
-    //add the action to the action group
-    trayActionGroup->addAction(tempAct); 
-    //Add the action to the menu
-    trayIconMenu->addAction(tempAct);
+    //Check for duplicate SSID entries
+    bool duplicateSSID = FALSE;
+    int dupRow;
+    for ( int z = 0 ; z < trayIconMenu->actions().count() ; z++){
+      //qDebug() << listWifi->item(z)->text() << ssid;
+      if ( trayIconMenu->actions()[z]->text().contains(ssid+" (") ){
+        duplicateSSID = TRUE;
+        dupRow = z;
+        break;
+      }
+    }
+    if(!duplicateSSID){
+      //Create the action
+      QAction* tempAct = new QAction(entry, this); //set the label for the action on creation
+      tempAct->setObjectName(wdata[0]); //set the action name as the SSID
+      tempAct->setIcon(ssidIcon); //set the action icon
+      //add the action to the action group
+      trayActionGroup->addAction(tempAct); 
+      //Add the action to the menu
+      trayIconMenu->addAction(tempAct);
+    }else{
+      //Check if the new signal strength is greater, replace if it is
+      QString oldStrength = trayIconMenu->actions()[dupRow]->text();
+      oldStrength = oldStrength.section("(signal:",1,1).section("%)",0,0).simplified();
+      if( strength.section("%",0,0).toInt() > oldStrength.toInt() ){
+        //New signal strength is greater - replace the string
+        //qDebug() << "Changing signal strength for "+ssid+" to reflect a stronger signal found";
+        //qDebug() << strength << oldStrength;
+        trayIconMenu->actions()[dupRow]->setText( ssid+" (signal: "+strength+")" );
+      }
+    }
   }
   //Connect the actionGroup signal with slotQuickConnect
   QObject::connect(trayActionGroup, SIGNAL(triggered(QAction*)),this,SLOT(slotGetNetKey(QAction*)));



More information about the Commits mailing list