SalomeApp_Application::SalomeApp_Application()
: LightApp_Application()
{
- connect( desktop(), SIGNAL( message( const QString& ) ),
- this, SLOT( onLoadDocMessage( const QString& ) ), Qt::UniqueConnection );
myIsSiman = false; // default
}
tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ),
/*Qt::SHIFT+Qt::Key_D*/0, desk, false, this, SLOT( onRegDisplay() ) );
- //rnv commented : implementation of the mono-study in GUI
- //
- //createAction( FileLoadId, tr( "TOT_DESK_FILE_LOAD" ),
- // resourceMgr()->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
- // tr( "MEN_DESK_FILE_LOAD" ), tr( "PRP_DESK_FILE_LOAD" ),
- // Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) );
+ createAction( ConnectId, tr( "TOT_DESK_CONNECT_STUDY" ), QIcon(),
+ tr( "MEN_DESK_CONNECT" ), tr( "PRP_DESK_CONNECT" ),
+ Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) );
+
+ createAction( DisconnectId, tr( "TOT_DESK_DISCONNECT_STUDY" ), QIcon(),
+ tr( "MEN_DESK_DISCONNECT" ), tr( "PRP_DESK_DISCONNECT" ),
+ Qt::CTRL+Qt::Key_U, desk, false, this, SLOT( onUnloadDoc() ) );
#ifdef WITH_SIMANIO
// creation of menu item is moved to VISU
// createMenu( SaveGUIStateId, fileMenu, 10, -1 );
- // createMenu( FileLoadId, fileMenu, 0 );
+ createMenu( ConnectId, fileMenu, 5 );
+ createMenu( DisconnectId, fileMenu, 5 );
+ createMenu( separator(), fileMenu, -1, 5 );
#ifdef WITH_SIMANIO
if (myIsSiman) {
}
#endif
createMenu( DumpStudyId, fileMenu, 10, -1 );
- createMenu( separator(), fileMenu, -1, 10, -1 );
createMenu( LoadScriptId, fileMenu, 10, -1 );
createMenu( separator(), fileMenu, -1, 10, -1 );
createMenu( PropertiesId, fileMenu, 10, -1 );
}
-
-/*!Set desktop:*/
-void SalomeApp_Application::setDesktop( SUIT_Desktop* desk )
-{
- LightApp_Application::setDesktop( desk );
-
- if ( desk ) {
- connect( desk, SIGNAL( message( const QString& ) ),
- this, SLOT( onLoadDocMessage( const QString& ) ), Qt::UniqueConnection );
- }
-}
-
/*!
\brief Close application.
*/
}
}
+/*!SLOT. Unload document.*/
+void SalomeApp_Application::onUnloadDoc( bool ask )
+{
+ if ( ask ) {
+ activeStudy()->abortAllOperations();
+ if ( activeStudy()->isModified() ) {
+ QString docName = activeStudy()->studyName().trimmed();
+ int answer = SUIT_MessageBox::question( desktop(), tr( "DISCONNECT_CAPTION" ),
+ tr( "DISCONNECT_DESCRIPTION" ),
+ tr( "DISCONNECT_SAVE" ),
+ tr( "DISCONNECT_WO_SAVE" ),
+ tr( "APPCLOSE_CANCEL" ), 0 );
+ if ( answer == 0 ) { // save before unload
+ if ( activeStudy()->isSaved() )
+ onSaveDoc();
+ else if ( !onSaveAsDoc() )
+ return;
+ }
+ else if ( answer == 2 ) // Cancel
+ return;
+ }
+ }
+ closeActiveDoc( false );
+}
+
/*!SLOT. Create new study and load script*/
void SalomeApp_Application::onNewWithScript()
{
return res;
}
-/*!SLOT. Load document with a name, specified in \a aMessage.*/
-void SalomeApp_Application::onLoadDocMessage(const QString& aMessage)
+/*!SLOT. Parse message for desktop.*/
+void SalomeApp_Application::onDesktopMessage( const QString& message )
{
- if (aMessage.indexOf("simanCheckoutDone ") == 0) {
+ if (message.indexOf("simanCheckoutDone ") == 0) {
#ifdef WITH_SIMANIO
- onLoadDoc(aMessage.section(' ', 1));
+ // Load document with a name, specified in aMessage.
+ onLoadDoc(message.section(' ', 1));
#else
printf( "****************************************************************\n" );
printf( "* Warning: SALOME is built without SIMAN support.\n" );
printf( "****************************************************************\n" );
#endif
}
+ else if (message.indexOf("studyCreated:") == 0) {
+ // Enable 'Connect' action
+ updateCommandsStatus();
+ }
+ else if (message.indexOf("studyClosed:") == 0) {
+ /* message also contains ID of the closed study,
+ but as soon as SALOME is mono-study application for the moment,
+ this ID is not needed now.*/
+ //long aStudyId = message.section(':', 1).toLong();
+ // Disconnect GUI from active study, because it was closed on DS side.
+ closeActiveDoc( false );
+ // Disable 'Connect' action
+ QAction* a = action( ConnectId );
+ if ( a )
+ a->setEnabled( false );
+ }
+ LightApp_Application::onDesktopMessage( message );
}
/*!SLOT. Copy objects to study maneger from selection maneger..*/
}
}
-
LightApp_Application::onCloseDoc( ask );
}
// Load script menu
a = action( LoadScriptId );
- if ( a )
- a->setEnabled( activeStudy() );
+ if( a )
+ a->setEnabled( pythonConsole() );
// Properties menu
a = action( PropertiesId );
if( a )
a->setEnabled( activeStudy() );
+ // Connect study menu
+ a = action( ConnectId );
+ if( a )
+ a->setEnabled( !activeStudy() && studyMgr()->GetOpenStudies().size() > 0 );
+
+ // Disconnect study menu
+ a = action( DisconnectId );
+ if( a )
+ a->setEnabled( activeStudy() );
+
// update state of Copy/Paste menu items
onSelectionChanged();
}
void SalomeApp_Application::onLoadScript( )
{
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
- if ( !appStudy ) return;
- _PTR(Study) aStudy = appStudy->studyDS();
-
- if ( aStudy->GetProperties()->IsLocked() ) {
- SUIT_MessageBox::warning( desktop(),
- QObject::tr("WRN_WARNING"),
- QObject::tr("WRN_STUDY_LOCKED") );
- return;
+ if ( appStudy ) {
+ _PTR(Study) aStudy = appStudy->studyDS();
+ if ( aStudy->GetProperties()->IsLocked() ) {
+ SUIT_MessageBox::warning( desktop(),
+ QObject::tr("WRN_WARNING"),
+ QObject::tr("WRN_STUDY_LOCKED") );
+ return;
+ }
}
QStringList filtersList;
{
QMap<int, QString> opmap = LightApp_Application::activateModuleActions();
- // rnv commented : implementation of the mono-study in GUI
- // opmap.insert( LoadStudyId, tr( "ACTIVATE_MODULE_OP_LOAD" ) );
+ opmap.insert( LoadStudyId, tr( "ACTIVATE_MODULE_OP_LOAD" ) );
opmap.insert( NewAndScriptId, tr( "ACTIVATE_MODULE_OP_SCRIPT" ) );
return opmap;
/*
Asks to close existing document.
*/
-bool SalomeApp_Application::checkExistingDoc() {
- bool result = true;
- if( activeStudy() ) {
- int answer = SUIT_MessageBox::question( desktop(),
- tr( "APPCLOSE_CAPTION" ),
- tr( "STUDYCLOSE_DESCRIPTION" ),
- tr( "APPCLOSE_SAVE" ),
- tr( "APPCLOSE_CLOSE" ),
- tr( "APPCLOSE_CANCEL" ), 0 );
- if(answer == 0) {
- if ( activeStudy()->isSaved() ) {
- onSaveDoc();
- closeDoc( false );
- } else if ( onSaveAsDoc() ) {
- if( !closeDoc( false ) ) {
- result = false;
- }
- } else {
- result = false;
- }
- }
- else if( answer == 1 ) {
- closeDoc( false );
- } else if( answer == 2 ) {
- result = false;
- }
- } else {
+bool SalomeApp_Application::checkExistingDoc()
+{
+ bool result = LightApp_Application::checkExistingDoc();
+ if ( result && !activeStudy() ) {
SALOMEDSClient_StudyManager* aMgr = studyMgr();
- if( aMgr ) {
+ if ( aMgr ) {
std::vector<std::string> List = studyMgr()->GetOpenStudies();
if( List.size() > 0 ) {
- int answer = SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_ACTIVEDOC_LOAD" ),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No );
- if ( answer == SUIT_MessageBox::Yes ) {
- onLoadDoc();
- }
+ SUIT_MessageBox::critical( desktop(), tr( "WRN_WARNING" ), tr( "ERR_ACTIVEDOC_LOAD" ));
result = false;
}
}