Exemplo n.º 1
0
bool MountTray::addDevice(QString dev, QString label, QString type, QString filesys){
  if(!dev.startsWith(DEVICEDIR)){ dev.prepend(DEVICEDIR); }
  
  //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 false; } //already exists, do nothing
    if( deviceList[i]->getDeviceName().startsWith(label) ){ tot++; }
  }
  //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)); }
 
  qDebug() << "Valid Device Connection:" << dev << type << label << filesys;
  //Create the menu item (will automount if necessary)
  MenuItem *tmp = new MenuItem(this, DCheck, dev, label, type, filesys);
  //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)) );
  connect(tmp, SIGNAL(itemWorking()), this, SLOT(slotCloseMenu()) );
  connect(tmp, SIGNAL(openAVDisk(QString)), this, SLOT(slotOpenAVDisk(QString)) );
  deviceList << tmp;
  //Update the menu
  updateMenu();
  return true;
}
Exemplo n.º 2
0
/*
  PRIVATE FUNCTIONS
*/
void MenuItem::slotMountClicked(){
  //Hide the parent menu
  emit itemWorking();
  //Now 
  if( isConnected() ){
    if( !isMounted() ){
      mountItem();
    }else{
      unmountItem();  
    }
  }else{
    emit itemRemoved(device);	  
  }
  updateItem();
}