#include <qlabel.h>
#include <qtimer.h>
#include <qstatusbar.h>
+#include <qapplication.h>
#include <QtxAction.h>
#include <QtxActionMenuMgr.h>
: QObject( 0 ),
myStudy( 0 ),
myDesktop( 0 ),
- myStatusLabel( 0 ),
- myIsInitiallyRegistered( false )
+ myStatusLabel( 0 )
{
}
delete myDesktop;
myDesktop = desk;
- if ( myDesktop )
+ if ( myDesktop ) {
connect( myDesktop, SIGNAL( activated() ), this, SLOT( onDesktopActivated() ) );
+ QApplication::postEvent(myDesktop, new QEvent(QEvent::WindowActivate));
+ }
}
/*!
//! Invokes application-specific "Select Directory" dialog and returns the selected directory name.
virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
- //! Perform required actions on the application, just registed in the session
- virtual void Registered() { myIsInitiallyRegistered = true; };
-
signals:
void applicationClosed( SUIT_Application* );
void activated( SUIT_Application* );
protected slots:
virtual void onDesktopActivated();
-protected:
- bool myIsInitiallyRegistered; //<! false before the first application registration in the session
-
private:
SUIT_Study* myStudy;
SUIT_Desktop* myDesktop;
if ( isFirst ) {
isFirst = false;
- /*
- QString hdffile;
- QStringList pyfiles;
-
- for (int i = 1; i < qApp->argc(); i++) {
- QRegExp rxs ("--study-hdf=(.+)");
- if ( rxs.search( QString(qApp->argv()[i]) ) >= 0 && rxs.capturedTexts().count() > 1 ) {
- QString file = rxs.capturedTexts()[1];
- QFileInfo fi ( file );
- QString extension = fi.extension( false ).lower();
- if ( extension == "hdf" && fi.exists() )
- hdffile = fi.absFilePath();
- }
- else {
- QRegExp rxp ("--pyscript=(.+)");
- if ( rxp.search( QString(qApp->argv()[i]) ) >= 0 && rxp.capturedTexts().count() > 1 ) {
- QStringList files = QStringList::split(",",rxp.capturedTexts()[1],false);
- pyfiles += files;
- }
- }
- }
-
- if ( !hdffile.isEmpty() ) // open hdf file given as parameter
- onOpenDoc( hdffile );
- else if ( pyfiles.count() > 0 ) // create new study
- onNewDoc();
-
- // import/execute python scripts
- if ( pyfiles.count() > 0 && activeStudy() ) {
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
- if ( appStudy ) {
- _PTR(Study) aStudy = appStudy->studyDS();
- if ( !aStudy->GetProperties()->IsLocked() ) {
- for (uint j = 0; j < pyfiles.count(); j++ ) {
- QFileInfo fi ( pyfiles[j] );
- PythonConsole* pyConsole = pythonConsole();
- if ( pyConsole ) {
- QString extension = fi.extension( false ).lower();
- if ( extension == "py" && fi.exists() ) {
- // execute python script
- QString command = QString( "execfile(\"%1\")" ).arg( fi.absFilePath() );
- pyConsole->exec( command );
- }
- else {
- // import python module
- QString command = QString( "import %1" ).arg( pyfiles[j] );
- //QString command = QString( "import %1" ).arg( fi.baseName( true ) );
- pyConsole->exec( command );
- }
- }
- }
- }
- }
- }
- */
- }
-}
-
-/*!Just registered in the session*/
-void SalomeApp_Application::Registered()
-{
- if (!myIsInitiallyRegistered)
- {
- myIsInitiallyRegistered = true;
-
- // execute python scripts
QString hdffile;
QStringList pyfiles;