1 // File : SALOME_InstallWizard.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
9 #include "SALOME_InstallWizard.hxx"
10 #include "SALOME_ProductsView.hxx"
11 #include "SALOME_ProgressView.hxx"
12 #include "SALOME_XmlHandler.hxx"
13 #include "SALOME_HelpWindow.hxx"
17 #include <qlineedit.h>
18 #include <qpushbutton.h>
19 #include <qlistview.h>
21 #include <qtextedit.h>
22 #include <qtextbrowser.h>
24 #include <qcheckbox.h>
25 #include <qsplitter.h>
27 #include <qfiledialog.h>
28 #include <qapplication.h>
29 #include <qfileinfo.h>
30 #include <qmessagebox.h>
33 #include <qwhatsthis.h>
46 #define max( x, y ) ( x ) > ( y ) ? ( x ) : ( y )
49 #define TEMPDIRNAME ( "/INSTALLWORK" + QString::number( getpid() ) )
51 // ================================================================
53 * DefineDependeces [ static ]
54 * Defines list of dependancies as string separated by space symbols
56 // ================================================================
57 static QString DefineDependeces(MapProducts& theProductsMap) {
58 QStringList aProducts;
59 for ( MapProducts::Iterator mapIter = theProductsMap.begin(); mapIter != theProductsMap.end(); ++mapIter ) {
60 QCheckListItem* item = mapIter.key();
61 Dependancies dep = mapIter.data();
62 QStringList deps = dep.getDependancies();
63 for (int i = 0; i<(int)deps.count(); i++ ) {
64 if ( !aProducts.contains( deps[i] ) )
65 aProducts.append( deps[i] );
67 if ( !aProducts.contains( item->text(0) ) )
68 aProducts.append( item->text(0) );
70 return aProducts.join(" ");
73 #define QUOTE(arg) QString("'") + QString(arg) + QString("'")
75 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
76 T H E O L D I M P L E M E N T A T I O N
77 static QString DefineDependeces(MapProducts& theProductsMap, QCheckListItem* product ){
78 QStringList aProducts;
79 if ( theProductsMap.contains( product ) ) {
80 Dependancies dep = theProductsMap[ product ];
81 QStringList deps = dep.getDependancies();
82 for (int i = 0; i<(int)deps.count(); i++ ) {
83 aProducts.append( deps[i] );
86 return QString("\"") + aProducts.join(" ") + QString("\"");
88 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
90 // ================================================================
93 * Makes directory recursively, returns false if not succedes
95 // ================================================================
96 static bool makeDir( const QString& theDir, QString& theCreated )
98 theCreated = QString::null;
99 if ( theDir.isEmpty() )
101 QString aDir = QDir::cleanDirPath( QFileInfo( theDir ).absFilePath() );
103 while ( start > 0 ) {
104 start = aDir.find( QDir::separator(), start );
106 QFileInfo fi( aDir.left( start ) );
107 if ( !fi.exists() ) {
108 // VSR: Create directory and set permissions to allow other users to remove it
109 QString script = "mkdir " + fi.absFilePath();
110 script += "; chmod 777 " + fi.absFilePath();
111 script += " > /dev/null";
112 if ( system( script.latin1() ) )
114 // VSR: Remember the top of the created directory (to remove it in the end of the installation)
115 if ( theCreated.isNull() )
116 theCreated = fi.absFilePath();
121 if ( !QFileInfo( aDir ).exists() ) {
122 // VSR: Create directory, other users should NOT have possibility to remove it!!!
123 QString script = "mkdir " + aDir;
124 script += " > /dev/null";
125 if ( system( script.latin1() ) )
127 // VSR: Remember the top of the created directory (to remove it in the end of the installation)
128 if ( theCreated.isNull() )
133 // ================================================================
135 * readFile [ static ]
136 * Reads the file, returns false if can't open it
138 // ================================================================
139 static bool readFile( const QString& fileName, QString& text )
141 if ( QFile::exists( fileName ) ) {
142 QFile file( fileName );
143 if ( file.open( IO_ReadOnly ) ) {
144 QTextStream stream( &file );
146 while ( !stream.eof() ) {
147 line = stream.readLine(); // line of text excluding '\n'
156 // ================================================================
158 * hasSpace [ static ]
159 * Checks if string contains spaces; used to check directory paths
161 // ================================================================
162 static bool hasSpace( const QString& dir )
164 for ( int i = 0; i < (int)dir.length(); i++ ) {
165 if ( dir[ i ].isSpace() )
171 // ================================================================
173 * SALOME_InstallWizard::SALOME_InstallWizard
176 // ================================================================
177 SALOME_InstallWizard::SALOME_InstallWizard(QString aXmlFileName)
178 : InstallWizard( qApp->desktop(), "SALOME_InstallWizard", false, 0 ),
182 exitConfirmed( false )
184 myIWName = tr( "Installation Wizard" );
185 tmpCreated = QString::null;
186 xmlFileName = aXmlFileName;
187 QFont fnt = font(); fnt.setPointSize( 14 ); fnt.setBold( true );
191 setIcon( QPixmap( ( const char** ) image0_data ) );
193 setSizeGripEnabled( true );
196 addLogo( QPixmap( (const char**)image1_data ) );
200 setCaption( tr( "PAL/SALOME %1" ).arg( myVersion ) );
201 setCopyright( tr( "Copyright (C) 2004 CEA" ) );
202 setLicense( tr( "All right reserved" ) );
206 cout << "Config. file : " << xmlFileName << endl;
210 QFile xmlfile(xmlFileName);
211 if ( xmlfile.exists() ) {
212 QXmlInputSource source( &xmlfile );
213 QXmlSimpleReader reader;
215 StructureParser* handler = new StructureParser( this );
216 reader.setContentHandler( handler );
217 reader.parse( source );
220 // create instance of class for starting shell install script
221 shellProcess = new QProcess( this, "shellProcess" );
223 // create introduction page
225 // create products page
227 // create prestart page
229 // create progress page
231 // create readme page
235 QWhatsThis::add( backButton(), tr( "Returns to the previous step of the installation procedure" ) );
236 QToolTip::add ( backButton(), tr( "Returns to the previous step of the installation procedure" ) );
237 QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
238 QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
239 QWhatsThis::add( finishButton(), tr( "Finishes installation and quits program" ) );
240 QToolTip::add ( finishButton(), tr( "Finishes installation and quits program" ) );
241 QWhatsThis::add( cancelButton(), tr( "Cancels installation and quits program" ) );
242 QToolTip::add ( cancelButton(), tr( "Cancels installation and quits program" ) );
243 QWhatsThis::add( helpButton(), tr( "Displays help information window" ) );
244 QToolTip::add ( helpButton(), tr( "Displays help information window" ) );
246 // common signals connections
247 connect( this, SIGNAL( selected( const QString& ) ),
248 this, SLOT( pageChanged( const QString& ) ) );
249 connect( this, SIGNAL( helpClicked() ), this, SLOT( helpClicked() ) );
250 // catch signals from launched script
251 connect(shellProcess, SIGNAL( readyReadStdout() ), this, SLOT( readFromStdout() ) );
252 connect(shellProcess, SIGNAL( readyReadStderr() ), this, SLOT( readFromStderr() ) );
253 connect(shellProcess, SIGNAL( processExited() ), this, SLOT( productInstalled() ) );
254 connect(shellProcess, SIGNAL( wroteToStdin() ), this, SLOT( wroteToStdin() ) );
256 // ================================================================
258 * SALOME_InstallWizard::~SALOME_InstallWizard
261 // ================================================================
262 SALOME_InstallWizard::~SALOME_InstallWizard()
264 shellProcess->kill(); // kill it for sure
265 QString script = "kill -9 ";
266 int PID = (int)shellProcess->processIdentifier();
268 script += QString::number( PID );
269 script += " > /dev/null";
271 cout << "script: "<< script.latin1() << endl;
273 if ( system( script.latin1() ) ) {
277 // ================================================================
279 * SALOME_InstallWizard::eventFilter
280 * Event filter, spies for Help window closing
282 // ================================================================
283 bool SALOME_InstallWizard::eventFilter( QObject* object, QEvent* event )
285 if ( object && object == helpWindow && event->type() == QEvent::Close )
287 return InstallWizard::eventFilter( object, event );
289 // ================================================================
291 * SALOME_InstallWizard::closeEvent
292 * Close event handler
294 // ================================================================
295 void SALOME_InstallWizard::closeEvent( QCloseEvent* ce )
297 if ( !exitConfirmed ) {
298 if ( QMessageBox::information( this,
300 tr( "Do you want to quit %1?" ).arg( getIWName() ),
310 exitConfirmed = true;
315 // ================================================================
317 * SALOME_InstallWizard::setupIntroPage
318 * Creates introduction page
320 // ================================================================
321 void SALOME_InstallWizard::setupIntroPage()
324 introPage = new QWidget( this, "IntroPage" );
325 QGridLayout* pageLayout = new QGridLayout( introPage );
326 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
327 // create logo picture
328 QPixmap logo( (const char**)SALOME_Logo_xpm );
329 logoLab = new QLabel( introPage );
330 logoLab->setPixmap( logo );
331 logoLab->setScaledContents( false );
332 logoLab->setFrameStyle( QLabel::Plain | QLabel::Box );
333 logoLab->setAlignment( AlignCenter );
334 // create version box
335 QVBox* versionBox = new QVBox( introPage ); versionBox->setSpacing( 6 );
336 versionBox->setFrameStyle( QVBox::Panel | QVBox::Sunken );
337 QWidget* stretch1 = new QWidget( versionBox ); versionBox->setStretchFactor( stretch1, 5 );
338 versionLab = new QLabel( QString("%1 %2").arg( tr( "Version" ) ).arg(myVersion), versionBox );
339 versionLab->setAlignment( AlignCenter );
340 copyrightLab = new QLabel( myCopyright, versionBox );
341 copyrightLab->setAlignment( AlignCenter );
342 licenseLab = new QLabel( myLicense, versionBox );
343 licenseLab->setAlignment( AlignCenter );
344 QWidget* stretch2 = new QWidget( versionBox ); versionBox->setStretchFactor( stretch2, 5 );
346 info = new QLabel( introPage );
347 info->setText( tr( "This program will install <b>%1</b>."
348 "<br><br>The wizard will also help you to install all products "
349 "which are necessary for <b>%2</b> and setup "
350 "your environment.<br><br>Click <code>Cancel</code> button to abort "
351 "installation and quit. Click <code>Next</code> button to continue with the "
352 "installation program." ).arg( myCaption ).arg( myCaption ) );
353 info->setFrameStyle( QLabel::WinPanel | QLabel::Sunken );
354 info->setMargin( 6 );
355 info->setAlignment( WordBreak );
356 info->setMinimumWidth( 250 );
357 QPalette pal = info->palette();
358 pal.setColor( QColorGroup::Background, QApplication::palette().active().base() );
359 info->setPalette( pal );
360 info->setLineWidth( 2 );
362 pageLayout->addWidget( logoLab, 0, 0 );
363 pageLayout->addWidget( versionBox, 1, 0 );
364 pageLayout->addMultiCellWidget( info, 0, 1, 1, 1 );
365 pageLayout->setColStretch( 1, 5 );
366 pageLayout->setRowStretch( 1, 5 );
368 addPage( introPage, tr( "Introduction" ) );
370 // ================================================================
372 * SALOME_InstallWizard::setupProductsPage
373 * Creates products page
375 // ================================================================
376 void SALOME_InstallWizard::setupProductsPage()
379 productsPage = new QWidget( this, "ProductsPage" );
380 QGridLayout* pageLayout = new QGridLayout( productsPage );
381 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
383 QLabel* targetLab = new QLabel( tr( "Type the target directory:" ), productsPage );
384 targetFolder = new QLineEdit( productsPage );
385 QWhatsThis::add( targetFolder, tr( "Enter target root directory where products will be installed" ) );
386 QToolTip::add ( targetFolder, tr( "Enter target root directory where products will be installed" ) );
387 targetBtn = new QPushButton( tr( "Browse..." ), productsPage );
388 QWhatsThis::add( targetBtn, tr( "Click this to browse target directory" ) );
389 QToolTip::add ( targetBtn, tr( "Click this to browse target directory" ) );
390 // create advanced mode widgets container
391 moreBox = new QWidget( productsPage );
392 QGridLayout* moreBoxLayout = new QGridLayout( moreBox );
393 moreBoxLayout->setMargin( 0 ); moreBoxLayout->setSpacing( 6 );
395 QLabel* tempLab = new QLabel( tr( "Type the directory for the temporary files:" ), moreBox );
396 tempFolder = new QLineEdit( moreBox );
397 // tempFolder->setText( "/tmp" ); // default is /tmp directory
398 QWhatsThis::add( tempFolder, tr( "Enter directory where to put temporary files" ) );
399 QToolTip::add ( tempFolder, tr( "Enter directory where to put temporary files" ) );
400 tempBtn = new QPushButton( tr( "Browse..." ), moreBox );
401 tempBtn->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
402 QWhatsThis::add( tempBtn, tr( "Click this to browse temporary directory" ) );
403 QToolTip::add ( tempBtn, tr( "Click this to browse temporary directory" ) );
404 // create products list
405 productsView = new ProductsView( moreBox );
406 productsView->setMinimumSize( 250, 180 );
407 QWhatsThis::add( productsView, tr( "This view lists the products you wish to be installed" ) );
408 QToolTip::add ( productsView, tr( "This view lists the products you wish to be installed" ) );
410 productsInfo = new QTextBrowser( moreBox );
411 productsInfo->setMinimumSize( 270, 135 );
412 QWhatsThis::add( productsInfo, tr( "Shows info about the product: required disk space and prerequisites" ) );
413 QToolTip::add ( productsInfo, tr( "Shows info about the product: required disk space and prerequisites" ) );
415 QLabel* reqLab1 = new QLabel( tr( "Total disk space required:" ), moreBox );
416 QWhatsThis::add( reqLab1, tr( "Shows total disk space required for installing selected products" ) );
417 QToolTip::add ( reqLab1, tr( "Shows total disk space required for installing selected products" ) );
418 requiredSize = new QLabel( moreBox );
419 requiredSize->setMinimumWidth( 100 );
420 QWhatsThis::add( requiredSize, tr( "Shows total disk space required for installing selected products" ) );
421 QToolTip::add ( requiredSize, tr( "Shows total disk space required for installing selected products" ) );
422 QLabel* reqLab2 = new QLabel( tr( "Space for temporary files:" ), moreBox );
423 QWhatsThis::add( reqLab2, tr( "Shows additional disk space which is required for temporary files" ) );
424 QToolTip::add ( reqLab2, tr( "Shows additional disk space which is required for temporary files" ) );
425 requiredTemp = new QLabel( moreBox );
426 requiredTemp->setMinimumWidth( 100 );
427 QWhatsThis::add( requiredTemp, tr( "Shows additional disk space which is required for temporary files" ) );
428 QToolTip::add ( requiredTemp, tr( "Shows additional disk space which is required for temporary files" ) );
429 QFont fnt = reqLab1->font();
431 reqLab1->setFont( fnt );
432 requiredSize->setFont( fnt );
433 reqLab2->setFont( fnt );
434 requiredTemp->setFont( fnt );
435 QGridLayout* sizeLayout = new QGridLayout; sizeLayout->setMargin( 0 ); sizeLayout->setSpacing( 6 );
436 sizeLayout->addWidget( reqLab1, 0, 0 );
437 sizeLayout->addWidget( requiredSize, 0, 1 );
438 sizeLayout->addWidget( reqLab2, 1, 0 );
439 sizeLayout->addWidget( requiredTemp, 1, 1 );
440 // prerequisites checkbox
441 prerequisites = new QCheckBox( tr( "Auto set prerequisites products" ), moreBox );
442 prerequisites->setChecked( true );
443 QWhatsThis::add( prerequisites, tr( "Check this if you want prerequisites products to be set on automatically" ) );
444 QToolTip::add ( prerequisites, tr( "Check this if you want prerequisites products to be set on automatically" ) );
445 // <Unselect All> buttons
446 unselectBtn = new QPushButton( tr( "&Unselect All" ), moreBox );
447 QWhatsThis::add( unselectBtn, tr( "Unselects all products" ) );
448 QToolTip::add ( unselectBtn, tr( "Unselects all products" ) );
449 QVBoxLayout* btnLayout = new QVBoxLayout; btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );
450 btnLayout->addWidget( unselectBtn );
451 // layouting advancet mode widgets
452 moreBoxLayout->addMultiCellWidget( tempLab, 0, 0, 0, 2 );
453 moreBoxLayout->addMultiCellWidget( tempFolder, 1, 1, 0, 1 );
454 moreBoxLayout->addWidget ( tempBtn, 1, 2 );
455 moreBoxLayout->addMultiCellWidget( productsView, 2, 5, 0, 0 );
456 moreBoxLayout->addMultiCellWidget( productsInfo, 2, 2, 1, 2 );
457 moreBoxLayout->addMultiCellWidget( prerequisites,3, 3, 1, 2 );
458 moreBoxLayout->addMultiCellLayout( btnLayout, 4, 4, 1, 2 );
459 moreBoxLayout->addMultiCellLayout( sizeLayout, 5, 5, 1, 2 );
461 moreBtn = new QPushButton( tr( "More..." ), productsPage );
463 pageLayout->addMultiCellWidget( targetLab, 0, 0, 0, 1 );
464 pageLayout->addWidget ( targetFolder, 1, 0 );
465 pageLayout->addWidget ( targetBtn, 1, 1 );
466 pageLayout->addMultiCellWidget( moreBox, 2, 2, 0, 1 );
467 pageLayout->addWidget ( moreBtn, 3, 1 );
468 pageLayout->setRowStretch( 2, 5 );
469 //pageLayout->addRowSpacing( 6, 10 );
471 QFile xmlfile(xmlFileName);
472 if ( xmlfile.exists() ) {
473 QXmlInputSource source( &xmlfile );
474 QXmlSimpleReader reader;
476 StructureParser* handler = new StructureParser( this );
477 handler->setProductsList(productsView);
478 handler->setTargetDir(targetFolder);
479 handler->setTempDir(tempFolder);
480 reader.setContentHandler( handler );
481 reader.parse( source );
483 // set first item to be selected
484 if ( productsView->childCount() > 0 ) {
485 productsView->setSelected( productsView->firstChild(), true );
486 onSelectionChanged();
489 addPage( productsPage, tr( "Installation settings" ) );
490 // connecting signals
491 connect( productsView, SIGNAL( selectionChanged() ),
492 this, SLOT( onSelectionChanged() ) );
493 connect( productsView, SIGNAL( itemToggled( QCheckListItem* ) ),
494 this, SLOT( onItemToggled( QCheckListItem* ) ) );
495 connect( unselectBtn, SIGNAL( clicked() ), this, SLOT( onProdBtn() ) );
496 // connecting signals
497 connect( targetFolder, SIGNAL( textChanged( const QString& ) ),
498 this, SLOT( directoryChanged( const QString& ) ) );
499 connect( targetBtn, SIGNAL( clicked() ), this, SLOT( browseDirectory() ) );
500 connect( tempFolder, SIGNAL( textChanged( const QString& ) ),
501 this, SLOT( directoryChanged( const QString& ) ) );
502 connect( tempBtn, SIGNAL( clicked() ), this, SLOT( browseDirectory() ) );
503 connect( moreBtn, SIGNAL( clicked() ), this, SLOT( onMoreBtn() ) );
504 // start on default - non-advanced - mode
507 // ================================================================
509 * SALOME_InstallWizard::setupCheckPage
510 * Creates prestart page
512 // ================================================================
513 void SALOME_InstallWizard::setupCheckPage()
516 prestartPage = new QWidget( this, "PrestartPage" );
517 QVBoxLayout* pageLayout = new QVBoxLayout( prestartPage );
518 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
520 choices = new QTextEdit( prestartPage );
521 choices->setReadOnly( true );
522 choices->setTextFormat( RichText );
523 choices->setUndoRedoEnabled ( false );
524 QWhatsThis::add( choices, tr( "Displays information about installation settings you made" ) );
525 QToolTip::add ( choices, tr( "Displays information about installation settings you made" ) );
526 QPalette pal = choices->palette();
527 pal.setColor( QColorGroup::Base, QApplication::palette().active().background() );
528 choices->setPalette( pal );
529 choices->setMinimumHeight( 10 );
531 pageLayout->addWidget( choices );
532 pageLayout->setStretchFactor( choices, 5 );
534 addPage( prestartPage, tr( "Check your choice" ) );
536 // ================================================================
538 * SALOME_InstallWizard::setupProgressPage
539 * Creates progress page
541 // ================================================================
542 void SALOME_InstallWizard::setupProgressPage()
545 progressPage = new QWidget( this, "progressPage" );
546 QGridLayout* pageLayout = new QGridLayout( progressPage );
547 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
549 splitter = new QSplitter( Vertical, progressPage );
550 splitter->setOpaqueResize( true );
551 // the parent for the widgets
552 QWidget* widget = new QWidget( splitter );
553 QGridLayout* layout = new QGridLayout( widget );
554 layout->setMargin( 0 ); layout->setSpacing( 6 );
555 // installation progress view box
556 installInfo = new QTextEdit( widget );
557 installInfo->setReadOnly( true );
558 installInfo->setTextFormat( RichText );
559 installInfo->setUndoRedoEnabled ( false );
560 installInfo->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
561 installInfo->setMinimumSize( 100, 10 );
562 QWhatsThis::add( installInfo, tr( "Displays installation process" ) );
563 QToolTip::add ( installInfo, tr( "Displays installation process" ) );
564 // parameters for the script
565 parametersLab = new QLabel( tr( "Enter your answer here:" ), widget );
566 passedParams = new QLineEdit ( widget );
567 QWhatsThis::add( passedParams, tr( "Use this field to enter answer for the running script when it is necessary") );
568 QToolTip::add ( passedParams, tr( "Use this field to enter answer for the running script when it is necessary") );
570 layout->addWidget( installInfo, 0, 0 );
571 layout->addWidget( parametersLab, 1, 0 );
572 layout->addWidget( passedParams, 2, 0 );
573 layout->addRowSpacing( 3, 6 );
574 // the parent for the widgets
575 widget = new QWidget( splitter );
576 layout = new QGridLayout( widget );
577 layout->setMargin( 0 ); layout->setSpacing( 6 );
578 // installation results view box
579 QLabel* resultLab = new QLabel( tr( "Installation Status:" ), widget );
580 progressView = new ProgressView( widget );
581 progressView->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
582 progressView->setMinimumSize( 100, 10 );
583 QWhatsThis::add( progressView, tr( "Displays installation status" ) );
584 QToolTip::add ( progressView, tr( "Displays installation status" ) );
586 layout->addRowSpacing( 0, 6 );
587 layout->addWidget( resultLab, 1, 0 );
588 layout->addWidget( progressView, 2, 0 );
590 pageLayout->addWidget( splitter, 0, 0 );
592 addPage( progressPage, tr( "Installation progress" ) );
594 connect( passedParams, SIGNAL( returnPressed() ), this, SLOT( onReturnPressed() ) ) ;
596 // ================================================================
598 * SALOME_InstallWizard::setupReadmePage
599 * Creates readme page
601 // ================================================================
602 void SALOME_InstallWizard::setupReadmePage()
605 readmePage = new QWidget( this, "ReadmePage" );
606 QVBoxLayout* pageLayout = new QVBoxLayout( readmePage );
607 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
608 // README info text box
609 readme = new QTextEdit( readmePage );
610 readme->setReadOnly( true );
611 readme->setTextFormat( PlainText );
612 readme->setUndoRedoEnabled ( false );
613 QWhatsThis::add( readme, tr( "Displays README information" ) );
614 QToolTip::add ( readme, tr( "Displays README information" ) );
615 QPalette pal = readme->palette();
616 pal.setColor( QColorGroup::Base, QApplication::palette().active().background() );
617 readme->setPalette( pal );
618 readme->setMinimumHeight( 10 );
619 // <Launch SALOME> button
620 runSalomeBtn = new QPushButton( tr( "Launch SALOME" ), readmePage );
621 QWhatsThis::add( runSalomeBtn, tr( "Click this button to run SALOME desktop" ) );
622 QToolTip::add ( runSalomeBtn, tr( "Click this button to run SALOME desktop" ) );
623 QHBoxLayout* hLayout = new QHBoxLayout;
624 hLayout->addWidget( runSalomeBtn ); hLayout->addStretch();
626 pageLayout->addWidget( readme );
627 pageLayout->setStretchFactor( readme, 5 );
628 pageLayout->addLayout( hLayout );
629 // connecting signals
630 connect( runSalomeBtn, SIGNAL( clicked() ), this, SLOT( onLaunchSalome() ) );
631 // loading README file
632 QString readmeFile = QDir::currentDirPath() + "/README";
634 if ( readFile( readmeFile, text ) )
635 readme->setText( text );
637 readme->setText( tr( "README file has not been found" ) );
639 addPage( readmePage, tr( "Finish installation" ) );
641 // ================================================================
643 * SALOME_InstallWizard::showChoiceInfo
644 * Displays choice info
646 // ================================================================
647 void SALOME_InstallWizard::showChoiceInfo()
651 long totSize, tempSize;
652 checkSize( &totSize, &tempSize );
656 if ( !xmlFileName.isEmpty() ) {
657 text += tr( "Configuration file" )+ ": <b>" + xmlFileName + "</b><br>";
660 if ( !myOS.isEmpty() ) {
661 text += tr( "Target platform" ) + ": <b>" + myOS + "</b><br>";
664 text += tr( "Products to be used" ) + ":<ul>";
665 QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
667 if ( productsMap.contains( item ) ) {
668 if ( item->childCount() > 0 ) {
669 if ( productsView->isNative( item ) ) {
670 text += "<li><b>" + item->text() + "</b> " + tr( "as native" ) + "<br>";
675 item = (QCheckListItem*)( item->nextSibling() );
678 text += "<li><b>" + tr( "none" ) + "</b><br>";
682 text += tr( "Products to be installed" ) + ":<ul>";
683 item = (QCheckListItem*)( productsView->firstChild() );
685 if ( productsMap.contains( item ) ) {
686 if ( item->childCount() > 0 ) {
687 if ( productsView->isBinaries( item ) ) {
688 text += "<li><b>" + item->text() + "</b> " + tr( "as binaries" ) + "<br>";
691 else if ( productsView->isSources( item ) ) {
692 text+= "<li><b>" + item->text() + "</b> " + tr( "as sources" ) + "<br>";
696 else if ( item->isOn() ) {
697 text+= "<li><b>" + item->text() + "</b><br>";
701 item = (QCheckListItem*)( item->nextSibling() );
704 text += "<li><b>" + tr( "none" ) + "</b><br>";
707 text += tr( "Total disk space required:" ) + " <b>" + QString::number( totSize ) + " Kb</b><br>" ;
708 text += tr( "Space for temporary files required:" ) + " <b>" + QString::number( tempSize ) + " Kb</b><br>" ;
710 text += tr( "Target directory:" ) + " <b>" + QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) + "</b><br>";
711 // VSR: Temporary folder is used always now and it is not necessary to disable it -->
712 // if ( tempSize > 0 )
713 // VSR: <----------------------------------------------------------------------------
714 text += tr( "Temp directory:" ) + " <b>" + QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + "</b><br>";
716 choices->setText( text );
718 // ================================================================
720 * SALOME_InstallWizard::acceptData
721 * Validates page when <Next> button is clicked
723 // ================================================================
724 bool SALOME_InstallWizard::acceptData( const QString& pageTitle )
727 QWidget* aPage = InstallWizard::page( pageTitle );
728 if ( aPage == productsPage ) {
729 // ########## check if any products are selected to be installed
730 long totSize, tempSize;
731 bool anySelected = checkSize( &totSize, &tempSize );
732 if ( !anySelected ) {
733 QMessageBox::warning( this,
735 tr( "Select one or more products to install" ),
737 QMessageBox::NoButton,
738 QMessageBox::NoButton );
741 // ########## check target and temp directories (existence and available disk space)
743 QString targetDir = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() );
744 QString tempDir = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() );
745 // directories should differ
746 // if (!targetDir.isEmpty() && tempDir == targetDir) {
747 // QMessageBox::warning( this,
749 // tr( "Target and temporary directories must be different"),
751 // QMessageBox::NoButton,
752 // QMessageBox::NoButton );
755 // check target directory
756 if ( targetDir.isEmpty() ) {
757 QMessageBox::warning( this,
759 tr( "Please, enter valid target directory path" ),
761 QMessageBox::NoButton,
762 QMessageBox::NoButton );
765 QFileInfo fi( QDir::cleanDirPath( targetDir ) );
766 if ( !fi.exists() ) {
768 QMessageBox::warning( this,
770 tr( "The directory %1 doesn't exist.\n"
771 "Do you want to create directory?" ).arg( fi.absFilePath() ),
774 QMessageBox::NoButton ) == QMessageBox::Yes;
777 if ( !makeDir( fi.absFilePath(), tmpstr ) ) {
778 QMessageBox::critical( this,
780 tr( "Can't create the directory\n%1").arg( fi.absFilePath() ),
782 QMessageBox::NoButton,
783 QMessageBox::NoButton );
788 QMessageBox::warning( this,
790 tr( "The directory %1 is not a directory.\n"
791 "Please, enter valid target directory path" ).arg( fi.absFilePath() ),
793 QMessageBox::NoButton,
794 QMessageBox::NoButton );
797 if ( !fi.isWritable() ) {
798 QMessageBox::warning( this,
800 tr( "The directory %1 is not writeable.\n"
801 "Please, enter valid target directory path or change permissions" ).arg( fi.absFilePath() ),
803 QMessageBox::NoButton,
804 QMessageBox::NoButton );
807 if ( hasSpace( fi.absFilePath() ) &&
808 QMessageBox::warning( this,
810 tr( "The target directory contains space symbols.\n"
811 "This may cause problems with compiling or installing of products.\n\n"
812 "Do you want to continue?"),
815 QMessageBox::NoButton ) == QMessageBox::No ) {
818 QString binDir = "./Products/BINARIES";
819 if ( !myOS.isEmpty() )
820 binDir += "/" + myOS;
821 QFileInfo fib( QDir::cleanDirPath( binDir ) );
822 if ( !fib.exists() ) {
823 QMessageBox::warning( this,
825 tr( "The directory %1 doesn't exist.\n"
826 "This directory must contain binaries archives." ).arg( fib.absFilePath() ));
828 // run script that checks available disk space for installing of products // returns 1 in case of error
829 QString script = "./config_files/checkSize.sh '";
830 script += fi.absFilePath();
832 script += QString( "%1" ).arg( totSize );
834 cout << "script = " << script << endl;
836 if ( system( script ) ) {
837 QMessageBox::critical( this,
838 tr( "Out of space" ),
839 tr( "There is not available disk space for installing of selected products" ),
841 QMessageBox::NoButton,
842 QMessageBox::NoButton );
845 // check temp directory
846 if ( tempDir.isEmpty() ) {
848 QMessageBox::warning( this,
850 tr( "Please, enter valid temp directory path" ),
852 QMessageBox::NoButton,
853 QMessageBox::NoButton );
857 tempFolder->setText( "/tmp" );
860 QFileInfo fit( QDir::cleanDirPath( tempDir ) );
861 if ( !makeDir( fit.absFilePath() + TEMPDIRNAME, tmpCreated ) ) {
862 QMessageBox::critical( this,
864 tr( "Can't use temporary directory.\nCheck permissions for the %1 directory.").arg( fit.absFilePath() ),
866 QMessageBox::NoButton,
867 QMessageBox::NoButton );
870 // run script that check available disk space for temporary files
871 // returns 1 in case of error
872 QString tscript = "./config_files/checkSize.sh '";
873 tscript += fit.absFilePath();
875 tscript += QString( "%1" ).arg( tempSize );
877 cout << "script = " << tscript << endl;
879 if ( system( tscript ) ) {
880 QMessageBox::critical( this,
881 tr( "Out of space" ),
882 tr( "There is not available disk space for the temporary files" ),
884 QMessageBox::NoButton,
885 QMessageBox::NoButton );
888 // VSR: <------------------------------------------------------------------------------
889 // ########## check native products
890 QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
893 if ( productsMap.contains( item ) ) {
894 if ( item->childCount() > 0 ) {
895 if ( !productsView->isNone( item ) ) {
896 if ( item->text(2).isEmpty() || item->text(2).isNull() ) {
897 QMessageBox::warning( this,
899 tr( "You don't have a defined script for %1").arg(item->text(0)),
901 QMessageBox::NoButton,
902 QMessageBox::NoButton );
903 productsView->setNone( item );
906 QFileInfo fi( QString("./config_files/") + item->text(2) );
907 if ( !fi.exists() ) {
908 QMessageBox::warning( this,
910 tr( "%1 required for %2 doesn't exist.").arg("./config_files/" + item->text(2)).arg(item->text(0)),
912 QMessageBox::NoButton,
913 QMessageBox::NoButton );
914 productsView->setNone( item );
919 // collect native products
920 if ( productsView->isNative( item ) ) {
921 if ( natives.find( item->text(0) ) == natives.end() )
922 natives.append( item->text(0) );
924 else if ( productsView->isBinaries( item ) || productsView->isSources( item ) ) {
925 QStringList dependOn = productsMap[ item ].getDependancies();
926 for ( int i = 0; i < (int)dependOn.count(); i++ ) {
927 QCheckListItem* depitem = findItem( dependOn[ i ] );
929 if ( productsView->isNative( depitem ) && natives.find( depitem->text(0) ) == natives.end() )
930 natives.append( depitem->text(0) );
933 QMessageBox::warning( this,
935 tr( "%1 is required for %2 %3 installation.\n"
936 "Please, add this product in config.xml file.").arg(dependOn[ i ]).arg(item->text(0)).arg(item->text(1)),
938 QMessageBox::NoButton,
939 QMessageBox::NoButton );
946 item = (QCheckListItem*)( item->nextSibling() );
948 QString tmpFolder = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
949 QString tgtFolder = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() );
950 for ( unsigned i = 0; i < natives.count(); i++ ) {
951 item = findItem( natives[ i ] );
953 QString script = "cd ./config_files/;" + item->text(2) + " try_native " +
954 QFileInfo( tmpFolder ).absFilePath() + " " + QDir::currentDirPath() + "/Products " + QFileInfo( tgtFolder ).absFilePath() + " " +
955 QUOTE(DefineDependeces(productsMap)) + " " + item->text(0);
958 cout << "1. Script : " << script << endl;
960 if ( system( script ) ) {
961 QMessageBox::warning( this,
963 tr( "You don't have native %1 %2 installed").arg(item->text(0)).arg(item->text(1)),
965 QMessageBox::NoButton,
966 QMessageBox::NoButton );
967 productsView->setNone( item );
972 QMessageBox::warning( this,
974 tr( "%The product %1 %2 required for installation.\n"
975 "Please, add this product in config.xml file.").arg(item->text(0)).arg(item->text(1)),
977 QMessageBox::NoButton,
978 QMessageBox::NoButton );
983 return InstallWizard::acceptData( pageTitle );
985 // ================================================================
987 * SALOME_InstallWizard::checkSize
988 * Calculates disk space required for the installation
990 // ================================================================
991 bool SALOME_InstallWizard::checkSize( long* totSize, long* tempSize )
993 long tots = 0, temps = 0;
996 MapProducts::Iterator mapIter;
997 for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
998 QCheckListItem* item = mapIter.key();
999 Dependancies dep = mapIter.data();
1000 if ( productsView->isBinaries( item ) ) {
1001 tots += dep.getSize();
1003 else if ( productsView->isSources( item ) ) {
1004 tots += dep.getSize(true);
1005 temps = max( temps, dep.getTempSize() );
1007 if ( !productsView->isNone( item ) )
1015 return ( nbSelected > 0 );
1017 // ================================================================
1019 * SALOME_InstallWizard::checkProductPage
1020 * Checks products page validity (directories and products selection) and
1021 * enabled/disables "Next" button for the Products page
1023 // ================================================================
1024 void SALOME_InstallWizard::checkProductPage()
1026 long tots = 0, temps = 0;
1028 // check if any product is selected;
1029 bool isAnyProductSelected = checkSize( &tots, &temps );
1030 // check if target directory is valid
1031 bool isTargetDirValid = !targetFolder->text().stripWhiteSpace().isEmpty();
1032 // check if temp directory is valid
1033 bool isTempDirValid = !moreMode || !tempFolder->text().stripWhiteSpace().isEmpty();
1035 // update required size information
1036 requiredSize->setText( QString::number( tots ) + " Kb");
1037 requiredTemp->setText( QString::number( temps ) + " Kb");
1039 // enable/disable "Next" button
1040 setNextEnabled( productsPage, isAnyProductSelected && isTargetDirValid && isTempDirValid );
1042 // ================================================================
1044 * SALOME_InstallWizard::setPrerequisites
1045 * Sets the product and all products this one depends on to be checked ( recursively )
1047 // ================================================================
1048 void SALOME_InstallWizard::setPrerequisites( QCheckListItem* item )
1050 if ( !productsMap.contains( item ) )
1052 if ( productsView->isNone( item ) )
1054 // get all prerequisites
1055 QStringList dependOn = productsMap[ item ].getDependancies();
1056 for ( int i = 0; i < (int)dependOn.count(); i++ ) {
1057 MapProducts::Iterator itProd;
1058 for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) {
1059 if ( itProd.data().getName() == dependOn[ i ] ) {
1060 if ( productsView->isNone( itProd.key() ) ) {
1061 QString defMode = itProd.data().getDefault();
1062 if ( defMode.isEmpty() )
1063 defMode = tr( "install binaries" );
1064 if ( defMode == tr( "install binaries" ) )
1065 productsView->setBinaries( itProd.key() );
1066 else if ( defMode == tr( "install sources" ) )
1067 productsView->setSources( itProd.key() );
1068 else if ( defMode == tr( "use native" ) )
1069 productsView->setNative( itProd.key() );
1070 setPrerequisites( itProd.key() );
1076 // ================================================================
1078 * SALOME_InstallWizard::launchScript
1079 * Runs installation script
1081 // ================================================================
1082 void SALOME_InstallWizard::launchScript()
1084 // try to find product being processed now
1085 QString prodProc = progressView->findStatus( Processing );
1086 if ( !prodProc.isNull() ) {
1088 cout << "Found <Processing>: " << prodProc.latin1() << endl;
1091 // if found - set status to "completed"
1092 progressView->setStatus( prodProc, Completed );
1093 // ... and call this method again
1097 // else try to find next product which is not processed yet
1098 prodProc = progressView->findStatus( Waiting );
1099 if ( !prodProc.isNull() ) {
1101 cout << "Found <Waiting>: " << prodProc.latin1() << endl;
1103 // if found - set status to "processed" and run script
1104 progressView->setStatus( prodProc, Processing );
1105 progressView->ensureVisible( prodProc );
1107 QCheckListItem* item = findItem( prodProc );
1108 Dependancies dep = productsMap[ item ];
1109 // fill in script parameters
1110 shellProcess->clearArguments();
1112 shellProcess->setWorkingDirectory( QDir::cleanDirPath( QFileInfo( "./config_files/" ).absFilePath() ) );
1113 shellProcess->addArgument( item->text(2) );
1116 QString tmpFolder = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
1117 if( !tempFolder->isEnabled() )
1121 if ( productsView->isBinaries( item ) ) {
1122 shellProcess->addArgument( "install_binary" );
1123 shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
1124 QString binDir = QDir::currentDirPath() + "/Products/BINARIES";
1125 if ( !myOS.isEmpty() )
1126 binDir += "/" + myOS;
1127 shellProcess->addArgument( binDir );
1130 else if ( productsView->isSources( item ) ) {
1131 shellProcess->addArgument( "install_source" );
1132 shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
1133 shellProcess->addArgument( QDir::currentDirPath() + "/Products/SOURCES" );
1136 else if ( productsView->isNative( item ) ) {
1137 shellProcess->addArgument( "try_native" );
1138 shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
1139 shellProcess->addArgument( QDir::currentDirPath() + "/Products" );
1141 // ... not install : try to find preinstalled
1143 shellProcess->addArgument( "try_preinstalled" );
1144 shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
1145 shellProcess->addArgument( QDir::currentDirPath() + "/Products" );
1147 // ... target folder
1148 QString tgtFolder = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() );
1149 shellProcess->addArgument( QFileInfo( tgtFolder ).absFilePath() );
1152 QString depproducts = DefineDependeces(productsMap);
1154 cout << "Dependancies"<< depproducts.latin1() << endl;
1157 shellProcess->addArgument( depproducts );
1158 // ... product name - currently instaled product
1159 shellProcess->addArgument( item->text(0) );
1162 if ( !shellProcess->start() ) {
1163 // error handling can be here
1165 cout << "error" << endl;
1171 cout << "All products have been installed successfully" << endl;
1173 // all products installed successfully
1175 nextButton()->setEnabled( true );
1176 nextButton()->setText( tr( "&Next >" ) );
1177 QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1178 QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1179 nextButton()->disconnect();
1180 connect( nextButton(), SIGNAL( clicked() ), this, SLOT( next() ) );
1182 backButton()->setEnabled( true );
1183 // script parameters
1184 passedParams->clear();
1185 passedParams->setEnabled( false );
1186 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1187 if ( isMinimized() )
1191 // ================================================================
1193 * SALOME_InstallWizard::onMoreBtn
1194 * <More...> button slot
1196 // ================================================================
1197 void SALOME_InstallWizard::onMoreBtn()
1201 moreBtn->setText( tr( "More..." ) );
1205 moreBtn->setText( tr( "Less..." ) );
1207 qApp->processEvents();
1208 moreMode = !moreMode;
1209 InstallWizard::layOut();
1210 qApp->processEvents();
1211 if ( !isMaximized() ) {
1212 //setGeometry( geometry().x(), geometry().y(), geometry().width(), 0 );
1213 resize( geometry().width(), 0 );
1214 qApp->processEvents();
1218 // ================================================================
1220 * SALOME_InstallWizard::onLaunchSalome
1221 * <Launch Salome> button slot
1223 // ================================================================
1224 void SALOME_InstallWizard::onLaunchSalome()
1226 QCheckListItem* item = 0;
1227 if ( ( item = findItem( "SalomePro-Bin" ) ) ) {
1228 QFileInfo fi( targetFolder->text() + "/SalomePro-" + item->text(1) + "/salome" );
1229 if ( fi.exists() ) {
1231 script += "cd " + targetFolder->text() + "/SalomePro-" + item->text(1) + "; ";
1232 script += "source salome.csh; ";
1233 //script += "cd bin; ";
1234 //script += "runSalome > /dev/null";
1235 script += "salome -g > /dev/null";
1236 script = "(csh -c '" + script + "')";
1238 cout << script.latin1() << endl;
1240 if ( system( script.latin1() ) ){
1241 QMessageBox::warning( this,
1243 tr( "Can't launch SALOME" ),
1245 QMessageBox::NoButton,
1246 QMessageBox::NoButton );
1251 QMessageBox::warning( this,
1253 tr( "You don't have SALOME binaries installed in the %1 directory!" ).arg( targetFolder->text() ),
1255 QMessageBox::NoButton,
1256 QMessageBox::NoButton );
1258 // ================================================================
1260 * SALOME_InstallWizard::findItem
1261 * Searches product listview item with given symbolic name
1263 // ================================================================
1264 QCheckListItem* SALOME_InstallWizard::findItem( const QString& sName )
1266 MapProducts::Iterator mapIter;
1267 for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
1268 if ( mapIter.data().getName() == sName )
1269 return mapIter.key();
1273 // ================================================================
1275 * SALOME_InstallWizard::abort
1276 * Sets progress state to Aborted
1278 // ================================================================
1279 void SALOME_InstallWizard::abort()
1281 QString prod = progressView->findStatus( Processing );
1282 while ( !prod.isNull() ) {
1283 progressView->setStatus( prod, Aborted );
1284 prod = progressView->findStatus( Processing );
1286 prod = progressView->findStatus( Waiting );
1287 while ( !prod.isNull() ) {
1288 progressView->setStatus( prod, Aborted );
1289 prod = progressView->findStatus( Waiting );
1292 // ================================================================
1294 * SALOME_InstallWizard::reject
1295 * Reject slot, clears temporary directory and closes application
1297 // ================================================================
1298 void SALOME_InstallWizard::reject()
1301 cout << "REJECTED" << endl;
1303 if ( !exitConfirmed ) {
1304 if ( QMessageBox::information( this,
1306 tr( "Do you want to quit %1?" ).arg( getIWName() ),
1314 exitConfirmed = true;
1317 InstallWizard::reject();
1319 // ================================================================
1321 * SALOME_InstallWizard::accept
1322 * Accept slot, clears temporary directory and closes application
1324 // ================================================================
1325 void SALOME_InstallWizard::accept()
1328 cout << "ACCEPTED" << endl;
1331 InstallWizard::accept();
1333 // ================================================================
1335 * SALOME_InstallWizard::clean
1336 * Clears and removes temporary directory
1338 // ================================================================
1339 void SALOME_InstallWizard::clean()
1341 // VSR: first remove temporary files
1342 QString script = "cd ./config_files/; remove_tmp.sh '";
1343 script += tempFolder->text().stripWhiteSpace();
1345 script += QUOTE(DefineDependeces(productsMap));
1346 script += " > /dev/null";
1348 cout << "script = " << script << endl;
1350 if ( system( script.latin1() ) ) {
1352 // VSR: then try to remove created temporary directory
1353 //script = "rm -rf " + QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
1354 if ( !tmpCreated.isNull() ) {
1355 script = "rm -rf " + tmpCreated;
1356 script += " > /dev/null";
1357 if ( system( script.latin1() ) ) {
1360 cout << "script = " << script << endl;
1364 // ================================================================
1366 * SALOME_InstallWizard::pageChanged
1367 * Called when user moves from page to page
1369 // ================================================================
1370 void SALOME_InstallWizard::pageChanged( const QString & mytitle)
1372 nextButton()->setText( tr( "&Next >" ) );
1373 QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1374 QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1375 nextButton()->disconnect();
1376 connect( nextButton(), SIGNAL( clicked() ), this, SLOT( next() ) );
1377 cancelButton()->disconnect();
1378 connect( cancelButton(), SIGNAL( clicked()), this, SLOT( reject() ) );
1380 QWidget* aPage = InstallWizard::page( mytitle );
1384 if ( aPage == productsPage ) {
1386 onSelectionChanged();
1389 else if ( aPage == prestartPage ) {
1393 else if ( aPage == progressPage ) {
1394 if ( previousPage == prestartPage ) {
1396 progressView->clear();
1397 installInfo->clear();
1398 passedParams->clear();
1399 passedParams->setEnabled( false );
1400 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1401 nextButton()->setText( tr( "&Start" ) );
1402 QWhatsThis::add( nextButton(), tr( "Starts installation process" ) );
1403 QToolTip::add ( nextButton(), tr( "Starts installation process" ) );
1404 // reconnect Next button - to use it as Start button
1405 nextButton()->disconnect();
1406 connect( nextButton(), SIGNAL( clicked() ), this, SLOT( onStart() ) );
1407 nextButton()->setEnabled( true );
1408 // reconnect Cancel button to terminate process
1409 cancelButton()->disconnect();
1410 connect( cancelButton(), SIGNAL( clicked() ), this, SLOT( tryTerminate() ) );
1413 else if ( aPage == readmePage ) {
1414 QCheckListItem* item = 0;
1415 runSalomeBtn->setEnabled( ( item = findItem( "SalomePro-Bin" ) ) &&
1416 QFileInfo( targetFolder->text() + "/SalomePro-" + item->text(1) + "/salome" ).exists() );
1417 finishButton()->setEnabled( true );
1419 previousPage = aPage;
1421 cout << "previousPage = " << previousPage << endl;
1424 // ================================================================
1426 * SALOME_InstallWizard::helpClicked
1429 // ================================================================
1430 void SALOME_InstallWizard::helpClicked()
1432 if ( helpWindow == NULL ) {
1433 helpWindow = HelpWindow::openHelp( this );
1436 helpWindow->installEventFilter( this );
1439 QMessageBox::warning( this,
1440 tr( "Help file not found" ),
1441 tr( "Sorry, help is unavailable" ) );
1445 helpWindow->raise();
1446 helpWindow->setActiveWindow();
1449 // ================================================================
1451 * SALOME_InstallWizard::browseDirectory
1452 * Shows directory selection dialog
1454 // ================================================================
1455 void SALOME_InstallWizard::browseDirectory()
1457 const QObject* theSender = sender();
1458 QLineEdit* theFolder;
1459 if ( theSender == targetBtn )
1460 theFolder = targetFolder;
1461 else if (theSender == tempBtn)
1462 theFolder = tempFolder;
1465 QString typedDir = QFileDialog::getExistingDirectory( QDir::cleanDirPath( theFolder->text().stripWhiteSpace() ), this );
1466 if ( !typedDir.isNull() ) {
1467 theFolder->setText( typedDir );
1468 theFolder->end( false );
1472 // ================================================================
1474 * SALOME_InstallWizard::directoryChanged
1475 * Called when directory path (target or temp) is changed
1477 // ================================================================
1478 void SALOME_InstallWizard::directoryChanged( const QString& /*text*/ )
1482 // ================================================================
1484 * SALOME_InstallWizard::onStart
1485 * <Start> button's slot - runs installation
1487 // ================================================================
1488 void SALOME_InstallWizard::onStart()
1490 // clear list of products to install ...
1492 // ... and fill it for new process
1493 QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
1495 // if ( productsView->isBinaries( item ) || productsView->isSources( item ) || productsView->isNative( item ) ) {
1496 if ( productsMap.contains( item ) )
1497 toInstall.append( productsMap[item].getName() );
1499 item = (QCheckListItem*)( item->nextSibling() );
1501 // if something at all is selected
1502 if ( !toInstall.isEmpty() ) {
1503 // disable <Next> button
1504 nextButton()->setEnabled( false );
1505 // disable <Back> button
1506 backButton()->setEnabled ( false );
1507 // enable script parameters line edit
1508 // VSR commented: 18/09/03: passedParams->setEnabled( true );
1509 // VSR commented: 18/09/03: passedParams->setFocus();
1510 // set status for all products
1511 for ( int i = 0; i < (int)toInstall.count(); i++ ) {
1512 item = findItem( toInstall[ i ] );
1514 if ( productsView->isBinaries( item ) )
1515 type = tr( "binaries" );
1516 else if ( productsView->isSources( item ) )
1517 type = tr( "sources" );
1518 else if ( productsView->isNative( item ) )
1519 type = tr( "native" );
1521 type = tr( "not install" );
1522 progressView->addProduct( item->text(0), type, item->text(2) );
1524 // launch install script
1528 // ================================================================
1530 * SALOME_InstallWizard::onReturnPressed
1531 * Called when users tries to pass parameters for the script
1533 // ================================================================
1534 void SALOME_InstallWizard::onReturnPressed()
1536 QString txt = passedParams->text();
1537 installInfo->append( txt );
1539 shellProcess->writeToStdin( txt );
1540 passedParams->clear();
1541 progressView->setFocus();
1542 passedParams->setEnabled( false );
1543 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1546 Callback function - as response for the script finishing
1548 void SALOME_InstallWizard::productInstalled( )
1551 cout << "process exited" << endl;
1553 if ( shellProcess->normalExit() ) {
1555 cout << "...normal exit" << endl;
1557 // normal exit - try to proceed installation further
1562 cout << "...abnormal exit" << endl;
1564 // installation aborted
1566 // clear script passed parameters lineedit
1567 passedParams->clear();
1568 passedParams->setEnabled( false );
1569 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1570 // enable <Next> button
1571 nextButton()->setEnabled( true );
1572 nextButton()->setText( tr( "&Next >" ) );
1573 QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1574 QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1575 nextButton()->disconnect();
1576 connect( nextButton(), SIGNAL( clicked() ), this, SLOT( next() ) );
1577 // enable <Back> button
1578 backButton()->setEnabled( true );
1581 // ================================================================
1583 * SALOME_InstallWizard::tryTerminate
1584 * Slot, called when <Cancel> button is clicked during installation script running
1586 // ================================================================
1587 void SALOME_InstallWizard::tryTerminate()
1589 if ( shellProcess->isRunning() ) {
1590 if ( QMessageBox::information( this,
1592 tr( "Do you want to quit %1?" ).arg( getIWName() ),
1600 exitConfirmed = true;
1601 // if process still running try to terminate it first
1602 shellProcess->tryTerminate();
1604 //QTimer::singleShot( 3000, this, SLOT( onCancel() ) );
1605 connect( shellProcess, SIGNAL( processExited() ), this, SLOT( onCancel() ) );
1608 // else just quit install wizard
1612 // ================================================================
1614 * SALOME_InstallWizard::onCancel
1615 * Kills installation process and quits application
1617 // ================================================================
1618 void SALOME_InstallWizard::onCancel()
1620 shellProcess->kill();
1623 // ================================================================
1625 * SALOME_InstallWizard::onSelectionChanged
1626 * Called when selection is changed in the products list view
1628 // ================================================================
1629 void SALOME_InstallWizard::onSelectionChanged()
1631 productsInfo->clear();
1632 QListViewItem* item = productsView->selectedItem();
1635 if ( item->parent() )
1636 item = item->parent();
1637 QCheckListItem* aItem = (QCheckListItem*)item;
1638 if ( !productsMap.contains( aItem ) )
1640 Dependancies dep = productsMap[ aItem ];
1641 QString text = "<b>" + aItem->text(0) + "</b>" + "<br>";
1642 if ( !aItem->text(1).stripWhiteSpace().isEmpty() )
1643 text += tr( "Version" ) + ": " + aItem->text(1) + "<br>";
1645 if ( !dep.getDescription().isEmpty() ) {
1646 text += "<i>" + dep.getDescription() + "</i><br><br>";
1648 text += tr( "User choice" ) + ": ";
1649 long totSize = 0, tempSize = 0;
1650 if ( productsView->isBinaries( aItem ) ) {
1651 text += "<b>" + tr( "install binaries" ) + "</b>" + "<br>";
1652 totSize = dep.getSize();
1654 else if ( productsView->isSources( aItem ) ) {
1655 text += "<b>" + tr( "install sources" ) + "</b>" + "<br>";
1656 totSize = dep.getSize( true );
1657 tempSize = dep.getTempSize();
1659 else if ( productsView->isNative( aItem ) ) {
1660 text += "<b>" + tr( "use native" ) + "</b>" + "<br>";
1663 text += "<b>" + tr( "not install" ) + "</b>" + "<br>";
1666 text += tr( "Disk space required" ) + ": " + QString::number( totSize ) + " Kb<br>";
1667 text += tr( "Disk space for tmp files required" ) + ": " + QString::number( tempSize ) + " Kb<br>";
1669 QString req = ( dep.getDependancies().count() > 0 ? dep.getDependancies().join(", ") : tr( "none" ) );
1670 text += tr( "Prerequisites" ) + ": " + req;
1671 productsInfo->setText( text );
1673 // ================================================================
1675 * SALOME_InstallWizard::onItemToggled
1676 * Called when user checks/unchecks any product item
1677 * Recursively sets all prerequisites and updates "Next" button state
1679 // ================================================================
1680 void SALOME_InstallWizard::onItemToggled( QCheckListItem* item )
1682 if ( prerequisites->isChecked() ) {
1683 if ( item->parent() )
1684 item = (QCheckListItem*)( item->parent() );
1685 if ( productsMap.contains( item ) ) {
1686 productsView->blockSignals( true );
1687 setPrerequisites( item );
1688 productsView->blockSignals( false );
1691 onSelectionChanged();
1694 // ================================================================
1696 * SALOME_InstallWizard::onProdBtn
1697 * This slot is called when user clicks one of <Select Sources>,
1698 * <Select Binaries>, <Unselect All> buttons ( products page )
1700 // ================================================================
1701 void SALOME_InstallWizard::onProdBtn()
1703 const QObject* snd = sender();
1704 productsView->blockSignals( true );
1705 if ( snd == unselectBtn ) {
1706 QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
1708 productsView->setNone( item );
1709 item = (QCheckListItem*)( item->nextSibling() );
1712 productsView->blockSignals( false );
1713 onSelectionChanged();
1716 // ================================================================
1718 * SALOME_InstallWizard::wroteToStdin
1719 * QProcess slot: -->something was written to stdin
1721 // ================================================================
1722 void SALOME_InstallWizard::wroteToStdin( )
1725 cout << "Something was sent to stdin" << endl;
1728 // ================================================================
1730 * SALOME_InstallWizard::readFromStdout
1731 * QProcess slot: -->something was written to stdout
1733 // ================================================================
1734 void SALOME_InstallWizard::readFromStdout( )
1737 cout << "Something was sent to stdout" << endl;
1739 while ( shellProcess->canReadLineStdout() ) {
1740 installInfo->append( QString( shellProcess->readLineStdout() ) );
1741 installInfo->scrollToBottom();
1743 QString str( shellProcess->readStdout() );
1744 if ( !str.isEmpty() ) {
1745 installInfo->append( str );
1746 installInfo->scrollToBottom();
1749 // ================================================================
1751 * SALOME_InstallWizard::readFromStderr
1752 * QProcess slot: -->something was written to stderr
1754 // ================================================================
1755 void SALOME_InstallWizard::readFromStderr( )
1758 cout << "Something was sent to stderr" << endl;
1760 while ( shellProcess->canReadLineStderr() ) {
1761 installInfo->append( QString( shellProcess->readLineStderr() ) );
1762 installInfo->scrollToBottom();
1764 QString str( shellProcess->readStderr() );
1765 if ( !str.isEmpty() ) {
1766 installInfo->append( str );
1767 installInfo->scrollToBottom();
1769 passedParams->setEnabled( true );
1770 passedParams->setFocus();
1771 QFont f = parametersLab->font(); f.setBold( true ); parametersLab->setFont( f );
1773 // ================================================================
1775 * SALOME_InstallWizard::setDependancies
1776 * Sets dependancies for the product item
1778 // ================================================================
1779 void SALOME_InstallWizard::setDependancies( QCheckListItem* item, Dependancies dep)
1781 productsMap[item] = dep;
1783 // ================================================================
1785 * SALOME_InstallWizard::polish
1786 * Polishing of the widget - to set right initial size
1788 // ================================================================
1789 void SALOME_InstallWizard::polish()
1792 InstallWizard::polish();
1794 // ================================================================
1796 * SALOME_InstallWizard::updateCaption
1797 * Updates caption according to the current page number
1799 // ================================================================
1800 void SALOME_InstallWizard::updateCaption()
1802 QWidget* aPage = InstallWizard::currentPage();
1805 InstallWizard::setCaption( tr( myCaption ) + " " +
1806 tr( getIWName() ) + " - " +
1807 tr( "Step %1 of %2").arg( QString::number( this->indexOf( aPage )+1 ) ).arg( QString::number( this->pageCount() ) ) );