1 // File : SALOME_InstallWizard.cxx
2 // Created : Thu Dec 18 12:01:00 2002
3 // Author : Vadim SANDLER
5 // Module : Installation Wizard
6 // Copyright : 2004-2005 CEA
10 #include "SALOME_InstallWizard.hxx"
11 #include "SALOME_ProductsView.hxx"
12 #include "SALOME_ProgressView.hxx"
13 #include "SALOME_XmlHandler.hxx"
14 #include "SALOME_HelpWindow.hxx"
18 #include <qlineedit.h>
19 #include <qpushbutton.h>
20 #include <qlistview.h>
22 #include <qtextedit.h>
23 #include <qtextbrowser.h>
25 #include <qcheckbox.h>
26 #include <qsplitter.h>
28 #include <qfiledialog.h>
29 #include <qapplication.h>
30 #include <qfileinfo.h>
31 #include <qmessagebox.h>
34 #include <qwhatsthis.h>
38 #include <qwaitcondition.h>
50 #define max( x, y ) ( x ) > ( y ) ? ( x ) : ( y )
53 QString tmpDirName() { return QString( "/INSTALLWORK" ) + QString::number( getpid() ); }
54 #define TEMPDIRNAME tmpDirName()
56 // ================================================================
59 * Class for executing systen commands
61 // ================================================================
62 static QMutex myMutex(false);
63 static QWaitCondition myWC;
64 class QProcessThread: public QThread
66 typedef QPtrList<QCheckListItem> ItemList;
68 QProcessThread( SALOME_InstallWizard* iw ) : QThread(), myWizard( iw ) { myItems.setAutoDelete( false ); }
70 void addCommand( QCheckListItem* item, const QString& cmd ) {
71 myItems.append( item );
72 myCommands.push_back( cmd );
75 bool hasCommands() const { return myCommands.count() > 0; }
76 void clearCommands() { myCommands.clear(); myItems.clear(); }
79 while ( hasCommands() ) {
80 ___MESSAGE___( "QProcessThread::run - Processing command : " << myCommands[ 0 ].latin1() );
81 int result = system( myCommands[ 0 ] ) / 256; // return code is <errno> * 256
82 ___MESSAGE___( "QProcessThread::run - Result : " << result );
83 QCheckListItem* item = myItems.first();
84 myCommands.pop_front();
85 myItems.removeFirst();
87 SALOME_InstallWizard::postValidateEvent( myWizard, result, (void*)item );
95 QStringList myCommands;
97 SALOME_InstallWizard* myWizard;
100 // ================================================================
105 // ================================================================
106 class WarnDialog: public QDialog
108 static WarnDialog* myDlg;
111 WarnDialog( QWidget* parent )
112 : QDialog( parent, "WarnDialog", true, WDestructiveClose ) {
113 setCaption( tr( "Information" ) );
115 QLabel* lab = new QLabel( tr( "Please, wait while checking native products configuration ..." ), this );
116 lab->setAlignment( AlignCenter );
117 lab->setFrameStyle( QFrame::Box | QFrame::Plain );
118 QVBoxLayout* l = new QVBoxLayout( this );
121 this->setFixedSize( lab->sizeHint().width() + 50,
122 lab->sizeHint().height() * 5 );
124 void accept() { return; }
125 void reject() { return; }
126 void closeEvent( QCloseEvent* e) { if ( !myCloseFlag ) return; QDialog::closeEvent( e ); }
128 ~WarnDialog() { myDlg = 0; }
130 static void showWarnDlg( QWidget* parent, bool show ) {
133 myDlg = new WarnDialog( parent );
134 QSize sh = myDlg->size();
135 myDlg->move( parent->x() + (parent->width()-sh.width())/2,
136 parent->y() + (parent->height()-sh.height())/2 );
144 myDlg->myCloseFlag = true;
149 static bool isWarnDlgShown() { return myDlg != 0; }
151 WarnDialog* WarnDialog::myDlg = 0;
153 // ================================================================
155 * DefineDependeces [ static ]
156 * Defines list of dependancies as string separated by space symbols
158 // ================================================================
159 static QString DefineDependeces(MapProducts& theProductsMap)
161 QStringList aProducts;
162 for ( MapProducts::Iterator mapIter = theProductsMap.begin(); mapIter != theProductsMap.end(); ++mapIter ) {
163 QCheckListItem* item = mapIter.key();
164 Dependancies dep = mapIter.data();
165 QStringList deps = dep.getDependancies();
166 for (int i = 0; i<(int)deps.count(); i++ ) {
167 if ( !aProducts.contains( deps[i] ) )
168 aProducts.append( deps[i] );
170 if ( !aProducts.contains( item->text(0) ) )
171 aProducts.append( item->text(0) );
173 return aProducts.join(" ");
176 #define QUOTE(arg) QString("'") + QString(arg) + QString("'")
178 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
179 T H E O L D I M P L E M E N T A T I O N
180 static QString DefineDependeces(MapProducts& theProductsMap, QCheckListItem* product ){
181 QStringList aProducts;
182 if ( theProductsMap.contains( product ) ) {
183 Dependancies dep = theProductsMap[ product ];
184 QStringList deps = dep.getDependancies();
185 for (int i = 0; i<(int)deps.count(); i++ ) {
186 aProducts.append( deps[i] );
189 return QString("\"") + aProducts.join(" ") + QString("\"");
191 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
193 // ================================================================
196 * Makes directory recursively, returns false if not succedes
198 // ================================================================
199 static bool makeDir( const QString& theDir, QString& theCreated )
201 if ( theDir.isEmpty() )
203 QString aDir = QDir::cleanDirPath( QFileInfo( theDir ).absFilePath() );
205 while ( start > 0 ) {
206 start = aDir.find( QDir::separator(), start );
208 QFileInfo fi( aDir.left( start ) );
209 if ( !fi.exists() ) {
210 // VSR: Create directory and set permissions to allow other users to remove it
211 QString script = "mkdir " + fi.absFilePath();
212 script += "; chmod 777 " + fi.absFilePath();
213 script += " > /dev/null";
214 if ( system( script.latin1() ) )
216 // VSR: Remember the top of the created directory (to remove it in the end of the installation)
217 if ( theCreated.isNull() )
218 theCreated = fi.absFilePath();
223 if ( !QFileInfo( aDir ).exists() ) {
224 // VSR: Create directory, other users should NOT have possibility to remove it!!!
225 QString script = "mkdir " + aDir;
226 script += " > /dev/null";
227 if ( system( script.latin1() ) )
229 // VSR: Remember the top of the created directory (to remove it in the end of the installation)
230 if ( theCreated.isNull() )
235 // ================================================================
237 * readFile [ static ]
238 * Reads the file, returns false if can't open it
240 // ================================================================
241 static bool readFile( const QString& fileName, QString& text )
243 if ( QFile::exists( fileName ) ) {
244 QFile file( fileName );
245 if ( file.open( IO_ReadOnly ) ) {
246 QTextStream stream( &file );
248 while ( !stream.eof() ) {
249 line = stream.readLine(); // line of text excluding '\n'
258 // ================================================================
260 * hasSpace [ static ]
261 * Checks if string contains spaces; used to check directory paths
263 // ================================================================
264 static bool hasSpace( const QString& dir )
266 for ( int i = 0; i < (int)dir.length(); i++ ) {
267 if ( dir[ i ].isSpace() )
273 // ================================================================
275 * QMyCheckBox class : custom check box
276 * The only goal is to give access to the protected setState() method
278 // ================================================================
279 class QMyCheckBox: public QCheckBox
282 QMyCheckBox( const QString& text, QWidget* parent, const char* name = 0 ) : QCheckBox ( text, parent, name ) {}
283 void setState ( ToggleState s ) { QCheckBox::setState( s ); }
286 // ================================================================
288 * SALOME_InstallWizard::SALOME_InstallWizard
291 // ================================================================
292 SALOME_InstallWizard::SALOME_InstallWizard(QString aXmlFileName)
293 : InstallWizard( qApp->desktop(), "SALOME_InstallWizard", false, 0 ),
297 exitConfirmed( false )
299 myIWName = tr( "Installation Wizard" );
300 tmpCreated = QString::null;
301 xmlFileName = aXmlFileName;
302 QFont fnt = font(); fnt.setPointSize( 14 ); fnt.setBold( true );
306 setIcon( QPixmap( ( const char** ) image0_data ) );
308 setSizeGripEnabled( true );
311 addLogo( QPixmap( (const char**)image1_data ) );
315 setCaption( tr( "PAL/SALOME %1" ).arg( myVersion ) );
316 setCopyright( tr( "Copyright (C) 2004 CEA" ) );
317 setLicense( tr( "All right reserved" ) );
320 ___MESSAGE___( "Config. file : " << xmlFileName );
323 QFile xmlfile(xmlFileName);
324 if ( xmlfile.exists() ) {
325 QXmlInputSource source( &xmlfile );
326 QXmlSimpleReader reader;
328 StructureParser* handler = new StructureParser( this );
329 reader.setContentHandler( handler );
330 reader.parse( source );
333 // create instance of class for starting shell install script
334 shellProcess = new QProcess( this, "shellProcess" );
336 // create introduction page
338 // create products page
340 // create prestart page
342 // create progress page
344 // create readme page
348 QWhatsThis::add( backButton(), tr( "Returns to the previous step of the installation procedure" ) );
349 QToolTip::add ( backButton(), tr( "Returns to the previous step of the installation procedure" ) );
350 QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
351 QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
352 QWhatsThis::add( finishButton(), tr( "Finishes installation and quits program" ) );
353 QToolTip::add ( finishButton(), tr( "Finishes installation and quits program" ) );
354 QWhatsThis::add( cancelButton(), tr( "Cancels installation and quits program" ) );
355 QToolTip::add ( cancelButton(), tr( "Cancels installation and quits program" ) );
356 QWhatsThis::add( helpButton(), tr( "Displays help information window" ) );
357 QToolTip::add ( helpButton(), tr( "Displays help information window" ) );
359 // common signals connections
360 connect( this, SIGNAL( selected( const QString& ) ),
361 this, SLOT( pageChanged( const QString& ) ) );
362 connect( this, SIGNAL( helpClicked() ), this, SLOT( helpClicked() ) );
363 // catch signals from launched script
364 connect(shellProcess, SIGNAL( readyReadStdout() ), this, SLOT( readFromStdout() ) );
365 connect(shellProcess, SIGNAL( readyReadStderr() ), this, SLOT( readFromStderr() ) );
366 connect(shellProcess, SIGNAL( processExited() ), this, SLOT( productInstalled() ) );
367 connect(shellProcess, SIGNAL( wroteToStdin() ), this, SLOT( wroteToStdin() ) );
369 // create validation thread
370 myThread = new QProcessThread( this );
372 // ================================================================
374 * SALOME_InstallWizard::~SALOME_InstallWizard
377 // ================================================================
378 SALOME_InstallWizard::~SALOME_InstallWizard()
380 shellProcess->kill(); // kill it for sure
381 QString script = "kill -9 ";
382 int PID = (int)shellProcess->processIdentifier();
384 script += QString::number( PID );
385 script += " > /dev/null";
386 ___MESSAGE___( "script: " << script.latin1() );
387 if ( system( script.latin1() ) ) {
392 // ================================================================
394 * SALOME_InstallWizard::eventFilter
395 * Event filter, spies for Help window closing
397 // ================================================================
398 bool SALOME_InstallWizard::eventFilter( QObject* object, QEvent* event )
400 if ( object && object == helpWindow && event->type() == QEvent::Close )
402 return InstallWizard::eventFilter( object, event );
404 // ================================================================
406 * SALOME_InstallWizard::closeEvent
407 * Close event handler
409 // ================================================================
410 void SALOME_InstallWizard::closeEvent( QCloseEvent* ce )
412 if ( WarnDialog::isWarnDlgShown() ) {
416 if ( !exitConfirmed ) {
417 if ( QMessageBox::information( this,
419 tr( "Do you want to quit %1?" ).arg( getIWName() ),
429 exitConfirmed = true;
434 // ================================================================
436 * SALOME_InstallWizard::setupIntroPage
437 * Creates introduction page
439 // ================================================================
440 void SALOME_InstallWizard::setupIntroPage()
443 introPage = new QWidget( this, "IntroPage" );
444 QGridLayout* pageLayout = new QGridLayout( introPage );
445 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
446 // create logo picture
447 QPixmap logo( (const char**)SALOME_Logo_xpm );
448 logoLab = new QLabel( introPage );
449 logoLab->setPixmap( logo );
450 logoLab->setScaledContents( false );
451 logoLab->setFrameStyle( QLabel::Plain | QLabel::Box );
452 logoLab->setAlignment( AlignCenter );
453 // create version box
454 QVBox* versionBox = new QVBox( introPage ); versionBox->setSpacing( 6 );
455 versionBox->setFrameStyle( QVBox::Panel | QVBox::Sunken );
456 QWidget* stretch1 = new QWidget( versionBox ); versionBox->setStretchFactor( stretch1, 5 );
457 versionLab = new QLabel( QString("%1 %2").arg( tr( "Version" ) ).arg(myVersion), versionBox );
458 versionLab->setAlignment( AlignCenter );
459 copyrightLab = new QLabel( myCopyright, versionBox );
460 copyrightLab->setAlignment( AlignCenter );
461 licenseLab = new QLabel( myLicense, versionBox );
462 licenseLab->setAlignment( AlignCenter );
463 QWidget* stretch2 = new QWidget( versionBox ); versionBox->setStretchFactor( stretch2, 5 );
465 info = new QLabel( introPage );
466 info->setText( tr( "This program will install <b>%1</b>."
467 "<br><br>The wizard will also help you to install all products "
468 "which are necessary for <b>%2</b> and setup "
469 "your environment.<br><br>Click <code>Cancel</code> button to abort "
470 "installation and quit. Click <code>Next</code> button to continue with the "
471 "installation program." ).arg( myCaption ).arg( myCaption ) );
472 info->setFrameStyle( QLabel::WinPanel | QLabel::Sunken );
473 info->setMargin( 6 );
474 info->setAlignment( WordBreak );
475 info->setMinimumWidth( 250 );
476 QPalette pal = info->palette();
477 pal.setColor( QColorGroup::Background, QApplication::palette().active().base() );
478 info->setPalette( pal );
479 info->setLineWidth( 2 );
481 pageLayout->addWidget( logoLab, 0, 0 );
482 pageLayout->addWidget( versionBox, 1, 0 );
483 pageLayout->addMultiCellWidget( info, 0, 1, 1, 1 );
484 pageLayout->setColStretch( 1, 5 );
485 pageLayout->setRowStretch( 1, 5 );
487 addPage( introPage, tr( "Introduction" ) );
489 // ================================================================
491 * SALOME_InstallWizard::setupProductsPage
492 * Creates products page
494 // ================================================================
495 void SALOME_InstallWizard::setupProductsPage()
498 productsPage = new QWidget( this, "ProductsPage" );
499 QGridLayout* pageLayout = new QGridLayout( productsPage );
500 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
502 QLabel* targetLab = new QLabel( tr( "Type the target directory:" ), productsPage );
503 targetFolder = new QLineEdit( productsPage );
504 QWhatsThis::add( targetFolder, tr( "Enter target root directory where products will be installed" ) );
505 QToolTip::add ( targetFolder, tr( "Enter target root directory where products will be installed" ) );
506 targetBtn = new QPushButton( tr( "Browse..." ), productsPage );
507 QWhatsThis::add( targetBtn, tr( "Click this to browse target directory" ) );
508 QToolTip::add ( targetBtn, tr( "Click this to browse target directory" ) );
509 // create advanced mode widgets container
510 moreBox = new QWidget( productsPage );
511 QGridLayout* moreBoxLayout = new QGridLayout( moreBox );
512 moreBoxLayout->setMargin( 0 ); moreBoxLayout->setSpacing( 6 );
514 QLabel* tempLab = new QLabel( tr( "Type the directory for the temporary files:" ), moreBox );
515 tempFolder = new QLineEdit( moreBox );
516 // tempFolder->setText( "/tmp" ); // default is /tmp directory
517 QWhatsThis::add( tempFolder, tr( "Enter directory where to put temporary files" ) );
518 QToolTip::add ( tempFolder, tr( "Enter directory where to put temporary files" ) );
519 tempBtn = new QPushButton( tr( "Browse..." ), moreBox );
520 tempBtn->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
521 QWhatsThis::add( tempBtn, tr( "Click this to browse temporary directory" ) );
522 QToolTip::add ( tempBtn, tr( "Click this to browse temporary directory" ) );
523 // create products list
524 productsView = new ProductsView( moreBox );
525 productsView->setMinimumSize( 250, 180 );
526 QWhatsThis::add( productsView, tr( "This view lists the products you wish to be installed" ) );
527 QToolTip::add ( productsView, tr( "This view lists the products you wish to be installed" ) );
529 productsInfo = new QTextBrowser( moreBox );
530 productsInfo->setMinimumSize( 270, 135 );
531 QWhatsThis::add( productsInfo, tr( "Shows info about the product: required disk space and prerequisites" ) );
532 QToolTip::add ( productsInfo, tr( "Shows info about the product: required disk space and prerequisites" ) );
534 QLabel* reqLab1 = new QLabel( tr( "Total disk space required:" ), moreBox );
535 QWhatsThis::add( reqLab1, tr( "Shows total disk space required for installing selected products" ) );
536 QToolTip::add ( reqLab1, tr( "Shows total disk space required for installing selected products" ) );
537 requiredSize = new QLabel( moreBox );
538 requiredSize->setMinimumWidth( 100 );
539 QWhatsThis::add( requiredSize, tr( "Shows total disk space required for installing selected products" ) );
540 QToolTip::add ( requiredSize, tr( "Shows total disk space required for installing selected products" ) );
541 QLabel* reqLab2 = new QLabel( tr( "Space for temporary files:" ), moreBox );
542 QWhatsThis::add( reqLab2, tr( "Shows additional disk space which is required for temporary files" ) );
543 QToolTip::add ( reqLab2, tr( "Shows additional disk space which is required for temporary files" ) );
544 requiredTemp = new QLabel( moreBox );
545 requiredTemp->setMinimumWidth( 100 );
546 QWhatsThis::add( requiredTemp, tr( "Shows additional disk space which is required for temporary files" ) );
547 QToolTip::add ( requiredTemp, tr( "Shows additional disk space which is required for temporary files" ) );
548 QFont fnt = reqLab1->font();
550 reqLab1->setFont( fnt );
551 requiredSize->setFont( fnt );
552 reqLab2->setFont( fnt );
553 requiredTemp->setFont( fnt );
554 QGridLayout* sizeLayout = new QGridLayout; sizeLayout->setMargin( 0 ); sizeLayout->setSpacing( 6 );
555 sizeLayout->addWidget( reqLab1, 0, 0 );
556 sizeLayout->addWidget( requiredSize, 0, 1 );
557 sizeLayout->addWidget( reqLab2, 1, 0 );
558 sizeLayout->addWidget( requiredTemp, 1, 1 );
559 // prerequisites checkbox
560 prerequisites = new QCheckBox( tr( "Auto set prerequisites products" ), moreBox );
561 prerequisites->setChecked( true );
562 QWhatsThis::add( prerequisites, tr( "Check this if you want prerequisites products to be set on automatically" ) );
563 QToolTip::add ( prerequisites, tr( "Check this if you want prerequisites products to be set on automatically" ) );
564 // <Unselect All> button
565 unselectBtn = new QPushButton( tr( "&Unselect All" ), moreBox );
566 QWhatsThis::add( unselectBtn, tr( "Unselects all products" ) );
567 QToolTip::add ( unselectBtn, tr( "Unselects all products" ) );
568 // <SALOME sources> / <SALOME binaries> tri-state checkboxes
569 selectSrcBtn = new QMyCheckBox( tr( "SALOME sources" ), moreBox );
570 selectSrcBtn->setTristate( true );
571 QWhatsThis::add( selectSrcBtn, tr( "Selects/unselects SALOME sources" ) );
572 QToolTip::add ( selectSrcBtn, tr( "Selects/unselects SALOME sources" ) );
573 selectBinBtn = new QMyCheckBox( tr( "SALOME binaries" ), moreBox );
574 selectBinBtn->setTristate( true );
575 QWhatsThis::add( selectBinBtn, tr( "Selects/unselects SALOME binaries" ) );
576 QToolTip::add ( selectBinBtn, tr( "Selects/unselects SALOME binaries" ) );
577 QVBoxLayout* btnLayout = new QVBoxLayout; btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );
578 btnLayout->addWidget( unselectBtn );
579 btnLayout->addWidget( selectSrcBtn );
580 btnLayout->addWidget( selectBinBtn );
581 // layouting advancet mode widgets
582 moreBoxLayout->addMultiCellWidget( tempLab, 0, 0, 0, 2 );
583 moreBoxLayout->addMultiCellWidget( tempFolder, 1, 1, 0, 1 );
584 moreBoxLayout->addWidget ( tempBtn, 1, 2 );
585 moreBoxLayout->addMultiCellWidget( productsView, 2, 5, 0, 0 );
586 moreBoxLayout->addMultiCellWidget( productsInfo, 2, 2, 1, 2 );
587 moreBoxLayout->addMultiCellWidget( prerequisites,3, 3, 1, 2 );
588 moreBoxLayout->addMultiCellLayout( btnLayout, 4, 4, 1, 2 );
589 moreBoxLayout->addMultiCellLayout( sizeLayout, 5, 5, 1, 2 );
591 moreBtn = new QPushButton( tr( "More..." ), productsPage );
593 pageLayout->addMultiCellWidget( targetLab, 0, 0, 0, 1 );
594 pageLayout->addWidget ( targetFolder, 1, 0 );
595 pageLayout->addWidget ( targetBtn, 1, 1 );
596 pageLayout->addMultiCellWidget( moreBox, 2, 2, 0, 1 );
597 pageLayout->addWidget ( moreBtn, 3, 1 );
598 pageLayout->setRowStretch( 2, 5 );
599 //pageLayout->addRowSpacing( 6, 10 );
601 QFile xmlfile(xmlFileName);
602 if ( xmlfile.exists() ) {
603 QXmlInputSource source( &xmlfile );
604 QXmlSimpleReader reader;
606 StructureParser* handler = new StructureParser( this );
607 handler->setProductsList(productsView);
608 handler->setTargetDir(targetFolder);
609 handler->setTempDir(tempFolder);
610 reader.setContentHandler( handler );
611 reader.parse( source );
613 // set first item to be selected
614 if ( productsView->childCount() > 0 ) {
615 productsView->setSelected( productsView->firstChild(), true );
616 onSelectionChanged();
619 addPage( productsPage, tr( "Installation settings" ) );
620 // connecting signals
621 connect( productsView, SIGNAL( selectionChanged() ),
622 this, SLOT( onSelectionChanged() ) );
623 connect( productsView, SIGNAL( itemToggled( QCheckListItem* ) ),
624 this, SLOT( onItemToggled( QCheckListItem* ) ) );
625 connect( unselectBtn, SIGNAL( clicked() ), this, SLOT( onProdBtn() ) );
626 connect( selectSrcBtn, SIGNAL( stateChanged(int) ),
627 this, SLOT( onProdBtn() ) );
628 connect( selectBinBtn, SIGNAL( stateChanged(int) ),
629 this, SLOT( onProdBtn() ) );
630 // connecting signals
631 connect( targetFolder, SIGNAL( textChanged( const QString& ) ),
632 this, SLOT( directoryChanged( const QString& ) ) );
633 connect( targetBtn, SIGNAL( clicked() ), this, SLOT( browseDirectory() ) );
634 connect( tempFolder, SIGNAL( textChanged( const QString& ) ),
635 this, SLOT( directoryChanged( const QString& ) ) );
636 connect( tempBtn, SIGNAL( clicked() ), this, SLOT( browseDirectory() ) );
637 connect( moreBtn, SIGNAL( clicked() ), this, SLOT( onMoreBtn() ) );
638 // start on default - non-advanced - mode
641 // ================================================================
643 * SALOME_InstallWizard::setupCheckPage
644 * Creates prestart page
646 // ================================================================
647 void SALOME_InstallWizard::setupCheckPage()
650 prestartPage = new QWidget( this, "PrestartPage" );
651 QVBoxLayout* pageLayout = new QVBoxLayout( prestartPage );
652 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
654 choices = new QTextEdit( prestartPage );
655 choices->setReadOnly( true );
656 choices->setTextFormat( RichText );
657 choices->setUndoRedoEnabled ( false );
658 QWhatsThis::add( choices, tr( "Displays information about installation settings you made" ) );
659 QToolTip::add ( choices, tr( "Displays information about installation settings you made" ) );
660 QPalette pal = choices->palette();
661 pal.setColor( QColorGroup::Base, QApplication::palette().active().background() );
662 choices->setPalette( pal );
663 choices->setMinimumHeight( 10 );
665 pageLayout->addWidget( choices );
666 pageLayout->setStretchFactor( choices, 5 );
668 addPage( prestartPage, tr( "Check your choice" ) );
670 // ================================================================
672 * SALOME_InstallWizard::setupProgressPage
673 * Creates progress page
675 // ================================================================
676 void SALOME_InstallWizard::setupProgressPage()
679 progressPage = new QWidget( this, "progressPage" );
680 QGridLayout* pageLayout = new QGridLayout( progressPage );
681 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
683 splitter = new QSplitter( Vertical, progressPage );
684 splitter->setOpaqueResize( true );
685 // the parent for the widgets
686 QWidget* widget = new QWidget( splitter );
687 QGridLayout* layout = new QGridLayout( widget );
688 layout->setMargin( 0 ); layout->setSpacing( 6 );
689 // installation progress view box
690 installInfo = new QTextEdit( widget );
691 installInfo->setReadOnly( true );
692 installInfo->setTextFormat( RichText );
693 installInfo->setUndoRedoEnabled ( false );
694 installInfo->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
695 installInfo->setMinimumSize( 100, 10 );
696 QWhatsThis::add( installInfo, tr( "Displays installation process" ) );
697 QToolTip::add ( installInfo, tr( "Displays installation process" ) );
698 // parameters for the script
699 parametersLab = new QLabel( tr( "Enter your answer here:" ), widget );
700 passedParams = new QLineEdit ( widget );
701 QWhatsThis::add( passedParams, tr( "Use this field to enter answer for the running script when it is necessary") );
702 QToolTip::add ( passedParams, tr( "Use this field to enter answer for the running script when it is necessary") );
704 layout->addWidget( installInfo, 0, 0 );
705 layout->addWidget( parametersLab, 1, 0 );
706 layout->addWidget( passedParams, 2, 0 );
707 layout->addRowSpacing( 3, 6 );
708 // the parent for the widgets
709 widget = new QWidget( splitter );
710 layout = new QGridLayout( widget );
711 layout->setMargin( 0 ); layout->setSpacing( 6 );
712 // installation results view box
713 QLabel* resultLab = new QLabel( tr( "Installation Status:" ), widget );
714 progressView = new ProgressView( widget );
715 progressView->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
716 progressView->setMinimumSize( 100, 10 );
717 QWhatsThis::add( progressView, tr( "Displays installation status" ) );
718 QToolTip::add ( progressView, tr( "Displays installation status" ) );
720 layout->addRowSpacing( 0, 6 );
721 layout->addWidget( resultLab, 1, 0 );
722 layout->addWidget( progressView, 2, 0 );
724 pageLayout->addWidget( splitter, 0, 0 );
726 addPage( progressPage, tr( "Installation progress" ) );
728 connect( passedParams, SIGNAL( returnPressed() ), this, SLOT( onReturnPressed() ) ) ;
730 // ================================================================
732 * SALOME_InstallWizard::setupReadmePage
733 * Creates readme page
735 // ================================================================
736 void SALOME_InstallWizard::setupReadmePage()
739 readmePage = new QWidget( this, "ReadmePage" );
740 QVBoxLayout* pageLayout = new QVBoxLayout( readmePage );
741 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
742 // README info text box
743 readme = new QTextEdit( readmePage );
744 readme->setReadOnly( true );
745 readme->setTextFormat( PlainText );
746 readme->setFont( QFont( "Fixed", 10 ) );
747 readme->setUndoRedoEnabled ( false );
748 QWhatsThis::add( readme, tr( "Displays README information" ) );
749 QToolTip::add ( readme, tr( "Displays README information" ) );
750 QPalette pal = readme->palette();
751 pal.setColor( QColorGroup::Base, QApplication::palette().active().background() );
752 readme->setPalette( pal );
753 readme->setMinimumHeight( 10 );
754 // <Launch SALOME> button
755 runSalomeBtn = new QPushButton( tr( "Launch SALOME" ), readmePage );
756 QWhatsThis::add( runSalomeBtn, tr( "Click this button to run SALOME desktop" ) );
757 QToolTip::add ( runSalomeBtn, tr( "Click this button to run SALOME desktop" ) );
758 QHBoxLayout* hLayout = new QHBoxLayout;
759 hLayout->addWidget( runSalomeBtn ); hLayout->addStretch();
761 pageLayout->addWidget( readme );
762 pageLayout->setStretchFactor( readme, 5 );
763 pageLayout->addLayout( hLayout );
764 // connecting signals
765 connect( runSalomeBtn, SIGNAL( clicked() ), this, SLOT( onLaunchSalome() ) );
766 // loading README file
767 QString readmeFile = QDir::currentDirPath() + "/README";
769 if ( readFile( readmeFile, text ) )
770 readme->setText( text );
772 readme->setText( tr( "README file has not been found" ) );
774 addPage( readmePage, tr( "Finish installation" ) );
776 // ================================================================
778 * SALOME_InstallWizard::showChoiceInfo
779 * Displays choice info
781 // ================================================================
782 void SALOME_InstallWizard::showChoiceInfo()
786 long totSize, tempSize;
787 checkSize( &totSize, &tempSize );
791 if ( !xmlFileName.isEmpty() ) {
792 text += tr( "Configuration file" )+ ": <b>" + xmlFileName + "</b><br>";
795 if ( !myOS.isEmpty() ) {
796 text += tr( "Target platform" ) + ": <b>" + myOS + "</b><br>";
799 text += tr( "Products to be used" ) + ":<ul>";
800 QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
802 if ( productsMap.contains( item ) ) {
803 if ( item->childCount() > 0 ) {
804 if ( productsView->isNative( item ) ) {
805 text += "<li><b>" + item->text() + "</b> " + tr( "as native" ) + "<br>";
810 item = (QCheckListItem*)( item->nextSibling() );
813 text += "<li><b>" + tr( "none" ) + "</b><br>";
817 text += tr( "Products to be installed" ) + ":<ul>";
818 item = (QCheckListItem*)( productsView->firstChild() );
820 if ( productsMap.contains( item ) ) {
821 if ( item->childCount() > 0 ) {
822 if ( productsView->isBinaries( item ) ) {
823 text += "<li><b>" + item->text() + "</b> " + tr( "as binaries" ) + "<br>";
826 else if ( productsView->isSources( item ) ) {
827 text+= "<li><b>" + item->text() + "</b> " + tr( "as sources" ) + "<br>";
831 else if ( item->isOn() ) {
832 text+= "<li><b>" + item->text() + "</b><br>";
836 item = (QCheckListItem*)( item->nextSibling() );
839 text += "<li><b>" + tr( "none" ) + "</b><br>";
842 text += tr( "Total disk space required:" ) + " <b>" + QString::number( totSize ) + " Kb</b><br>" ;
843 text += tr( "Space for temporary files required:" ) + " <b>" + QString::number( tempSize ) + " Kb</b><br>" ;
845 text += tr( "Target directory:" ) + " <b>" + QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) + "</b><br>";
846 // VSR: Temporary folder is used always now and it is not necessary to disable it -->
847 // if ( tempSize > 0 )
848 // VSR: <----------------------------------------------------------------------------
849 text += tr( "Temp directory:" ) + " <b>" + QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + "</b><br>";
851 choices->setText( text );
853 // ================================================================
855 * SALOME_InstallWizard::acceptData
856 * Validates page when <Next> button is clicked
858 // ================================================================
859 bool SALOME_InstallWizard::acceptData( const QString& pageTitle )
862 QWidget* aPage = InstallWizard::page( pageTitle );
863 if ( aPage == productsPage ) {
864 // ########## check if any products are selected to be installed
865 long totSize, tempSize;
866 bool anySelected = checkSize( &totSize, &tempSize );
867 if ( !anySelected ) {
868 QMessageBox::warning( this,
870 tr( "Select one or more products to install" ),
872 QMessageBox::NoButton,
873 QMessageBox::NoButton );
876 // ########## check target and temp directories (existence and available disk space)
878 QString targetDir = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() );
879 QString tempDir = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() );
880 // directories should differ
881 // if (!targetDir.isEmpty() && tempDir == targetDir) {
882 // QMessageBox::warning( this,
884 // tr( "Target and temporary directories must be different"),
886 // QMessageBox::NoButton,
887 // QMessageBox::NoButton );
890 // check target directory
891 if ( targetDir.isEmpty() ) {
892 QMessageBox::warning( this,
894 tr( "Please, enter valid target directory path" ),
896 QMessageBox::NoButton,
897 QMessageBox::NoButton );
900 QFileInfo fi( QDir::cleanDirPath( targetDir ) );
901 if ( !fi.exists() ) {
903 QMessageBox::warning( this,
905 tr( "The directory %1 doesn't exist.\n"
906 "Do you want to create directory?" ).arg( fi.absFilePath() ),
909 QMessageBox::NoButton ) == QMessageBox::Yes;
912 if ( !makeDir( fi.absFilePath(), tmpstr ) ) {
913 QMessageBox::critical( this,
915 tr( "Can't create the directory\n%1").arg( fi.absFilePath() ),
917 QMessageBox::NoButton,
918 QMessageBox::NoButton );
923 QMessageBox::warning( this,
925 tr( "The directory %1 is not a directory.\n"
926 "Please, enter valid target directory path" ).arg( fi.absFilePath() ),
928 QMessageBox::NoButton,
929 QMessageBox::NoButton );
932 if ( !fi.isWritable() ) {
933 QMessageBox::warning( this,
935 tr( "The directory %1 is not writeable.\n"
936 "Please, enter valid target directory path or change permissions" ).arg( fi.absFilePath() ),
938 QMessageBox::NoButton,
939 QMessageBox::NoButton );
942 if ( hasSpace( fi.absFilePath() ) &&
943 QMessageBox::warning( this,
945 tr( "The target directory contains space symbols.\n"
946 "This may cause problems with compiling or installing of products.\n\n"
947 "Do you want to continue?"),
950 QMessageBox::NoButton ) == QMessageBox::No ) {
953 QString binDir = "./Products/BINARIES";
954 if ( !myOS.isEmpty() )
955 binDir += "/" + myOS;
956 QFileInfo fib( QDir::cleanDirPath( binDir ) );
957 if ( !fib.exists() ) {
958 QMessageBox::warning( this,
960 tr( "The directory %1 doesn't exist.\n"
961 "This directory must contain binaries archives." ).arg( fib.absFilePath() ));
963 // run script that checks available disk space for installing of products // returns 1 in case of error
964 QString script = "./config_files/checkSize.sh '";
965 script += fi.absFilePath();
967 script += QString( "%1" ).arg( totSize );
968 ___MESSAGE___( "script = " << script );
969 if ( system( script ) ) {
970 QMessageBox::critical( this,
971 tr( "Out of space" ),
972 tr( "There is not available disk space for installing of selected products" ),
974 QMessageBox::NoButton,
975 QMessageBox::NoButton );
978 // check temp directory
979 if ( tempDir.isEmpty() ) {
981 QMessageBox::warning( this,
983 tr( "Please, enter valid temp directory path" ),
985 QMessageBox::NoButton,
986 QMessageBox::NoButton );
991 tempFolder->setText( tempDir );
994 QFileInfo fit( QDir::cleanDirPath( tempDir ) );
995 if ( !makeDir( fit.absFilePath() + TEMPDIRNAME, tmpCreated ) ) {
996 QMessageBox::critical( this,
998 tr( "Can't use temporary directory.\nCheck permissions for the %1 directory.").arg( fit.absFilePath() ),
1000 QMessageBox::NoButton,
1001 QMessageBox::NoButton );
1004 // run script that check available disk space for temporary files
1005 // returns 1 in case of error
1006 QString tscript = "./config_files/checkSize.sh '";
1007 tscript += fit.absFilePath();
1009 tscript += QString( "%1" ).arg( tempSize );
1010 ___MESSAGE___( "script = " << tscript );
1011 if ( system( tscript ) ) {
1012 QMessageBox::critical( this,
1013 tr( "Out of space" ),
1014 tr( "There is not available disk space for the temporary files" ),
1016 QMessageBox::NoButton,
1017 QMessageBox::NoButton );
1020 // VSR: <------------------------------------------------------------------------------
1021 // ########## check native products
1022 QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
1023 QStringList natives;
1025 if ( productsMap.contains( item ) ) {
1026 if ( item->childCount() > 0 ) {
1027 if ( !productsView->isNone( item ) ) {
1028 if ( item->text(2).isEmpty() || item->text(2).isNull() ) {
1029 QMessageBox::warning( this,
1031 tr( "You don't have a defined script for %1").arg(item->text(0)),
1033 QMessageBox::NoButton,
1034 QMessageBox::NoButton );
1035 productsView->setNone( item );
1038 QFileInfo fi( QString("./config_files/") + item->text(2) );
1039 if ( !fi.exists() ) {
1040 QMessageBox::warning( this,
1042 tr( "%1 required for %2 doesn't exist.").arg("./config_files/" + item->text(2)).arg(item->text(0)),
1044 QMessageBox::NoButton,
1045 QMessageBox::NoButton );
1046 productsView->setNone( item );
1051 // collect native products
1052 if ( productsView->isNative( item ) ) {
1053 if ( natives.find( item->text(0) ) == natives.end() )
1054 natives.append( item->text(0) );
1056 else if ( productsView->isBinaries( item ) || productsView->isSources( item ) ) {
1057 QStringList dependOn = productsMap[ item ].getDependancies();
1058 for ( int i = 0; i < (int)dependOn.count(); i++ ) {
1059 QCheckListItem* depitem = findItem( dependOn[ i ] );
1061 if ( productsView->isNative( depitem ) && natives.find( depitem->text(0) ) == natives.end() )
1062 natives.append( depitem->text(0) );
1065 QMessageBox::warning( this,
1067 tr( "%1 is required for %2 %3 installation.\n"
1068 "Please, add this product in config.xml file.").arg(dependOn[ i ]).arg(item->text(0)).arg(item->text(1)),
1070 QMessageBox::NoButton,
1071 QMessageBox::NoButton );
1078 item = (QCheckListItem*)( item->nextSibling() );
1080 QString tmpFolder = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
1081 QString tgtFolder = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() );
1082 myThread->clearCommands();
1083 if ( natives.count() > 0 ) {
1084 for ( unsigned i = 0; i < natives.count(); i++ ) {
1085 item = findItem( natives[ i ] );
1087 QString dependOn = productsMap[ item ].getDependancies().join(" ");
1088 QString script = "cd ./config_files/;" + item->text(2) + " try_native " +
1089 QFileInfo( tmpFolder ).absFilePath() + " " + QDir::currentDirPath() + "/Products " + QFileInfo( tgtFolder ).absFilePath() + " " +
1090 QUOTE(dependOn) + " " + item->text(0);
1092 myThread->addCommand( item, script );
1095 QMessageBox::warning( this,
1097 tr( "%The product %1 %2 required for installation.\n"
1098 "Please, add this product in config.xml file.").arg(item->text(0)).arg(item->text(1)),
1100 QMessageBox::NoButton,
1101 QMessageBox::NoButton );
1105 WarnDialog::showWarnDlg( this, true );
1107 return true; // return in order to avoid default postValidateEvent() action
1110 return InstallWizard::acceptData( pageTitle );
1112 // ================================================================
1114 * SALOME_InstallWizard::checkSize
1115 * Calculates disk space required for the installation
1117 // ================================================================
1118 bool SALOME_InstallWizard::checkSize( long* totSize, long* tempSize )
1120 long tots = 0, temps = 0;
1123 MapProducts::Iterator mapIter;
1124 for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
1125 QCheckListItem* item = mapIter.key();
1126 Dependancies dep = mapIter.data();
1127 if ( productsView->isBinaries( item ) ) {
1128 tots += dep.getSize();
1130 else if ( productsView->isSources( item ) ) {
1131 tots += dep.getSize(true);
1132 temps = max( temps, dep.getTempSize() );
1134 if ( !productsView->isNone( item ) )
1142 return ( nbSelected > 0 );
1144 // ================================================================
1146 * SALOME_InstallWizard::checkProductPage
1147 * Checks products page validity (directories and products selection) and
1148 * enabled/disables "Next" button for the Products page
1150 // ================================================================
1151 void SALOME_InstallWizard::checkProductPage()
1153 long tots = 0, temps = 0;
1155 // check if any product is selected;
1156 bool isAnyProductSelected = checkSize( &tots, &temps );
1157 // check if target directory is valid
1158 bool isTargetDirValid = !targetFolder->text().stripWhiteSpace().isEmpty();
1159 // check if temp directory is valid
1160 bool isTempDirValid = !moreMode || !tempFolder->text().stripWhiteSpace().isEmpty();
1162 // update required size information
1163 requiredSize->setText( QString::number( tots ) + " Kb");
1164 requiredTemp->setText( QString::number( temps ) + " Kb");
1166 // update <SALOME sources>, <SALOME binaries> check boxes state
1167 int totSrc = 0, selSrc = 0;
1168 int totBin = 0, selBin = 0;
1169 MapProducts::Iterator itProd;
1170 for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) {
1171 if ( itProd.data().getContext() == "salome sources" ) {
1173 if ( productsView->isSources( itProd.key() ) )
1176 if ( itProd.data().getContext() == "salome binaries" ) {
1178 if ( productsView->isBinaries( itProd.key() ) )
1182 selectSrcBtn->blockSignals( true );
1183 selectBinBtn->blockSignals( true );
1184 selectSrcBtn->setState( selSrc == 0 ? QButton::Off : ( selSrc == totSrc ? QButton::On : QButton::NoChange ) );
1185 selectBinBtn->setState( selBin == 0 ? QButton::Off : ( selBin == totBin ? QButton::On : QButton::NoChange ) );
1186 selectSrcBtn->blockSignals( false );
1187 selectBinBtn->blockSignals( false );
1189 // enable/disable "Next" button
1190 setNextEnabled( productsPage, isAnyProductSelected && isTargetDirValid && isTempDirValid );
1192 // ================================================================
1194 * SALOME_InstallWizard::setPrerequisites
1195 * Sets the product and all products this one depends on to be checked ( recursively )
1197 // ================================================================
1198 void SALOME_InstallWizard::setPrerequisites( QCheckListItem* item )
1200 if ( !productsMap.contains( item ) )
1202 if ( productsView->isNone( item ) )
1204 // get all prerequisites
1205 QStringList dependOn = productsMap[ item ].getDependancies();
1206 for ( int i = 0; i < (int)dependOn.count(); i++ ) {
1207 MapProducts::Iterator itProd;
1208 for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) {
1209 if ( itProd.data().getName() == dependOn[ i ] ) {
1210 if ( productsView->isNone( itProd.key() ) ) {
1211 QString defMode = itProd.data().getDefault();
1212 if ( defMode.isEmpty() )
1213 defMode = tr( "install binaries" );
1214 if ( defMode == tr( "install binaries" ) )
1215 productsView->setBinaries( itProd.key() );
1216 else if ( defMode == tr( "install sources" ) )
1217 productsView->setSources( itProd.key() );
1218 else if ( defMode == tr( "use native" ) )
1219 productsView->setNative( itProd.key() );
1220 setPrerequisites( itProd.key() );
1226 // ================================================================
1228 * SALOME_InstallWizard::launchScript
1229 * Runs installation script
1231 // ================================================================
1232 void SALOME_InstallWizard::launchScript()
1234 // try to find product being processed now
1235 QString prodProc = progressView->findStatus( Processing );
1236 if ( !prodProc.isNull() ) {
1237 ___MESSAGE___( "Found <Processing>: " );
1239 // if found - set status to "completed"
1240 progressView->setStatus( prodProc, Completed );
1241 // ... and call this method again
1245 // else try to find next product which is not processed yet
1246 prodProc = progressView->findStatus( Waiting );
1247 if ( !prodProc.isNull() ) {
1248 ___MESSAGE___( "Found <Waiting>: " << prodProc.latin1() );
1249 // if found - set status to "processed" and run script
1250 progressView->setStatus( prodProc, Processing );
1251 progressView->ensureVisible( prodProc );
1253 QCheckListItem* item = findItem( prodProc );
1254 // fill in script parameters
1255 shellProcess->clearArguments();
1257 shellProcess->setWorkingDirectory( QDir::cleanDirPath( QFileInfo( "./config_files/" ).absFilePath() ) );
1258 shellProcess->addArgument( item->text(2) );
1261 QString tmpFolder = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
1262 //if( !tempFolder->isEnabled() )
1263 //tmpFolder = "/tmp";
1266 if ( productsView->isBinaries( item ) ) {
1267 shellProcess->addArgument( "install_binary" );
1268 shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
1269 QString binDir = QDir::currentDirPath() + "/Products/BINARIES";
1270 if ( !myOS.isEmpty() )
1271 binDir += "/" + myOS;
1272 shellProcess->addArgument( binDir );
1275 else if ( productsView->isSources( item ) ) {
1276 shellProcess->addArgument( "install_source" );
1277 shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
1278 shellProcess->addArgument( QDir::currentDirPath() + "/Products/SOURCES" );
1281 else if ( productsView->isNative( item ) ) {
1282 shellProcess->addArgument( "try_native" );
1283 shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
1284 shellProcess->addArgument( QDir::currentDirPath() + "/Products" );
1286 // ... not install : try to find preinstalled
1288 shellProcess->addArgument( "try_preinstalled" );
1289 shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
1290 shellProcess->addArgument( QDir::currentDirPath() + "/Products" );
1292 // ... target folder
1293 QString tgtFolder = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() );
1294 shellProcess->addArgument( QFileInfo( tgtFolder ).absFilePath() );
1297 QString depproducts = DefineDependeces(productsMap);
1298 ___MESSAGE___( "Dependancies"<< depproducts.latin1() );
1300 shellProcess->addArgument( depproducts );
1301 // ... product name - currently instaled product
1302 shellProcess->addArgument( item->text(0) );
1305 if ( !shellProcess->start() ) {
1306 // error handling can be here
1307 ___MESSAGE___( "error" );
1311 ___MESSAGE___( "All products have been installed successfully" );
1312 // all products are installed successfully
1313 QString workDir = QDir::cleanDirPath( QFileInfo( "./config_files/" ).absFilePath() );
1314 MapProducts::Iterator mapIter;
1315 ___MESSAGE___( "starting pick-up environment" );
1316 for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
1317 QCheckListItem* item = mapIter.key();
1318 Dependancies dep = mapIter.data();
1319 QString depproducts = QUOTE( DefineDependeces(productsMap) );
1320 if ( dep.pickUpEnvironment() ) {
1321 ___MESSAGE___( "... for " << dep.getName() );
1323 script += "cd " + QUOTE( QFileInfo( QDir::cleanDirPath( "./config_files/" ) ).absFilePath() ) + "; ";
1324 script += item->text(2) + " ";
1325 script += "pickup_env ";
1326 script += QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() ) + " ";
1327 script += QUOTE( QFileInfo( QDir::cleanDirPath( QDir::currentDirPath() + "/Products" ) ).absFilePath() ) + " ";
1328 script += QUOTE( QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) ).absFilePath() ) + " ";
1329 script += depproducts + " ";
1330 script += item->text(0);
1331 ___MESSAGE___( "... --> " << script.latin1() );
1332 if ( system( script.latin1() ) ) {
1333 ___MESSAGE___( "ERROR" );
1338 setNextEnabled( true );
1339 nextButton()->setText( tr( "&Next >" ) );
1340 QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1341 QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1342 nextButton()->disconnect();
1343 connect( nextButton(), SIGNAL( clicked() ), this, SLOT( next() ) );
1345 setBackEnabled( true );
1346 // script parameters
1347 passedParams->clear();
1348 passedParams->setEnabled( false );
1349 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1350 if ( isMinimized() )
1354 // ================================================================
1356 * SALOME_InstallWizard::onMoreBtn
1357 * <More...> button slot
1359 // ================================================================
1360 void SALOME_InstallWizard::onMoreBtn()
1364 moreBtn->setText( tr( "More..." ) );
1368 moreBtn->setText( tr( "Less..." ) );
1370 qApp->processEvents();
1371 moreMode = !moreMode;
1372 InstallWizard::layOut();
1373 qApp->processEvents();
1374 if ( !isMaximized() ) {
1375 //setGeometry( geometry().x(), geometry().y(), geometry().width(), 0 );
1376 resize( geometry().width(), 0 );
1377 qApp->processEvents();
1381 // ================================================================
1383 * SALOME_InstallWizard::onLaunchSalome
1384 * <Launch Salome> button slot
1386 // ================================================================
1387 void SALOME_InstallWizard::onLaunchSalome()
1389 QString msg = tr( "You don't have SALOME binaries installed in the %1 directory!" ).arg( targetFolder->text() );
1391 QCheckListItem* item = findItem( "KERNEL-Bin" );
1393 QFileInfo fi( targetFolder->text() + "/KERNEL_" + item->text(1) + "/bin/salome/runSalome" );
1394 QFileInfo fienv( targetFolder->text() + "/KERNEL_" + item->text(1) + "/salome.csh" );
1395 if ( fienv.exists() ) {
1396 if ( fi.exists() ) {
1398 script += "cd " + targetFolder->text() + "/KERNEL_" + item->text(1) + "; ";
1399 script += "source salome.csh; ";
1400 script += "cd bin/salome; ";
1401 script += "runSalome > /dev/null";
1402 script = "(csh -c '" + script + "')";
1403 ___MESSAGE___( "script: " << script.latin1() );
1404 if ( !system( script.latin1() ) )
1407 msg = tr( "Can't launch SALOME." );
1410 msg = tr( "Can't launch SALOME." ) + "\n" + tr( "runSalome file can not be found." );
1413 msg = tr( "Can't launch SALOME." ) + "\n" + tr( "Can't find environment file." );
1415 QMessageBox::warning( this,
1419 QMessageBox::NoButton,
1420 QMessageBox::NoButton );
1422 // ================================================================
1424 * SALOME_InstallWizard::findItem
1425 * Searches product listview item with given symbolic name
1427 // ================================================================
1428 QCheckListItem* SALOME_InstallWizard::findItem( const QString& sName )
1430 MapProducts::Iterator mapIter;
1431 for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
1432 if ( mapIter.data().getName() == sName )
1433 return mapIter.key();
1437 // ================================================================
1439 * SALOME_InstallWizard::abort
1440 * Sets progress state to Aborted
1442 // ================================================================
1443 void SALOME_InstallWizard::abort()
1445 QString prod = progressView->findStatus( Processing );
1446 while ( !prod.isNull() ) {
1447 progressView->setStatus( prod, Aborted );
1448 prod = progressView->findStatus( Processing );
1450 prod = progressView->findStatus( Waiting );
1451 while ( !prod.isNull() ) {
1452 progressView->setStatus( prod, Aborted );
1453 prod = progressView->findStatus( Waiting );
1456 // ================================================================
1458 * SALOME_InstallWizard::reject
1459 * Reject slot, clears temporary directory and closes application
1461 // ================================================================
1462 void SALOME_InstallWizard::reject()
1464 ___MESSAGE___( "REJECTED" );
1465 if ( !exitConfirmed ) {
1466 if ( QMessageBox::information( this,
1468 tr( "Do you want to quit %1?" ).arg( getIWName() ),
1476 exitConfirmed = true;
1479 InstallWizard::reject();
1481 // ================================================================
1483 * SALOME_InstallWizard::accept
1484 * Accept slot, clears temporary directory and closes application
1486 // ================================================================
1487 void SALOME_InstallWizard::accept()
1489 ___MESSAGE___( "ACCEPTED" );
1491 InstallWizard::accept();
1493 // ================================================================
1495 * SALOME_InstallWizard::clean
1496 * Clears and (optionally) removes temporary directory
1498 // ================================================================
1499 void SALOME_InstallWizard::clean(bool rmDir)
1501 WarnDialog::showWarnDlg( 0, false );
1502 myThread->clearCommands();
1504 while ( myThread->running() );
1505 // VSR: first remove temporary files
1506 QString script = "cd ./config_files/; remove_tmp.sh '";
1507 script += tempFolder->text().stripWhiteSpace() + TEMPDIRNAME;
1509 script += QUOTE(DefineDependeces(productsMap));
1510 script += " > /dev/null";
1511 ___MESSAGE___( "script = " << script );
1512 if ( system( script.latin1() ) ) {
1514 // VSR: then try to remove created temporary directory
1515 //script = "rm -rf " + QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
1516 if ( rmDir && !tmpCreated.isNull() ) {
1517 script = "rm -rf " + tmpCreated;
1518 script += " > /dev/null";
1519 if ( system( script.latin1() ) ) {
1521 ___MESSAGE___( "script = " << script );
1524 // ================================================================
1526 * SALOME_InstallWizard::pageChanged
1527 * Called when user moves from page to page
1529 // ================================================================
1530 void SALOME_InstallWizard::pageChanged( const QString & mytitle)
1532 nextButton()->setText( tr( "&Next >" ) );
1533 QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1534 QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1535 nextButton()->disconnect();
1536 connect( nextButton(), SIGNAL( clicked() ), this, SLOT( next() ) );
1537 cancelButton()->disconnect();
1538 connect( cancelButton(), SIGNAL( clicked()), this, SLOT( reject() ) );
1540 QWidget* aPage = InstallWizard::page( mytitle );
1544 if ( aPage == productsPage ) {
1546 onSelectionChanged();
1549 else if ( aPage == prestartPage ) {
1553 else if ( aPage == progressPage ) {
1554 if ( previousPage == prestartPage ) {
1556 progressView->clear();
1557 installInfo->clear();
1558 passedParams->clear();
1559 passedParams->setEnabled( false );
1560 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1561 nextButton()->setText( tr( "&Start" ) );
1562 QWhatsThis::add( nextButton(), tr( "Starts installation process" ) );
1563 QToolTip::add ( nextButton(), tr( "Starts installation process" ) );
1564 // reconnect Next button - to use it as Start button
1565 nextButton()->disconnect();
1566 connect( nextButton(), SIGNAL( clicked() ), this, SLOT( onStart() ) );
1567 setNextEnabled( true );
1568 // reconnect Cancel button to terminate process
1569 cancelButton()->disconnect();
1570 connect( cancelButton(), SIGNAL( clicked() ), this, SLOT( tryTerminate() ) );
1573 else if ( aPage == readmePage ) {
1574 QCheckListItem* item = findItem( "KERNEL-Bin" );
1575 runSalomeBtn->setEnabled( item &&
1576 QFileInfo( targetFolder->text() + "/KERNEL_" + item->text(1) + "/bin/salome/runSalome" ).exists() &&
1577 QFileInfo( targetFolder->text() + "/KERNEL_" + item->text(1) + "/salome.csh" ).exists() );
1578 finishButton()->setEnabled( true );
1580 previousPage = aPage;
1581 ___MESSAGE___( "previousPage = " << previousPage );
1583 // ================================================================
1585 * SALOME_InstallWizard::helpClicked
1588 // ================================================================
1589 void SALOME_InstallWizard::helpClicked()
1591 if ( helpWindow == NULL ) {
1592 helpWindow = HelpWindow::openHelp( this );
1595 helpWindow->installEventFilter( this );
1598 QMessageBox::warning( this,
1599 tr( "Help file not found" ),
1600 tr( "Sorry, help is unavailable" ) );
1604 helpWindow->raise();
1605 helpWindow->setActiveWindow();
1608 // ================================================================
1610 * SALOME_InstallWizard::browseDirectory
1611 * Shows directory selection dialog
1613 // ================================================================
1614 void SALOME_InstallWizard::browseDirectory()
1616 const QObject* theSender = sender();
1617 QLineEdit* theFolder;
1618 if ( theSender == targetBtn )
1619 theFolder = targetFolder;
1620 else if (theSender == tempBtn)
1621 theFolder = tempFolder;
1624 QString typedDir = QFileDialog::getExistingDirectory( QDir::cleanDirPath( theFolder->text().stripWhiteSpace() ), this );
1625 if ( !typedDir.isNull() ) {
1626 theFolder->setText( typedDir );
1627 theFolder->end( false );
1631 // ================================================================
1633 * SALOME_InstallWizard::directoryChanged
1634 * Called when directory path (target or temp) is changed
1636 // ================================================================
1637 void SALOME_InstallWizard::directoryChanged( const QString& /*text*/ )
1641 // ================================================================
1643 * SALOME_InstallWizard::onStart
1644 * <Start> button's slot - runs installation
1646 // ================================================================
1647 void SALOME_InstallWizard::onStart()
1649 // clear list of products to install ...
1651 // ... and fill it for new process
1652 QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
1654 // if ( productsView->isBinaries( item ) || productsView->isSources( item ) || productsView->isNative( item ) ) {
1655 if ( productsMap.contains( item ) )
1656 toInstall.append( productsMap[item].getName() );
1658 item = (QCheckListItem*)( item->nextSibling() );
1660 // if something at all is selected
1661 if ( !toInstall.isEmpty() ) {
1662 clean(false); // VSR 07/02/05 - bug fix: first we should clear temporary directory
1663 // disable <Next> button
1664 setNextEnabled( false );
1665 // disable <Back> button
1666 setBackEnabled( false );
1667 // enable script parameters line edit
1668 // VSR commented: 18/09/03: passedParams->setEnabled( true );
1669 // VSR commented: 18/09/03: passedParams->setFocus();
1670 // set status for all products
1671 for ( int i = 0; i < (int)toInstall.count(); i++ ) {
1672 item = findItem( toInstall[ i ] );
1674 if ( productsView->isBinaries( item ) )
1675 type = tr( "binaries" );
1676 else if ( productsView->isSources( item ) )
1677 type = tr( "sources" );
1678 else if ( productsView->isNative( item ) )
1679 type = tr( "native" );
1681 type = tr( "not install" );
1682 progressView->addProduct( item->text(0), type, item->text(2) );
1684 // launch install script
1688 // ================================================================
1690 * SALOME_InstallWizard::onReturnPressed
1691 * Called when users tries to pass parameters for the script
1693 // ================================================================
1694 void SALOME_InstallWizard::onReturnPressed()
1696 QString txt = passedParams->text();
1697 installInfo->append( txt );
1699 shellProcess->writeToStdin( txt );
1700 passedParams->clear();
1701 progressView->setFocus();
1702 passedParams->setEnabled( false );
1703 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1706 Callback function - as response for the script finishing
1708 void SALOME_InstallWizard::productInstalled( )
1710 ___MESSAGE___( "process exited" );
1711 if ( shellProcess->normalExit() ) {
1712 ___MESSAGE___( "...normal exit" );
1713 // normal exit - try to proceed installation further
1717 ___MESSAGE___( "...abnormal exit" );
1718 // installation aborted
1720 // clear script passed parameters lineedit
1721 passedParams->clear();
1722 passedParams->setEnabled( false );
1723 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1724 // enable <Next> button
1725 setNextEnabled( true );
1726 nextButton()->setText( tr( "&Next >" ) );
1727 QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1728 QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1729 nextButton()->disconnect();
1730 connect( nextButton(), SIGNAL( clicked() ), this, SLOT( next() ) );
1731 // enable <Back> button
1732 setBackEnabled( true );
1735 // ================================================================
1737 * SALOME_InstallWizard::tryTerminate
1738 * Slot, called when <Cancel> button is clicked during installation script running
1740 // ================================================================
1741 void SALOME_InstallWizard::tryTerminate()
1743 if ( shellProcess->isRunning() ) {
1744 if ( QMessageBox::information( this,
1746 tr( "Do you want to quit %1?" ).arg( getIWName() ),
1754 exitConfirmed = true;
1755 // if process still running try to terminate it first
1756 shellProcess->tryTerminate();
1758 //QTimer::singleShot( 3000, this, SLOT( onCancel() ) );
1759 connect( shellProcess, SIGNAL( processExited() ), this, SLOT( onCancel() ) );
1762 // else just quit install wizard
1766 // ================================================================
1768 * SALOME_InstallWizard::onCancel
1769 * Kills installation process and quits application
1771 // ================================================================
1772 void SALOME_InstallWizard::onCancel()
1774 shellProcess->kill();
1777 // ================================================================
1779 * SALOME_InstallWizard::onSelectionChanged
1780 * Called when selection is changed in the products list view
1782 // ================================================================
1783 void SALOME_InstallWizard::onSelectionChanged()
1785 productsInfo->clear();
1786 QListViewItem* item = productsView->selectedItem();
1789 if ( item->parent() )
1790 item = item->parent();
1791 QCheckListItem* aItem = (QCheckListItem*)item;
1792 if ( !productsMap.contains( aItem ) )
1794 Dependancies dep = productsMap[ aItem ];
1795 QString text = "<b>" + aItem->text(0) + "</b>" + "<br>";
1796 if ( !aItem->text(1).stripWhiteSpace().isEmpty() )
1797 text += tr( "Version" ) + ": " + aItem->text(1) + "<br>";
1799 if ( !dep.getDescription().isEmpty() ) {
1800 text += "<i>" + dep.getDescription() + "</i><br><br>";
1802 text += tr( "User choice" ) + ": ";
1803 long totSize = 0, tempSize = 0;
1804 if ( productsView->isBinaries( aItem ) ) {
1805 text += "<b>" + tr( "install binaries" ) + "</b>" + "<br>";
1806 totSize = dep.getSize();
1808 else if ( productsView->isSources( aItem ) ) {
1809 text += "<b>" + tr( "install sources" ) + "</b>" + "<br>";
1810 totSize = dep.getSize( true );
1811 tempSize = dep.getTempSize();
1813 else if ( productsView->isNative( aItem ) ) {
1814 text += "<b>" + tr( "use native" ) + "</b>" + "<br>";
1817 text += "<b>" + tr( "not install" ) + "</b>" + "<br>";
1820 text += tr( "Disk space required" ) + ": " + QString::number( totSize ) + " Kb<br>";
1821 text += tr( "Disk space for tmp files required" ) + ": " + QString::number( tempSize ) + " Kb<br>";
1823 QString req = ( dep.getDependancies().count() > 0 ? dep.getDependancies().join(", ") : tr( "none" ) );
1824 text += tr( "Prerequisites" ) + ": " + req;
1825 productsInfo->setText( text );
1827 // ================================================================
1829 * SALOME_InstallWizard::onItemToggled
1830 * Called when user checks/unchecks any product item
1831 * Recursively sets all prerequisites and updates "Next" button state
1833 // ================================================================
1834 void SALOME_InstallWizard::onItemToggled( QCheckListItem* item )
1836 if ( prerequisites->isChecked() ) {
1837 if ( item->parent() )
1838 item = (QCheckListItem*)( item->parent() );
1839 if ( productsMap.contains( item ) ) {
1840 productsView->blockSignals( true );
1841 setPrerequisites( item );
1842 productsView->blockSignals( false );
1845 onSelectionChanged();
1848 // ================================================================
1850 * SALOME_InstallWizard::onProdBtn
1851 * This slot is called when user clicks one of <Select Sources>,
1852 * <Select Binaries>, <Unselect All> buttons ( products page )
1854 // ================================================================
1855 void SALOME_InstallWizard::onProdBtn()
1857 const QObject* snd = sender();
1858 productsView->blockSignals( true );
1859 selectSrcBtn->blockSignals( true );
1860 selectBinBtn->blockSignals( true );
1861 if ( snd == unselectBtn ) {
1862 QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
1864 productsView->setNone( item );
1865 item = (QCheckListItem*)( item->nextSibling() );
1868 else if ( snd == selectSrcBtn ) {
1869 QMyCheckBox* checkBox = ( QMyCheckBox* )snd;
1870 if ( checkBox->state() == QButton::NoChange )
1871 checkBox->setState( QButton::On );
1872 MapProducts::Iterator itProd;
1873 for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) {
1874 if ( itProd.data().getContext() == "salome sources" ) {
1875 if ( checkBox->state() == QButton::Off )
1876 productsView->setNone( itProd.key() );
1878 productsView->setSources( itProd.key() );
1882 else if ( snd == selectBinBtn ) {
1883 QMyCheckBox* checkBox = ( QMyCheckBox* )snd;
1884 if ( checkBox->state() == QButton::NoChange )
1885 checkBox->setState( QButton::On );
1886 MapProducts::Iterator itProd;
1887 for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) {
1888 if ( itProd.data().getContext() == "salome binaries" ) {
1889 if ( checkBox->state() == QButton::Off )
1890 productsView->setNone( itProd.key() );
1892 productsView->setBinaries( itProd.key() );
1896 selectSrcBtn->blockSignals( false );
1897 selectBinBtn->blockSignals( false );
1898 productsView->blockSignals( false );
1899 onSelectionChanged();
1902 // ================================================================
1904 * SALOME_InstallWizard::wroteToStdin
1905 * QProcess slot: -->something was written to stdin
1907 // ================================================================
1908 void SALOME_InstallWizard::wroteToStdin( )
1910 ___MESSAGE___( "Something was sent to stdin" );
1912 // ================================================================
1914 * SALOME_InstallWizard::readFromStdout
1915 * QProcess slot: -->something was written to stdout
1917 // ================================================================
1918 void SALOME_InstallWizard::readFromStdout( )
1920 ___MESSAGE___( "Something was sent to stdout" );
1921 while ( shellProcess->canReadLineStdout() ) {
1922 installInfo->append( QString( shellProcess->readLineStdout() ) );
1923 installInfo->scrollToBottom();
1925 QString str( shellProcess->readStdout() );
1926 if ( !str.isEmpty() ) {
1927 installInfo->append( str );
1928 installInfo->scrollToBottom();
1931 // ================================================================
1933 * SALOME_InstallWizard::readFromStderr
1934 * QProcess slot: -->something was written to stderr
1936 // ================================================================
1937 void SALOME_InstallWizard::readFromStderr( )
1939 ___MESSAGE___( "Something was sent to stderr" );
1940 while ( shellProcess->canReadLineStderr() ) {
1941 installInfo->append( QString( shellProcess->readLineStderr() ) );
1942 installInfo->scrollToBottom();
1944 QString str( shellProcess->readStderr() );
1945 if ( !str.isEmpty() ) {
1946 installInfo->append( str );
1947 installInfo->scrollToBottom();
1949 passedParams->setEnabled( true );
1950 passedParams->setFocus();
1951 QFont f = parametersLab->font(); f.setBold( true ); parametersLab->setFont( f );
1953 // ================================================================
1955 * SALOME_InstallWizard::setDependancies
1956 * Sets dependancies for the product item
1958 // ================================================================
1959 void SALOME_InstallWizard::setDependancies( QCheckListItem* item, Dependancies dep)
1961 productsMap[item] = dep;
1963 // ================================================================
1965 * SALOME_InstallWizard::polish
1966 * Polishing of the widget - to set right initial size
1968 // ================================================================
1969 void SALOME_InstallWizard::polish()
1972 InstallWizard::polish();
1974 // ================================================================
1976 * SALOME_InstallWizard::updateCaption
1977 * Updates caption according to the current page number
1979 // ================================================================
1980 void SALOME_InstallWizard::updateCaption()
1982 QWidget* aPage = InstallWizard::currentPage();
1985 InstallWizard::setCaption( tr( myCaption ) + " " +
1986 tr( getIWName() ) + " - " +
1987 tr( "Step %1 of %2").arg( QString::number( this->indexOf( aPage )+1 ) ).arg( QString::number( this->pageCount() ) ) );
1990 // ================================================================
1992 * SALOME_InstallWizard::processValidateEvent
1993 * Processes validation event (<val> is validation code)
1995 // ================================================================
1996 void SALOME_InstallWizard::processValidateEvent( const int val, void* data )
1998 QWidget* aPage = InstallWizard::currentPage();
1999 if ( aPage != productsPage ) {
2000 InstallWizard::processValidateEvent( val, data );
2005 QCheckListItem* item = (QCheckListItem*)data;
2008 WarnDialog::showWarnDlg( 0, false );
2009 // when try_native returns 2 it means that native product version is higher than that is prerequisited
2010 if ( QMessageBox::warning( this,
2012 tr( "You have newer version of %1 installed on your computer than that is required (%2).\nContinue?").arg(item->text(0)).arg(item->text(1)),
2015 QMessageBox::NoButton ) == QMessageBox::No ) {
2016 myThread->clearCommands();
2018 setNextEnabled( true );
2019 setBackEnabled( true );
2022 WarnDialog::showWarnDlg( this, true );
2025 WarnDialog::showWarnDlg( 0, false );
2026 QMessageBox::warning( this,
2028 tr( "You don't have native %1 %2 installed").arg(item->text(0)).arg(item->text(1)),
2030 QMessageBox::NoButton,
2031 QMessageBox::NoButton );
2032 myThread->clearCommands();
2034 setNextEnabled( true );
2035 setBackEnabled( true );
2036 productsView->setNone( item );
2040 if ( myThread->hasCommands() )
2043 WarnDialog::showWarnDlg( 0, false );
2044 InstallWizard::processValidateEvent( val, data );