00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 #include "Riostream.h"
00017 #include <stdlib.h>
00018 
00019 #include "qdir.h"
00020 
00021 #include "TSystem.h"
00022 
00023 #include "tqapplication.h"
00024 #include "qrootapplication.h"
00025 
00026 #include "TGo4Log.h"
00027 #include "TGo4Version.h"
00028 #include "TGo4MainWindow.h"
00029 #include "TGo4QSettings.h"
00030 
00031 int main(int argc, char **argv) {
00032 
00033     bool traceon = false;
00034     bool servermode = true;
00035     QString hotstart = "";
00036 
00037     for(int narg=1;narg<argc;narg++) {
00038        if (strlen(argv[narg])==0) continue;
00039 
00040        if (argv[narg][0]=='-') {
00041           if(!strcmp(argv[narg], "-debug")) {
00042              cout << "G-OOOO-> MainGo4GUI switched on debug output" << endl;
00043              traceon = true;
00044           } else
00045           if(strstr(argv[narg], "-client")) {
00046              cout << "G-OOOO-> MainGo4GUI is starting as client." << endl;
00047              servermode = false;
00048              if(strstr(argv[narg], "-debug")) traceon = true;
00049           }
00050 
00051        } else
00052          if (hotstart.length()==0) {
00053             hotstart = argv[narg];
00054             if(!strstr(argv[narg], ".hotstart")) hotstart.append(".hotstart");
00055             exit;
00056          }
00057     }
00058 
00059     TQApplication app("uno",&argc,argv); 
00060 
00061     QRootApplication myapp( argc, argv, 0 );
00062 
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     if(traceon) TGo4Log::SetIgnoreLevel(0);
00127            else TGo4Log::SetIgnoreLevel(1);
00128 
00129     if (argc<2)
00130        cout << "G-OOOO->  Started go4gui. "  << endl;
00131 
00132     cout << "   Go4 " << __GO4RELEASE__ << endl;
00133 
00134     
00135     go4sett = new TGo4QSettings();
00136 
00137     TGo4MainWindow* Go4MainGUI = new TGo4MainWindow(&myapp, servermode);
00138 
00139 
00140     myapp.setMainWidget(Go4MainGUI);
00141     Go4MainGUI->polish();
00142     Go4MainGUI->show();
00143     myapp.connect( &myapp, SIGNAL( lastWindowClosed() ), &myapp, SLOT( quit() ) );
00144     QApplication::setDoubleClickInterval(400); 
00145     QApplication::setStartDragTime(150); 
00146 
00147     if (hotstart.length()>0)
00148       Go4MainGUI->HotStart(hotstart.latin1());
00149     int res = myapp.exec();
00150 
00151     delete go4sett;
00152 
00153     return res;
00154 }
00155 
00156 
00157