[PC-BSD Commits] r19639 - in pcbsd/current/src-qt4/pc-mounttray: . icons

svn at pcbsd.org svn at pcbsd.org
Wed Oct 10 20:02:01 PDT 2012


Author: kenmoore
Date: 2012-10-11 03:02:01 +0000 (Thu, 11 Oct 2012)
New Revision: 19639

Added:
   pcbsd/current/src-qt4/pc-mounttray/icons/dvd.png
   pcbsd/current/src-qt4/pc-mounttray/icons/eject.png
   pcbsd/current/src-qt4/pc-mounttray/icons/harddrive.png
   pcbsd/current/src-qt4/pc-mounttray/icons/mount.png
   pcbsd/current/src-qt4/pc-mounttray/icons/musiccd.png
   pcbsd/current/src-qt4/pc-mounttray/icons/sdcard.png
   pcbsd/current/src-qt4/pc-mounttray/icons/usb.png
Removed:
   pcbsd/current/src-qt4/pc-mounttray/icons/USBblue.png
   pcbsd/current/src-qt4/pc-mounttray/icons/USBgrey.png
   pcbsd/current/src-qt4/pc-mounttray/icons/USBred.png
Modified:
   pcbsd/current/src-qt4/pc-mounttray/menuItem.cpp
   pcbsd/current/src-qt4/pc-mounttray/menuItem.h
   pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp
   pcbsd/current/src-qt4/pc-mounttray/mountTray.h
   pcbsd/current/src-qt4/pc-mounttray/pc-mounttray.qrc
Log:
Large commit for pc-mounttray for 9.2
The new interface is up and running just fine. The only issue so far is to make sure to not display the partitions that makup your currently running system, and double check the disk detection algorithms to make sure I did not break anything.



Index: pcbsd/current/src-qt4/pc-mounttray/icons/dvd.png
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/icons/dvd.png	2012-10-10 20:50:04 UTC (rev 19638)
+++ pcbsd/current/src-qt4/pc-mounttray/icons/dvd.png	2012-10-11 03:02:01 UTC (rev 19639)

Property changes on: pcbsd/current/src-qt4/pc-mounttray/icons/dvd.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+image/png
Index: pcbsd/current/src-qt4/pc-mounttray/icons/eject.png
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/icons/eject.png	2012-10-10 20:50:04 UTC (rev 19638)
+++ pcbsd/current/src-qt4/pc-mounttray/icons/eject.png	2012-10-11 03:02:01 UTC (rev 19639)

Property changes on: pcbsd/current/src-qt4/pc-mounttray/icons/eject.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+image/png
Index: pcbsd/current/src-qt4/pc-mounttray/icons/harddrive.png
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/icons/harddrive.png	2012-10-10 20:50:04 UTC (rev 19638)
+++ pcbsd/current/src-qt4/pc-mounttray/icons/harddrive.png	2012-10-11 03:02:01 UTC (rev 19639)

Property changes on: pcbsd/current/src-qt4/pc-mounttray/icons/harddrive.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+image/png
Index: pcbsd/current/src-qt4/pc-mounttray/icons/mount.png
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/icons/mount.png	2012-10-10 20:50:04 UTC (rev 19638)
+++ pcbsd/current/src-qt4/pc-mounttray/icons/mount.png	2012-10-11 03:02:01 UTC (rev 19639)

Property changes on: pcbsd/current/src-qt4/pc-mounttray/icons/mount.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+image/png
Index: pcbsd/current/src-qt4/pc-mounttray/icons/musiccd.png
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/icons/musiccd.png	2012-10-10 20:50:04 UTC (rev 19638)
+++ pcbsd/current/src-qt4/pc-mounttray/icons/musiccd.png	2012-10-11 03:02:01 UTC (rev 19639)

Property changes on: pcbsd/current/src-qt4/pc-mounttray/icons/musiccd.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+image/png
Index: pcbsd/current/src-qt4/pc-mounttray/icons/sdcard.png
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/icons/sdcard.png	2012-10-10 20:50:04 UTC (rev 19638)
+++ pcbsd/current/src-qt4/pc-mounttray/icons/sdcard.png	2012-10-11 03:02:01 UTC (rev 19639)

Property changes on: pcbsd/current/src-qt4/pc-mounttray/icons/sdcard.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+image/png
Index: pcbsd/current/src-qt4/pc-mounttray/icons/usb.png
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/icons/usb.png	2012-10-10 20:50:04 UTC (rev 19638)
+++ pcbsd/current/src-qt4/pc-mounttray/icons/usb.png	2012-10-11 03:02:01 UTC (rev 19639)

Property changes on: pcbsd/current/src-qt4/pc-mounttray/icons/usb.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+image/png
Modified: pcbsd/current/src-qt4/pc-mounttray/menuItem.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/menuItem.cpp	2012-10-10 20:50:04 UTC (rev 19638)
+++ pcbsd/current/src-qt4/pc-mounttray/menuItem.cpp	2012-10-11 03:02:01 UTC (rev 19639)
@@ -2,41 +2,59 @@
 #include <pcbsd-utils.h>
 #include "menuItem.h"
 
