Example #1
0
// ===================
//      PUBLIC SLOTS
// ===================
void LDesktopPluginSpace::UpdateGeom(int oldgrid){
  if(DEBUG){ qDebug() << "Updated Desktop Geom:" << this->size() << GRIDSIZE << this->size()/GRIDSIZE; }
  //Go through and check the locations/sizes of all items (particularly the ones on the bottom/right edges)
  //bool reload = false;
  for(int i=0; i<ITEMS.length(); i++){
    QRect grid = geomToGrid(ITEMS[i]->geometry(), oldgrid);
    if(DEBUG){ qDebug() << " - Check Plugin:" << ITEMS[i]->whatsThis() << grid; }
    if( !ValidGrid(grid) ){
      //This plugin is too far out of the screen - find new location for it
      if(DEBUG){ qDebug() << " -- Out of bounds - Find a new spot"; }
      grid = findOpenSpot(grid, ITEMS[i]->whatsThis(), true); //Reverse lookup spot
    }
    if(!ValidGrid(grid)){
      qDebug() << "No Place for plugin:" << ITEMS[i]->whatsThis();
      qDebug() << " - Removing it for now...";
      ITEMS.takeAt(i)->deleteLater();
      i--;
    }else{
      //NOTE: We are not doing the ValidGeometry() checks because we are only resizing existing plugin with pre-set & valid grid positions
      grid = gridToGeom(grid); //convert to pixels before saving/sizing
      MovePlugin(ITEMS[i], grid);
      /*ITEMS[i]->setGeometry( grid );
      ITEMS[i]->setFixedSize(grid.size());
      ITEMS[i]->savePluginGeometry(grid);*/
    }
  }
  //if(reload){ QTimer::singleShot(0,this, SLOT(reloadPlugins())); }
}
Example #2
0
void LDesktopPluginSpace::addDesktopPlugin(QString plugID){
  //This is used for generic plugins (QWidget-based)
  if(DEBUG){ qDebug() << "Adding Desktop Plugin:" << plugID; }
  LDPlugin *plug = NewDP::createPlugin(plugID, this);
    if(plug==0){ return; } //invalid plugin
    //plug->setAttribute(Qt::WA_TranslucentBackground);
    plug->setWhatsThis(plugID);
  //Now get the saved geometry for the plugin
  QRect geom = plug->gridGeometry(); //grid coordinates
  if(geom.isNull()){
    //Try the old format (might be slight drift between sessions if the grid size changes)
    geom = plug->loadPluginGeometry(); //in pixel coords
    if(!geom.isNull()){ geom = geomToGrid(geom); } //convert to grid coordinates
  }
  if(DEBUG){ qDebug() << "Saved plugin geom:" << geom << plugID; }
  //Now determine the position to put it
  if(geom.isNull()){
    //No previous location - need to calculate initial geom
    QSize sz = plug->defaultPluginSize(); //in grid coordinates
    geom.setSize(sz);
    //if an applauncher - add from top-left, otherwise add in from bottom-right
    if(plugID.startsWith("applauncher")){ geom = findOpenSpot(geom.width(), geom.height() ); }
    else{ geom = findOpenSpot(geom.width(), geom.height(), RoundUp(this->height()/GRIDSIZE), RoundUp(this->width()/GRIDSIZE), true); }
  }else if(!ValidGeometry(plugID, gridToGeom(geom)) ){
    //Find a new location for the plugin (saved location is invalid)
    geom = findOpenSpot(geom.width(), geom.height(), geom.y(), geom.x(), false); //try to get it within the same general area first
  }
  if(geom.x() < 0 || geom.y() < 0){
    qDebug() << "No available space for desktop plugin:" << plugID << " - IGNORING";
    delete plug;
  }else{
    if(DEBUG){ qDebug() <<  " - New Plugin Geometry (grid):" << geom; }
    //Now place the item in the proper spot/size
    plug->setGridGeometry(geom); //save for later
    MovePlugin(plug, gridToGeom(geom));
    //plug->setGeometry( gridToGeom(geom) );
    plug->show();
    if(DEBUG){ qDebug() << " - New Plugin Geometry (px):" << plug->geometry(); }
    ITEMS << plug;
    connect(plug, SIGNAL(StartMoving(QString)), this, SLOT(StartItemMove(QString)) );
    connect(plug, SIGNAL(StartResizing(QString)), this, SLOT(StartItemResize(QString)) );
    connect(plug, SIGNAL(RemovePlugin(QString)), this, SLOT(RemoveItem(QString)) );
    connect(plug, SIGNAL(IncreaseIconSize()), this, SIGNAL(IncreaseIcons()) );
    connect(plug, SIGNAL(DecreaseIconSize()), this, SIGNAL(DecreaseIcons()) );
    connect(plug, SIGNAL(CloseDesktopMenu()), this, SIGNAL(HideDesktopMenu()) );
  }
}
Example #3
0
void LDesktopPluginSpace::addDesktopPlugin(QString plugID){
  //This is used for generic plugins (QWidget-based)
  if(DEBUG){ qDebug() << "Adding Desktop Plugin:" << plugID; }
  LDPlugin *plug = NewDP::createPlugin(plugID, this);
    plug->setWhatsThis(plugID);
  //Now get the geometry for the plugin
  QRect geom = plug->loadPluginGeometry(); //in pixel coords
  if(!geom.isNull()){ geom = geomToGrid(geom); } //convert to grid coordinates
  if(geom.isNull()){
    //No previous location - need to calculate initial geom
    QSize sz = plug->defaultPluginSize(); //in grid coordinates
    geom.setSize(sz);
    geom = findOpenSpot(geom.width(), geom.height() );
  }else if(!ValidGeometry(plugID, gridToGeom(geom)) ){
    //Find a new location for the plugin (saved location is invalid)
    geom = findOpenSpot(geom.width(), geom.height(), geom.y(), geom.x(), false); //try to get it within the same general area first
  }
  if(geom.x() < 0 || geom.y() < 0){
    qDebug() << "No available space for desktop plugin:" << plugID << " - IGNORING";
    delete plug;
  }else{
    if(DEBUG){ qDebug() <<  " - New Plugin Geometry (grid):" << geom; }
    //Now place the item in the proper spot/size
    MovePlugin(plug, gridToGeom(geom));
    //plug->setGeometry( gridToGeom(geom) );
    plug->show();
    if(DEBUG){ qDebug() << " - New Plugin Geometry (px):" << plug->geometry(); }
    ITEMS << plug;
    connect(plug, SIGNAL(StartMoving(QString)), this, SLOT(StartItemMove(QString)) );
    connect(plug, SIGNAL(StartResizing(QString)), this, SLOT(StartItemResize(QString)) );
    connect(plug, SIGNAL(RemovePlugin(QString)), this, SLOT(RemoveItem(QString)) );
    connect(plug, SIGNAL(IncreaseIconSize()), this, SIGNAL(IncreaseIcons()) );
    connect(plug, SIGNAL(DecreaseIconSize()), this, SIGNAL(DecreaseIcons()) );
    connect(plug, SIGNAL(CloseDesktopMenu()), this, SIGNAL(HideDesktopMenu()) );
  }
}