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( pixmap( pxIcon ) );
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( pixmap( pxBack ) ),
59 button->setEnabled( FALSE );
60 connect( browser, SIGNAL( backwardAvailable( bool ) ), button, SLOT( setEnabled( bool ) ) );
62 button = new QToolButton( QIconSet( pixmap( pxNext ) ),
68 button->setEnabled( FALSE );
69 connect( browser, SIGNAL( forwardAvailable( bool ) ), button, SLOT( setEnabled( bool ) ) );
71 button = new QToolButton( QIconSet( pixmap( pxHome ) ),
77 toolbar->addSeparator();
78 button = new QToolButton( QIconSet( pixmap( pxZoomIn ) ),
79 tr( "Increaze font size" ),
84 button = new QToolButton( QIconSet( pixmap( pxZoomOut ) ),
85 tr( "Decreaze font size" ),
90 toolbar->addSeparator();
91 button = new QToolButton( QIconSet( pixmap( pxClose ) ),
97 toolbar->addSeparator();
99 QLabel* logo = new QLabel( toolbar, "logo" );
100 logo->setPixmap( pixmap( pxLogo ) );
101 logo->setAlignment( AlignRight | AlignVCenter );
102 logo->setScaledContents( false );
103 toolbar->setStretchableWidget( logo );
104 setRightJustification( TRUE );
105 // disable docking of toolbar
106 setDockEnabled( Qt::DockLeft, FALSE );
107 setDockEnabled( Qt::DockRight, FALSE );
108 setDockEnabled( Qt::DockBottom, FALSE );
109 setDockEnabled( Qt::DockTornOff, FALSE );
111 setDockMenuEnabled ( FALSE ) ;
113 connect( browser, SIGNAL( highlighted( const QString&) ), statusBar(), SLOT( message( const QString&)) );
117 QSize sz = qApp->desktop()->size();
118 int x = ( sz.width() - DEFAULT_WIDTH ) / 2;
119 int y = ( sz.height() - DEFAULT_HEIGHT ) / 2;
120 setGeometry( x, y, DEFAULT_WIDTH, DEFAULT_HEIGHT );
122 // ================================================================
124 * HelpWindow::~HelpWindow
127 // ================================================================
128 HelpWindow::~HelpWindow()
131 // ================================================================
133 * HelpWindow::keyPressEvent
134 * Key press event handler
136 // ================================================================
137 void HelpWindow::keyPressEvent( QKeyEvent* e )
139 if ( e->key() == Key_Escape )
141 QMainWindow::keyPressEvent( e );
143 // ================================================================
145 * HelpWindow::openHelp [ static ]
146 * Creates Help window ane return pointer to it if help file exists,
147 * otherwise returns 0
149 // ================================================================
150 HelpWindow* HelpWindow::openHelp( SALOME_InstallWizard* wizard )
152 if ( QFile::exists( QDir::currentDirPath() + "/doc/readme.html" ) )
153 return new HelpWindow( wizard );