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>
40 #include <qstringlist.h>
41 #include <qpopupmenu.h>
52 #define max( x, y ) ( x ) > ( y ) ? ( x ) : ( y )
55 QString tmpDirName() { return QString( "/INSTALLWORK" ) + QString::number( getpid() ); }
56 #define TEMPDIRNAME tmpDirName()
58 // ================================================================
61 * Class for executing systen commands
63 // ================================================================
64 static QMutex myMutex(false);
65 static QWaitCondition myWC;
66 class ProcessThread: public QThread
68 typedef QPtrList<QCheckListItem> ItemList;
70 ProcessThread( SALOME_InstallWizard* iw ) : QThread(), myWizard( iw ) { myItems.setAutoDelete( false ); }
72 void addCommand( QCheckListItem* item, const QString& cmd ) {
73 myItems.append( item );
74 myCommands.push_back( cmd );
77 bool hasCommands() const { return myCommands.count() > 0; }
78 void clearCommands() { myCommands.clear(); myItems.clear(); }
81 while ( hasCommands() ) {
82 ___MESSAGE___( "ProcessThread::run - Processing command : " << myCommands[ 0 ].latin1() );
83 int result = system( myCommands[ 0 ] ) / 256; // return code is <errno> * 256
84 ___MESSAGE___( "ProcessThread::run - Result : " << result );
85 QCheckListItem* item = myItems.first();
86 myCommands.pop_front();
87 myItems.removeFirst();
89 SALOME_InstallWizard::postValidateEvent( myWizard, result, (void*)item );
97 QStringList myCommands;
99 SALOME_InstallWizard* myWizard;
102 // ================================================================
107 // ================================================================
108 class WarnDialog: public QDialog
110 static WarnDialog* myDlg;
113 WarnDialog( QWidget* parent )
114 : QDialog( parent, "WarnDialog", true, WDestructiveClose ) {
115 setCaption( tr( "Information" ) );
117 QLabel* lab = new QLabel( tr( "Please, wait while checking native products configuration ..." ), this );
118 lab->setAlignment( AlignCenter );
119 lab->setFrameStyle( QFrame::Box | QFrame::Plain );
120 QVBoxLayout* l = new QVBoxLayout( this );
123 this->setFixedSize( lab->sizeHint().width() + 50,
124 lab->sizeHint().height() * 5 );
126 void accept() { return; }
127 void reject() { return; }
128 void closeEvent( QCloseEvent* e )
129 { if ( !myCloseFlag ) return;
131 QDialog::closeEvent( e );
133 ~WarnDialog() { myDlg = 0; }
135 static void showWarnDlg( QWidget* parent, bool show ) {
138 myDlg = new WarnDialog( parent );
139 QSize sh = myDlg->size();
140 myDlg->move( parent->x() + (parent->width()-sh.width())/2,
141 parent->y() + (parent->height()-sh.height())/2 );
149 myDlg->myCloseFlag = true;
154 static bool isWarnDlgShown() { return myDlg != 0; }
156 WarnDialog* WarnDialog::myDlg = 0;
158 // ================================================================
161 * Installation progress info window class
163 // ================================================================
164 class InstallInfo : public QTextEdit
167 InstallInfo( QWidget* parent ) : QTextEdit( parent ), finished( false ) {}
168 void setFinished( const bool f ) { finished = f; }
170 QPopupMenu* createPopupMenu( const QPoint& )
172 int para1, col1, para2, col2;
173 getSelection(¶1, &col1, ¶2, &col2);
174 bool allSelected = hasSelectedText() &&
175 para1 == 0 && para2 == paragraphs()-1 && col1 == 0 && col2 == paragraphLength(para2);
176 QPopupMenu* popup = new QPopupMenu( this );
177 int id = popup->insertItem( tr( "&Copy" ) );
178 popup->setItemEnabled( id, hasSelectedText() );
179 popup->connectItem ( id, this, SLOT( copy() ) );
180 id = popup->insertItem( tr( "Select &All" ) );
181 popup->setItemEnabled( id, (bool)text().length() && !allSelected );
182 popup->connectItem ( id, this, SLOT( selectAll() ) );
184 QWidget* p = parentWidget();
185 while ( p && !p->inherits( "SALOME_InstallWizard" ) )
186 p = p->parentWidget();
187 if ( p && p->inherits( "SALOME_InstallWizard" ) ) {
188 popup->insertSeparator();
189 id = popup->insertItem( tr( "&Save Log" ) );
190 popup->setItemEnabled( id, (bool)text().length() );
191 popup->connectItem ( id, (SALOME_InstallWizard*)p, SLOT( saveLog() ) );
200 // ================================================================
202 * DefineDependeces [ static ]
203 * Defines list of dependancies as string separated by space symbols
205 // ================================================================
206 static QString DefineDependeces(MapProducts& theProductsMap)
208 QStringList aProducts;
209 for ( MapProducts::Iterator mapIter = theProductsMap.begin(); mapIter != theProductsMap.end(); ++mapIter ) {
210 QCheckListItem* item = mapIter.key();
211 Dependancies dep = mapIter.data();
212 QStringList deps = dep.getDependancies();
213 for (int i = 0; i<(int)deps.count(); i++ ) {
214 if ( !aProducts.contains( deps[i] ) )
215 aProducts.append( deps[i] );
217 if ( !aProducts.contains( item->text(0) ) )
218 aProducts.append( item->text(0) );
220 return aProducts.join(" ");
223 #define QUOTE(arg) QString("'") + QString(arg) + QString("'")
225 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
226 T H E O L D I M P L E M E N T A T I O N
227 static QString DefineDependeces(MapProducts& theProductsMap, QCheckListItem* product ){
228 QStringList aProducts;
229 if ( theProductsMap.contains( product ) ) {
230 Dependancies dep = theProductsMap[ product ];
231 QStringList deps = dep.getDependancies();
232 for (int i = 0; i<(int)deps.count(); i++ ) {
233 aProducts.append( deps[i] );
236 return QString("\"") + aProducts.join(" ") + QString("\"");
238 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
240 // ================================================================
243 * Makes directory recursively, returns false if not succedes
245 // ================================================================
246 static bool makeDir( const QString& theDir, QString& theCreated )
248 if ( theDir.isEmpty() )
250 QString aDir = QDir::cleanDirPath( QFileInfo( theDir ).absFilePath() );
252 while ( start > 0 ) {
253 start = aDir.find( QDir::separator(), start );
255 QFileInfo fi( aDir.left( start ) );
256 if ( !fi.exists() ) {
257 // VSR: Create directory and set permissions to allow other users to remove it
258 QString script = "mkdir " + fi.absFilePath();
259 script += "; chmod 777 " + fi.absFilePath();
260 script += " > /dev/null";
261 if ( system( script.latin1() ) )
263 // VSR: Remember the top of the created directory (to remove it in the end of the installation)
264 if ( theCreated.isNull() )
265 theCreated = fi.absFilePath();
270 if ( !QFileInfo( aDir ).exists() ) {
271 // VSR: Create directory, other users should NOT have possibility to remove it!!!
272 QString script = "mkdir " + aDir;
273 script += " > /dev/null";
274 if ( system( script.latin1() ) )
276 // VSR: Remember the top of the created directory (to remove it in the end of the installation)
277 if ( theCreated.isNull() )
282 // ================================================================
284 * readFile [ static ]
285 * Reads the file, returns false if can't open it
287 // ================================================================
288 static bool readFile( const QString& fileName, QString& text )
290 if ( QFile::exists( fileName ) ) {
291 QFile file( fileName );
292 if ( file.open( IO_ReadOnly ) ) {
293 QTextStream stream( &file );
295 while ( !stream.eof() ) {
296 line = stream.readLine(); // line of text excluding '\n'
305 // ================================================================
307 * hasSpace [ static ]
308 * Checks if string contains spaces; used to check directory paths
310 // ================================================================
311 static bool hasSpace( const QString& dir )
313 for ( int i = 0; i < (int)dir.length(); i++ ) {
314 if ( dir[ i ].isSpace() )
320 // ================================================================
323 * Creates HTML-wrapped title text
325 // ================================================================
326 QString makeTitle( const QString& text, const QString& separator = " ", bool fl = true )
328 QStringList words = QStringList::split( separator, text );
330 for ( uint i = 0; i < words.count(); i++ )
331 words[i] = QString( "<font color=red>%1</font>" ).arg( words[i].left(1) ) + words[i].mid(1);
334 if ( words.count() > 0 )
335 words[0] = QString( "<font color=red>%1</font>" ).arg( words[0] );
336 if ( words.count() > 1 )
337 words[words.count()-1] = QString( "<font color=red>%1</font>" ).arg( words[words.count()-1] );
339 QString res = words.join( separator );
340 if ( !res.isEmpty() )
341 res = QString( "<b>%1</b>" ).arg( res );
345 // ================================================================
347 * QMyCheckBox class : custom check box
348 * The only goal is to give access to the protected setState() method
350 // ================================================================
351 class QMyCheckBox: public QCheckBox
354 QMyCheckBox( const QString& text, QWidget* parent, const char* name = 0 ) : QCheckBox ( text, parent, name ) {}
355 void setState ( ToggleState s ) { QCheckBox::setState( s ); }
358 // ================================================================
363 // ================================================================
364 class AboutDlg: public QDialog
367 AboutDlg( SALOME_InstallWizard* parent ) : QDialog( parent, "About dialog box", true )
370 setCaption( QString( "About %1" ).arg( parent->getIWName() ) );
372 QPalette pal = palette();
373 QColorGroup cg = pal.active();
374 cg.setColor( QColorGroup::Foreground, Qt::darkBlue );
375 cg.setColor( QColorGroup::Background, Qt::white );
376 pal.setActive( cg ); pal.setInactive( cg ); pal.setDisabled( cg );
379 QGridLayout* main = new QGridLayout( this, 1, 1, 11, 6 );
381 QLabel* logo = new QLabel( this, "logo" );
382 logo->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
383 logo->setMinimumSize( 32, 32 ); logo->setMaximumSize( 32, 32 );
384 logo->setPaletteBackgroundColor( QColor( 234, 250, 234 ) );
385 logo->setFrameStyle( QLabel::NoFrame | QLabel::Plain );
386 logo->setPixmap( pixmap( pxAbout ) );
387 logo->setScaledContents( false );
388 logo->setAlignment( QLabel::AlignCenter );
390 QLabel* decorLeft = new QLabel( this, "decorLeft" );
391 decorLeft->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) );
392 decorLeft->setMinimumWidth( 32 ); decorLeft->setMaximumWidth( 32 );
393 decorLeft->setPaletteBackgroundColor( QColor( 234, 250, 234 ) );
394 decorLeft->setScaledContents( false );
395 QLabel* decorTop = new QLabel( this, "decorTop" );
396 decorTop->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
397 decorTop->setMinimumHeight( 32 ); decorTop->setMaximumHeight( 32 );
398 decorTop->setPaletteBackgroundColor( QColor( 234, 250, 234 ) );
399 decorTop->setScaledContents( false );
401 QLabel* title = new QLabel( this, "title" );
402 QString tlt = parent->getIWName();
403 title->setText( makeTitle( tlt ) );
404 QLabel* version = new QLabel( this, "version" );
405 version->setText( QString( "<b>Version</b>: %1.%1.%1" ).arg( __IW_VERSION_MAJOR__ ) \
406 .arg( __IW_VERSION_MINOR__ ) \
407 .arg( __IW_VERSION_PATCH__ ) );
408 QLabel* copyright = new QLabel( this, "copyright" );
409 copyright->setText( "<b>Copyright</b> © 2004-2006 CEA" );
410 QFont font = title->font();
411 font.setPointSize( (int)( font.pointSize() * 1.8 ) );
412 title->setFont( font );
413 QFrame* line = new QFrame( this, "line" );
414 line->setFrameStyle( QFrame::HLine | QFrame::Sunken );
415 QLabel* url = new QLabel( this, "url" );
416 url->setText( makeTitle( "www.salome-platform.org", ".", false ) );
417 url->setAlignment( AlignRight );
418 font = version->font();
419 font.setPointSize( (int)( font.pointSize() / 1.2 ) );
420 version->setFont( font );
421 copyright->setFont( font );
422 url->setFont( font );
424 main->addWidget( logo, 0, 0 );
425 main->addMultiCellWidget( decorLeft, 1, 5, 0, 0 );
426 main->addWidget( decorTop, 0, 1 );
427 main->addWidget( title, 1, 1 );
428 main->addWidget( version, 2, 1 );
429 main->addWidget( copyright, 3, 1 );
430 main->addWidget( line, 4, 1 );
431 main->addWidget( url, 5, 1 );
433 QFontMetrics fm( title->font() );
434 int width = (int)( fm.width( tlt ) * 1.5 );
435 title->setMinimumWidth( width );
436 setMaximumSize( minimumSize() );
438 void mousePressEvent( QMouseEvent* )
444 // ================================================================
446 * SALOME_InstallWizard::SALOME_InstallWizard
449 // ================================================================
450 SALOME_InstallWizard::SALOME_InstallWizard(const QString& aXmlFileName,
451 const QString& aTargetDir,
452 const QString& aTmpDir)
453 : InstallWizard( qApp->desktop(), "SALOME_InstallWizard", false, 0 ),
457 exitConfirmed( false )
459 myIWName = tr( "Installation Wizard" );
460 tmpCreated = QString::null;
461 xmlFileName = aXmlFileName;
462 targetDirPath = aTargetDir;
463 tmpDirPath = aTmpDir;
465 // set application font
467 fnt.setPointSize( 14 );
472 setIcon( pixmap( pxIcon ) );
474 setSizeGripEnabled( true );
477 addLogo( pixmap( pxLogo ) );
481 setCaption( tr( "PAL/SALOME %1" ).arg( myVersion ) );
482 setCopyright( tr( "Copyright (C) 2004 CEA" ) );
483 setLicense( tr( "All right reserved" ) );
486 ___MESSAGE___( "Configuration file : " << xmlFileName );
487 ___MESSAGE___( "Target directory : " << targetDirPath );
488 ___MESSAGE___( "Temporary directory: " << tmpDirPath );
491 QFile xmlfile(xmlFileName);
492 if ( xmlfile.exists() ) {
493 QXmlInputSource source( &xmlfile );
494 QXmlSimpleReader reader;
496 StructureParser* handler = new StructureParser( this );
497 reader.setContentHandler( handler );
498 reader.parse( source );
501 // create instance of class for starting shell install script
502 shellProcess = new QProcess( this, "shellProcess" );
504 // create introduction page
506 // create products page
508 // create prestart page
510 // create progress page
512 // create readme page
516 QWhatsThis::add( backButton(), tr( "Returns to the previous step of the installation procedure" ) );
517 QToolTip::add ( backButton(), tr( "Returns to the previous step of the installation procedure" ) );
518 QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
519 QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
520 QWhatsThis::add( finishButton(), tr( "Finishes installation and quits program" ) );
521 QToolTip::add ( finishButton(), tr( "Finishes installation and quits program" ) );
522 QWhatsThis::add( cancelButton(), tr( "Cancels installation and quits program" ) );
523 QToolTip::add ( cancelButton(), tr( "Cancels installation and quits program" ) );
524 QWhatsThis::add( helpButton(), tr( "Displays help information window" ) );
525 QToolTip::add ( helpButton(), tr( "Displays help information window" ) );
527 // common signals connections
528 connect( this, SIGNAL( selected( const QString& ) ),
529 this, SLOT( pageChanged( const QString& ) ) );
530 connect( this, SIGNAL( helpClicked() ), this, SLOT( helpClicked() ) );
531 connect( this, SIGNAL( aboutClicked() ), this, SLOT( onAbout() ) );
533 // catch signals from launched script
534 connect(shellProcess, SIGNAL( readyReadStdout() ), this, SLOT( readFromStdout() ) );
535 connect(shellProcess, SIGNAL( readyReadStderr() ), this, SLOT( readFromStderr() ) );
536 connect(shellProcess, SIGNAL( processExited() ), this, SLOT( productInstalled() ) );
537 connect(shellProcess, SIGNAL( wroteToStdin() ), this, SLOT( wroteToStdin() ) );
539 // create validation thread
540 myThread = new ProcessThread( this );
543 setAboutIcon( pixmap( pxAbout ) );
544 showAboutBtn( true );
546 // ================================================================
548 * SALOME_InstallWizard::~SALOME_InstallWizard
551 // ================================================================
552 SALOME_InstallWizard::~SALOME_InstallWizard()
554 shellProcess->kill(); // kill it for sure
555 QString script = "kill -9 ";
556 int PID = (int)shellProcess->processIdentifier();
558 script += QString::number( PID );
559 script += " > /dev/null";
560 ___MESSAGE___( "script: " << script.latin1() );
561 if ( system( script.latin1() ) ) {
566 // ================================================================
568 * SALOME_InstallWizard::eventFilter
569 * Event filter, spies for Help window closing
571 // ================================================================
572 bool SALOME_InstallWizard::eventFilter( QObject* object, QEvent* event )
574 if ( object && object == helpWindow && event->type() == QEvent::Close )
576 return InstallWizard::eventFilter( object, event );
578 // ================================================================
580 * SALOME_InstallWizard::closeEvent
581 * Close event handler
583 // ================================================================
584 void SALOME_InstallWizard::closeEvent( QCloseEvent* ce )
586 if ( WarnDialog::isWarnDlgShown() ) {
590 if ( !exitConfirmed ) {
591 if ( QMessageBox::information( this,
593 tr( "Do you want to quit %1?" ).arg( getIWName() ),
603 exitConfirmed = true;
608 // ================================================================
610 * SALOME_InstallWizard::setupIntroPage
611 * Creates introduction page
613 // ================================================================
614 void SALOME_InstallWizard::setupIntroPage()
617 introPage = new QWidget( this, "IntroPage" );
618 QGridLayout* pageLayout = new QGridLayout( introPage );
619 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
620 // create logo picture
621 logoLab = new QLabel( introPage );
622 logoLab->setPixmap( pixmap( pxBigLogo ) );
623 logoLab->setScaledContents( false );
624 logoLab->setFrameStyle( QLabel::Plain | QLabel::NoFrame );
625 logoLab->setAlignment( AlignCenter );
626 // create version box
627 QVBox* versionBox = new QVBox( introPage ); versionBox->setSpacing( 6 );
628 versionBox->setFrameStyle( QVBox::Panel | QVBox::Sunken );
629 QWidget* stretch1 = new QWidget( versionBox ); versionBox->setStretchFactor( stretch1, 5 );
630 versionLab = new QLabel( QString("%1 %2").arg( tr( "Version" ) ).arg(myVersion), versionBox );
631 versionLab->setAlignment( AlignCenter );
632 copyrightLab = new QLabel( myCopyright, versionBox );
633 copyrightLab->setAlignment( AlignCenter );
634 licenseLab = new QLabel( myLicense, versionBox );
635 licenseLab->setAlignment( AlignCenter );
636 QWidget* stretch2 = new QWidget( versionBox ); versionBox->setStretchFactor( stretch2, 5 );
638 info = new QLabel( introPage );
639 info->setText( tr( "This program will install <b>%1</b>."
640 "<br><br>The wizard will also help you to install all products "
641 "which are necessary for <b>%2</b> and setup "
642 "your environment.<br><br>Click <code>Cancel</code> button to abort "
643 "installation and quit. Click <code>Next</code> button to continue with the "
644 "installation program." ).arg( myCaption ).arg( myCaption ) );
645 info->setFrameStyle( QLabel::WinPanel | QLabel::Sunken );
646 info->setMargin( 6 );
647 info->setAlignment( WordBreak );
648 info->setMinimumWidth( 250 );
649 QPalette pal = info->palette();
650 pal.setColor( QColorGroup::Background, QApplication::palette().active().base() );
651 info->setPalette( pal );
652 info->setLineWidth( 2 );
654 pageLayout->addWidget( logoLab, 0, 0 );
655 pageLayout->addWidget( versionBox, 1, 0 );
656 pageLayout->addMultiCellWidget( info, 0, 1, 1, 1 );
657 pageLayout->setColStretch( 1, 5 );
658 pageLayout->setRowStretch( 1, 5 );
660 addPage( introPage, tr( "Introduction" ) );
662 // ================================================================
664 * SALOME_InstallWizard::setupProductsPage
665 * Creates products page
667 // ================================================================
668 void SALOME_InstallWizard::setupProductsPage()
671 productsPage = new QWidget( this, "ProductsPage" );
672 QGridLayout* pageLayout = new QGridLayout( productsPage );
673 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
675 QLabel* targetLab = new QLabel( tr( "Type the target directory:" ), productsPage );
676 targetFolder = new QLineEdit( productsPage );
677 QWhatsThis::add( targetFolder, tr( "Enter target root directory where products will be installed" ) );
678 QToolTip::add ( targetFolder, tr( "Enter target root directory where products will be installed" ) );
679 targetBtn = new QPushButton( tr( "Browse..." ), productsPage );
680 QWhatsThis::add( targetBtn, tr( "Click this to browse target directory" ) );
681 QToolTip::add ( targetBtn, tr( "Click this to browse target directory" ) );
682 // create advanced mode widgets container
683 moreBox = new QWidget( productsPage );
684 QGridLayout* moreBoxLayout = new QGridLayout( moreBox );
685 moreBoxLayout->setMargin( 0 ); moreBoxLayout->setSpacing( 6 );
687 QLabel* tempLab = new QLabel( tr( "Type the directory for the temporary files:" ), moreBox );
688 tempFolder = new QLineEdit( moreBox );
689 // tempFolder->setText( "/tmp" ); // default is /tmp directory
690 QWhatsThis::add( tempFolder, tr( "Enter directory where to put temporary files" ) );
691 QToolTip::add ( tempFolder, tr( "Enter directory where to put temporary files" ) );
692 tempBtn = new QPushButton( tr( "Browse..." ), moreBox );
693 tempBtn->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
694 QWhatsThis::add( tempBtn, tr( "Click this to browse temporary directory" ) );
695 QToolTip::add ( tempBtn, tr( "Click this to browse temporary directory" ) );
696 // create products list
697 productsView = new ProductsView( moreBox );
698 productsView->setMinimumSize( 250, 180 );
699 QWhatsThis::add( productsView, tr( "This view lists the products you wish to be installed" ) );
700 QToolTip::add ( productsView, tr( "This view lists the products you wish to be installed" ) );
702 productsInfo = new QTextBrowser( moreBox );
703 productsInfo->setMinimumSize( 270, 135 );
704 QWhatsThis::add( productsInfo, tr( "Shows info about the product: required disk space and prerequisites" ) );
705 QToolTip::add ( productsInfo, tr( "Shows info about the product: required disk space and prerequisites" ) );
707 QLabel* reqLab1 = new QLabel( tr( "Total disk space required:" ), moreBox );
708 QWhatsThis::add( reqLab1, tr( "Shows total disk space required for installing selected products" ) );
709 QToolTip::add ( reqLab1, tr( "Shows total disk space required for installing selected products" ) );
710 requiredSize = new QLabel( moreBox );
711 requiredSize->setMinimumWidth( 100 );
712 QWhatsThis::add( requiredSize, tr( "Shows total disk space required for installing selected products" ) );
713 QToolTip::add ( requiredSize, tr( "Shows total disk space required for installing selected products" ) );
714 QLabel* reqLab2 = new QLabel( tr( "Space for temporary files:" ), moreBox );
715 QWhatsThis::add( reqLab2, tr( "Shows additional disk space which is required for temporary files" ) );
716 QToolTip::add ( reqLab2, tr( "Shows additional disk space which is required for temporary files" ) );
717 requiredTemp = new QLabel( moreBox );
718 requiredTemp->setMinimumWidth( 100 );
719 QWhatsThis::add( requiredTemp, tr( "Shows additional disk space which is required for temporary files" ) );
720 QToolTip::add ( requiredTemp, tr( "Shows additional disk space which is required for temporary files" ) );
721 QFont fnt = reqLab1->font();
723 reqLab1->setFont( fnt );
724 requiredSize->setFont( fnt );
725 reqLab2->setFont( fnt );
726 requiredTemp->setFont( fnt );
727 QGridLayout* sizeLayout = new QGridLayout; sizeLayout->setMargin( 0 ); sizeLayout->setSpacing( 6 );
728 sizeLayout->addWidget( reqLab1, 0, 0 );
729 sizeLayout->addWidget( requiredSize, 0, 1 );
730 sizeLayout->addWidget( reqLab2, 1, 0 );
731 sizeLayout->addWidget( requiredTemp, 1, 1 );
732 // prerequisites checkbox
733 prerequisites = new QCheckBox( tr( "Auto set prerequisites products" ), moreBox );
734 prerequisites->setChecked( true );
735 QWhatsThis::add( prerequisites, tr( "Check this if you want prerequisites products to be set on automatically" ) );
736 QToolTip::add ( prerequisites, tr( "Check this if you want prerequisites products to be set on automatically" ) );
737 // <Unselect All> button
738 unselectBtn = new QPushButton( tr( "&Unselect All" ), moreBox );
739 QWhatsThis::add( unselectBtn, tr( "Unselects all products" ) );
740 QToolTip::add ( unselectBtn, tr( "Unselects all products" ) );
741 // <SALOME sources> / <SALOME binaries> tri-state checkboxes
742 selectSrcBtn = new QMyCheckBox( tr( "SALOME sources" ), moreBox );
743 selectSrcBtn->setTristate( true );
744 QWhatsThis::add( selectSrcBtn, tr( "Selects/unselects SALOME sources" ) );
745 QToolTip::add ( selectSrcBtn, tr( "Selects/unselects SALOME sources" ) );
746 selectBinBtn = new QMyCheckBox( tr( "SALOME binaries" ), moreBox );
747 selectBinBtn->setTristate( true );
748 QWhatsThis::add( selectBinBtn, tr( "Selects/unselects SALOME binaries" ) );
749 QToolTip::add ( selectBinBtn, tr( "Selects/unselects SALOME binaries" ) );
750 QVBoxLayout* btnLayout = new QVBoxLayout; btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );
751 btnLayout->addWidget( unselectBtn );
752 btnLayout->addWidget( selectSrcBtn );
753 btnLayout->addWidget( selectBinBtn );
754 // layouting advancet mode widgets
755 moreBoxLayout->addMultiCellWidget( tempLab, 0, 0, 0, 2 );
756 moreBoxLayout->addMultiCellWidget( tempFolder, 1, 1, 0, 1 );
757 moreBoxLayout->addWidget ( tempBtn, 1, 2 );
758 moreBoxLayout->addMultiCellWidget( productsView, 2, 5, 0, 0 );
759 moreBoxLayout->addMultiCellWidget( productsInfo, 2, 2, 1, 2 );
760 moreBoxLayout->addMultiCellWidget( prerequisites,3, 3, 1, 2 );
761 moreBoxLayout->addMultiCellLayout( btnLayout, 4, 4, 1, 2 );
762 moreBoxLayout->addMultiCellLayout( sizeLayout, 5, 5, 1, 2 );
764 moreBtn = new QPushButton( tr( "More..." ), productsPage );
766 pageLayout->addMultiCellWidget( targetLab, 0, 0, 0, 1 );
767 pageLayout->addWidget ( targetFolder, 1, 0 );
768 pageLayout->addWidget ( targetBtn, 1, 1 );
769 pageLayout->addMultiCellWidget( moreBox, 2, 2, 0, 1 );
770 pageLayout->addWidget ( moreBtn, 3, 1 );
771 pageLayout->setRowStretch( 2, 5 );
772 //pageLayout->addRowSpacing( 6, 10 );
774 QFile xmlfile(xmlFileName);
775 if ( xmlfile.exists() ) {
776 QXmlInputSource source( &xmlfile );
777 QXmlSimpleReader reader;
779 StructureParser* handler = new StructureParser( this );
780 handler->setProductsList(productsView);
781 handler->setTargetDir(targetFolder);
782 handler->setTempDir(tempFolder);
783 reader.setContentHandler( handler );
784 reader.parse( source );
786 // take into account command line parameters
787 if ( !targetDirPath.isEmpty() )
788 targetFolder->setText( targetDirPath );
789 if ( !tmpDirPath.isEmpty() )
790 tempFolder->setText( tmpDirPath );
792 // set first item to be selected
793 if ( productsView->childCount() > 0 ) {
794 productsView->setSelected( productsView->firstChild(), true );
795 onSelectionChanged();
798 addPage( productsPage, tr( "Installation settings" ) );
799 // connecting signals
800 connect( productsView, SIGNAL( selectionChanged() ),
801 this, SLOT( onSelectionChanged() ) );
802 connect( productsView, SIGNAL( itemToggled( QCheckListItem* ) ),
803 this, SLOT( onItemToggled( QCheckListItem* ) ) );
804 connect( unselectBtn, SIGNAL( clicked() ), this, SLOT( onProdBtn() ) );
805 connect( selectSrcBtn, SIGNAL( stateChanged(int) ),
806 this, SLOT( onProdBtn() ) );
807 connect( selectBinBtn, SIGNAL( stateChanged(int) ),
808 this, SLOT( onProdBtn() ) );
809 // connecting signals
810 connect( targetFolder, SIGNAL( textChanged( const QString& ) ),
811 this, SLOT( directoryChanged( const QString& ) ) );
812 connect( targetBtn, SIGNAL( clicked() ), this, SLOT( browseDirectory() ) );
813 connect( tempFolder, SIGNAL( textChanged( const QString& ) ),
814 this, SLOT( directoryChanged( const QString& ) ) );
815 connect( tempBtn, SIGNAL( clicked() ), this, SLOT( browseDirectory() ) );
816 connect( moreBtn, SIGNAL( clicked() ), this, SLOT( onMoreBtn() ) );
817 // start on default - non-advanced - mode
820 // ================================================================
822 * SALOME_InstallWizard::setupCheckPage
823 * Creates prestart page
825 // ================================================================
826 void SALOME_InstallWizard::setupCheckPage()
829 prestartPage = new QWidget( this, "PrestartPage" );
830 QVBoxLayout* pageLayout = new QVBoxLayout( prestartPage );
831 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
833 choices = new QTextEdit( prestartPage );
834 choices->setReadOnly( true );
835 choices->setTextFormat( RichText );
836 choices->setUndoRedoEnabled ( false );
837 QWhatsThis::add( choices, tr( "Displays information about installation settings you made" ) );
838 QToolTip::add ( choices, tr( "Displays information about installation settings you made" ) );
839 QPalette pal = choices->palette();
840 pal.setColor( QColorGroup::Base, QApplication::palette().active().background() );
841 choices->setPalette( pal );
842 choices->setMinimumHeight( 10 );
844 pageLayout->addWidget( choices );
845 pageLayout->setStretchFactor( choices, 5 );
847 addPage( prestartPage, tr( "Check your choice" ) );
849 // ================================================================
851 * SALOME_InstallWizard::setupProgressPage
852 * Creates progress page
854 // ================================================================
855 void SALOME_InstallWizard::setupProgressPage()
858 progressPage = new QWidget( this, "progressPage" );
859 QGridLayout* pageLayout = new QGridLayout( progressPage );
860 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
862 splitter = new QSplitter( Vertical, progressPage );
863 splitter->setOpaqueResize( true );
864 // the parent for the widgets
865 QWidget* widget = new QWidget( splitter );
866 QGridLayout* layout = new QGridLayout( widget );
867 layout->setMargin( 0 ); layout->setSpacing( 6 );
868 // installation progress view box
869 installInfo = new InstallInfo( widget );
870 installInfo->setReadOnly( true );
871 installInfo->setTextFormat( RichText );
872 installInfo->setUndoRedoEnabled ( false );
873 installInfo->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
874 installInfo->setMinimumSize( 100, 10 );
875 QWhatsThis::add( installInfo, tr( "Displays installation process" ) );
876 QToolTip::add ( installInfo, tr( "Displays installation process" ) );
877 // parameters for the script
878 parametersLab = new QLabel( tr( "Enter your answer here:" ), widget );
879 passedParams = new QLineEdit ( widget );
880 QWhatsThis::add( passedParams, tr( "Use this field to enter answer for the running script when it is necessary") );
881 QToolTip::add ( passedParams, tr( "Use this field to enter answer for the running script when it is necessary") );
882 // VSR: 10/11/05 - disable answer mode ==>
883 parametersLab->hide();
884 passedParams->hide();
885 // VSR: 10/11/05 - disable answer mode <==
887 layout->addWidget( installInfo, 0, 0 );
888 layout->addWidget( parametersLab, 1, 0 );
889 layout->addWidget( passedParams, 2, 0 );
890 layout->addRowSpacing( 3, 6 );
891 // the parent for the widgets
892 widget = new QWidget( splitter );
893 layout = new QGridLayout( widget );
894 layout->setMargin( 0 ); layout->setSpacing( 6 );
895 // installation results view box
896 QLabel* resultLab = new QLabel( tr( "Installation Status:" ), widget );
897 progressView = new ProgressView( widget );
898 progressView->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
899 progressView->setMinimumSize( 100, 10 );
900 QWhatsThis::add( progressView, tr( "Displays installation status" ) );
901 QToolTip::add ( progressView, tr( "Displays installation status" ) );
903 layout->addRowSpacing( 0, 6 );
904 layout->addWidget( resultLab, 1, 0 );
905 layout->addWidget( progressView, 2, 0 );
907 pageLayout->addWidget( splitter, 0, 0 );
909 addPage( progressPage, tr( "Installation progress" ) );
911 connect( passedParams, SIGNAL( returnPressed() ), this, SLOT( onReturnPressed() ) ) ;
913 // ================================================================
915 * SALOME_InstallWizard::setupReadmePage
916 * Creates readme page
918 // ================================================================
919 void SALOME_InstallWizard::setupReadmePage()
922 readmePage = new QWidget( this, "ReadmePage" );
923 QVBoxLayout* pageLayout = new QVBoxLayout( readmePage );
924 pageLayout->setMargin( 0 ); pageLayout->setSpacing( 6 );
925 // README info text box
926 readme = new QTextEdit( readmePage );
927 readme->setReadOnly( true );
928 readme->setTextFormat( PlainText );
929 readme->setFont( QFont( "Fixed", 12 ) );
930 readme->setUndoRedoEnabled ( false );
931 QWhatsThis::add( readme, tr( "Displays README information" ) );
932 QToolTip::add ( readme, tr( "Displays README information" ) );
933 QPalette pal = readme->palette();
934 pal.setColor( QColorGroup::Base, QApplication::palette().active().background() );
935 readme->setPalette( pal );
936 readme->setMinimumHeight( 10 );
937 // <Launch SALOME> button
938 runSalomeBtn = new QPushButton( tr( "Launch SALOME" ), readmePage );
939 QWhatsThis::add( runSalomeBtn, tr( "Click this button to run SALOME desktop" ) );
940 QToolTip::add ( runSalomeBtn, tr( "Click this button to run SALOME desktop" ) );
941 QHBoxLayout* hLayout = new QHBoxLayout;
942 hLayout->addWidget( runSalomeBtn ); hLayout->addStretch();
944 pageLayout->addWidget( readme );
945 pageLayout->setStretchFactor( readme, 5 );
946 pageLayout->addLayout( hLayout );
947 // connecting signals
948 connect( runSalomeBtn, SIGNAL( clicked() ), this, SLOT( onLaunchSalome() ) );
949 // loading README file
950 QString readmeFile = QDir::currentDirPath() + "/README";
952 if ( readFile( readmeFile, text ) )
953 readme->setText( text );
955 readme->setText( tr( "README file has not been found" ) );
957 addPage( readmePage, tr( "Finish installation" ) );
959 // ================================================================
961 * SALOME_InstallWizard::showChoiceInfo
962 * Displays choice info
964 // ================================================================
965 void SALOME_InstallWizard::showChoiceInfo()
969 long totSize, tempSize;
970 checkSize( &totSize, &tempSize );
974 if ( !xmlFileName.isEmpty() ) {
975 text += tr( "Configuration file" )+ ": <b>" + xmlFileName + "</b><br>";
978 if ( !myOS.isEmpty() ) {
979 text += tr( "Reference Linux platform" ) + ": <b>" + myOS + "</b><br>";
982 text += tr( "Native products to be used" ) + ":<ul>";
983 QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
985 if ( productsMap.contains( item ) ) {
986 if ( item->childCount() > 0 ) {
987 if ( productsView->isNative( item ) ) {
988 text += "<li><b>" + item->text() + "</b><br>";
993 item = (QCheckListItem*)( item->nextSibling() );
996 text += "<li><b>" + tr( "none" ) + "</b><br>";
1000 text += tr( "Products to be installed" ) + ":<ul>";
1001 item = (QCheckListItem*)( productsView->firstChild() );
1003 if ( productsMap.contains( item ) ) {
1004 if ( item->childCount() > 0 ) {
1005 if ( productsView->isBinaries( item ) ) {
1006 text += "<li><b>" + item->text() + " " + item->text(1) + "</b> " + tr( "as binaries" ) + "<br>";
1009 else if ( productsView->isSources( item ) ) {
1010 text+= "<li><b>" + item->text() + " " + item->text(1) + "</b> " + tr( "as sources" ) + "<br>";
1014 else if ( item->isOn() ) {
1015 text+= "<li><b>" + item->text() + "</b><br>";
1019 item = (QCheckListItem*)( item->nextSibling() );
1021 if ( nbProd == 0 ) {
1022 text += "<li><b>" + tr( "none" ) + "</b><br>";
1025 text += tr( "Total disk space required:" ) + " <b>" + QString::number( totSize ) + " Kb</b><br>" ;
1026 text += tr( "Space for temporary files required:" ) + " <b>" + QString::number( tempSize ) + " Kb</b><br>" ;
1028 text += tr( "Target directory:" ) + " <b>" + QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) + "</b><br>";
1029 // VSR: Temporary folder is used always now and it is not necessary to disable it -->
1030 // if ( tempSize > 0 )
1031 // VSR: <----------------------------------------------------------------------------
1032 text += tr( "Temporary directory:" ) + " <b>" + QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + "</b><br>";
1034 choices->setText( text );
1036 // ================================================================
1038 * SALOME_InstallWizard::acceptData
1039 * Validates page when <Next> button is clicked
1041 // ================================================================
1042 bool SALOME_InstallWizard::acceptData( const QString& pageTitle )
1045 QWidget* aPage = InstallWizard::page( pageTitle );
1046 if ( aPage == productsPage ) {
1047 // ########## check if any products are selected to be installed
1048 long totSize, tempSize;
1049 bool anySelected = checkSize( &totSize, &tempSize );
1050 if ( !anySelected ) {
1051 QMessageBox::warning( this,
1053 tr( "Select one or more products to install" ),
1055 QMessageBox::NoButton,
1056 QMessageBox::NoButton );
1059 // ########## check target and temp directories (existence and available disk space)
1061 QString targetDir = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() );
1062 QString tempDir = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() );
1063 // directories should differ
1064 // if (!targetDir.isEmpty() && tempDir == targetDir) {
1065 // QMessageBox::warning( this,
1067 // tr( "Target and temporary directories must be different"),
1069 // QMessageBox::NoButton,
1070 // QMessageBox::NoButton );
1073 // check target directory
1074 if ( targetDir.isEmpty() ) {
1075 QMessageBox::warning( this,
1077 tr( "Please, enter valid target directory path" ),
1079 QMessageBox::NoButton,
1080 QMessageBox::NoButton );
1083 QFileInfo fi( QDir::cleanDirPath( targetDir ) );
1084 if ( !fi.exists() ) {
1086 QMessageBox::warning( this,
1088 tr( "The directory %1 doesn't exist.\n"
1089 "Create directory?" ).arg( fi.absFilePath() ),
1092 QMessageBox::NoButton ) == QMessageBox::Yes;
1095 if ( !makeDir( fi.absFilePath(), tmpstr ) ) {
1096 QMessageBox::critical( this,
1098 tr( "Can't create the directory\n%1").arg( fi.absFilePath() ),
1100 QMessageBox::NoButton,
1101 QMessageBox::NoButton );
1105 if ( !fi.isDir() ) {
1106 QMessageBox::warning( this,
1108 tr( "%1 is not a directory.\n"
1109 "Please, enter valid target directory path" ).arg( fi.absFilePath() ),
1111 QMessageBox::NoButton,
1112 QMessageBox::NoButton );
1115 if ( !fi.isWritable() ) {
1116 QMessageBox::warning( this,
1118 tr( "The directory %1 is not writeable.\n"
1119 "Please, enter valid target directory path or change permissions" ).arg( fi.absFilePath() ),
1121 QMessageBox::NoButton,
1122 QMessageBox::NoButton );
1125 if ( hasSpace( fi.absFilePath() ) &&
1126 QMessageBox::warning( this,
1128 tr( "The target directory contains space symbols.\n"
1129 "This may cause problems with compiling or installing of products.\n\n"
1130 "Do you want to continue?"),
1133 QMessageBox::NoButton ) == QMessageBox::No ) {
1136 QString binDir = "./Products/BINARIES";
1137 if ( !myOS.isEmpty() )
1138 binDir += "/" + myOS;
1139 QFileInfo fib( QDir::cleanDirPath( binDir ) );
1140 if ( !fib.exists() ) {
1141 QMessageBox::warning( this,
1143 tr( "The directory %1 doesn't exist.\n"
1144 "This directory must contain binaries archives." ).arg( fib.absFilePath() ));
1146 // run script that checks available disk space for installing of products // returns 1 in case of error
1147 QString script = "./config_files/checkSize.sh '";
1148 script += fi.absFilePath();
1150 script += QString( "%1" ).arg( totSize );
1151 ___MESSAGE___( "script = " << script );
1152 if ( system( script ) ) {
1153 QMessageBox::critical( this,
1154 tr( "Out of space" ),
1155 tr( "There is no available disk space for installing of selected products" ),
1157 QMessageBox::NoButton,
1158 QMessageBox::NoButton );
1161 // check temp directory
1162 if ( tempDir.isEmpty() ) {
1164 QMessageBox::warning( this,
1166 tr( "Please, enter valid temporary directory path" ),
1168 QMessageBox::NoButton,
1169 QMessageBox::NoButton );
1174 tempFolder->setText( tempDir );
1177 QFileInfo fit( QDir::cleanDirPath( tempDir ) );
1178 if ( !makeDir( fit.absFilePath() + TEMPDIRNAME, tmpCreated ) ) {
1179 QMessageBox::critical( this,
1181 tr( "Can't use temporary directory.\nCheck permissions for the %1 directory.").arg( fit.absFilePath() ),
1183 QMessageBox::NoButton,
1184 QMessageBox::NoButton );
1187 // run script that check available disk space for temporary files
1188 // returns 1 in case of error
1189 QString tscript = "./config_files/checkSize.sh '";
1190 tscript += fit.absFilePath();
1192 tscript += QString( "%1" ).arg( tempSize );
1193 ___MESSAGE___( "script = " << tscript );
1194 if ( system( tscript ) ) {
1195 QMessageBox::critical( this,
1196 tr( "Out of space" ),
1197 tr( "There is no available disk space for the temporary files" ),
1199 QMessageBox::NoButton,
1200 QMessageBox::NoButton );
1203 // VSR: <------------------------------------------------------------------------------
1204 // ########## check native products
1205 QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
1206 QStringList natives;
1208 if ( productsMap.contains( item ) ) {
1209 if ( item->childCount() > 0 ) {
1210 // VSR : 29/01/05 : Check installation script even if product is not being installed
1211 // if ( !productsView->isNone( item ) ) {
1212 if ( item->text(2).isEmpty() || item->text(2).isNull() ) {
1213 QMessageBox::warning( this,
1215 tr( "The installation script for %1 is not defined.").arg(item->text(0)),
1217 QMessageBox::NoButton,
1218 QMessageBox::NoButton );
1221 productsView->setCurrentItem( item );
1222 productsView->setSelected( item, true );
1223 productsView->ensureItemVisible( item );
1224 //productsView->setNone( item );
1227 QFileInfo fi( QString("./config_files/") + item->text(2) );
1228 if ( !fi.exists() || !fi.isExecutable() ) {
1229 QMessageBox::warning( this,
1231 tr( "The script %1 required for %2 doesn't exist or doesn't have execute permissions.").arg("./config_files/" + item->text(2)).arg(item->text(0)),
1233 QMessageBox::NoButton,
1234 QMessageBox::NoButton );
1237 productsView->setCurrentItem( item );
1238 productsView->setSelected( item, true );
1239 productsView->ensureItemVisible( item );
1240 //productsView->setNone( item );
1245 // collect native products
1246 if ( productsView->isNative( item ) ) {
1247 if ( natives.find( item->text(0) ) == natives.end() )
1248 natives.append( item->text(0) );
1250 else if ( productsView->isBinaries( item ) || productsView->isSources( item ) ) {
1251 QStringList dependOn = productsMap[ item ].getDependancies();
1252 for ( int i = 0; i < (int)dependOn.count(); i++ ) {
1253 QCheckListItem* depitem = findItem( dependOn[ i ] );
1255 if ( productsView->isNative( depitem ) && natives.find( depitem->text(0) ) == natives.end() )
1256 natives.append( depitem->text(0) );
1259 QMessageBox::warning( this,
1261 tr( "%1 is required for %2 %3 installation.\n"
1262 "This product is missing in the configuration file %4.").arg(dependOn[ i ]).arg(item->text(0)).arg(item->text(1)).arg(xmlFileName),
1264 QMessageBox::NoButton,
1265 QMessageBox::NoButton );
1272 item = (QCheckListItem*)( item->nextSibling() );
1274 QString tmpFolder = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
1275 QString tgtFolder = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() );
1276 myThread->clearCommands();
1277 if ( natives.count() > 0 ) {
1278 for ( unsigned i = 0; i < natives.count(); i++ ) {
1279 item = findItem( natives[ i ] );
1281 QString dependOn = productsMap[ item ].getDependancies().join(" ");
1282 QString script = "cd ./config_files/;" + item->text(2) + " try_native " +
1283 QFileInfo( tmpFolder ).absFilePath() + " " + QDir::currentDirPath() + "/Products " + QFileInfo( tgtFolder ).absFilePath() + " " +
1284 QUOTE(dependOn) + " " + item->text(0);
1286 myThread->addCommand( item, script );
1289 QMessageBox::warning( this,
1291 tr( "%The product %1 %2 required for installation.\n"
1292 "This product is missing in the configuration file %4.").arg(item->text(0)).arg(item->text(1)).arg(xmlFileName),
1294 QMessageBox::NoButton,
1295 QMessageBox::NoButton );
1299 WarnDialog::showWarnDlg( this, true );
1301 return true; // return in order to avoid default postValidateEvent() action
1304 return InstallWizard::acceptData( pageTitle );
1306 // ================================================================
1308 * SALOME_InstallWizard::checkSize
1309 * Calculates disk space required for the installation
1311 // ================================================================
1312 bool SALOME_InstallWizard::checkSize( long* totSize, long* tempSize )
1314 long tots = 0, temps = 0;
1317 MapProducts::Iterator mapIter;
1318 for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
1319 QCheckListItem* item = mapIter.key();
1320 Dependancies dep = mapIter.data();
1321 if ( productsView->isBinaries( item ) ) {
1322 tots += dep.getSize();
1324 else if ( productsView->isSources( item ) ) {
1325 tots += dep.getSize(true);
1326 temps = max( temps, dep.getTempSize() );
1328 if ( !productsView->isNone( item ) )
1336 return ( nbSelected > 0 );
1338 // ================================================================
1340 * SALOME_InstallWizard::checkProductPage
1341 * Checks products page validity (directories and products selection) and
1342 * enabled/disables "Next" button for the Products page
1344 // ================================================================
1345 void SALOME_InstallWizard::checkProductPage()
1347 long tots = 0, temps = 0;
1349 // check if any product is selected;
1350 bool isAnyProductSelected = checkSize( &tots, &temps );
1351 // check if target directory is valid
1352 bool isTargetDirValid = !targetFolder->text().stripWhiteSpace().isEmpty();
1353 // check if temp directory is valid
1354 bool isTempDirValid = !moreMode || !tempFolder->text().stripWhiteSpace().isEmpty();
1356 // update required size information
1357 requiredSize->setText( QString::number( tots ) + " Kb");
1358 requiredTemp->setText( QString::number( temps ) + " Kb");
1360 // update <SALOME sources>, <SALOME binaries> check boxes state
1361 int totSrc = 0, selSrc = 0;
1362 int totBin = 0, selBin = 0;
1363 MapProducts::Iterator itProd;
1364 for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) {
1365 bool srcctx = itProd.data().hasContext( "salome sources" );
1366 bool binctx = itProd.data().hasContext( "salome binaries" );
1367 if ( srcctx && !binctx ) {
1369 if ( productsView->isSources( itProd.key() ) )
1372 if ( binctx && !srcctx ) {
1374 if ( productsView->isBinaries( itProd.key() ) )
1378 selectSrcBtn->blockSignals( true );
1379 selectBinBtn->blockSignals( true );
1380 selectSrcBtn->setState( selSrc == 0 ? QButton::Off : ( selSrc == totSrc ? QButton::On : QButton::NoChange ) );
1381 selectBinBtn->setState( selBin == 0 ? QButton::Off : ( selBin == totBin ? QButton::On : QButton::NoChange ) );
1382 selectSrcBtn->blockSignals( false );
1383 selectBinBtn->blockSignals( false );
1385 // enable/disable "Next" button
1386 setNextEnabled( productsPage, isAnyProductSelected && isTargetDirValid && isTempDirValid );
1388 // ================================================================
1390 * SALOME_InstallWizard::setPrerequisites
1391 * Sets the product and all products this one depends on to be checked ( recursively )
1393 // ================================================================
1394 void SALOME_InstallWizard::setPrerequisites( QCheckListItem* item )
1396 if ( !productsMap.contains( item ) )
1398 if ( productsView->isNone( item ) )
1400 // get all prerequisites
1401 QStringList dependOn = productsMap[ item ].getDependancies();
1402 for ( int i = 0; i < (int)dependOn.count(); i++ ) {
1403 MapProducts::Iterator itProd;
1404 for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) {
1405 if ( itProd.data().getName() == dependOn[ i ] ) {
1406 if ( productsView->isNone( itProd.key() ) ) {
1407 QString defMode = itProd.data().getDefault();
1408 if ( defMode.isEmpty() )
1409 defMode = tr( "install binaries" );
1410 if ( defMode == tr( "install binaries" ) )
1411 productsView->setBinaries( itProd.key() );
1412 else if ( defMode == tr( "install sources" ) )
1413 productsView->setSources( itProd.key() );
1414 else if ( defMode == tr( "use native" ) )
1415 productsView->setNative( itProd.key() );
1416 setPrerequisites( itProd.key() );
1422 // ================================================================
1424 * SALOME_InstallWizard::launchScript
1425 * Runs installation script
1427 // ================================================================
1428 void SALOME_InstallWizard::launchScript()
1430 // try to find product being processed now
1431 QString prodProc = progressView->findStatus( Processing );
1432 if ( !prodProc.isNull() ) {
1433 ___MESSAGE___( "Found <Processing>: " );
1435 // if found - set status to "completed"
1436 progressView->setStatus( prodProc, Completed );
1437 // ... and call this method again
1441 // else try to find next product which is not processed yet
1442 prodProc = progressView->findStatus( Waiting );
1443 if ( !prodProc.isNull() ) {
1444 ___MESSAGE___( "Found <Waiting>: " << prodProc.latin1() );
1445 // if found - set status to "processed" and run script
1446 progressView->setStatus( prodProc, Processing );
1447 progressView->ensureVisible( prodProc );
1449 QCheckListItem* item = findItem( prodProc );
1450 // fill in script parameters
1451 shellProcess->clearArguments();
1453 shellProcess->setWorkingDirectory( QDir::cleanDirPath( QFileInfo( "./config_files/" ).absFilePath() ) );
1454 shellProcess->addArgument( item->text(2) );
1457 QString tmpFolder = QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
1458 //if( !tempFolder->isEnabled() )
1459 //tmpFolder = "/tmp";
1462 if ( productsView->isBinaries( item ) ) {
1463 shellProcess->addArgument( "install_binary" );
1464 shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
1465 QString binDir = QDir::currentDirPath() + "/Products/BINARIES";
1466 if ( !myOS.isEmpty() )
1467 binDir += "/" + myOS;
1468 shellProcess->addArgument( binDir );
1471 else if ( productsView->isSources( item ) ) {
1472 shellProcess->addArgument( "install_source" );
1473 shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
1474 shellProcess->addArgument( QDir::currentDirPath() + "/Products/SOURCES" );
1477 else if ( productsView->isNative( item ) ) {
1478 shellProcess->addArgument( "try_native" );
1479 shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
1480 shellProcess->addArgument( QDir::currentDirPath() + "/Products" );
1482 // ... not install : try to find preinstalled
1484 shellProcess->addArgument( "try_preinstalled" );
1485 shellProcess->addArgument( QFileInfo( tmpFolder ).absFilePath() );
1486 shellProcess->addArgument( QDir::currentDirPath() + "/Products" );
1488 // ... target folder
1489 QString tgtFolder = QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() );
1490 shellProcess->addArgument( QFileInfo( tgtFolder ).absFilePath() );
1493 QString depproducts = DefineDependeces(productsMap);
1494 ___MESSAGE___( "Dependancies"<< depproducts.latin1() );
1496 shellProcess->addArgument( depproducts );
1497 // ... product name - currently instaled product
1498 shellProcess->addArgument( item->text(0) );
1501 if ( !shellProcess->start() ) {
1502 // error handling can be here
1503 ___MESSAGE___( "error" );
1507 ___MESSAGE___( "All products have been installed successfully" );
1508 // all products are installed successfully
1509 QString workDir = QDir::cleanDirPath( QFileInfo( "./config_files/" ).absFilePath() );
1510 MapProducts::Iterator mapIter;
1511 ___MESSAGE___( "starting pick-up environment" );
1512 for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
1513 QCheckListItem* item = mapIter.key();
1514 Dependancies dep = mapIter.data();
1515 QString depproducts = QUOTE( DefineDependeces(productsMap) );
1516 if ( dep.pickUpEnvironment() ) {
1517 ___MESSAGE___( "... for " << dep.getName() );
1519 script += "cd " + QUOTE( QFileInfo( QDir::cleanDirPath( "./config_files/" ) ).absFilePath() ) + "; ";
1520 script += item->text(2) + " ";
1521 script += "pickup_env ";
1522 script += QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() ) + " ";
1523 script += QUOTE( QFileInfo( QDir::cleanDirPath( QDir::currentDirPath() + "/Products" ) ).absFilePath() ) + " ";
1524 script += QUOTE( QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) ).absFilePath() ) + " ";
1525 script += depproducts + " ";
1526 script += item->text(0);
1527 ___MESSAGE___( "... --> " << script.latin1() );
1528 if ( system( script.latin1() ) ) {
1529 ___MESSAGE___( "ERROR" );
1534 setNextEnabled( true );
1535 nextButton()->setText( tr( "&Next >" ) );
1536 QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1537 QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1538 disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
1539 disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
1540 connect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
1542 setBackEnabled( true );
1543 // script parameters
1544 passedParams->clear();
1545 passedParams->setEnabled( false );
1546 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1547 installInfo->setFinished( true );
1548 if ( isMinimized() )
1552 // ================================================================
1554 * SALOME_InstallWizard::onMoreBtn
1555 * <More...> button slot
1557 // ================================================================
1558 void SALOME_InstallWizard::onMoreBtn()
1562 moreBtn->setText( tr( "More..." ) );
1566 moreBtn->setText( tr( "Less..." ) );
1568 qApp->processEvents();
1569 moreMode = !moreMode;
1570 InstallWizard::layOut();
1571 qApp->processEvents();
1572 if ( !isMaximized() ) {
1573 //setGeometry( geometry().x(), geometry().y(), geometry().width(), 0 );
1574 resize( geometry().width(), 0 );
1575 qApp->processEvents();
1579 // ================================================================
1581 * SALOME_InstallWizard::onLaunchSalome
1582 * <Launch Salome> button slot
1584 // ================================================================
1585 void SALOME_InstallWizard::onLaunchSalome()
1587 QString msg = tr( "You don't have SALOME binaries installed in the %1 directory!" ).arg( targetFolder->text() );
1589 QCheckListItem* item = findItem( "KERNEL-Bin" );
1591 QFileInfo fi( targetFolder->text() + "/KERNEL_" + item->text(1) + "/bin/salome/runSalome" );
1592 QFileInfo fienv( targetFolder->text() + "/KERNEL_" + item->text(1) + "/salome.sh" );
1593 if ( fienv.exists() ) {
1594 if ( fi.exists() ) {
1596 script += "cd " + targetFolder->text() + "/KERNEL_" + item->text(1) + "; ";
1597 script += "source salome.sh; ";
1598 script += "cd bin/salome; ";
1599 script += "runSalome > /dev/null";
1600 script = "(bash -c '" + script + "')";
1601 ___MESSAGE___( "script: " << script.latin1() );
1602 if ( !system( script.latin1() ) )
1605 msg = tr( "Can't launch SALOME." );
1608 msg = tr( "Can't launch SALOME." ) + "\n" + tr( "runSalome file can not be found." );
1611 msg = tr( "Can't launch SALOME." ) + "\n" + tr( "Can't find environment file." );
1613 QMessageBox::warning( this,
1617 QMessageBox::NoButton,
1618 QMessageBox::NoButton );
1621 // ================================================================
1623 * SALOME_InstallWizard::onAbout
1624 * <About> button slot: shows <About> dialog box
1626 // ================================================================
1627 void SALOME_InstallWizard::onAbout()
1633 // ================================================================
1635 * SALOME_InstallWizard::findItem
1636 * Searches product listview item with given symbolic name
1638 // ================================================================
1639 QCheckListItem* SALOME_InstallWizard::findItem( const QString& sName )
1641 MapProducts::Iterator mapIter;
1642 for ( mapIter = productsMap.begin(); mapIter != productsMap.end(); ++mapIter ) {
1643 if ( mapIter.data().getName() == sName )
1644 return mapIter.key();
1648 // ================================================================
1650 * SALOME_InstallWizard::abort
1651 * Sets progress state to Aborted
1653 // ================================================================
1654 void SALOME_InstallWizard::abort()
1656 QString prod = progressView->findStatus( Processing );
1657 while ( !prod.isNull() ) {
1658 progressView->setStatus( prod, Aborted );
1659 prod = progressView->findStatus( Processing );
1661 prod = progressView->findStatus( Waiting );
1662 while ( !prod.isNull() ) {
1663 progressView->setStatus( prod, Aborted );
1664 prod = progressView->findStatus( Waiting );
1667 // ================================================================
1669 * SALOME_InstallWizard::reject
1670 * Reject slot, clears temporary directory and closes application
1672 // ================================================================
1673 void SALOME_InstallWizard::reject()
1675 ___MESSAGE___( "REJECTED" );
1676 if ( !exitConfirmed ) {
1677 if ( QMessageBox::information( this,
1679 tr( "Do you want to quit %1?" ).arg( getIWName() ),
1687 exitConfirmed = true;
1690 InstallWizard::reject();
1692 // ================================================================
1694 * SALOME_InstallWizard::accept
1695 * Accept slot, clears temporary directory and closes application
1697 // ================================================================
1698 void SALOME_InstallWizard::accept()
1700 ___MESSAGE___( "ACCEPTED" );
1702 InstallWizard::accept();
1704 // ================================================================
1706 * SALOME_InstallWizard::clean
1707 * Clears and (optionally) removes temporary directory
1709 // ================================================================
1710 void SALOME_InstallWizard::clean(bool rmDir)
1712 WarnDialog::showWarnDlg( 0, false );
1713 myThread->clearCommands();
1715 while ( myThread->running() );
1716 // VSR: first remove temporary files
1717 QString script = "cd ./config_files/; remove_tmp.sh '";
1718 script += tempFolder->text().stripWhiteSpace() + TEMPDIRNAME;
1720 script += QUOTE(DefineDependeces(productsMap));
1721 script += " > /dev/null";
1722 ___MESSAGE___( "script = " << script );
1723 if ( system( script.latin1() ) ) {
1725 // VSR: then try to remove created temporary directory
1726 //script = "rm -rf " + QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME;
1727 if ( rmDir && !tmpCreated.isNull() ) {
1728 script = "rm -rf " + tmpCreated;
1729 script += " > /dev/null";
1730 if ( system( script.latin1() ) ) {
1732 ___MESSAGE___( "script = " << script );
1735 // ================================================================
1737 * SALOME_InstallWizard::pageChanged
1738 * Called when user moves from page to page
1740 // ================================================================
1741 void SALOME_InstallWizard::pageChanged( const QString & mytitle)
1743 nextButton()->setText( tr( "&Next >" ) );
1744 QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1745 QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1746 disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
1747 disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
1748 connect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
1749 cancelButton()->disconnect();
1750 connect( cancelButton(), SIGNAL( clicked()), this, SLOT( reject() ) );
1752 QWidget* aPage = InstallWizard::page( mytitle );
1756 if ( aPage == productsPage ) {
1758 onSelectionChanged();
1761 else if ( aPage == prestartPage ) {
1765 else if ( aPage == progressPage ) {
1766 if ( previousPage == prestartPage ) {
1768 progressView->clear();
1769 installInfo->clear();
1770 installInfo->setFinished( false );
1771 passedParams->clear();
1772 passedParams->setEnabled( false );
1773 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1774 nextButton()->setText( tr( "&Start" ) );
1775 QWhatsThis::add( nextButton(), tr( "Starts installation process" ) );
1776 QToolTip::add ( nextButton(), tr( "Starts installation process" ) );
1777 // reconnect Next button - to use it as Start button
1778 disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
1779 disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
1780 connect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
1781 setNextEnabled( true );
1782 // reconnect Cancel button to terminate process
1783 cancelButton()->disconnect();
1784 connect( cancelButton(), SIGNAL( clicked() ), this, SLOT( tryTerminate() ) );
1787 else if ( aPage == readmePage ) {
1788 QCheckListItem* item = findItem( "KERNEL-Bin" );
1789 runSalomeBtn->setEnabled( item &&
1790 QFileInfo( targetFolder->text() + "/KERNEL_" + item->text(1) + "/bin/salome/runSalome" ).exists() &&
1791 QFileInfo( targetFolder->text() + "/KERNEL_" + item->text(1) + "/salome.csh" ).exists() );
1792 finishButton()->setEnabled( true );
1794 previousPage = aPage;
1795 ___MESSAGE___( "previousPage = " << previousPage );
1797 // ================================================================
1799 * SALOME_InstallWizard::helpClicked
1802 // ================================================================
1803 void SALOME_InstallWizard::helpClicked()
1805 if ( helpWindow == NULL ) {
1806 helpWindow = HelpWindow::openHelp( this );
1809 helpWindow->installEventFilter( this );
1812 QMessageBox::warning( this,
1813 tr( "Help file not found" ),
1814 tr( "Sorry, help is unavailable" ) );
1818 helpWindow->raise();
1819 helpWindow->setActiveWindow();
1822 // ================================================================
1824 * SALOME_InstallWizard::browseDirectory
1825 * Shows directory selection dialog
1827 // ================================================================
1828 void SALOME_InstallWizard::browseDirectory()
1830 const QObject* theSender = sender();
1831 QLineEdit* theFolder;
1832 if ( theSender == targetBtn )
1833 theFolder = targetFolder;
1834 else if (theSender == tempBtn)
1835 theFolder = tempFolder;
1838 QString typedDir = QFileDialog::getExistingDirectory( QDir::cleanDirPath( theFolder->text().stripWhiteSpace() ), this );
1839 if ( !typedDir.isNull() ) {
1840 theFolder->setText( typedDir );
1841 theFolder->end( false );
1845 // ================================================================
1847 * SALOME_InstallWizard::directoryChanged
1848 * Called when directory path (target or temp) is changed
1850 // ================================================================
1851 void SALOME_InstallWizard::directoryChanged( const QString& /*text*/ )
1855 // ================================================================
1857 * SALOME_InstallWizard::onStart
1858 * <Start> button's slot - runs installation
1860 // ================================================================
1861 void SALOME_InstallWizard::onStart()
1863 if ( nextButton()->text() == tr( "&Stop" ) ) {
1864 shellProcess->kill();
1865 while( shellProcess->isRunning() );
1868 progressView->clear();
1869 installInfo->clear();
1870 installInfo->setFinished( false );
1871 passedParams->clear();
1872 passedParams->setEnabled( false );
1873 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1874 // clear list of products to install ...
1876 // ... and fill it for new process
1877 QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
1879 // if ( productsView->isBinaries( item ) || productsView->isSources( item ) || productsView->isNative( item ) ) {
1880 if ( productsMap.contains( item ) )
1881 toInstall.append( productsMap[item].getName() );
1883 item = (QCheckListItem*)( item->nextSibling() );
1885 // if something at all is selected
1886 if ( !toInstall.isEmpty() ) {
1887 clean(false); // VSR 07/02/05 - bug fix: first we should clear temporary directory
1888 // disable <Next> button
1889 //setNextEnabled( false );
1890 nextButton()->setText( tr( "&Stop" ) );
1891 QWhatsThis::add( nextButton(), tr( "Aborts installation process" ) );
1892 QToolTip::add ( nextButton(), tr( "Aborts installation process" ) );
1893 // disable <Back> button
1894 setBackEnabled( false );
1895 // enable script parameters line edit
1896 // VSR commented: 18/09/03: passedParams->setEnabled( true );
1897 // VSR commented: 18/09/03: passedParams->setFocus();
1898 // set status for all products
1899 for ( int i = 0; i < (int)toInstall.count(); i++ ) {
1900 item = findItem( toInstall[ i ] );
1902 if ( productsView->isBinaries( item ) )
1903 type = tr( "binaries" );
1904 else if ( productsView->isSources( item ) )
1905 type = tr( "sources" );
1906 else if ( productsView->isNative( item ) )
1907 type = tr( "native" );
1909 type = tr( "not install" );
1910 progressView->addProduct( item->text(0), type, item->text(2) );
1912 // launch install script
1916 // ================================================================
1918 * SALOME_InstallWizard::onReturnPressed
1919 * Called when users tries to pass parameters for the script
1921 // ================================================================
1922 void SALOME_InstallWizard::onReturnPressed()
1924 QString txt = passedParams->text();
1925 installInfo->append( txt );
1927 shellProcess->writeToStdin( txt );
1928 passedParams->clear();
1929 progressView->setFocus();
1930 passedParams->setEnabled( false );
1931 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1934 Callback function - as response for the script finishing
1936 void SALOME_InstallWizard::productInstalled( )
1938 ___MESSAGE___( "process exited" );
1939 if ( shellProcess->normalExit() ) {
1940 ___MESSAGE___( "...normal exit" );
1941 // normal exit - try to proceed installation further
1945 ___MESSAGE___( "...abnormal exit" );
1946 // installation aborted
1948 // clear script passed parameters lineedit
1949 passedParams->clear();
1950 passedParams->setEnabled( false );
1951 QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
1952 installInfo->setFinished( true );
1953 // enable <Next> button
1954 setNextEnabled( true );
1955 nextButton()->setText( tr( "&Start" ) );
1956 QWhatsThis::add( nextButton(), tr( "Starts installation process" ) );
1957 QToolTip::add ( nextButton(), tr( "Starts installation process" ) );
1958 // reconnect Next button - to use it as Start button
1959 disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
1960 disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
1961 connect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
1962 //nextButton()->setText( tr( "&Next >" ) );
1963 //QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1964 //QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
1965 //disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
1966 //disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
1967 //connect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
1968 // enable <Back> button
1969 setBackEnabled( true );
1972 // ================================================================
1974 * SALOME_InstallWizard::tryTerminate
1975 * Slot, called when <Cancel> button is clicked during installation script running
1977 // ================================================================
1978 void SALOME_InstallWizard::tryTerminate()
1980 if ( shellProcess->isRunning() ) {
1981 if ( QMessageBox::information( this,
1983 tr( "Do you want to quit %1?" ).arg( getIWName() ),
1991 exitConfirmed = true;
1992 // if process still running try to terminate it first
1993 shellProcess->tryTerminate();
1995 //QTimer::singleShot( 3000, this, SLOT( onCancel() ) );
1996 connect( shellProcess, SIGNAL( processExited() ), this, SLOT( onCancel() ) );
1999 // else just quit install wizard
2003 // ================================================================
2005 * SALOME_InstallWizard::onCancel
2006 * Kills installation process and quits application
2008 // ================================================================
2009 void SALOME_InstallWizard::onCancel()
2011 shellProcess->kill();
2014 // ================================================================
2016 * SALOME_InstallWizard::onSelectionChanged
2017 * Called when selection is changed in the products list view
2019 // ================================================================
2020 void SALOME_InstallWizard::onSelectionChanged()
2022 productsInfo->clear();
2023 QListViewItem* item = productsView->selectedItem();
2026 if ( item->parent() )
2027 item = item->parent();
2028 QCheckListItem* aItem = (QCheckListItem*)item;
2029 if ( !productsMap.contains( aItem ) )
2031 Dependancies dep = productsMap[ aItem ];
2032 QString text = "<b>" + aItem->text(0) + "</b>" + "<br>";
2033 if ( !aItem->text(1).stripWhiteSpace().isEmpty() )
2034 text += tr( "Version" ) + ": " + aItem->text(1) + "<br>";
2036 if ( !dep.getDescription().isEmpty() ) {
2037 text += "<i>" + dep.getDescription() + "</i><br><br>";
2039 text += tr( "User choice" ) + ": ";
2040 long totSize = 0, tempSize = 0;
2041 if ( productsView->isBinaries( aItem ) ) {
2042 text += "<b>" + tr( "install binaries" ) + "</b>" + "<br>";
2043 totSize = dep.getSize();
2045 else if ( productsView->isSources( aItem ) ) {
2046 text += "<b>" + tr( "install sources" ) + "</b>" + "<br>";
2047 totSize = dep.getSize( true );
2048 tempSize = dep.getTempSize();
2050 else if ( productsView->isNative( aItem ) ) {
2051 text += "<b>" + tr( "use native" ) + "</b>" + "<br>";
2054 text += "<b>" + tr( "not install" ) + "</b>" + "<br>";
2057 text += tr( "Disk space required" ) + ": " + QString::number( totSize ) + " Kb<br>";
2058 text += tr( "Disk space for tmp files required" ) + ": " + QString::number( tempSize ) + " Kb<br>";
2060 QString req = ( dep.getDependancies().count() > 0 ? dep.getDependancies().join(", ") : tr( "none" ) );
2061 text += tr( "Prerequisites" ) + ": " + req;
2062 productsInfo->setText( text );
2064 // ================================================================
2066 * SALOME_InstallWizard::onItemToggled
2067 * Called when user checks/unchecks any product item
2068 * Recursively sets all prerequisites and updates "Next" button state
2070 // ================================================================
2071 void SALOME_InstallWizard::onItemToggled( QCheckListItem* item )
2073 if ( prerequisites->isChecked() ) {
2074 if ( item->parent() )
2075 item = (QCheckListItem*)( item->parent() );
2076 if ( productsMap.contains( item ) ) {
2077 productsView->blockSignals( true );
2078 setPrerequisites( item );
2079 productsView->blockSignals( false );
2082 onSelectionChanged();
2085 // ================================================================
2087 * SALOME_InstallWizard::onProdBtn
2088 * This slot is called when user clicks one of <Select Sources>,
2089 * <Select Binaries>, <Unselect All> buttons ( products page )
2091 // ================================================================
2092 void SALOME_InstallWizard::onProdBtn()
2094 const QObject* snd = sender();
2095 productsView->blockSignals( true );
2096 selectSrcBtn->blockSignals( true );
2097 selectBinBtn->blockSignals( true );
2098 if ( snd == unselectBtn ) {
2099 QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
2101 productsView->setNone( item );
2102 item = (QCheckListItem*)( item->nextSibling() );
2105 else if ( snd == selectSrcBtn ) {
2106 QMyCheckBox* checkBox = ( QMyCheckBox* )snd;
2107 if ( checkBox->state() == QButton::NoChange )
2108 checkBox->setState( QButton::On );
2109 MapProducts::Iterator itProd;
2110 for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) {
2111 if ( itProd.data().hasContext( "salome sources" ) ) {
2112 if ( checkBox->state() == QButton::Off ) {
2114 MapProducts::Iterator itProd1;
2115 for ( itProd1 = productsMap.begin(); itProd1 != productsMap.end(); ++itProd1 ) {
2116 if ( itProd1.data().hasContext( "salome binaries" ) &&
2117 !itProd1.data().hasContext( "salome sources" ) &&
2118 productsView->isBinaries( itProd1.key() ) )
2121 if ( !itProd.data().hasContext( "salome binaries" ) || !selBin )
2122 productsView->setNone( itProd.key() );
2125 productsView->setSources( itProd.key() );
2126 if ( prerequisites->isChecked() )
2127 setPrerequisites( itProd.key() );
2132 else if ( snd == selectBinBtn ) {
2133 QMyCheckBox* checkBox = ( QMyCheckBox* )snd;
2134 if ( checkBox->state() == QButton::NoChange )
2135 checkBox->setState( QButton::On );
2136 MapProducts::Iterator itProd;
2137 for ( itProd = productsMap.begin(); itProd != productsMap.end(); ++itProd ) {
2138 if ( itProd.data().hasContext( "salome binaries" ) ) {
2139 if ( checkBox->state() == QButton::Off ) {
2141 MapProducts::Iterator itProd1;
2142 for ( itProd1 = productsMap.begin(); itProd1 != productsMap.end(); ++itProd1 ) {
2143 if ( itProd1.data().hasContext( "salome sources" ) &&
2144 !itProd1.data().hasContext( "salome binaries" ) &&
2145 productsView->isSources( itProd1.key() ) )
2148 if ( !itProd.data().hasContext( "salome sources" ) || !selSrc )
2149 productsView->setNone( itProd.key() );
2152 productsView->setBinaries( itProd.key() );
2153 if ( prerequisites->isChecked() )
2154 setPrerequisites( itProd.key() );
2159 selectSrcBtn->blockSignals( false );
2160 selectBinBtn->blockSignals( false );
2161 productsView->blockSignals( false );
2162 onSelectionChanged();
2165 // ================================================================
2167 * SALOME_InstallWizard::wroteToStdin
2168 * QProcess slot: -->something was written to stdin
2170 // ================================================================
2171 void SALOME_InstallWizard::wroteToStdin( )
2173 ___MESSAGE___( "Something was sent to stdin" );
2175 // ================================================================
2177 * SALOME_InstallWizard::readFromStdout
2178 * QProcess slot: -->something was written to stdout
2180 // ================================================================
2181 void SALOME_InstallWizard::readFromStdout( )
2183 ___MESSAGE___( "Something was sent to stdout" );
2184 while ( shellProcess->canReadLineStdout() ) {
2185 installInfo->append( QString( shellProcess->readLineStdout() ) );
2186 installInfo->scrollToBottom();
2188 QString str( shellProcess->readStdout() );
2189 if ( !str.isEmpty() ) {
2190 installInfo->append( str );
2191 installInfo->scrollToBottom();
2195 #define OUTLINE_TEXT(x) QString( "<font color=#FF0000><b>" ) + QString( x ) + QString( "</b></font>" )
2197 // ================================================================
2199 * SALOME_InstallWizard::readFromStderr
2200 * QProcess slot: -->something was written to stderr
2202 // ================================================================
2203 void SALOME_InstallWizard::readFromStderr( )
2205 ___MESSAGE___( "Something was sent to stderr" );
2206 while ( shellProcess->canReadLineStderr() ) {
2207 installInfo->append( OUTLINE_TEXT( QString( shellProcess->readLineStderr() ) ) );
2208 installInfo->scrollToBottom();
2210 QString str( shellProcess->readStderr() );
2211 if ( !str.isEmpty() ) {
2212 installInfo->append( OUTLINE_TEXT( str ) );
2213 installInfo->scrollToBottom();
2215 // VSR: 10/11/05 - disable answer mode ==>
2216 // passedParams->setEnabled( true );
2217 // passedParams->setFocus();
2218 // QFont f = parametersLab->font(); f.setBold( true ); parametersLab->setFont( f );
2219 // VSR: 10/11/05 - disable answer mode <==
2221 // ================================================================
2223 * SALOME_InstallWizard::setDependancies
2224 * Sets dependancies for the product item
2226 // ================================================================
2227 void SALOME_InstallWizard::setDependancies( QCheckListItem* item, Dependancies dep)
2229 productsMap[item] = dep;
2231 // ================================================================
2233 * SALOME_InstallWizard::polish
2234 * Polishing of the widget - to set right initial size
2236 // ================================================================
2237 void SALOME_InstallWizard::polish()
2240 InstallWizard::polish();
2242 // ================================================================
2244 * SALOME_InstallWizard::saveLog
2245 * Save installation log to file
2247 // ================================================================
2248 void SALOME_InstallWizard::saveLog()
2250 QString txt = installInfo->text();
2251 if ( txt.length() <= 0 )
2253 QDateTime dt = QDateTime::currentDateTime();
2254 QString fileName = dt.toString("ddMMyy-hhmm");
2255 fileName.prepend("install-"); fileName.append(".html");
2256 fileName = QFileDialog::getSaveFileName( fileName,
2257 QString( "HTML files (*.htm *.html)" ),
2259 tr( "Save Log file" ) );
2260 if ( !fileName.isEmpty() ) {
2261 QFile f( fileName );
2262 if ( f.open( IO_WriteOnly ) ) {
2263 QTextStream stream( &f );
2268 QMessageBox::critical( this,
2270 tr( "Can't save file %1.\nCheck path and permissions.").arg( fileName ),
2272 QMessageBox::NoButton,
2273 QMessageBox::NoButton );
2277 // ================================================================
2279 * SALOME_InstallWizard::updateCaption
2280 * Updates caption according to the current page number
2282 // ================================================================
2283 void SALOME_InstallWizard::updateCaption()
2285 QWidget* aPage = InstallWizard::currentPage();
2288 InstallWizard::setCaption( tr( myCaption ) + " " +
2289 tr( getIWName() ) + " - " +
2290 tr( "Step %1 of %2").arg( QString::number( this->indexOf( aPage )+1 ) ).arg( QString::number( this->pageCount() ) ) );
2293 // ================================================================
2295 * SALOME_InstallWizard::processValidateEvent
2296 * Processes validation event (<val> is validation code)
2298 // ================================================================
2299 void SALOME_InstallWizard::processValidateEvent( const int val, void* data )
2301 QWidget* aPage = InstallWizard::currentPage();
2302 if ( aPage != productsPage ) {
2303 InstallWizard::processValidateEvent( val, data );
2308 QCheckListItem* item = (QCheckListItem*)data;
2311 WarnDialog::showWarnDlg( 0, false );
2312 // when try_native returns 2 it means that native product version is higher than that is prerequisited
2313 if ( QMessageBox::warning( this,
2315 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)),
2318 QMessageBox::NoButton ) == QMessageBox::No ) {
2319 myThread->clearCommands();
2321 setNextEnabled( true );
2322 setBackEnabled( true );
2325 WarnDialog::showWarnDlg( this, true );
2328 WarnDialog::showWarnDlg( 0, false );
2329 bool binMode = productsView->hasBinaries( item );
2330 bool srcMode = productsView->hasSources( item );
2331 QStringList buttons;
2332 buttons.append( binMode ? tr( "Install binaries" ) : ( srcMode ? tr( "Install sources" ) :
2333 tr( "Select manually" ) ) );
2334 buttons.append( binMode ? ( srcMode ? tr( "Install sources" ) : tr( "Select manually" ) ) :
2335 ( srcMode ? tr( "Select manually" ) : QString::null ) );
2336 buttons.append( binMode && srcMode ? tr( "Select manually" ) : QString::null );
2337 int answer = QMessageBox::warning( this,
2339 tr( "You don't have native %1 %2 on your computer.\nPlease, change your installation settings.").arg(item->text(0)).arg(item->text(1)),
2343 if ( buttons[ answer ] == tr( "Install binaries" ) )
2344 productsView->setBinaries( item );
2345 else if ( buttons[ answer ] == tr( "Install sources" ) )
2346 productsView->setSources( item );
2350 productsView->setCurrentItem( item );
2351 productsView->setSelected( item, true );
2352 productsView->ensureItemVisible( item );
2353 myThread->clearCommands();
2355 setNextEnabled( true );
2356 setBackEnabled( true );
2359 WarnDialog::showWarnDlg( this, true );
2362 if ( myThread->hasCommands() )
2365 WarnDialog::showWarnDlg( 0, false );
2366 InstallWizard::processValidateEvent( val, data );