1 // File : SALOME_HelpWindow.cxx
2 // Created : Thu Dec 18 12:01:00 2002
3 // Author : Vadim SANDLER
5 // Module : Installation Wizard
6 // Copyright : 2004-2005 CEA
8 #include "SALOME_HelpWindow.hxx"
9 #include "SALOME_InstallWizard.hxx"
11 #include <qstatusbar.h>
13 #include <qtoolbutton.h>
16 #include <qtextbrowser.h>
17 #include <qapplication.h>
23 #define DEFAULT_WIDTH 800
24 #define DEFAULT_HEIGHT 700
26 // ================================================================
28 * HelpWindow::HelpWindow
31 // ================================================================
32 HelpWindow::HelpWindow( SALOME_InstallWizard* wizard ) : QMainWindow( 0, "SalomeProHelpWindow", WDestructiveClose )
34 QString hlpFile = QDir::currentDirPath() + "/doc/readme.html";
37 setCaption( wizard->getCaption() + " " + wizard->getIWName() + " " + tr( "Help" ) );
39 setIcon( QPixmap( (const char**)image0_data ) );
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 );
49 QToolBar* toolbar = new QToolBar( this );
50 addToolBar( toolbar, "Toolbar" );
53 button = new QToolButton( QIconSet( (const char**)_img_back ),
59 button->setEnabled( FALSE );
60 connect( browser, SIGNAL( backwardAvailable( bool ) ), button, SLOT( setEnabled( bool ) ) );
62 button = new QToolButton( QIconSet( (const char**)_img_forward ),
68 button->setEnabled( FALSE );
69 connect( browser, SIGNAL( forwardAvailable( bool ) ), button, SLOT( setEnabled( bool ) ) );
71 button = new QToolButton( QIconSet( (const char**)_img_home ),
77 toolbar->addSeparator();
78 button = new QToolButton( QIconSet( (const char**)_img_close ),
84 toolbar->addSeparator();
86 QLabel* logo = new QLabel( toolbar, "logo" );
87 logo->setPixmap( QPixmap( (const char**)image1_data ) );
88 logo->setAlignment( AlignRight | AlignVCenter );
89 logo->setScaledContents( false );
90 toolbar->setStretchableWidget( logo );
91 setRightJustification( TRUE );
92 // disable docking of toolbar
93 setDockEnabled( Qt::DockLeft, FALSE );
94 setDockEnabled( Qt::DockRight, FALSE );
95 setDockEnabled( Qt::DockBottom, FALSE );
96 setDockEnabled( Qt::DockTornOff, FALSE );
98 setDockMenuEnabled ( FALSE ) ;
100 connect( browser, SIGNAL( highlighted( const QString&) ), statusBar(), SLOT( message( const QString&)) );
104 QSize sz = qApp->desktop()->size();
105 int x = ( sz.width() - DEFAULT_WIDTH ) / 2;
106 int y = ( sz.height() - DEFAULT_HEIGHT ) / 2;
107 setGeometry( x, y, DEFAULT_WIDTH, DEFAULT_HEIGHT );
109 // ================================================================
111 * HelpWindow::~HelpWindow
114 // ================================================================
115 HelpWindow::~HelpWindow()
118 // ================================================================
120 * HelpWindow::keyPressEvent
121 * Key press event handler
123 // ================================================================
124 void HelpWindow::keyPressEvent( QKeyEvent* e )
126 if ( e->key() == Key_Escape )
128 QMainWindow::keyPressEvent( e );
130 // ================================================================
132 * HelpWindow::openHelp [ static ]
133 * Creates Help window ane return pointer to it if help file exists,
134 * otherwise returns 0
136 // ================================================================
137 HelpWindow* HelpWindow::openHelp( SALOME_InstallWizard* wizard )
139 if ( QFile::exists( QDir::currentDirPath() + "/doc/readme.html" ) )
140 return new HelpWindow( wizard );