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