// $Id$ //----------------------------------------------------------------------- // The GSI Online Offline Object Oriented (Go4) Project // Experiment Data Processing at EE department, GSI //----------------------------------------------------------------------- // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH // Planckstr. 1, 64291 Darmstadt, Germany // Contact: http://go4.gsi.de //----------------------------------------------------------------------- // This software can be used under the license agreements as stated // in Go4License.txt file which is part of the distribution. //----------------------------------------------------------------------- #include #include #include #include #include "TSystem.h" #include "RVersion.h" #include "Riostream.h" #include "TInterpreter.h" #include "TEnv.h" #include "tqapplication.h" #include "qrootapplication.h" #include "TGo4Log.h" #include "TGo4Version.h" #include "TGo4MainWindow.h" #include "TGo4QSettings.h" #include "TGo4BrowserProxy.h" #include "TGo4AbstractInterface.h" int main(int argc, char **argv) { if (!TGo4Version::CheckVersion(__GO4BUILDVERSION__)) { std::cerr << "Go4 was build with version " << __GO4BUILDVERSION__ << std::endl; std::cerr << "Loaded go4 libraries has version " << TGo4Version::Instance()->GetBuildVersion() << std::endl; std::cerr << "Please configure your system correctly and restart go4 again" << std::endl; return -1; } int dologin = -1; const char* loghost = "localhost"; int logport = 5000; const char* logpass = 0; bool traceon = false; bool prepare_for_client = false; QString hotstart = ""; QStringList files; for(int narg=1;narg MainGo4GUI switched on debug output" << std::endl; traceon = true; } else if((strcmp(argv[narg], "-observer")==0) || (strcmp(argv[narg], "-controller")==0) || (strcmp(argv[narg], "-admin")==0)) { if(strcmp(argv[narg], "-observer")==0) dologin = 0; if(strcmp(argv[narg], "-controller")==0) dologin = 1; if(strcmp(argv[narg], "-admin")==0) dologin = 2; if ((narg+1='0') && (argv[narg+1][0]<='9')) logport = atoi(argv[++narg]); if ((narg+1SetProcessLineLock(kFALSE); // ShowGuideLines cases crashes - it has stored gpad in static variable gEnv->SetValue("Canvas.ShowGuideLines", 0); ///////////// Define the GO4 Settings. ////////////////////// // has to be done here, since mainwindow components have local // settings access before mainwindow init is executed! // Default is to use current directory. Environment variable // GO4SETTINGS can be set to a certain go4 setup location // if GO4SETTINGS contains the "ACCOUNT" keyword, we use the // qt default to have the settings in $HOME/.qt/ // NOTE: if $HOME/.qt/go4rc exists, // Qt would use these settings even if the TGo4QSettings use the // current dir option or userpath for saving the settings; // Therefore, the local settings will have different names go4localrc TGo4QSettings::SetHomeSettingsFile("/go4"); // might change the default filename in .qt here bool accountsettings=false; QString settingsenv=getenv("GO4SETTINGS"); if(settingsenv.isEmpty()) { // use Qt settings in $PWD/.qt. if false, use $HOME/.qt, or the user path if set if (gSystem->AccessPathName(QDir::currentDirPath(),kWritePermission)) { TGo4QSettings::SetToCurrentDir(false); accountsettings=true; } else { TGo4QSettings::SetToCurrentDir(true); } } else if(settingsenv.contains("ACCOUNT")) { TGo4QSettings::SetToCurrentDir(false); accountsettings=true; } else { TGo4QSettings::SetUserPath(settingsenv); } /// check here if current settings exist. If not, copy from home QString homesettings = QDir::homeDirPath()+ "/.qt/go4rc"; QString usersettings = TGo4QSettings::GetUserPath()+TGo4QSettings::GetSettingsName()+"rc"; QString hometools = QDir::homeDirPath()+ "/.qt/go4toolsrc"; QString usertools = TGo4QSettings::GetUserPath()+"/go4toolsrc"; if(!accountsettings && gSystem->AccessPathName(usersettings)) // file not there { // first create subfolder .qt if not there, otherwise copy fails! QString qsubdir=TGo4QSettings::GetUserPath(); if(gSystem->AccessPathName(qsubdir)) { std::cout <<"Creating settings subdirectory "<mkdir(qsubdir,true)!=0) std::cout <<"Could not create "<CopyFile(homesettings,usersettings,kTRUE)==0) std::cout <<"Copied account settings "<CopyFile(hometools,usertools,kTRUE)==0) std::cout <<"Copied account settings "<polish(); Go4MainGUI->show(); myapp.connect( &myapp, SIGNAL( lastWindowClosed() ), &myapp, SLOT( quit() ) ); QApplication::setDoubleClickInterval(400); //ms, for Qt>=3.3 avoid very fast defaults! QApplication::setStartDragTime(150); // ms for ( QStringList::Iterator it = files.begin(); it != files.end(); ++it ) Go4MainGUI->Browser()->OpenFile((*it).latin1()); if (hotstart.length()>0) Go4MainGUI->HotStart(hotstart.latin1()); if (dologin>=0) { go4sett->setClientNode(loghost); go4sett->setClientPort(logport); go4sett->setClientDefaultPass(logpass==0); go4sett->setClientControllerMode(dologin); Go4MainGUI->ConnectServerSlot(false, logpass); } else if (prepare_for_client) { Go4MainGUI->PrepareForClientConnectionSlot(false); } int res = myapp.exec(); delete go4sett; return res; }