#include <assert.h>
#include "TQtApplication.h"
#if QT_VERSION < 0x40000
#  include "qapplication.h"
#else
#  include <QApplication>
#  include <QCoreApplication>
#endif
#include "TSystem.h"
#include "TROOT.h"
#include "TEnv.h"
#include "qmessagebox.h"
static int QVersion(const char *ver) {
   
    QString version = QString::fromLatin1(ver);
    return   (version.section('.',0,0).toInt()<<16)
          +  (version.section('.',1,1).toInt()<<8 )
          +  (version.section('.',2,2).toInt()    );
}
TQtApplication *TQtApplication::fgQtApplication = 0;
ClassImp(TQtApplication)
TQtApplication::TQtApplication(const char * , int &argc,char **argv)
                : fGUIThread(0)
{
   assert(!fgQtApplication);
   fgQtApplication  = this;
   CreateGUIThread(argc,argv);
}
TQtApplication::~TQtApplication()
{ }
void TQtApplication::CreateQApplication(int &argc, char ** argv, bool GUIenabled)
{
  
  
   
  
  
   if (!qApp) {
      
       QApplication::setColorSpec( QApplication::ManyColor );
       QString display = gSystem->Getenv("DISPLAY");
       
       if (display.contains("QT_BATCH")) GUIenabled = false;
#if QT_VERSION < 0x40000
       qApp = new QApplication(argc,argv,GUIenabled);
#else /* QT_VERSION */
#ifdef NOSYNC       
       int argC = 2;
       static char *argV[] = {"root.exe", "-sync" };
       fprintf(stderr," argc = %d, argv = %s %s\n", argC,argV[0],argV[1]);
       new QApplication(argC,argV,GUIenabled);
#else       
#ifndef R__WIN32       
       QCoreApplication::setAttribute(Qt::AA_ImmediateWidgetCreation);
#endif       
       new QApplication(argc,argv,GUIenabled);
#endif       
#endif /* QT_VERSION */
       
       
       
       
      QString fromConfig = "native";
      if (gEnv)
         fromConfig = gEnv->GetValue("Gui.Style","native");
      if (fromConfig != "native" ) QApplication::setStyle(fromConfig);
#ifdef Q_WS_MACX
      
      TTimer *idle = new TTimer(240); idle->TurnOn();
#endif
   }
   
   Int_t validQtVersion = QVersion(ROOT_VALID_QT_VERSION);
   Int_t thisQtVersion  = QVersion(qVersion());
   if (thisQtVersion < validQtVersion) {
       QString s = QApplication::tr("Executable '%1' was compiled with Qt %2 and requires Qt %3 at least, found Qt %4.")
            .arg(QString::fromLatin1(qAppName()))
            .arg(QString::fromLatin1(QT_VERSION_STR))
            .arg(QString::fromLatin1(ROOT_VALID_QT_VERSION))
            .arg(QString::fromLatin1(qVersion()) ); 
      QMessageBox::critical( 0, QApplication::tr("Incompatible Qt Library Error" ), s, QMessageBox::Abort,0 );
      qFatal(s.ascii());
   } else if (thisQtVersion < QtVersion()) {
       QString s = QApplication::tr("Executable '%1' was compiled with Qt %2, found Qt %3.")
            .arg(QString::fromLatin1(qAppName()))
            .arg(QString::fromLatin1(QT_VERSION_STR))
            .arg(QString::fromLatin1(qVersion()) ); 
      QMessageBox::warning( 0, QApplication::tr("Upgrade Qt Library Warning" ), s, QMessageBox::Abort,0 );
      qWarning(s.ascii());
   }
  
   
   char *qtPluginPath = gSystem->ConcatFileName(gSystem->Getenv("ROOTSYS"),"/Qt/plugins");
   if (!gSystem->AccessPathName(qtPluginPath))
       qApp->addLibraryPath(qtPluginPath);
   delete [] qtPluginPath;
}
void TQtApplication::CreateGUIThread(int &argc, char **argv)
{
  
   if (gROOT->IsBatch()) {
     CreateQApplication(argc,argv,kFALSE);
   } else {
     CreateQApplication(argc,argv, TRUE);
   }
}
TQtApplication *TQtApplication::GetQtApplication(){return fgQtApplication;}
bool TQtApplication::Terminate()
{
  
  if (fgQtApplication) {
    TQtApplication *app = fgQtApplication;
    fgQtApplication = 0;
    delete  app;
  }
  return TRUE;
}
Int_t TQtApplication::QtVersion(){
     
   return  QVersion(QT_VERSION_STR);
}
bool TQtApplication::IsThisGuiThread()
{
   
  return true;
}
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.