-MenuItem::MenuItem(QWidget* parent, QString newdevice, bool automount) : QWidget(parent)
+MenuItem::MenuItem(QWidget* parent, QString newdevice, QString label) : QWidgetAction(parent)
 {
-  //Set the direcectory to mount devices in
-  MOUNTDIR="/media/";
+  MOUNTDIR="/media/";   //Set the direcectory to mount devices in
+  AMFILE= QDir::homePath() + "/.pc-automounttray";   //File to save/load all the devices to be automounted
   //Set the device
   device = newdevice;
-  isSelected = FALSE;
   //Create the layout
   QGridLayout* layout = new QGridLayout();
+  QHBoxLayout* hlayout = new QHBoxLayout();
   //Create the gui items
   devLabel = new QLabel;
+    devLabel->setToolTip(device);
+    
   devIcon = new QLabel;
+    devIcon->setToolTip(device);
   currentSpace = new QProgressBar;
     currentSpace->setMinimum(0);
   pushMount = new QPushButton;
   checkAutomount = new QCheckBox;
-    checkAutomount->setChecked(automount);
+    checkAutomount->setChecked( checkSavedAutoMount() );
+    checkAutomount->setText( tr("Auto-mount this device") );
   //Add the widgets to the layout
   layout->addWidget(devIcon,0,0,3,1);	
-  layout->addWidget(devLabel,0,1);
-  layout->addWidget(pushMount,0,2);
-  layout->addWidget(currentSpace,1,1,1,2);
+  hlayout->addWidget(devLabel);
+  hlayout->addWidget(pushMount);
+  layout->addLayout(hlayout,0,1);
+  layout->addWidget(currentSpace,1,1);
   layout->addWidget(checkAutomount,2,1);
   //Set the layout
-  this->setLayout(layout);
-  
+  frame = new QWidget();
+  frame->setLayout(layout);
+  this->setDefaultWidget(frame);
   //Connect the signals/slots
   connect(pushMount,SIGNAL(clicked()), this, SLOT(slotMountClicked()));
   connect(checkAutomount,SIGNAL(toggled(bool)),this,SLOT(slotAutoMountToggled(bool)));
-  
+  //Setup the initial device variables
+  QString nLabel;
+  getDevInfo(newdevice,&devType,&nLabel,&filesystem,&maxSize); //this will set the devType, filesystem, and maxSize variables
+  //Device Label/Name
+  if( (!nLabel.isEmpty() && label.isEmpty()) || (!label.startsWith(nLabel)) ){
+    devLabel->setText(nLabel);  //use auto-detected name if none given initially or a better name auto-detected now
+  }else{
+    devLabel->setText(label);  //use the given label
+  }
+  //Setup the device Icon based on the type
+  if(devType == "USB"){ devIcon->setPixmap(QPixmap(":icons/usb.png")); }
+  else if(devType == "SATA"){ devIcon->setPixmap(QPixmap(":icons/harddrive.png")); }
+  else if(devType == "SD"){ devIcon->setPixmap(QPixmap(":icons/sdcard.png")); }
+  if(devType == "CD9660"){ devIcon->setPixmap(QPixmap(":icons/dvd.png")); }
   //Start the automount procedure if necessary
-  if(automount){
+  if(checkAutomount->isChecked()){
     mountItem();
   }
-  
   //Update the Item based upon current device status
   updateItem();
 
@@ -48,14 +66,7 @@
 /*
   PUBLIC FUNCTIONS
 */
-void MenuItem::setDeviceName(QString label){
-  devLabel->setText(label);
-}
 
-void MenuItem::setDeviceIcon(QString iconFile){
-  devIcon->setPixmap(QPixmap(iconFile));	
-}
-
 void MenuItem::updateItem(){
   //Update the item visuals, based upon current device status
   if( isConnected() ){
@@ -63,10 +74,12 @@
       devIcon->setEnabled(TRUE);  //Make the icon full color
       pushMount->setText(tr("Eject"));
       pushMount->setIcon(QIcon(":icons/eject.png"));
+      checkAutomount->setVisible(TRUE);
     }else{	  
-      devIcon->setEnabled(FALSE); //Grey out the icon
+      devIcon->setEnabled(FALSE); //Grey out the icon if not mounted
       pushMount->setText(tr("Mount"));
       pushMount->setIcon(QIcon(":icons/mount.png"));
+      checkAutomount->setVisible(FALSE);
     }
   }else{
     emit itemRemoved(device);
@@ -102,6 +115,7 @@
   //make sure to use the absolute path
   if(!dev.startsWith("/dev/")){ dev.prepend("/dev/"); }
   
+  if(!QFile::symLinkTarget(dev).isEmpty()){ return; } //do not follow sym-links
   //Check for valid device types
   QStringList validdev, devtype;
   validdev << "da" << "ad"    << "mmcsd" << "cd"         << "acd";
@@ -111,7 +125,7 @@
     if(node.startsWith(validdev[i])){ type->append(devtype[i]); break; }
   }
   //Make sure we quit before running commands on any invalid device nodes
-  if(type->isEmpty()){return;}
+  if(type->isEmpty() || !QFile::exists(dev) ){return;}
   
   //Read the Device Info using "file -s <device>"
   QString cmd = "file -s "+dev;
@@ -181,7 +195,7 @@
 */
 void MenuItem::slotMountClicked(){
   if( isConnected() ){
-    if( isMounted() ){
+    if( !isMounted() ){
       mountItem();
     }else{
       unmountItem();  
@@ -189,16 +203,36 @@
   }else{
     emit itemRemoved(device);	  
   }
+  updateItem();
 }
 
-void MenuItem::slotAutoMountToggled(){
-  if(checkAutomount->isChecked()){
-    emit itemAllowAutoMount( devLabel->text(), filesystem, maxSize);
+void MenuItem::slotAutoMountToggled(bool checked){
+  qDebug() << "Auto-mount toggled for:" << device << checked;
+  QString entry = devLabel->text()+":::"+devType+":::"+filesystem+":::"+maxSize;
+  if(checked){
+    //Add this entry to the auto-mount file
+    QString cmd = "echo \""+entry+"\" >> "+AMFILE;
+    system( cmd.toUtf8() );
   }else{
-    emit itemDisallowAutoMount( devLabel->text(), filesystem, maxSize);	  
+    //Remove this entry from the automount file
+    QString tmpFile = AMFILE+".tmp";
+    QString cmd = "cat "+AMFILE+" | grep -v "+entry+" > "+tmpFile+"; mv "+tmpFile+" "+AMFILE;
+    system( cmd.toUtf8() );
   }
 }
 
+bool MenuItem::checkSavedAutoMount(){
+  if(QFile::exists(AMFILE)){
+    QString cmd = "cat "+AMFILE;
+    QString search = devLabel->text() +" "+ devType +" "+ filesystem +" "+ maxSize;
+    QString chk = Utils::runShellCommandSearch(cmd, search);
+    if( chk.isEmpty() ){ return FALSE; }
+    else{ return TRUE; }
+  }else{
+    return FALSE;
+  }
+}
+
 void MenuItem::mountItem(){
   //Mount the device
   
@@ -237,26 +271,29 @@
   qDebug() << " - command:" << cmd2;
   
   bool ok = FALSE;
-  QString result;
+  QString result, title;
   //Run the mounting commands
   QStringList output = Utils::runShellCommand(cmd1);
   if( output.join(" ").simplified().isEmpty() ){
     //directory created, run the next command
     output = Utils::runShellCommand(cmd2);
     if( output.join(" ").simplified().isEmpty() ){
-      result = QString( tr("Successfully mounted %1 at %2") ).arg(deviceName).arg(mntpoint);
+      title = tr("Success");
+      result = QString( tr("%1 mounted at %2") ).arg(deviceName).arg(mntpoint);
       ok = TRUE;
     }else{
       qDebug() << "pc-mounttray: Error mounting device:" << device;
       qDebug() << " - Error message:" << output;
-      result = QString( tr("Error mounting %1 at %2") +"\n"+output.join(" ") ).arg(deviceName).arg(mntpoint);
+      title = QString( tr("Error mounting %1 at %2") ).arg(deviceName).arg(mntpoint);
+      result =  output.join(" ");
       //Remove the mount point just created
       Utils::runShellCommand("rmdir "+mntpoint);
     }
   }else{
     qDebug() << "pc-mounttray: Error creating mountpoint:" << mntpoint;
     qDebug() << " - Error message:" << output;
-    result = QString( tr("Error mounting %1") +"/n"+ tr("Could not create mount point at %2") ).arg(deviceName).arg(mntpoint);
+    title = QString( tr("Error mounting %1") ).arg(deviceName);
+    result =  QString( tr("Could not create mount point at %1") ).arg(mntpoint);
   }
   //Output the proper signals depending upon success
   if(ok){
@@ -265,7 +302,9 @@
   }else{
     mountpoint.clear();
   }
-  emit newMessage(result);
+  if( !checkAutomount->isChecked() ){
+    emit newMessage(title, result); //suppress the output message if it was automounted
+  }
   
 }
 
@@ -289,7 +328,7 @@
   qDebug() << "Unmounting device from" << mountpoint;
   //Run the commands
   QStringList output;
-  QString result;
+  QString result, title;
   bool ok = FALSE;
   output = Utils::runShellCommand(cmd1);
   if(output.join(" ").simplified().isEmpty()){
@@ -300,18 +339,20 @@
       qDebug() << " - Error message:" << output;
     }
     ok = TRUE;
-    result = QString( tr("%1 has been successfully unmounted.")+"\n"+tr("It is now safe to remove the device") ).arg(devLabel->text());
+    title = QString( tr("%1 has been successfully unmounted.") ).arg(devLabel->text());
+    result = tr("It is now safe to remove the device");
   }else{
     qDebug() << "pc-mounttray: Error unmounting mountpoint:" << mountpoint;
     qDebug() << " - Error message:" << output;
-    result = QString( tr("Error: %1 could not be unmounted")+"\n"+output.join(" ") ).arg(devLabel->text());
+    title = QString( tr("Error: %1 could not be unmounted") ).arg(devLabel->text());
+    result = output.join(" ");
   }
   //emit the proper signals
   if(ok){
     emit itemUnmounted(device);
     mountpoint.clear();
   }
-  emit newMessage(result);
+  emit newMessage(title, result);
 }
 
 void MenuItem::updateSizes(){

Modified: pcbsd/current/src-qt4/pc-mounttray/menuItem.h
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/menuItem.h	2012-10-10 20:50:04 UTC (rev 19638)
+++ pcbsd/current/src-qt4/pc-mounttray/menuItem.h	2012-10-11 03:02:01 UTC (rev 19639)
@@ -5,7 +5,7 @@
 #ifndef MENU_ITEM_H
 #define MENU_ITEM_H
 
-#include <QWidget>
+#include <QWidgetAction>
 #include <QDir>
 #include <QFile>
 #include <QPushButton>
@@ -15,12 +15,12 @@
 #include <QDebug>
 #include <QLabel>
 
-class MenuItem : public QWidget
+class MenuItem : public QWidgetAction
 {
 	Q_OBJECT
 
   public:
-	MenuItem(QWidget* parent = 0, QString newdevice = "", bool automount = FALSE);
+	MenuItem(QWidget* parent = 0, QString newdevice = "", QString label = "");
 	~MenuItem();
 	
 	QString device;
@@ -29,10 +29,9 @@
         QString mountpoint;
         QString maxSize;  //number in KB saved as a QString
         QString currentSize; //number in KB saved as a QString
+        QString AMFILE;
 	
   	//Setters
-	void setDeviceName(QString);
-	void setDeviceIcon(QString);
 	void updateItem();
 	
 	//Getters
@@ -45,31 +44,30 @@
 	static void getDevInfo(QString, QString*, QString*, QString*, QString*);
         
   private:
+	QWidget *frame;
 	QString MOUNTDIR;
   	QLabel* devLabel;
   	QLabel* devIcon;
   	QProgressBar* currentSpace;
   	QPushButton* pushMount;
   	QCheckBox* checkAutomount;
-  	bool isSelected;
 
 	void mountItem();
   	void unmountItem();
         void updateSizes();
         QString getSizeDisplay(int);
+        bool checkSavedAutoMount();
   	
   private slots:
   	void slotMountClicked();
-        void slotAutoMountToggled();
+        void slotAutoMountToggled(bool);
 	
   signals:
 	//Emits these signals whenever needed
 	void itemMounted(QString);  	//device node (/dev/da*)
 	void itemUnmounted(QString); 	//device node
 	void itemRemoved(QString);  	//device node
-        void itemAllowAutoMount(QString,QString,QString); 	//device label, filesystem, and size in kB (in that order)
-        void itemDisallowAutoMount(QString,QString,QString); 	// device label, filesystem, and size in kB (in that order)
-        void newMessage(QString);	//message to be displayed
+        void newMessage(QString, QString);	//message to be displayed
 
 };
 #endif

Modified: pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp	2012-10-10 20:50:04 UTC (rev 19638)
+++ pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp	2012-10-11 03:02:01 UTC (rev 19639)
@@ -20,14 +20,14 @@
 void MountTray::programInit()
 {
   qDebug() << "pc-mounttray: starting up";
-  MOUNTDIR = "/media/"; //Directory for all the devices to be mounted
   DEVICEDIR = "/dev/";  //Directory that new devices are discovered
-  AMFILE = QDir::homePath() + "/.pc-automounttray"; //File to save/load all the devices to be automounted
+  MOUNTDIR = "/media/"; //Directory that all devices get mounted to
   getInitialUsername(); //try to detect the non-root user who is running the program with root permissions
   getDefaultFileManager(); //try to detect the default file-manager for opening the mount directory
 
   trayIcon = new QSystemTrayIcon(this);
-  
+  trayIconMenu = new QMenu();
+	
   // Tie the left-click signal to open the context menu
   connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(slotTrayActivated(QSystemTrayIcon::ActivationReason)) );
   
@@ -36,8 +36,8 @@
   trayIcon->show();
   
   //Load the automount file and populate the list
-  qDebug() << "-Loading automount device list:" << AMFILE;
-  loadAutoMountFile();
+  //qDebug() << "-Loading automount device list:" << AMFILE;
+  //loadAutoMountFile();
 
   //Startup the devd watching process
   qDebug() << "-Starting up the DEVD watcher";
@@ -45,42 +45,44 @@
   
   //Do an initial scan of the devices with dmesg
   qDebug() << "-Performing initial device scan";
-  initialDeviceScan();
+  scanInitialDevices();
   
-  //Update the tray icon
-  QAction* junk = new QAction("",this);
-  showDeviceNotification(0,junk);
+  //Update the tray menu and icons
+  updateMenu();
+
   qDebug() << "-Program now ready for use";
 }
 
-void MountTray::showDeviceNotification(int ident, QAction* device){
-  //ident: 0-refresh icon only, 1-device connected, 2-device mounted, 3-device unmounted, 4-device disconnected
-
-  if(ident==0){
-    //no message, only update tray icon
-  }else if(ident==1){
-    //Device connected
-    trayIcon->showMessage( tr("Device Connected"), tr("New device detected"), QSystemTrayIcon::NoIcon,3000 );
-    
-  }else if(ident==2){
-    //Device mounted
-    trayIcon->showMessage( tr("Device Mounted"), QString(tr("Device %1 has been mounted at %2")).arg(device->text()).arg(MOUNTDIR+device->text()), QSystemTrayIcon::NoIcon,3000 );
-    
-  }else if(ident==3){
-    //Device unmounted
-    trayIcon->showMessage( tr("Device Unmounted"), QString(tr("Device %1 may now be safely removed")).arg(device->text()), QSystemTrayIcon::NoIcon,3000 );
-    
-  }else if(ident==4){
-    //Device disconnected
-    //DOn't show a message
-  
-  }else{
-    //Unknown identifier
-    qDebug() << "pc-mounttray: unknown device notification identifier";
-    return;
+void MountTray::updateMenu(){
+  //Clear the menu
+  trayIconMenu->clear();
+  trayIconMenu->disconnect();
+  numAvail = 0;
+  numMount = 0;
+  //Iterate through all the devices and add them as necessary
+  for(int i=0; i<deviceList.length(); i++){
+    if(deviceList[i]->isConnected()) { 
+      trayIconMenu->addAction(deviceList[i]);
+      numAvail++;
+      if(deviceList[i]->isMounted() ){ numMount++; }
+      deviceList[i]->updateItem(); //refresh the item now as well
+    }else{
+      //Remove any devices that are not connected
+      deviceList.removeAt(i);
+      i--; //roll back one to catch the new index values for the list
+    }
   }
+  //Separate the extra options at the end
+  trayIconMenu->addSeparator();
+  //Add the "open media" entry to the list
+  trayIconMenu->addAction( QIcon(":icons/folder.png"), tr("Open Media Directory"), this, SLOT(slotOpenMediaDir()) );
+  //Add the "close tray" entry to the list
+  trayIconMenu->addAction( QIcon(":icons/application-exit.png"), tr("Close Tray"), this, SLOT(closeTray()) );
   
-  //Set the main Tray icon 
+  //Apply the menu to the Tray
+  trayIcon->setContextMenu(trayIconMenu);
+
+  //Update the main icon based upon whether devices have been found
   if(numAvail==0){
     trayIcon->setIcon( QIcon(":icons/CDdevices-inactive.png") );
   }else{
@@ -90,432 +92,71 @@
       trayIcon->setIcon( QIcon(":icons/CDdevices.png") );
     }
   }
-  
 }
 
-QAction* MountTray::newDeviceAction(QString deviceLocation, QString type){
-  //Turn a device location into a QAction for use in this program
-  /* -- SAVED DATA FORMAT WITHIN THE QACTION ---
-    text() -> Device Name (multiple words allowed)
-    whatsThis() -> Device Location (example: /dev/da0 )
-    statusTip() -> Device type and filesystem (example: USB:::msdosfs)
-  */
-  QAction* newdev = new QAction(this);
-  newdev->setCheckable(FALSE); //don't let the menu action be checkable -- looks funny with the icons 
-  
-  //Set the device location
-  if( !deviceLocation.startsWith(DEVICEDIR) ){
-    deviceLocation.prepend(DEVICEDIR);
-  }
-  QString dev = deviceLocation.section("/",-1);
-  newdev->setWhatsThis(deviceLocation);
-
-  //Shortcut for junk actions (to speed up list searches)
-  if(type == "JUNK"){
-    return newdev;	  
-  }
-  
-  //Don't run "file" command on certain devices that are known non-storage devices
-  if(dev.startsWith("pcm") || dev.startsWith("tty") ){
-    return newdev;
-  } 
-
-  //Get the Device Info
-  QString cmd = "file -s "+deviceLocation;
-  QString output = Utils::runShellCommand(cmd).join(" ");
-  //qDebug() << "File -s output:" << output;  
-  // - get the device storage size
-  QStringList tmp = output.split(",");
-  int kb;
-  //qDebug() << "tmp:" << tmp;
-  if( !tmp.filter("number of data blocks").isEmpty() ){
-    tmp = tmp.filter("number of data blocks");
-    kb = tmp[0].remove("number of data blocks").simplified().toInt();
-  }else if( !tmp.filter("number of blocks").isEmpty() ){
-    tmp = tmp.filter("number of blocks");
-    kb = tmp[0].remove("number of blocks").simplified().toInt();
-  }else if( !tmp.filter("sectors ").isEmpty()){
-    tmp = tmp.filter("sectors ");
-    kb = tmp[0].remove("sectors ").section("(",0,0).simplified().toInt();
-  }else{ kb = 1; }
-
-  //Filter out all devices with less than a MB of storage
-  //qDebug() << "kb detected:" << kb;
-  if( (kb < 1024) && (type=="USB") ){
-    return newdev;
-  }
-  // - get the device label
-  QString label = output.section("label: \"",1,1).section("\"",0,0).simplified(); //device name
-  if(label.isEmpty()){
-    //Try another method to find the device label
-
-    QStringList glout = Utils::runShellCommandSearch("glabel list "+dev,"Name:").split("\n");
-    for(int i=0; i<glout.length(); i++){
-      if(!glout[i].contains(dev)){
-        label = glout[i].section("Name:",1,1).section("/",-1).simplified();
-	break;
+void MountTray::scanInitialDevices(){
+  //Scan the /dev/ directory for all valid devices and check them 
+  QDir dir(DEVICEDIR);
+  QStringList allDevs = dir.entryList( QDir::System | QDir::NoDotAndDotDot | QDir::NoSymLinks );
+  //Now that we have a quick and dirty list, lets clean it up 
+  QString dType, dLabel, dFS, dSize;
+  for(int i=0; i<allDevs.length(); i++){
+    //Run it through the device info function to filter out all the "invalid" devices (audio, USB hubs, etc...)
+    MenuItem::getDevInfo(allDevs[i], &dType, &dLabel, &dFS, &dSize);
+    if( !dType.isEmpty() ){ // ignore devices that fail the information check
+      //Allow all filesystems for the moment (could remove UNKNOWN's in the future)
+      //Filter out all devices with limited storage (1 block ~= 8kB usually)
+      if( dSize.toInt() > 512 ){ //Use 512 blocks as the cutoff for the moment
+        //Add the device to the menu list
+	addDevice(allDevs[i], dLabel);
       }
     }
   }
-  // - trim the label out of the output line for filesystem type detection
-  QString devFSsec = output.section("label:",0,0);
-  QString devFSsec2 = output.section("label:",1,3).section(",",1,1,QString::SectionSkipEmpty);
-  // - Find the filesystem type for the device
-  QString filesys;
-  QStringList fsdetect, fslabel;
-  fsdetect << "FAT" << "NTFS" << "EXT" << "ISO 9660" << "Unix Fast File system" << "Reiser" << "XFS"; //string to match for a particular filesystem
-  fslabel << "FAT" << "NTFS" << "EXT" << "CD9660" << "UFS" << "REISERFS" << "XFS"; //internal labels for the filesystems
-  for(int i=0; i<fsdetect.length(); i++){
-    if(devFSsec.contains(fsdetect[i]) || devFSsec2.contains(fsdetect[i]) ){
-      filesys = fslabel[i]; 
-    }
-  }
-  //If the filesystem could not be detected or is not supported
-  if(filesys.isEmpty()){
-    filesys = "UNKNOWN"; 
-    //return newdev;
-  }
-
-  //Set the Device type and file system type
-  if(type.isEmpty()){ type = "USB"; }
-  if( filesys == "CD9660" ){ type = "CD/DVD"; }  
-  newdev->setStatusTip( type+":::"+filesys);
-
-  //Set the Device Name
-  if(label.isEmpty()){
-    int num = 0;
-    for(int i=0; i<devList.length(); i++){
-      if( devList[i]->text().contains(type+"-Device-") ){
-	num++;
-      }
-    }
-    label = type+"-Device-"+QString::number(num);
-  }
-  newdev->setText(label);
-
-  //set the default Icon
-  setDeviceIcon(newdev);
-
-  return newdev;
   
 }
 
-void MountTray::setDeviceIcon(QAction* device){
-  bool ismnt = isMounted(device);
-  QString type = device->statusTip().section(":::",0,0);
-  if(type=="USB" && ismnt){
-    device->setIcon( QIcon(":icons/USBblue.png") );
-  }else if( type=="USB" && !ismnt){
-    device->setIcon( QIcon(":icons/USBgrey.png") );
-  }else if( type=="SATA" && ismnt){
-    device->setIcon( QIcon(":icons/CDdevices.png") );
-  }else if( type=="SATA" && !ismnt){
-    device->setIcon( QIcon(":icons/CDdevices-inactive.png") );
-  }else{
-    device->setIcon( QIcon(":icons/CDdevices-inactive.png") );
+int MountTray::findDeviceInList(QString newDev){
+  for(int i=0; i<deviceList.length(); i++){
+    if( deviceList[i]->device == newDev ){ return i; }
   }
-}
-
-bool MountTray::updateDeviceList(int act, QAction* device){
-  //act: 0-verify device  1-add device  2-mount device 3-unmount device 4-remove device 5-mount silently 
-
-  bool status = FALSE;
-  if(act==0){
-    //verify that device is still valid
-    if( isConnected(device) ){
-      status = TRUE;
-    }else{
-      status = updateDeviceList(4, device);
-    }
-    
-  }else if(act==1){
-    //Device connected (add new device entry)
-    if( findDeviceInList(device) == -1 ){
-      device->setToolTip( QString(tr("%1 unmounted - may be removed")).arg(device->whatsThis()) );
-      devList << device;
-      numAvail++;
-      status = TRUE;
-    }
-      
-  }else if(act==2){
-    //Mount device
-    if( mountDevice(device) ){
-      device->setToolTip( QString(tr("%1 mounted at %2")).arg(device->whatsThis()).arg(MOUNTDIR+device->text().replace(" ","-")) );
-      numMount++;
-      status = TRUE;
-    }
-  
-  }else if(act==3){
-    //Unmount device
-    if( unmountDevice(device) ){
-      device->setToolTip( QString(tr("%1 unmounted - may be removed")).arg(device->whatsThis()) );
-      numMount--;
-      status = TRUE;
-    } 
-    
-  }else if(act==4){
-    //Device disconnected
-    int index = findDeviceInList(device);
-    if(index != -1){
-      devList.removeAt(index);
-      numAvail--;
-      status = TRUE;
-    }
-     
-  }else if(act==5){
-    //Mount device silently
-    if( mountDevice(device,FALSE) ){
-      device->setToolTip( QString(tr("%1 mounted at %2")).arg(device->whatsThis()).arg(MOUNTDIR+device->text().replace(" ","-")) );
-      numMount++;
-      status = TRUE;
-    }
- 
-  }else{
-    //Unknown identifier
-    qDebug() << "pc-mounttray: unknown device update identifier";
-  }
-  
-  //update the icon for the device
-  setDeviceIcon(device);
-  
-  return status;
-}
-
-int MountTray::findDeviceInList(QAction* device){
-  for(int i=0; i<devList.length(); i++){
-    if( devList[i]->whatsThis() == device->whatsThis() ){
-      return i;
-    }
-  }
   return -1;
 }
 
-bool MountTray::mountDevice(QAction* devAct,bool openDir){
-  if(isMounted(devAct)){
-    //Device is already mounted
-    return TRUE;
-  }
+void MountTray::addDevice(QString dev, QString label){
+  if(!dev.startsWith(DEVICEDIR)){ dev.prepend(DEVICEDIR); }
   
-  //Mount the device
-  bool status = FALSE;
-  
-  QString dev = devAct->whatsThis();
-  QString mntpoint = MOUNTDIR + devAct->text().replace(" ","-"); //take into account spaces in the name
-  QString dtype = devAct->statusTip().section(":::",0,0);
-  QString fstypedet = devAct->statusTip().section(":::",1,1); 
-  
-  //Create the fileystem specific command for mounting
-  QString fstype;
-  QString fsopts="";
-  if( fstypedet == "FAT" ){ fstype = "mount -t msdosfs"; fsopts = "-o large,-m=644,-M=777"; }
-  else if(fstypedet == "NTFS"){ fstype = "ntfs-3g"; }
-  else if(fstypedet == "EXT"){ fstype = "mount -t ext2fs"; }
-  else if(fstypedet == "CD9660"){ fstype = "mount -t cd9660"; }
-  else if(fstypedet == "UFS"){ fstype = "mount -t ufs"; }
-  else if(fstypedet == "REISERFS"){ fstype = "mount -t reiserfs"; }
-  else if(fstypedet == "XFS"){ fstype = "mount -t xfs"; }
-  else{
-    qDebug() << "Unknown device filesystem:" << dev << fstypedet << " attempting mount_auto command";
-    fstype = "mount_auto";
-    //QMessageBox::warning(this,tr("Unknown Device Filesystem"),tr("The filesystem on this device is unknown and cannot be mounted at this time") );
-    //return FALSE;
+  //Check if the device is already in the list
+  int tot=0;
+  for(int i=0; i<deviceList.length(); i++){
+    if( deviceList[i]->device == dev ){ return; } //already exists, do nothing
+    if( deviceList[i]->getDeviceName().startsWith(label) ){ tot++; }
   }
-  //Make sure the mntpoint is available
-  QDir mpd(mntpoint);
-  if(mpd.exists()){
-    //Remove the existing directory (will work only if it is empty)
-    mpd.cdUp();
-    mpd.rmdir(mntpoint);
-  }
-  //Prepare the commands to run
-  QString cmd1 = "mkdir " + mntpoint;
-  QString cmd2 = fstype + " " +fsopts + " " + dev + " " + mntpoint;
-  
-  qDebug() << "Mounting device" << dev << "on" << mntpoint << "("<<fstypedet<<")";
-  qDebug() << " - command:" << cmd2;
-  //Run the mounting commands
-  QStringList output = Utils::runShellCommand(cmd1);
-  if( output.join(" ").simplified().isEmpty() ){
-    //directory created, run the next command
-    output = Utils::runShellCommand(cmd2);
-    if( output.join(" ").simplified().isEmpty() ){
-      //Mounted successfully
-      if(openDir){ openMediaDir(mntpoint); }//open the mountpoint directory
-      status = TRUE;
-    }else{
-      qDebug() << "pc-mounttray: Error mounting device:" << dev;
-      qDebug() << " - Error message:" << output;
-      //Remove the mount point just created
-      Utils::runShellCommand("rmdir "+mntpoint);
-    }
-  }else{
-    qDebug() << "pc-mounttray: Error creating mountpoint:" << mntpoint;
-    qDebug() << " - Error message:" << output;
-  }
-  
-  return status;
+  //See if the label is unique as well, otherwise add a number to the end to make it unique
+  if(tot > 0 && !label.isEmpty()){ label.append("-"+QString::number(tot)); }
+ 
+  //Create the menu item (will automount if necessary)
+  MenuItem *tmp = new MenuItem(this, dev, label);
+  //connect the signals/slots
+  connect(tmp, SIGNAL(itemMounted(QString)), this, SLOT(openMediaDir(QString)) );
+  connect(tmp, SIGNAL(newMessage(QString,QString)), this, SLOT(slotDisplayPopup(QString,QString)) );
+  connect(tmp, SIGNAL(itemRemoved(QString)), this, SLOT(removeDevice(QString)) );
+  deviceList << tmp;
+  //Update the menu
+  updateMenu();
 }
 
-bool MountTray::unmountDevice(QAction* devAct){
-  //Unmount the device
-  bool status = FALSE;
-  QString mntpoint = MOUNTDIR + devAct->text().replace(" ","-");
-  if( !QFile::exists(mntpoint.remove("\"")) ){
-    if( isMounted(devAct) ){
-      //mounted someplace else - find it
-      QString output = Utils::runShellCommandSearch("mount",devAct->whatsThis());
-      mntpoint = output.section(" on ",1,1).section(" (",0,0).replace(" ","-");
-    }else{
-      //is not mounted to begin with
-      return TRUE;
-    }
-  }
+void MountTray::removeDevice(QString dev){
+  if(!dev.startsWith(DEVICEDIR)){ dev.prepend(DEVICEDIR); }
   
-  QString cmd1 = "umount " + mntpoint;
-  QString cmd2 = "rmdir " + mntpoint;
-  qDebug() << "Unmounting device from" << mntpoint;
-  //Run the commands
-  QStringList output;
-  output = Utils::runShellCommand(cmd1);
-  if(output.join(" ").simplified().isEmpty()){
-    //unmounting successful, remove the mount point directory
-    output = Utils::runShellCommand(cmd2);
-    if(output.join(" ").simplified().isEmpty()){
-      //Directory removed
-      status = TRUE;
-    }else{
-      qDebug() << "pc-mounttray: Error removing mountpoint:" << mntpoint;
-      qDebug() << " - Error message:" << output;
-    }
-  }else{
-    qDebug() << "pc-mounttray: Error unmounting mountpoint:" << mntpoint;
-    qDebug() << " - Error message:" << output;
-  }
-    
-  return status;
+  //Find the device in the list
+  int index = findDeviceInList(dev);
+  if( index == -1 ){ return; } //does not exist, do nothing
+  //Remove the menu entry from the list
+  deviceList.removeAt(index);
+  //Update the menu
+  updateMenu();
 }
 
-bool MountTray::isMounted(QAction* device){
-  //Check if device is mounted
-  QString chk = Utils::runShellCommandSearch("mount",device->whatsThis());  
-  if(chk.isEmpty() ){ chk = Utils::runShellCommandSearch("mount",device->text().replace(" ","-")); } 
-
-  if(chk.isEmpty() ){
-    device->setChecked(FALSE);
-    return FALSE;
-  }else{
-    device->setChecked(TRUE);
-    return TRUE;
-  }
-}
-
-bool MountTray::isConnected(QAction* device){
-  if( QFile::exists( device->whatsThis() ) ){
-    return TRUE;
-  }else{
-    return FALSE;
-  }
-}
-
-
-void MountTray::initialDeviceScan(){
-  //Load all the devices plugged in before the program started up
-  trayIconMenu = new QMenu;
-  trayIconMenu->clear();
-  devList.clear();
-  numAvail = 0;
-  numMount = 0;
-  
-  //Scan for all the connected devices and add them to the device list
-  // -- Parse out the "dmesg" command to search for connected devices
-  QStringList output = Utils::runShellCommand("dmesg");
-  QStringList devs;
-  for(int i=0; i<output.length(); i++){
-    QString line = output[i];
-    //umass devices (careful - USB devices can be connected and disconnected)
-    if( line.contains("umass") ){
-      if(line.contains("removing device entry") || line.contains("lost device")){
-        //Device Removed (format: line=([device]:...... )
-        QString dev = line.section(":",0,0).section("(",1,1);
-        devs.removeAll(dev+":::USB");
-      }else if(line.contains(" at umass") ){
-        QString dev = line.section(" ",0,0,QString::SectionSkipEmpty);
-        devs << dev+":::USB";
-      }
-    }
-    //SATA devices
-    if( line.contains("SATA") && line.contains("device") && !line.contains("controller") ){
-      QString pdev = line.section(":",0,0,QString::SectionSkipEmpty); //parent device
-      if( devs.filter(pdev).length() == 0 ){
-        //Check for child partitions within the parent device
-        int i=1;
-        QString cdev = DEVICEDIR+pdev+"s"+QString::number(i);
-        while( QFile::exists(cdev) ){
-          //qDebug() << "cdev:" << cdev;
-          if( cdev.simplified() != (DEVICEDIR+pdev) ){
-            QString cfile = Utils::runShellCommand("file -s "+cdev).join(" ");
-            if( !cfile.contains(" last mounted on /") ){ //ignore the partition PC-BSD is currently running on
-              if( !devs.contains(cdev+":::SATA") ){ devs << cdev+":::SATA"; }
-
-            }
-          }
-          i++;
-          cdev = DEVICEDIR+pdev+"s"+QString::number(i);
-        }
-      }
-    }
-  }
-  //qDebug() << "devs:"<<devs;
-  //If there are any devices connected, create actions for them and add them to the list
-  for(int i=0; i<devs.length(); i++){
-    if(i==0){ qDebug() << "-Existing devices discovered:"; }
-    QAction* newdevice = newDeviceAction( devs[i].section(":::",0,0), devs[i].section(":::",1,1) );
-    qDebug() << " - "<<newdevice->whatsThis()<<" -> "<<newdevice->text()<<", "<<newdevice->statusTip();
-    updateDeviceList(1, newdevice);
-    if(isMounted(newdevice)){ 
-      numMount++; 
-      newdevice->setToolTip( QString(tr("%1 Mounted")).arg(MOUNTDIR+newdevice->text().replace(" ","-")) );
-    }else{
-      newdevice->setToolTip(tr("Unmounted - May be removed"));
-    }
-    autoMount(newdevice,TRUE);
-  }
-  
-  //Update the Tray Menu
-  updateTrayMenu();
-  //Update the Tray Icon
-  QAction* junk = new QAction("",this);
-  showDeviceNotification(0,junk);
-}
- 
-void MountTray::updateTrayMenu(){
-  trayIconMenu->clear();
-  trayIconMenu->disconnect(); //clear any existing connections  
-  
-  //Add all the elements in the saved list to the menu
-  for(int i=0; i<devList.length(); i++){
-    //Create the submenu for this action and fill it
-    setSubMenu(devList[i]);
-    //Add this item to the main menu
-    trayIconMenu->addAction( devList[i] );
-  }
-  
-  trayIconMenu->addSeparator();
-  //Add the "open media" entry to the list
-  trayIconMenu->addAction( QIcon(":icons/folder.png"), tr("Open Media Directory"), this, SLOT(slotOpenMediaDir()) );
-  //Add the "close tray" entry to the list
-  trayIconMenu->addAction( QIcon(":icons/application-exit.png"), tr("Close Tray"), this, SLOT(closeTray()) );
-  
-  //Apply the menu to the Tray
-  trayIcon->setContextMenu(trayIconMenu);
-  
-  //Update the tray icon
-  QAction* junk = new QAction("",this);
-  showDeviceNotification(0,junk);
-  
-}
-
-
 void MountTray::slotTrayActivated(QSystemTrayIcon::ActivationReason reason) {
    if(reason == QSystemTrayIcon::Trigger) {
      trayIcon->contextMenu()->popup(QCursor::pos());
@@ -540,96 +181,43 @@
     QString line = lList[i];
     bool isAttached=FALSE;
     bool deviceFound=FALSE;
-    QString cdev,cdevtype;
+    QString cdev, cdevtype, dlab, dmax, dfs;
+    int index;
     if(line.startsWith("!system=DEVFS")){
       //qDebug() << line;
       QString type = line.section("type=",1,1).section(" ",0,0).simplified();
       cdev = line.section("cdev=",1,1).section(" ",0,0).simplified();
-      //Only recognize certain device types (mass storage devices)
-      if(cdev.startsWith("da")){  cdevtype="USB"; }
-      else if(cdev.startsWith("mmcsd")){ cdevtype="SD"; }
-      else if(cdev.startsWith("ad")){ cdevtype="SATA"; }
-      else if(cdev.startsWith("cd") || cdev.startsWith("acd")){ cdevtype="CD9660"; }
-      else{ cdevtype.clear(); }
+      cdev.prepend("/dev/");
+      if(type=="CREATE"){ isAttached=TRUE; }
+      MenuItem::getDevInfo(cdev, &cdevtype, &dlab, &dfs, &dmax);
+	    
       //If device is recognized - make sure it is also valid
+      index = findDeviceInList(cdev);
       if( !cdevtype.isEmpty() ){
-        if(type=="CREATE"){ isAttached=TRUE; }
-        //Simple check to make sure that a couple types of devices are never used
-        if(!cdev.contains("/") && !cdev.contains("pass") ){
-          cdev.prepend("/dev/");
-          if( QFile::symLinkTarget(cdev).isEmpty() && isAttached && QFile::exists(cdev) ){
-            deviceFound=TRUE;
-          }
-          else if(!isAttached){
-            //Find out if this device is on the list of currently connected devices
-  	    if( findDeviceInList(newDeviceAction(cdev,"JUNK"))!=-1 ){ deviceFound=TRUE; }
-          }
-        }
-      } // end cdevtype device check
+        if( isAttached && !dlab.isEmpty() && (index == -1) ){ deviceFound = TRUE; }
+	else if( !isAttached && ( index != -1) ){ deviceFound = TRUE; }
+      }
     }
     //Perform action if a device is found
     if(deviceFound){
-      checkDevices(); // this will remove any stale device links
       if(isAttached){
-      	QAction* newdev = newDeviceAction(cdev,cdevtype);  
-        qDebug() << "New device detected:" << newdev->text() << newdev->whatsThis() << newdev->statusTip();
-	if( !newdev->statusTip().isEmpty() ){ //make sure the device is valid
-          if( updateDeviceList( 1 , newdev ) ){
-            showDeviceNotification(1,newdev);
-            autoMount(newdev,FALSE);
-          }
+        qDebug() << "New device detected:" << dlab << cdev << cdevtype << dfs << dmax +" blocks";
+	if(dmax.toInt() > 512){     
+	   addDevice(cdev,dlab);  
+	   QString title = tr("New Device");
+	   QString message = QString( tr("%1 can now be accessed")).arg(dlab);
+	   slotDisplayPopup(title, message);
 	}else{ 
-	  qDebug() << " - Ignoring device (less than 1MB of storage detected)";
+	  qDebug() << " - Ignoring device (less than 512 blocks of storage detected)";
 	}
       }else{
+	removeDevice(cdev);
         qDebug() << "Device removal detected:" <<  cdev;
       }
-      //Update the Tray menu
-      updateTrayMenu();
     }
   } // end loop over all devd output lines
 }
 
-void MountTray::menuDeviceToggled(QAction* currentAct){
-  //Make sure that the device list is current
-  checkDevices();
-  //Get the parent action (parentAct->submenu->currentAct)
-  //qDebug() << currentAct->whatsThis();
-  QAction* device = newDeviceAction( currentAct->whatsThis() );
-  //qDebug() << device->whatsThis() << device->text() << device->statusTip();
-  int index = findDeviceInList(device);
-  if(index == -1){ return;} //invalid index
-
-  if(currentAct->isCheckable()){ //toggling auto-mount
-    qDebug() << "Auto-mount toggled for device: "<< currentAct->whatsThis()<<currentAct->isChecked();
-    setAutoMount(devList[index],currentAct->isChecked());
-    autoMount(devList[index],FALSE);
-  }else{  //mount or unmount
-    if( isMounted(devList[index]) ){
-      //Unmount the device
-      if( updateDeviceList(3,devList[index]) ){
-        showDeviceNotification(3,devList[index]);
-      }
-    }else{
-      //Mount the device
-      if( updateDeviceList(2,devList[index]) ){
-        showDeviceNotification(2,devList[index]);
-      }
-    }
-  }
-  //Refresh the menu
-  updateTrayMenu();
-}
-
-void MountTray::menuDeviceHovered(QAction* device){
-  //Display tooltip if there is one
-  if(device->toolTip() != device->text()){
-    QToolTip::showText(QCursor::pos(), device->toolTip());
-  }else{
-    QToolTip::showText(QCursor::pos(), ""); 
-  }
-}
-
 void MountTray::closeTray(){
   qDebug() << "pc-mounttray: closing down";
   //Kill the devd watching process
@@ -706,97 +294,7 @@
   trayIcon->show();
 }
 
-void MountTray::loadAutoMountFile(){
-  QFile file(AMFILE);
-  if(file.exists()){
-    if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
-      qDebug() << "Could not open file for reading:" << AMFILE;
-    }else{
-      QTextStream in(&file);
-      while(!in.atEnd()){
-        AMList << in.readLine();
-      }
-    }
-    file.close();
-  }
+void MountTray::slotDisplayPopup(QString title, QString msg){
+  //Display a popup bubble with the given message for 3 seconds
+  trayIcon->showMessage(title, msg , QSystemTrayIcon::NoIcon,3000 );
 }
-
-void MountTray::setAutoMount(QAction* device, bool enable){
-  QString listchk = device->text()+":::"+device->statusTip();
-  bool changed=FALSE;
-  if(AMList.contains(listchk) ){
-    if(enable){}//do nothing, already enabled
-    else{ 
-      AMList.removeAll(listchk); 
-      changed=TRUE;
-    } //Remove this entry
-  }else{
-    if(enable){ 
-      AMList << listchk;
-      changed=TRUE;
-    }else{} //do nothing, not enabled already;
-  }
-  //Save the changes to file if needed
-  if(changed){
-    QFile file(AMFILE);
-    if(!file.open(QIODevice::WriteOnly | QIODevice::Text)){
-      qDebug() << "Could not open file for writing:" << AMFILE;
-    }else{
-      QTextStream out(&file);
-      for(int i=0; i<AMList.length(); i++){
-        out << AMList[i] << "\n";
-      }
-    }
-    file.close();
-  }
-
-}
-
-void MountTray::autoMount(QAction* device,bool onStartup){
-  if( isAutoMountEnabled(device) && !isMounted(device) ){
-    if(onStartup){ updateDeviceList(5,device); } //Mount device silently
-    else{ updateDeviceList(2, device); }//mount the device (and open dir)
-  }
-}
-
-bool MountTray::isAutoMountEnabled(QAction* device){
-  QString listchk = device->text()+":::"+device->statusTip();
-  if(AMList.contains(listchk)){ return TRUE; }
-  else{ return FALSE; }
-}
-
-void MountTray::setSubMenu(QAction* device){
-  QMenu* submenu = new QMenu;
-  QString dev = device->whatsThis().section("/",-1);
-  // - mount/unmount
-  QAction* mount = new QAction(this);
-  mount->setWhatsThis(dev);
-  if( isMounted(device) ){
-    mount->setText( QString(tr("Unmount %1")).arg(dev) );
-  }else{
-    mount->setText( QString(tr("Mount %1")).arg(dev) );
-  }
-  submenu->addAction(mount);
-  // - device automount
-  QAction* amchk = new QAction(tr("Auto-mount"),this);
-  amchk->setWhatsThis(dev);
-  amchk->setCheckable(TRUE);
-  amchk->setChecked( isAutoMountEnabled(device) );
-  submenu->addAction(amchk);
-  //Setup the signal/slot connections
-  connect(submenu, SIGNAL(triggered(QAction*)), this, SLOT(menuDeviceToggled(QAction*)) );
-  //connect(submenu, SIGNAL(hovered(QAction*)), this, SLOT(menuDeviceHovered(QAction*)) );
-  //Add the submenu
-  device->setMenu(submenu);
-
-}
-
-void MountTray::checkDevices(){
-  for(int i=0; i<devList.length(); i++){
-    if( !isConnected(devList[i]) ){
-      //Remove the dead device link from the action list
-      updateDeviceList(4,devList[i]);
-      i--; //make sure we account for the new size of the list
-    }
-  }
-}

Modified: pcbsd/current/src-qt4/pc-mounttray/mountTray.h
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/mountTray.h	2012-10-10 20:50:04 UTC (rev 19638)
+++ pcbsd/current/src-qt4/pc-mounttray/mountTray.h	2012-10-11 03:02:01 UTC (rev 19639)
@@ -6,6 +6,7 @@
 #include <QSystemTrayIcon>
 #include <QMenu>
 
+#include "menuItem.h"
 
 class QString;
 class QPixmap;
@@ -25,39 +26,28 @@
 private slots:
   void closeTray();
   void slotSingleInstance();
-  void menuDeviceToggled(QAction*);
-  void menuDeviceHovered(QAction*);
   void newDevdMessage();
   void slotTrayActivated(QSystemTrayIcon::ActivationReason);
   void slotOpenMediaDir();
-  void autoMount(QAction*,bool onstartup);  
+  void openMediaDir(QString); 
+  void slotDisplayPopup(QString,QString);
+  void removeDevice(QString);
   
 private:
-  QString MOUNTDIR, DEVICEDIR, USERNAME, FILEMAN, AMFILE;
+  QString MOUNTDIR, DEVICEDIR, USERNAME, FILEMAN;
   QProcess *devdProc;
-  QStringList AMList;
   int numMount, numAvail;
   QSystemTrayIcon* trayIcon;
   QMenu* trayIconMenu;
-  QList<QAction*> devList;
-  void showDeviceNotification(int, QAction*);
-  void initialDeviceScan();
-  bool isMounted(QAction*);
-  bool isConnected(QAction*);
-  bool updateDeviceList(int, QAction*);
-  int findDeviceInList(QAction*);
-  bool mountDevice(QAction*,bool openDir=TRUE);
-  bool unmountDevice(QAction*);
-  QAction* newDeviceAction(QString,QString type="USB");
-  void updateTrayMenu();
+  QList<MenuItem*> deviceList;
+
+  void updateMenu();
+  void scanInitialDevices();
+  int findDeviceInList(QString);
+  void addDevice(QString,QString);
   void startupDevdProc();
-  void openMediaDir(QString);
   void setDeviceIcon(QAction*);
   void getInitialUsername();
   void getDefaultFileManager();
-  void loadAutoMountFile();
-  void setAutoMount(QAction*, bool);
-  bool isAutoMountEnabled(QAction*);
-  void setSubMenu(QAction*);
-  void checkDevices();
+
 };

Modified: pcbsd/current/src-qt4/pc-mounttray/pc-mounttray.qrc
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/pc-mounttray.qrc	2012-10-10 20:50:04 UTC (rev 19638)
+++ pcbsd/current/src-qt4/pc-mounttray/pc-mounttray.qrc	2012-10-11 03:02:01 UTC (rev 19639)
@@ -1,13 +1,15 @@
 <RCC>
   <qresource>
-    <file>icons/USBblue.png</file>
-    <file>icons/USBred.png</file>
-    <file>icons/USBgrey.png</file>
+    <file>icons/usb.png</file>
+    <file>icons/dvd.png</file>
+    <file>icons/sdcard.png</file>
     <file>icons/CDdevices.png</file>
     <file>icons/CDdevices-inactive.png</file>
     <file>icons/folder.png</file>
     <file>icons/application-exit.png</file>
     <file>icons/eject.png</file>
     <file>icons/mount.png</file>
+    <file>icons/musiccd.png</file>
+    <file>icons/harddrive.png</file>
   </qresource>
 </RCC>



More information about the Commits mailing list