X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSUIT%2FSUIT_Application.cxx;h=816f8d41f948fb83c66e70091b36e94f02b699c2;hb=1bbe280f64cbc74a35a7d7e92270ebf4a6e9b0b7;hp=a107e6b33fd7f936ee2ff8861ab3acd5de618fd0;hpb=140c5a341bb885f62cbc569dbd517610e7c76abc;p=modules%2Fgui.git diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index a107e6b33..816f8d41f 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -4,6 +4,8 @@ #include "SUIT_Desktop.h" #include "SUIT_ResourceMgr.h" +#include +#include #include #include @@ -13,7 +15,8 @@ SUIT_Application::SUIT_Application() : QObject( 0 ), myStudy( 0 ), -myDesktop( 0 ) +myDesktop( 0 ), +myStatusLabel( 0 ) { } @@ -21,6 +24,8 @@ SUIT_Application::~SUIT_Application() { delete myStudy; myStudy = 0; + + setDesktop( 0 ); } SUIT_Desktop* SUIT_Application::desktop() @@ -54,11 +59,25 @@ void SUIT_Application::start() desktop()->show(); } -void SUIT_Application::useFile( const QString& theFileName ) +bool SUIT_Application::useFile( const QString& theFileName ) { createEmptyStudy(); - if ( activeStudy() ) - activeStudy()->openDocument( theFileName ); + SUIT_Study* study = activeStudy(); + + bool status = study ? study->openDocument( theFileName ) : false; + + if ( !status ) + { + setActiveStudy( 0 ); + delete study; + } + + return status; +} + +bool SUIT_Application::useStudy( const QString& theName ) +{ + return false; } void SUIT_Application::createEmptyStudy() @@ -83,8 +102,16 @@ SUIT_ResourceMgr* SUIT_Application::resourceMgr() const #define DEFAULT_MESSAGE_DELAY 3000 void SUIT_Application::putInfo ( const QString& msg, const int msec ) { - if ( desktop() ) - desktop()->statusBar()->message( msg, msec <= 0 ? DEFAULT_MESSAGE_DELAY : msec ); + if ( desktop() ) { + //desktop()->statusBar()->message( msg, msec <= 0 ? DEFAULT_MESSAGE_DELAY : msec ); + if ( !myStatusLabel ) { + myStatusLabel = new QLabel (desktop()->statusBar()); + desktop()->statusBar()->addWidget(myStatusLabel, /*int stretch = */1); + } + myStatusLabel->setText(msg); + if( msec != -1 ) + QTimer::singleShot(msec <= 0 ? DEFAULT_MESSAGE_DELAY : msec, myStatusLabel, SLOT(clear())); + } } SUIT_Application* SUIT_Application::startApplication( int argc, char** argv ) const @@ -108,8 +135,8 @@ void SUIT_Application::setDesktop( SUIT_Desktop* desk ) delete myDesktop; myDesktop = desk; - connect( myDesktop, SIGNAL( activated() ), - this, SLOT( onDesktopActivated() ) ); + if ( myDesktop ) + connect( myDesktop, SIGNAL( activated() ), this, SLOT( onDesktopActivated() ) ); } SUIT_Study* SUIT_Application::createNewStudy() @@ -240,6 +267,18 @@ void SUIT_Application::setToolShown( const int id, const bool on ) desktop()->toolMgr()->setShown( id, on ); } +void SUIT_Application::setActionShown( QAction* a, const bool on ) +{ + setMenuShown( a, on ); + setToolShown( a, on ); +} + +void SUIT_Application::setActionShown( const int id, const bool on ) +{ + setMenuShown( id, on ); + setToolShown( id, on ); +} + QAction* SUIT_Application::action( const int id ) const { SUIT_Application* that = (SUIT_Application*)this;