Ejemplo n.º 1
0
LSingleApplication::LSingleApplication(int &argc, char **argv, QString appname) : QApplication(argc, argv){
  //Load the proper translation systems
  if(appname!="lumina-desktop"){ cTrans = LUtils::LoadTranslation(this, appname); }//save the translator for later
  //Initialize a couple convenience internal variables
  cfile = QDir::tempPath()+"/.LSingleApp-%1-%2-%3";
  QString username = QString(getlogin());
  //For locking the process use the official process name - not the user input (no masking)
  appname = this->applicationName();
  cfile = cfile.arg( username, appname, QString::number(QX11Info::appScreen()) );
  lockfile = new QLockFile(cfile+"-lock");
    lockfile->setStaleLockTime(0); //long-lived processes
  for(int i=1; i<argc; i++){ 
    QString path = QString::fromLocal8Bit(argv[i]);
    //do few quick conversions for relative paths and such as necessary
    // (Remember: this is only used for secondary processes, not the primary)
      if(path=="."){
	//Insert the current working directory instead
	path = QDir::currentPath();
      }else{
	if(!path.startsWith("/") && !path.startsWith("-") ){ path.prepend(QDir::currentPath()+"/"); }
      }
    inputlist << path; 
  }
  isActive = isBypass = false;
  lserver = 0;
  //Now check for the manual CLI flag to bypass single-instance forwarding (if necessary)
  if(inputlist.contains("-new-instance")){ 
    isBypass = true;
    inputlist.removeAll("-new-instance");
  }
  PerformLockChecks();
}
Ejemplo n.º 2
0
PCSingleApplication::PCSingleApplication(int &argc, char **argv) : QApplication(argc, argv){
  //Initialize a couple convenience internal variables
  cfile = QDir::tempPath()+"/.PCSingleApp-%1-%2";
  QString username = QString(getlogin());
  QString appname = this->applicationName();
  cfile = cfile.arg( username, appname );
  lockfile = new QLockFile(cfile+"-lock");
    lockfile->setStaleLockTime(0); //long-lived processes
  for(int i=1; i<argc; i++){ inputlist << QString(argv[i]); }
  isActive = false;
  lserver = 0;
  PerformLockChecks();
}