Exemplo n.º 1
0
void LDesktop::UpdateDesktop(){
  if(DEBUG){ qDebug() << " - Update Desktop Plugins for screen:" << desktopnumber; }
  QStringList plugins = settings->value(DPREFIX+"pluginlist", QStringList()).toStringList();
  if(defaultdesktop && plugins.isEmpty()){
    //plugins << "sample" << "sample" << "sample";
  }
  bool changed=false; //in case the plugin list needs to be changed
  //First make sure all the plugin names are unique
  for(int i=0; i<plugins.length(); i++){
	if(!plugins[i].contains("---") ){
	  int num=1;
	  while( plugins.contains(plugins[i]+"---"+QString::number(desktopnumber)+"."+QString::number(num)) ){
	    num++;
	  }
	  plugins[i] = plugins[i]+"---"+QString::number(desktopnumber)+"."+QString::number(num);
	  changed=true;
	}
  }
  //Go through the plugins and remove any existing ones that do not show up on the current list
  for(int i=0; i<PLUGINS.length(); i++){
    if(!plugins.contains(PLUGINS[i]->ID())){
      //Remove this plugin (with settings) - is not currently listed
      
      DesktopPluginRemoved(PLUGINS[i]->ID());
      i--;
    }
  }
  //Now add/update plugins
  for(int i=0; i<plugins.length(); i++){
    //See if this plugin is already there
    LDPlugin *plug = 0;
    for(int p=0; p<PLUGINS.length(); p++){
      //qDebug() << " -- Existing Plugin:" << PLUGINS[p]->ID() << p << PLUGINS.length();
      if(PLUGINS[p]->ID()==plugins[i]){
	//qDebug() << "  -- Found Plugin";
	plug = PLUGINS[p];
	break;
      }
    }
    if(plug==0){
      //New Plugin
      if(DEBUG){qDebug() << " -- New Plugin:" << plugins[i];}
      plug = NewDP::createPlugin(plugins[i], bgDesktop);
      if(plug != 0){
	connect(plug, SIGNAL(OpenDesktopMenu()), this, SLOT(ShowMenu()) );
	//qDebug() << " -- Show Plugin";
	PLUGINS << plug;
	CreateDesktopPluginContainer(plug);
      }
    }

  }
  if(changed){
    //save the modified plugin list to file (so per-plugin settings are preserved)
    issyncing=true; //don't let the change cause a refresh
    settings->setValue(DPREFIX+"pluginlist", plugins);
    settings->sync();
    QTimer::singleShot(200, this, SLOT(UnlockSettings()) );
  }
}
Exemplo n.º 2
0
void LDesktop::ToggleDesktopLock(){
  desktoplocked = !desktoplocked; //flip to other value
  //Remove all the current containers
  QList<QMdiSubWindow*> wins = bgDesktop->subWindowList();
  for(int i=0; i<wins.length(); i++){
    wins[i]->setWhatsThis(""); //clear this so it knows it is being temporarily removed
    bgDesktop->removeSubWindow(wins[i]->widget()); //unhook plugin from container
    bgDesktop->removeSubWindow(wins[i]); //remove container from screen
    delete wins[i]; //delete old container
  }
  //Now recreate all the containers on the screen
  for(int i=0; i<PLUGINS.length(); i++){
    CreateDesktopPluginContainer(PLUGINS[i]);
  }
  bgDesktop->update(); //refresh visuals
  UpdateMenu(false);
}
Exemplo n.º 3
0
void LDesktop::UpdateDesktop(){
  if(DEBUG){ qDebug() << " - Update Desktop Plugins for screen:" << desktopnumber; }
  QStringList plugins = settings->value(DPREFIX+"pluginlist", QStringList()).toStringList();
  if(defaultdesktop && plugins.isEmpty()){
    //plugins << "sample" << "sample" << "sample";
  }
  bool changed=false; //in case the plugin list needs to be changed
  //First make sure all the plugin names are unique
  for(int i=0; i<plugins.length(); i++){
	if(!plugins[i].contains("---") ){
	  int num=1;
	  while( plugins.contains(plugins[i]+"---"+QString::number(desktopnumber)+"."+QString::number(num)) ){
	    num++;
	  }
	  plugins[i] = plugins[i]+"---"+QString::number(desktopnumber)+"."+QString::number(num);
	  changed=true;
	}
  }
  if(changed){
    //save the modified plugin list to file (so per-plugin settings are preserved)
    issyncing=true; //don't let the change cause a refresh
    settings->setValue(DPREFIX+"pluginlist", plugins);
    settings->sync();
    QTimer::singleShot(200, this, SLOT(UnlockSettings()) );
  }
  //If generating desktop file launchers, add those in
  if(settings->value(DPREFIX+"generateDesktopIcons",false).toBool()){
    QFileInfoList files = LSession::handle()->DesktopFiles();
    for(int i=0; i<files.length(); i++){
      plugins << "applauncher::"+files[i].absoluteFilePath()+"---"+DPREFIX;
    }
  }
  //Go through the plugins and remove any existing ones that do not show up on the current list
  for(int i=0; i<PLUGINS.length(); i++){
    if(!plugins.contains(PLUGINS[i]->ID())){
      //Remove this plugin (with settings) - is not currently listed
      DesktopPluginRemoved(PLUGINS[i]->ID(),true); //flag this as an internal removal
      i--;
    }
  }
  //Now get an accounting of all the available/used space (overwriting the private variable)
  QSize ssize = LSession::handle()->screenGeom(desktopnumber).size();
  //qDebug() << "Screen Size:" << ssize << desktopnumber;
  if(bgDesktop->isVisible() && ( (bgDesktop->size().height() <= ssize.height()) && (bgDesktop->size().width() <= ssize.width()) )){ ssize = bgDesktop->size(); qDebug() << " - Adjusted:" << ssize; }
  availDPArea = QRegion(QRect(QPoint(0,0), ssize)); //Note that this is child-geometry space
  //Remove all the space currently occupied
  //qDebug() << "Available Screen Geom:" << avail.boundingRect();
  QList<QMdiSubWindow*> wins = bgDesktop->subWindowList();
  for(int i=0; i<wins.length(); i++){ 
    qDebug() << "Subtracting Geom:" << wins[i]->geometry();
    availDPArea = availDPArea.subtracted( QRegion(wins[i]->geometry()) ); 
  }
  //Now add/update plugins
  for(int i=0; i<plugins.length(); i++){
    //See if this plugin is already there
    LDPlugin *plug = 0;
    for(int p=0; p<PLUGINS.length(); p++){
      //qDebug() << " -- Existing Plugin:" << PLUGINS[p]->ID() << p << PLUGINS.length();
      if(PLUGINS[p]->ID()==plugins[i]){
	//qDebug() << "  -- Found Plugin";
	plug = PLUGINS[p];
	break;
      }
    }
    if(plug==0){
      //New Plugin
      if(DEBUG){qDebug() << " -- New Plugin:" << plugins[i];}
      plug = NewDP::createPlugin(plugins[i], bgDesktop);
      if(plug != 0){
	connect(plug, SIGNAL(OpenDesktopMenu()), this, SLOT(ShowMenu()) );
	if(DEBUG){ qDebug() << " --- Show Plugin"; }
	PLUGINS << plug;
	QApplication::processEvents(); //need a moment between plugin/container creation
	LDPluginContainer *cont = CreateDesktopPluginContainer(plug);
	//Done with this plugin - removed it's area from the available space
	if(DEBUG){ qDebug() << " ---  Done Creating Plugin Container" << cont->geometry(); }
	//avail = avail.subtracted( QRegion(cont->geometry()) ); //remove this space from the available region as well
      }
    }
    QApplication::processEvents(); //need to process events between loading of plugins
  }
}