00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <iostream.h>
00017
00018 #include "qdir.h"
00019
00020 #include "qtroot/interface/tqapplication.h"
00021 #include "qtroot/interface/qrootapplication.h"
00022
00023 #include "Go4Log/TGo4Log.h"
00024 #include "Go4Display/TGo4Display.h"
00025 #include "Go4Analysis/TGo4Version.h"
00026 #include "TGo4MainWindow.h"
00027 #include "TGo4QSettings.h"
00028
00029 int main(int argc, char **argv) {
00030
00031 bool localmode = false;
00032 bool traceon = false;
00033 bool servermode = true;
00034 QString hotstart = "";
00035
00036 for(int narg=1;narg<argc;narg++) {
00037 if (strlen(argv[narg])==0) continue;
00038
00039 if (argv[narg][0]=='-') {
00040 if(!strcmp(argv[narg], "-local")) {
00041 cout << "G-OOOO-> MainGo4GUI is starting in local mode only " << endl;
00042 localmode = true;
00043 } else
00044 if(!strcmp(argv[narg], "-debug")) {
00045 cout << "G-OOOO-> MainGo4GUI switched on debug output" << endl;
00046 traceon = true;
00047 } else
00048 if(strstr(argv[narg], "-client")) {
00049 cout << "G-OOOO-> MainGo4GUI is starting as client." << endl;
00050 servermode = false;
00051 if(strstr(argv[narg], "-debug")) traceon = true;
00052 }
00053
00054 } else
00055 if (hotstart.length()==0) hotstart = argv[narg];
00056 }
00057
00058 TQApplication app("uno",&argc,argv);
00059
00060 QRootApplication myapp( argc, argv, 0 );
00061
00062 Int_t negport=0;
00063 TGo4Log::Instance();
00064 TGo4Log::SetIgnoreLevel(1);
00065
00066
00067 TGo4Log::LogfileEnable(kFALSE);
00068
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 TGo4QSettings::SetHomeSettingsFile("/go4");
00081 bool accountsettings=false;
00082 QString settingsenv=getenv("GO4SETTINGS");
00083 if(settingsenv.isEmpty()) {
00084
00085 if (gSystem->AccessPathName(QDir::currentDirPath(),kWritePermission)) {
00086 TGo4QSettings::SetToCurrentDir(false);
00087 accountsettings=true;
00088 } else {
00089 TGo4QSettings::SetToCurrentDir(true);
00090 }
00091 } else
00092 if(settingsenv.contains("ACCOUNT")) {
00093 TGo4QSettings::SetToCurrentDir(false);
00094 accountsettings=true;
00095 } else {
00096 TGo4QSettings::SetUserPath(settingsenv);
00097 }
00099 QString homesettings = QDir::homeDirPath()+ "/.qt/go4rc";
00100 QString usersettings = TGo4QSettings::GetUserPath()+TGo4QSettings::GetSettingsName()+"rc";
00101 QString hometools = QDir::homeDirPath()+ "/.qt/go4toolsrc";
00102 QString usertools = TGo4QSettings::GetUserPath()+"/go4toolsrc";
00103
00104 if(!accountsettings && gSystem->AccessPathName(usersettings))
00105 {
00106
00107 QString qsubdir=TGo4QSettings::GetUserPath();
00108 if(gSystem->AccessPathName(qsubdir))
00109 {
00110 cout <<"Creating settings subdirectory "<<qsubdir<<" ..."<< endl;
00111 if(gSystem->mkdir(qsubdir,true)!=0)
00112 cout <<"Could not create "<<qsubdir<<" !"<< endl;
00113
00114 }
00115
00116 if(gSystem->CopyFile(homesettings,usersettings,kTRUE)==0)
00117 cout <<"Copied account settings "<<homesettings<<" to "<<usersettings << endl;
00118 else
00119 cout<<"Could not copy "<<homesettings<<" to "<<usersettings << endl;
00120 if(gSystem->CopyFile(hometools,usertools,kTRUE)==0)
00121 cout <<"Copied account settings "<<hometools<<" to "<<usertools << endl;
00122 else
00123 cout<<"Could not copy "<<hometools<<" to "<<usertools << endl;
00124 }
00126 TGo4Display *exserver=0;
00127
00128 if(traceon) TGo4Log::SetIgnoreLevel(0);
00129 else TGo4Log::SetIgnoreLevel(1);
00130
00131 if (argc<2)
00132 cout << "G-OOOO-> Started go4gui. " << endl;
00133
00134 cout << " Go4 " << __GO4RELEASE__ << endl;
00135
00136 TGo4MainWindow *Go4MainGUI;
00137 if(!localmode) {
00138 exserver = new TGo4Display(negport,"dummy",servermode);
00139 Go4MainGUI = new TGo4MainWindow();
00140 } else
00141 Go4MainGUI = new TGo4MainWindow(0, 0, Qt::WType_TopLevel, true);
00142
00143 myapp.setMainWidget(Go4MainGUI);
00144 Go4MainGUI->polish();
00145 Go4MainGUI->show();
00146 myapp.connect( &myapp, SIGNAL( lastWindowClosed() ), &myapp, SLOT( quit() ) );
00147 QApplication::setDoubleClickInterval(400);
00148 QApplication::setStartDragTime(150);
00149 if (hotstart.length()>0)
00150 Go4MainGUI->HotStart(hotstart.data());
00151 int res = myapp.exec();
00152 return res;
00153 }
00154
00155
00156