示例#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()) );
  }
}
示例#2
0
void LDesktop::IncreaseDesktopPluginIcons(){
  int cur = settings->value(DPREFIX+"GridSize",-1).toInt();
  if(cur<0 && bgWindow->height() > 2000){ cur = 200; }
  else if(cur<0){  cur = 100; }
  cur+=16;
  issyncing=true; //don't let the change cause a refresh
  settings->setValue(DPREFIX+"GridSize",cur);
    settings->sync();
    QTimer::singleShot(200, this, SLOT(UnlockSettings()) );
  bgDesktop->SetIconSize(cur);
}
示例#3
0
void LDesktop::SettingsChanged(){
  if(issyncing){ return; } //don't refresh for internal modifications to the 
  issyncing = true;
  qDebug() << "Found Settings Change:" << desktopnumber;
  settings->sync(); //make sure to sync with external settings changes
  UpdateBackground();
  UpdateDesktop();
  UpdatePanels();
  UpdateMenu();
  issyncing = false;
  QTimer::singleShot(100, this, SLOT(UnlockSettings()) ); //give it a few moments to settle before performing another sync
}
示例#4
0
void LDesktop::RemoveDeskPlugin(QString ID){
  //This is called after a plugin is manually removed by the user
  //	just need to ensure that the plugin is also removed from the settings file
  QStringList plugs = settings->value(DPREFIX+"pluginlist", QStringList()).toStringList();
  if(plugs.contains(ID)){ 
    plugs.removeAll(ID); 
    issyncing=true; //don't let the change cause a refresh
    settings->setValue(DPREFIX+"pluginlist", plugs);
    settings->sync();
    QTimer::singleShot(200, this, SLOT(UnlockSettings()) );
  }
}
示例#5
0
void LDesktop::DesktopPluginRemoved(QString ID, bool internal){
  //NOTE: This function is only run when the plugin is deliberately removed
  //  The "internal" flag is for whether the plugin was closed by the user (external), or programmatically removed (internal)
  //Close down that plugin instance (NOTE: the container might have already closed by the user)
  if(DEBUG){ qDebug() << "Desktop Plugin Removed:" << ID; }
  //First look for the container (just in case)
  QList<QMdiSubWindow*> wins = bgDesktop->subWindowList();
  for(int i=0; i<wins.length(); i++){
    if(wins[i]->whatsThis() == ID){
      if(DEBUG){ qDebug() << " - Removing Plugin Container"; }
      //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
      if(internal){ delete wins[i]; }//delete old container
      break;
    }
  }
  
  //qDebug() << "PLUGINS:" << PLUGINS.length() << ID;
  for(int i=0; i<PLUGINS.length(); i++){
    if(PLUGINS[i]->ID() == ID){
      //qDebug() << "- found ID";
      if(DEBUG){ qDebug() << " - Deleting Desktop Plugin:" << ID; }
      //Special check for auto-generated desktop icons
      if(ID.startsWith("applauncher::")){
	qDebug() << "Desktop Icon Removal:" << !internal;
	PLUGINS[i]->removeSettings(!internal);  //Only remove the file if an external removal on an auto-generated shortcut
      }else{
        PLUGINS[i]->removeSettings(true); //Remove any settings associated with this plugin
      }
      delete PLUGINS.takeAt(i);
      break;
    }
  }
  
  //Now remove that plugin from the internal list (then let the plugin system remove the actual plugin)
  QStringList plugins = settings->value(DPREFIX+"pluginlist",QStringList()).toStringList();
  if(DEBUG){ qDebug() << " - Also removing plugin from future list"; }
  if(plugins.removeAll(ID) > 0){
    issyncing = true;
    if(DEBUG){ qDebug() << " - Save modified plugins list"; }
    settings->setValue(DPREFIX+"pluginlist", plugins);
    if(DEBUG){ qDebug() << " - Unlock settings file in 200 ms"; }
    QTimer::singleShot(200, this, SLOT(UnlockSettings()) );
  }
    /*if(QFile::exists(QDir::homePath()+"/.lumina/desktop-plugins/"+ID+".conf")){
      if(DEBUG){ qDebug() << " - Removing settings file"; }
      QFile::remove(QDir::homePath()+"/.lumina/desktop-plugins/"+ID+".conf");
    }*/
  if(DEBUG){ qDebug() << " - Done removing plugin"; }
}
示例#6
0
void LDesktop::DesktopPluginRemoved(QString ID){
  //Close down that plugin instance (NOTE: the container might have already closed by the user)
  if(DEBUG){ qDebug() << "Desktop Plugin Removed:" << ID; }
  //First look for the container (just in case)
  QList<QMdiSubWindow*> wins = bgDesktop->subWindowList();
  for(int i=0; i<wins.length(); i++){
    if(wins[i]->whatsThis() == ID){
      if(DEBUG){ qDebug() << " - Removing Plugin Container"; }
      //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
      break;
    }
  }
	
  //qDebug() << "PLUGINS:" << PLUGINS.length() << ID;
  for(int i=0; i<PLUGINS.length(); i++){
    if(PLUGINS[i]->ID() == ID){
      //qDebug() << "- found ID";
      if(DEBUG){ qDebug() << " - Deleting Desktop Plugin:" << ID; }
      delete PLUGINS.takeAt(i);
      break;
    }
  }
  
  //Now remove that plugin from the internal list (then let the plugin system remove the actual plugin)
  QStringList plugins = settings->value(DPREFIX+"pluginlist",QStringList()).toStringList();
  if(DEBUG){ qDebug() << " - Also removing plugin from future list"; }
  plugins.removeAll(ID);
    issyncing = true;
    if(DEBUG){ qDebug() << " - Save modified plugins list"; }
    settings->setValue(DPREFIX+"pluginlist", plugins);
    if(DEBUG){ qDebug() << " - Unlock settings file in 200 ms"; }
    //settings->sync();
  QTimer::singleShot(200, this, SLOT(UnlockSettings()) );
  if(DEBUG){ qDebug() << " - Done removing plugin"; }
}
示例#7
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
  QStringList filelist;
  if(settings->value(DPREFIX+"generateDesktopIcons",false).toBool()){
    QFileInfoList files = LSession::handle()->DesktopFiles();
    for(int i=0; i<files.length(); i++){
	filelist << files[i].absoluteFilePath();
    }
  }
  UpdateDesktopPluginArea();
  bgDesktop->LoadItems(plugins, filelist);
}
示例#8
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
  }
}