#include <qwaitcondition.h>
#include <qmutex.h>
#include <qstringlist.h>
+#include <qpopupmenu.h>
#ifdef WNT
#include <iostream.h>
// ================================================================
/*!
- * QProcessThread
+ * ProcessThread
* Class for executing systen commands
*/
// ================================================================
static QMutex myMutex(false);
static QWaitCondition myWC;
-class QProcessThread: public QThread
+class ProcessThread: public QThread
{
typedef QPtrList<QCheckListItem> ItemList;
public:
- QProcessThread( SALOME_InstallWizard* iw ) : QThread(), myWizard( iw ) { myItems.setAutoDelete( false ); }
+ ProcessThread( SALOME_InstallWizard* iw ) : QThread(), myWizard( iw ) { myItems.setAutoDelete( false ); }
void addCommand( QCheckListItem* item, const QString& cmd ) {
myItems.append( item );
virtual void run() {
while ( hasCommands() ) {
- ___MESSAGE___( "QProcessThread::run - Processing command : " << myCommands[ 0 ].latin1() );
+ ___MESSAGE___( "ProcessThread::run - Processing command : " << myCommands[ 0 ].latin1() );
int result = system( myCommands[ 0 ] ) / 256; // return code is <errno> * 256
- ___MESSAGE___( "QProcessThread::run - Result : " << result );
+ ___MESSAGE___( "ProcessThread::run - Result : " << result );
QCheckListItem* item = myItems.first();
myCommands.pop_front();
myItems.removeFirst();
}
void accept() { return; }
void reject() { return; }
- void closeEvent( QCloseEvent* e) { if ( !myCloseFlag ) return; QDialog::closeEvent( e ); }
-
+ void closeEvent( QCloseEvent* e )
+ { if ( !myCloseFlag ) return;
+ e->accept();
+ QDialog::closeEvent( e );
+ }
~WarnDialog() { myDlg = 0; }
public:
static void showWarnDlg( QWidget* parent, bool show ) {
};
WarnDialog* WarnDialog::myDlg = 0;
+// ================================================================
+/*!
+ * InstallInfo
+ * Installation progress info window class
+ */
+// ================================================================
+class InstallInfo : public QTextEdit
+{
+public:
+ InstallInfo( QWidget* parent ) : QTextEdit( parent ), finished( false ) {}
+ void setFinished( const bool f ) { finished = f; }
+protected:
+ QPopupMenu* createPopupMenu( const QPoint& )
+ {
+ int para1, col1, para2, col2;
+ getSelection(¶1, &col1, ¶2, &col2);
+ bool allSelected = hasSelectedText() &&
+ para1 == 0 && para2 == paragraphs()-1 && col1 == 0 && col2 == paragraphLength(para2);
+ QPopupMenu* popup = new QPopupMenu( this );
+ int id = popup->insertItem( tr( "&Copy" ) );
+ popup->setItemEnabled( id, hasSelectedText() );
+ popup->connectItem ( id, this, SLOT( copy() ) );
+ id = popup->insertItem( tr( "Select &All" ) );
+ popup->setItemEnabled( id, (bool)text().length() && !allSelected );
+ popup->connectItem ( id, this, SLOT( selectAll() ) );
+ if ( finished ) {
+ QWidget* p = parentWidget();
+ while ( p && !p->inherits( "SALOME_InstallWizard" ) )
+ p = p->parentWidget();
+ if ( p && p->inherits( "SALOME_InstallWizard" ) ) {
+ popup->insertSeparator();
+ id = popup->insertItem( tr( "&Save Log" ) );
+ popup->setItemEnabled( id, (bool)text().length() );
+ popup->connectItem ( id, (SALOME_InstallWizard*)p, SLOT( saveLog() ) );
+ }
+ }
+ return popup;
+ }
+private:
+ bool finished;
+};
+
// ================================================================
/*!
* DefineDependeces [ static ]
connect(shellProcess, SIGNAL( wroteToStdin() ), this, SLOT( wroteToStdin() ) );
// create validation thread
- myThread = new QProcessThread( this );
+ myThread = new ProcessThread( this );
}
// ================================================================
/*!
QGridLayout* layout = new QGridLayout( widget );
layout->setMargin( 0 ); layout->setSpacing( 6 );
// installation progress view box
- installInfo = new QTextEdit( widget );
+ installInfo = new InstallInfo( widget );
installInfo->setReadOnly( true );
installInfo->setTextFormat( RichText );
installInfo->setUndoRedoEnabled ( false );
text += "<br>";
}
if ( !myOS.isEmpty() ) {
- text += tr( "Target platform" ) + ": <b>" + myOS + "</b><br>";
+ text += tr( "Reference Linux platform" ) + ": <b>" + myOS + "</b><br>";
text += "<br>";
}
- text += tr( "Products to be used" ) + ":<ul>";
+ text += tr( "Native products to be used" ) + ":<ul>";
QCheckListItem* item = (QCheckListItem*)( productsView->firstChild() );
while( item ) {
if ( productsMap.contains( item ) ) {
if ( item->childCount() > 0 ) {
if ( productsView->isNative( item ) ) {
- text += "<li><b>" + item->text() + "</b> " + tr( "as native" ) + "<br>";
+ text += "<li><b>" + item->text() + "</b><br>";
nbProd++;
}
}
if ( productsMap.contains( item ) ) {
if ( item->childCount() > 0 ) {
if ( productsView->isBinaries( item ) ) {
- text += "<li><b>" + item->text() + "</b> " + tr( "as binaries" ) + "<br>";
+ text += "<li><b>" + item->text() + " " + item->text(1) + "</b> " + tr( "as binaries" ) + "<br>";
nbProd++;
}
else if ( productsView->isSources( item ) ) {
- text+= "<li><b>" + item->text() + "</b> " + tr( "as sources" ) + "<br>";
+ text+= "<li><b>" + item->text() + " " + item->text(1) + "</b> " + tr( "as sources" ) + "<br>";
nbProd++;
}
}
// VSR: Temporary folder is used always now and it is not necessary to disable it -->
// if ( tempSize > 0 )
// VSR: <----------------------------------------------------------------------------
- text += tr( "Temp directory:" ) + " <b>" + QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + "</b><br>";
+ text += tr( "Temporary directory:" ) + " <b>" + QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + "</b><br>";
text += "<br>";
choices->setText( text );
}
QMessageBox::warning( this,
tr( "Warning" ),
tr( "The directory %1 doesn't exist.\n"
- "Do you want to create directory?" ).arg( fi.absFilePath() ),
+ "Create directory?" ).arg( fi.absFilePath() ),
QMessageBox::Yes,
QMessageBox::No,
QMessageBox::NoButton ) == QMessageBox::Yes;
if ( !fi.isDir() ) {
QMessageBox::warning( this,
tr( "Warning" ),
- tr( "The directory %1 is not a directory.\n"
+ tr( "%1 is not a directory.\n"
"Please, enter valid target directory path" ).arg( fi.absFilePath() ),
QMessageBox::Ok,
QMessageBox::NoButton,
if ( system( script ) ) {
QMessageBox::critical( this,
tr( "Out of space" ),
- tr( "There is not available disk space for installing of selected products" ),
+ tr( "There is no available disk space for installing of selected products" ),
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton );
if ( moreMode ) {
QMessageBox::warning( this,
tr( "Warning" ),
- tr( "Please, enter valid temp directory path" ),
+ tr( "Please, enter valid temporary directory path" ),
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton );
if ( system( tscript ) ) {
QMessageBox::critical( this,
tr( "Out of space" ),
- tr( "There is not available disk space for the temporary files" ),
+ tr( "There is no available disk space for the temporary files" ),
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton );
while( item ) {
if ( productsMap.contains( item ) ) {
if ( item->childCount() > 0 ) {
- if ( !productsView->isNone( item ) ) {
+ // VSR : 29/01/05 : Check installation script even if product is not being installed
+ // if ( !productsView->isNone( item ) ) {
if ( item->text(2).isEmpty() || item->text(2).isNull() ) {
QMessageBox::warning( this,
tr( "Error" ),
- tr( "You don't have a defined script for %1").arg(item->text(0)),
+ tr( "The installation script for %1 is not defined.").arg(item->text(0)),
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton );
return false;
} else {
QFileInfo fi( QString("./config_files/") + item->text(2) );
- if ( !fi.exists() ) {
+ if ( !fi.exists() || !fi.isExecutable() ) {
QMessageBox::warning( this,
tr( "Error" ),
- tr( "%1 required for %2 doesn't exist.").arg("./config_files/" + item->text(2)).arg(item->text(0)),
+ 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)),
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton );
return false;
}
}
- }
+ // }
// collect native products
if ( productsView->isNative( item ) ) {
if ( natives.find( item->text(0) ) == natives.end() )
}
else {
QMessageBox::warning( this,
- tr( "Warning" ),
+ tr( "Error" ),
tr( "%1 is required for %2 %3 installation.\n"
- "Please, add this product in config.xml file.").arg(dependOn[ i ]).arg(item->text(0)).arg(item->text(1)),
+ "This product is missing in the configuration file %4.").arg(dependOn[ i ]).arg(item->text(0)).arg(item->text(1)).arg(xmlFileName),
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton );
QMessageBox::warning( this,
tr( "Warning" ),
tr( "%The product %1 %2 required for installation.\n"
- "Please, add this product in config.xml file.").arg(item->text(0)).arg(item->text(1)),
+ "This product is missing in the configuration file %4.").arg(item->text(0)).arg(item->text(1)).arg(xmlFileName),
QMessageBox::Ok,
QMessageBox::NoButton,
QMessageBox::NoButton );
passedParams->clear();
passedParams->setEnabled( false );
QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
+ installInfo->setFinished( true );
if ( isMinimized() )
showNormal();
raise();
QCheckListItem* item = findItem( "KERNEL-Bin" );
if ( item ) {
QFileInfo fi( targetFolder->text() + "/KERNEL_" + item->text(1) + "/bin/salome/runSalome" );
- QFileInfo fienv( targetFolder->text() + "/KERNEL_" + item->text(1) + "/salome.csh" );
+ QFileInfo fienv( targetFolder->text() + "/KERNEL_" + item->text(1) + "/salome.sh" );
if ( fienv.exists() ) {
if ( fi.exists() ) {
QString script;
script += "cd " + targetFolder->text() + "/KERNEL_" + item->text(1) + "; ";
- script += "source salome.csh; ";
+ script += "source salome.sh; ";
script += "cd bin/salome; ";
script += "runSalome > /dev/null";
- script = "(csh -c '" + script + "')";
+ script = "(bash -c '" + script + "')";
___MESSAGE___( "script: " << script.latin1() );
if ( !system( script.latin1() ) )
return;
// progress page
progressView->clear();
installInfo->clear();
+ installInfo->setFinished( false );
passedParams->clear();
passedParams->setEnabled( false );
QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
// ================================================================
void SALOME_InstallWizard::onStart()
{
+ if ( nextButton()->text() == tr( "&Stop" ) ) {
+ shellProcess->kill();
+ while( shellProcess->isRunning() );
+ return;
+ }
+ progressView->clear();
+ installInfo->clear();
+ installInfo->setFinished( false );
+ passedParams->clear();
+ passedParams->setEnabled( false );
+ QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
// clear list of products to install ...
toInstall.clear();
// ... and fill it for new process
if ( !toInstall.isEmpty() ) {
clean(false); // VSR 07/02/05 - bug fix: first we should clear temporary directory
// disable <Next> button
- setNextEnabled( false );
+ //setNextEnabled( false );
+ nextButton()->setText( tr( "&Stop" ) );
+ QWhatsThis::add( nextButton(), tr( "Aborts installation process" ) );
+ QToolTip::add ( nextButton(), tr( "Aborts installation process" ) );
// disable <Back> button
setBackEnabled( false );
// enable script parameters line edit
passedParams->clear();
passedParams->setEnabled( false );
QFont f = parametersLab->font(); f.setBold( false ); parametersLab->setFont( f );
+ installInfo->setFinished( true );
// enable <Next> button
setNextEnabled( true );
- nextButton()->setText( tr( "&Next >" ) );
- QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
- QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
+ nextButton()->setText( tr( "&Start" ) );
+ QWhatsThis::add( nextButton(), tr( "Starts installation process" ) );
+ QToolTip::add ( nextButton(), tr( "Starts installation process" ) );
+ // reconnect Next button - to use it as Start button
disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
- connect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
+ connect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
+ //nextButton()->setText( tr( "&Next >" ) );
+ //QWhatsThis::add( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
+ //QToolTip::add ( nextButton(), tr( "Moves to the next step of the installation procedure" ) );
+ //disconnect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
+ //disconnect( this, SIGNAL( nextClicked() ), this, SLOT( onStart() ) );
+ //connect( this, SIGNAL( nextClicked() ), this, SLOT( next() ) );
// enable <Back> button
setBackEnabled( true );
}
InstallWizard::polish();
}
// ================================================================
+/*!
+ * SALOME_InstallWizard::saveLog
+ * Save installation log to file
+ */
+// ================================================================
+void SALOME_InstallWizard::saveLog()
+{
+ QString txt = installInfo->text();
+ if ( txt.length() <= 0 )
+ return;
+ QDateTime dt = QDateTime::currentDateTime();
+ QString fileName = dt.toString("ddMMyy-hhmm");
+ fileName.prepend("install-"); fileName.append(".html");
+ fileName = QFileDialog::getSaveFileName( fileName,
+ QString( "HTML files (*.htm *.html)" ),
+ this, 0,
+ tr( "Save Log file" ) );
+ if ( !fileName.isEmpty() ) {
+ QFile f( fileName );
+ if ( f.open( IO_WriteOnly ) ) {
+ QTextStream stream( &f );
+ stream << txt;
+ f.close();
+ }
+ else {
+ QMessageBox::critical( this,
+ tr( "Error" ),
+ tr( "Can't save file %1.\nCheck path and permissions.").arg( fileName ),
+ QMessageBox::Ok,
+ QMessageBox::NoButton,
+ QMessageBox::NoButton );
+ }
+ }
+}
+// ================================================================
/*!
* SALOME_InstallWizard::updateCaption
* Updates caption according to the current page number
class QCheckBox;
class QSplitter;
class QMyCheckBox;
-class QProcessThread;
+class ProcessThread;
class ProductsView;
class ProgressView;
class HelpWindow;
+class InstallInfo;
typedef QMap<QCheckListItem*, Dependancies> MapProducts;
QString getOS() { return myOS; }
// get InstallWizard's name
QString getIWName() { return myIWName; }
+
+ // save install log to file
+ void saveLog();
protected:
// updates caption according to the current page number
void readFromStderr();
private:
- QString myIWName; // Installation Wizard's name
- QString myVersion; // version info
- QString myCaption; // application name
- QString myCopyright; // copyright info
- QString myLicense; // license info
- QString myOS; // operation system
+ QString myIWName; // Installation Wizard's name
+ QString myVersion; // version info
+ QString myCaption; // application name
+ QString myCopyright; // copyright info
+ QString myLicense; // license info
+ QString myOS; // operation system
- HelpWindow* helpWindow; // help window
- QProcess* shellProcess; // shell process (install script)
- MapProducts productsMap; // products info (name, dependancies, disk space )
- QStringList toInstall; // list of products being installed
- QString xmlFileName; // xml file
- bool moreMode; // advanced mode flag
- QWidget* previousPage; // previous page
- QString tmpCreated; // created temporary directory
- bool exitConfirmed; // flag: "Exit confirmed"
+ HelpWindow* helpWindow; // help window
+ QProcess* shellProcess; // shell process (install script)
+ MapProducts productsMap; // products info (name, dependancies, disk space )
+ QStringList toInstall; // list of products being installed
+ QString xmlFileName; // xml file
+ bool moreMode; // advanced mode flag
+ QWidget* previousPage; // previous page
+ QString tmpCreated; // created temporary directory
+ bool exitConfirmed; // flag: "Exit confirmed"
// Widgets
// --> introduction page
- QWidget* introPage; // page itself
- QLabel* logoLab; // logo pixmap
- QLabel* versionLab; // vesrsion info
- QLabel* copyrightLab; // copyright info
- QLabel* licenseLab; // license info
- QLabel* info; // program info
+ QWidget* introPage; // page itself
+ QLabel* logoLab; // logo pixmap
+ QLabel* versionLab; // vesrsion info
+ QLabel* copyrightLab; // copyright info
+ QLabel* licenseLab; // license info
+ QLabel* info; // program info
// --> products page
- QWidget* productsPage; // page itself
- QLineEdit* targetFolder; // target directory for installing of products
- QPushButton* targetBtn; // browse target directory button
- QLineEdit* tempFolder; // directory for the temporary files: /tmp by default
- QPushButton* tempBtn; // browse temp directory button
- QLabel* requiredSize; // <Total disk space required> label
- QLabel* requiredTemp; // <Space required for temporary files> label
- QPushButton* moreBtn; // <More...> button
- QWidget* moreBox; // container for the <More...> mode widgets
- ProductsView* productsView; // products list view
- QTextBrowser* productsInfo; // products info box
- QCheckBox* prerequisites; // <Auto check prerequisites products> checkbox
- QMyCheckBox* selectSrcBtn; // <SALOME sources> check box
- QMyCheckBox* selectBinBtn; // <SALOME binaries> check box
- QPushButton* unselectBtn; // <Unselect All> button
+ QWidget* productsPage; // page itself
+ QLineEdit* targetFolder; // target directory for installing of products
+ QPushButton* targetBtn; // browse target directory button
+ QLineEdit* tempFolder; // directory for the temporary files: /tmp by default
+ QPushButton* tempBtn; // browse temp directory button
+ QLabel* requiredSize; // <Total disk space required> label
+ QLabel* requiredTemp; // <Space required for temporary files> label
+ QPushButton* moreBtn; // <More...> button
+ QWidget* moreBox; // container for the <More...> mode widgets
+ ProductsView* productsView; // products list view
+ QTextBrowser* productsInfo; // products info box
+ QCheckBox* prerequisites; // <Auto check prerequisites products> checkbox
+ QMyCheckBox* selectSrcBtn; // <SALOME sources> check box
+ QMyCheckBox* selectBinBtn; // <SALOME binaries> check box
+ QPushButton* unselectBtn; // <Unselect All> button
// --> prestart page
- QWidget* prestartPage; // page itself
- QTextEdit* choices; // choice text view
+ QWidget* prestartPage; // page itself
+ QTextEdit* choices; // choice text view
// --> progress page
- QWidget* progressPage; // page itself
- QSplitter* splitter; // splitter window
- QTextEdit* installInfo; // information about running installation scripts
- QLabel* parametersLab; // answer field's label
- QLineEdit* passedParams; // user can pass data to running script
- QTextEdit* installProgress;// contains information about progress of installing selected products
- ProgressView* progressView; // displays information about progress of installing selected products
+ QWidget* progressPage; // page itself
+ QSplitter* splitter; // splitter window
+ InstallInfo* installInfo; // information about running installation scripts
+ QLabel* parametersLab; // answer field's label
+ QLineEdit* passedParams; // user can pass data to running script
+ QTextEdit* installProgress;// contains information about progress of installing selected products
+ ProgressView* progressView; // displays information about progress of installing selected products
// --> readme page
- QWidget* readmePage; // page itself
- QTextEdit* readme; // Readme information window
- QPushButton* runSalomeBtn; // <Launch Salome> buttnon
+ QWidget* readmePage; // page itself
+ QTextEdit* readme; // Readme information window
+ QPushButton* runSalomeBtn; // <Launch Salome> buttnon
- QProcessThread* myThread; // validation thread
+ ProcessThread* myThread; // validation thread
};
#endif