]> SALOME platform Git repositories - tools/install.git/blob - src/main.cxx
Salome HOME
Remove V3.1.0 release notes
[tools/install.git] / src / main.cxx
1 //  File      : main.cxx 
2 //  Created   : Thu Dec 18 12:01:00 2002
3 //  Author    : Vadim SANDLER
4 //  Project   : SALOME
5 //  Module    : Installation Wizard
6 //  Copyright : 2004-2005 CEA
7
8 #include "globals.h"
9
10 #include "SALOME_InstallWizard.hxx"
11 #include <qapplication.h>
12 #include <qfile.h>
13 #include <qmessagebox.h>
14
15 // ================================================================
16 /*!
17  *  MessageOutput
18  *  Qt's messages handler funcion
19  */
20 // ================================================================
21 void MessageOutput( QtMsgType type, 
22 #ifdef QT_DEBUG
23                     const char* msg
24 #else
25                     const char*
26 #endif
27                     )
28 {
29   switch ( type ) {
30   case QtDebugMsg:
31     ___DEBUG___( msg );
32     break;
33   case QtWarningMsg:
34     ___WARNING___( msg );
35     break;
36   case QtFatalMsg:
37     ___FATAL___( msg );
38     break;
39   }
40 }
41
42 // ================================================================
43 /*!
44  *  main
45  *  Program starts here
46  */
47 // ================================================================
48 int main( int argc, char **argv )
49 {
50   qInstallMsgHandler( MessageOutput );
51
52   QString xmlFileName;
53   for( int i = 1; i < argc; i++ ) {
54     QString a = QString( argv[i] );
55     if ( a == "--version" || a == "-v" ) {
56       printf("SALOME Installation Wizard version %d.%d.%d ",
57              ( __IW_VERSION__ / 10000 ),
58              ( __IW_VERSION__ / 100 % 100 ),
59              ( __IW_VERSION__ % 100 ) );
60       printf("(Qt version %d.%d.%d)\n",
61              ( QT_VERSION >> 16 ) & 0xFF,
62              ( QT_VERSION >> 8  ) & 0xFF,
63              ( QT_VERSION       ) & 0xFF );
64       return 0;
65     }
66     if ( xmlFileName.isEmpty() )
67       xmlFileName = a;
68   }
69   if ( xmlFileName.isEmpty() )
70     xmlFileName = "config.xml";
71
72   QApplication a( argc, argv );
73   a.setFont( QFont( "Sans", 12 ) );
74
75   int result = -1;
76   QFile xmlfile(xmlFileName);
77   if ( xmlfile.exists() ) {
78     SALOME_InstallWizard wizard(xmlFileName);
79     a.setMainWidget( &wizard );
80     wizard.show();
81     result = a.exec();
82   }
83   else {
84     QMessageBox::critical( 0, 
85                            QObject::tr( "Error" ), 
86                            QObject::tr( "Can't open config file:\n%1\n\nQuitting...").arg( xmlFileName ), 
87                            QMessageBox::Ok,
88                            QMessageBox::NoButton, 
89                            QMessageBox::NoButton );
90   }
91   return result;
92 }
93