pal.setColor( QColorGroup::Base, QApplication::palette().active().background() );
readme->setPalette( pal );
readme->setMinimumHeight( 10 );
- // <Launch SALOME> button
- runSalomeBtn = new QPushButton( tr( "Launch SALOME" ), readmePage );
- QWhatsThis::add( runSalomeBtn, tr( "Click this button to run SALOME desktop" ) );
- QToolTip::add ( runSalomeBtn, tr( "Click this button to run SALOME desktop" ) );
- QHBoxLayout* hLayout = new QHBoxLayout;
- hLayout->addWidget( runSalomeBtn ); hLayout->addStretch();
- // layouting
+
pageLayout->addWidget( readme );
pageLayout->setStretchFactor( readme, 5 );
- pageLayout->addLayout( hLayout );
- // connecting signals
- connect( runSalomeBtn, SIGNAL( clicked() ), this, SLOT( onLaunchSalome() ) );
+
+ // Operation buttons
+ if ( buttons.count() > 0 ) {
+ QHBoxLayout* hLayout = new QHBoxLayout;
+ hLayout->setMargin( 0 ); hLayout->setSpacing( 6 );
+ ButtonList::Iterator it;
+ for ( it = buttons.begin(); it != buttons.end(); ++it ) {
+ QButton* b = new QPushButton( tr( (*it).label() ), readmePage );
+ if ( !(*it).tootip().isEmpty() ) {
+ QWhatsThis::add( b, tr( (*it).tootip() ) );
+ QToolTip::add ( b, tr( (*it).tootip() ) );
+ }
+ hLayout->addWidget( b );
+ (*it).setButton( b );
+ connect( b, SIGNAL( clicked() ), this, SLOT( onFinishButton() ) );
+ }
+ hLayout->addStretch();
+ pageLayout->addLayout( hLayout );
+ }
+
// loading README file
QString readmeFile = QDir::currentDirPath() + "/README";
QString text;
readme->setText( text );
else
readme->setText( tr( "README file has not been found" ) );
+
// adding page
addPage( readmePage, tr( "Finish installation" ) );
}
QMessageBox::NoButton ) == QMessageBox::No ) {
return false;
}
- QString binDir = "./Products/BINARIES";
- if ( !myOS.isEmpty() )
- binDir += "/" + myOS;
- QFileInfo fib( QDir::cleanDirPath( binDir ) );
- if ( !fib.exists() ) {
- QMessageBox::warning( this,
- tr( "Warning" ),
- tr( "The directory %1 doesn't exist.\n"
- "This directory must contain binaries archives." ).arg( fib.absFilePath() ));
+ // check sources/binaries archives directories existance
+ int nbSources = 0, nbBinaries = 0;
+ QCheckListItem* nitem = (QCheckListItem*)( productsView->firstChild() );
+ while( nitem ) {
+ if ( productsMap.contains( nitem ) ) {
+ if ( nitem->childCount() > 0 ) {
+ if ( productsView->isBinaries( nitem ) )
+ nbBinaries++;
+ else if ( productsView->isSources( nitem ) )
+ nbSources++;
+ }
+ else if ( nitem->isOn() ) {
+ nbBinaries++;
+ nbSources++;
+ }
+ }
+ nitem = (QCheckListItem*)( nitem->nextSibling() );
+ }
+
+ if ( nbBinaries > 0 ) {
+ QString binDir = "./Products/BINARIES";
+ if ( !myOS.isEmpty() )
+ binDir += "/" + myOS;
+ QFileInfo fib( QDir::cleanDirPath( binDir ) );
+ if ( !fib.exists() ) {
+ if ( QMessageBox::warning( this,
+ tr( "Warning" ),
+ tr( "The directory %1 doesn't exist.\n"
+ "This directory must contain binaries archives.\n"
+ "Continue?" ).arg( fib.absFilePath() ),
+ QMessageBox::Yes,
+ QMessageBox::No,
+ QMessageBox::NoButton ) == QMessageBox::No )
+ return false;
+ }
+ }
+ if ( nbSources > 0 ) {
+ QString srcDir = "./Products/SOURCES";
+ QFileInfo fis( QDir::cleanDirPath( srcDir ) );
+ if ( !fis.exists() ) {
+ if ( QMessageBox::warning( this,
+ tr( "Warning" ),
+ tr( "The directory %1 doesn't exist.\n"
+ "This directory must contain sources archives.\n"
+ "Continue?" ).arg( fis.absFilePath() ),
+ QMessageBox::Yes,
+ QMessageBox::No,
+ QMessageBox::NoButton ) == QMessageBox::No )
+ return false;
+ }
}
// run script that checks available disk space for installing of products // returns 1 in case of error
QString script = "./config_files/checkSize.sh '";
}
// ================================================================
/*!
- * SALOME_InstallWizard::onLaunchSalome
- * <Launch Salome> button slot
+ * SALOME_InstallWizard::onFinishButton
+ * Operation buttons slot
*/
// ================================================================
-void SALOME_InstallWizard::onLaunchSalome()
+void SALOME_InstallWizard::onFinishButton()
{
- QString msg = tr( "You don't have SALOME binaries installed in the %1 directory!" ).arg( targetFolder->text() );
-
- 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.sh" );
- if ( fienv.exists() ) {
- if ( fi.exists() ) {
- QString script;
- script += "cd " + targetFolder->text() + "/KERNEL_" + item->text(1) + "; ";
- script += "source salome.sh; ";
- script += "cd bin/salome; ";
- script += "runSalome > /dev/null";
- script = "(bash -c '" + script + "')";
- ___MESSAGE___( "script: " << script.latin1() );
- if ( !system( script.latin1() ) )
- return;
- else
- msg = tr( "Can't launch SALOME." );
+ const QObject* btn = sender();
+ ButtonList::Iterator it;
+ for ( it = buttons.begin(); it != buttons.end(); ++it ) {
+ if ( (*it).button() && (*it).button() == btn ) {
+ QString script;
+ script += "( cd " + QUOTE( QFileInfo( QDir::cleanDirPath( "./config_files/" ) ).absFilePath() ) + "; ";
+ script += + (*it).script();
+ script += " execute ";
+ script += QUOTE( QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) ).absFilePath() ) + " ";
+ script += QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() ) + " ";
+ script += " > /dev/null )";
+ ___MESSAGE___( "script: " << script.latin1() );
+ if ( (*it).script().isEmpty() || system( script.latin1() ) ) {
+ QMessageBox::warning( this,
+ tr( "Error" ),
+ tr( "Can't perform action!"),
+ QMessageBox::Ok,
+ QMessageBox::NoButton,
+ QMessageBox::NoButton );
}
- else
- msg = tr( "Can't launch SALOME." ) + "\n" + tr( "runSalome file can not be found." );
+ return;
}
- else
- msg = tr( "Can't launch SALOME." ) + "\n" + tr( "Can't find environment file." );
- }
- QMessageBox::warning( this,
- tr( "Error" ),
- msg,
- QMessageBox::Ok,
- QMessageBox::NoButton,
- QMessageBox::NoButton );
+ }
}
-
// ================================================================
/*!
* SALOME_InstallWizard::onAbout
}
}
else if ( aPage == readmePage ) {
- QCheckListItem* item = findItem( "KERNEL-Bin" );
- runSalomeBtn->setEnabled( item &&
- QFileInfo( targetFolder->text() + "/KERNEL_" + item->text(1) + "/bin/salome/runSalome" ).exists() &&
- QFileInfo( targetFolder->text() + "/KERNEL_" + item->text(1) + "/salome.csh" ).exists() );
+ ButtonList::Iterator it;
+ for ( it = buttons.begin(); it != buttons.end(); ++it ) {
+ if ( (*it).button() ) {
+ QString script;
+ script += "( cd " + QUOTE( QFileInfo( QDir::cleanDirPath( "./config_files/" ) ).absFilePath() ) + "; ";
+ script += + (*it).script();
+ script += " check_enabled ";
+ script += QUOTE( QFileInfo( QDir::cleanDirPath( targetFolder->text().stripWhiteSpace() ) ).absFilePath() ) + " ";
+ script += QUOTE( QFileInfo( QDir::cleanDirPath( tempFolder->text().stripWhiteSpace() ) + TEMPDIRNAME ).absFilePath() ) + " ";
+ script += " > /dev/null )";
+ ___MESSAGE___( "script: " << script.latin1() );
+ (*it).button()->setEnabled( !(*it).script().isEmpty() && !system( script.latin1() ) );
+ }
+ }
finishButton()->setEnabled( true );
}
previousPage = aPage;
productsMap[item] = dep;
}
// ================================================================
+/*!
+ * SALOME_InstallWizard::addFinishButton
+ * Add button for the <Finish> page
+ */
+// ================================================================
+void SALOME_InstallWizard::addFinishButton( const QString& label,
+ const QString& tooltip,
+ const QString& script)
+{
+ if ( !label.isEmpty() )
+ buttons.append( Button( label, tooltip, script ) );
+}
+// ================================================================
/*!
* SALOME_InstallWizard::polish
* Polishing of the widget - to set right initial size
#include "InstallWizard.h"
#include <qmap.h>
+#include <qvaluelist.h>
#include <qstringlist.h>
+class QLineEdit;
+class QPushButton;
+class QListViewItem;
+class QCheckListItem;
+class QLabel;
+class QTextEdit;
+class QTextBrowser;
+class QProcess;
+class QCheckBox;
+class QSplitter;
+class QMyCheckBox;
+class ProcessThread;
+class ProductsView;
+class ProgressView;
+class HelpWindow;
+class InstallInfo;
+class QButton;
+
/*!
Class Dependancies : Products info
This class stores all product dependancies for correct work of installation procedure
- smbName - parameter for launching install shell script (e.g. cas for CASCADE4.0).
- dependsOn - list of products needed for correct installation of product
- (e.g tcl is checked during installation of CASCADE 4).
- sizeTotal - amount of disk space in Kbytes required for installation
- of this product
- sizeTemp - amount of disk space in Kbytes required for the temporary files
*/
class Dependancies
{
bool pickupEnv; // "Pick-up environment" flag
};
-class QLineEdit;
-class QPushButton;
-class QListViewItem;
-class QCheckListItem;
-class QLabel;
-class QTextEdit;
-class QTextBrowser;
-class QProcess;
-class QCheckBox;
-class QSplitter;
-class QMyCheckBox;
-class ProcessThread;
-class ProductsView;
-class ProgressView;
-class HelpWindow;
-class InstallInfo;
+/*!
+ Class Button : Operation button info
+ This class stores information about the custom operation buttons which appear on
+ the <Finish> page of the Install Wizard.
+*/
+class Button
+{
+ public:
+ // default constructor, required for list
+ Button() : myButton( 0 ) {}
+ // constructor
+ Button( const QString& label, const QString& tooltip, const QString& script )
+ : myLabel( label ), myTootip( tooltip ), myScript( script ), myButton( 0 ) {}
+
+ // set operation button
+ void setButton( QButton* btn ) { myButton = btn; }
+
+ // get label
+ QString label() const { return myLabel; }
+ // get tooltip
+ QString tootip() const { return myTootip; }
+ // get script name
+ QString script() const { return myScript; }
+ // get operation button
+ QButton* button() const { return myButton; }
+
+ private:
+ QString myLabel; // button label
+ QString myTootip; // button tooltip
+ QString myScript; // operation script
+ QButton* myButton; // operation button
+};
typedef QMap<QCheckListItem*, Dependancies> MapProducts;
+typedef QValueList<Button> ButtonList;
/*!
Class SALOME_InstallWizard : Installation Wizard's main window
// set dependancies
void setDependancies( QCheckListItem* item, Dependancies dep);
- // process validation event (<val> is validation code)
- void processValidateEvent( const int val, void* data );
+ // add button for the <Finish> page
+ void addFinishButton( const QString& label,
+ const QString& tooltip,
+ const QString& script);
- public slots:
- // polishing of the widget
- void polish();
-
// set version
void setVersion( const QString& version ) { myVersion = version; }
// set caption
QString getOS() { return myOS; }
// get InstallWizard's name
QString getIWName() { return myIWName; }
+
+ // process validation event (<val> is validation code)
+ void processValidateEvent( const int val, void* data );
+
+ public slots:
+ // polishing of the widget
+ void polish();
// save install log to file
void saveLog();
void onProdBtn();
// <More...> button slot
void onMoreBtn();
- // <Launch Salome> button slot
- void onLaunchSalome();
+
+ // <Finish> page buttons slot
+ void onFinishButton();
+
// <About> button slot
void onAbout();
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
+ // --> finish page
QWidget* readmePage; // page itself
QTextEdit* readme; // Readme information window
- QPushButton* runSalomeBtn; // <Launch Salome> buttnon
+ ButtonList buttons; // operation buttons
ProcessThread* myThread; // validation thread
};