Salome HOME
a08b99564af4da30a392480619b405a2eae7b13b
[tools/install.git] / src / SALOME_HelpWindow.cxx
1 //  File      : SALOME_HelpWindow.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 "SALOME_HelpWindow.hxx"
9 #include "SALOME_InstallWizard.hxx"
10
11 #include <qstatusbar.h>
12 #include <qtoolbar.h>
13 #include <qtoolbutton.h>
14 #include <qiconset.h>
15 #include <qlabel.h>
16 #include <qtextbrowser.h>
17 #include <qapplication.h>
18 #include <qdir.h> 
19 #include <qfile.h>
20
21 #include "icons.h" 
22
23 #define  DEFAULT_WIDTH    800
24 #define  DEFAULT_HEIGHT   700
25
26 // ================================================================
27 /*!
28  *  HelpWindow::HelpWindow
29  *  Constructor
30  */
31 // ================================================================
32 HelpWindow::HelpWindow( SALOME_InstallWizard* wizard ) : QMainWindow( 0, "SalomeProHelpWindow", WDestructiveClose )
33 {
34   QString hlpFile = QDir::currentDirPath() + "/doc/readme.html";
35   QString hlpDir = ".";
36   // caption
37   setCaption( wizard->getCaption() + " " + wizard->getIWName() + " " + tr( "Help" ) );
38   // icon
39   setIcon( QPixmap( (const char**)image0_data ) );
40   // create browser
41   browser = new QTextBrowser( this );
42   browser->mimeSourceFactory()->setFilePath( hlpDir );
43   browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
44   setCentralWidget( browser );
45   // set source directory
46   if ( !hlpFile.isEmpty() )
47     browser->setSource( hlpFile );
48   // toolbar
49   QToolBar* toolbar = new QToolBar( this );
50   addToolBar( toolbar, "Toolbar" );
51   QToolButton* button;
52   // --> back
53   button = new QToolButton( QIconSet( (const char**)back ), 
54                             tr( "Backward" ), 
55                             "", 
56                             browser, 
57                             SLOT( backward() ), 
58                             toolbar );
59   button->setEnabled( FALSE );
60   connect( browser, SIGNAL( backwardAvailable( bool ) ), button, SLOT( setEnabled( bool ) ) );
61   // --> forward
62   button = new QToolButton( QIconSet( (const char**)forward ), 
63                             tr( "Forward" ), 
64                             "", 
65                             browser, 
66                             SLOT( forward() ), 
67                             toolbar );
68   button->setEnabled( FALSE );
69   connect( browser, SIGNAL( forwardAvailable( bool ) ),  button, SLOT( setEnabled( bool ) ) );
70   // --> home
71   button = new QToolButton( QIconSet( (const char**)home ), 
72                             tr( "Home" ), 
73                             "", 
74                             browser, 
75                             SLOT( home() ), 
76                             toolbar );
77   toolbar->addSeparator();
78   // --> logo
79   QLabel* logo = new QLabel( toolbar, "logo" );
80   logo->setPixmap( QPixmap( (const char**)image1_data ) );
81   logo->setAlignment( AlignRight | AlignVCenter );
82   logo->setScaledContents( false );
83   toolbar->setStretchableWidget( logo );
84   setRightJustification( TRUE );
85   // disable docking of toolbar
86   setDockEnabled( Qt::DockLeft,    FALSE );
87   setDockEnabled( Qt::DockRight,   FALSE );
88   setDockEnabled( Qt::DockBottom,  FALSE );
89   setDockEnabled( Qt::DockTornOff, FALSE );
90   // disable dock menu
91   setDockMenuEnabled ( FALSE ) ;
92   // connect signals
93   connect( browser, SIGNAL( highlighted( const QString&) ), statusBar(), SLOT( message( const QString&)) );
94   // set focus
95   browser->setFocus();
96   // initial size
97   QSize sz = qApp->desktop()->size();
98   int x = ( sz.width()  - DEFAULT_WIDTH )  / 2;
99   int y = ( sz.height() - DEFAULT_HEIGHT ) / 2;
100   setGeometry( x, y, DEFAULT_WIDTH, DEFAULT_HEIGHT );
101 }
102 // ================================================================
103 /*!
104  *  HelpWindow::~HelpWindow
105  *  Destructor
106  */
107 // ================================================================
108 HelpWindow::~HelpWindow()
109 {
110 }
111 // ================================================================
112 /*!
113  *  HelpWindow::openHelp [ static ]
114  *  Creates Help window ane return pointer to it if help file exists,
115  *  otherwise returns 0
116  */
117 // ================================================================
118 HelpWindow* HelpWindow::openHelp( SALOME_InstallWizard* wizard )
119 {
120   if ( QFile::exists( QDir::currentDirPath() + "/doc/readme.html" ) )
121     return new HelpWindow( wizard );
122   else
123     return 0;
124 }