X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpBaseQtApplication%2FMainWindow.cxx;h=830508fb18d58a60ef0f14106d746735ff2314e0;hb=1eca6dc8780b7fda231cf03e7ec56c77549bf865;hp=d70d4c014bca5b19988f95a417bfb165ab5b38b1;hpb=e5916bd329611f11ff2f31ff42e853bac21b825a;p=cpPlugins.git diff --git a/lib/cpBaseQtApplication/MainWindow.cxx b/lib/cpBaseQtApplication/MainWindow.cxx index d70d4c0..830508f 100644 --- a/lib/cpBaseQtApplication/MainWindow.cxx +++ b/lib/cpBaseQtApplication/MainWindow.cxx @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -47,19 +48,22 @@ MainWindow( m_Editor( NULL ), m_MPR( NULL ) { - QFileInfo i( argv[ 0 ] ); - if( i.exists( ) ) - { - this->m_ExecutionPath = i.canonicalPath( ).toStdString( ); - try - { - this->m_Interface.OpenEnvironments( this->m_ExecutionPath ); - this->m_Interface.UpdateEnvironments( this->m_ExecutionPath ); - } - catch( ... ) { } - } - else - this->m_ExecutionPath = ""; + QFileInfo e_path( argv[ 0 ] ); + QDir r_path( "." ); + this->m_RunPath = r_path.canonicalPath( ).toStdString( ); + std::stringstream paths; + paths + << e_path.canonicalPath( ).toStdString( ) + << cpPlugins_SEPARATOR + << this->m_RunPath; + + try { this->m_Interface.AddEnvironments( this->m_RunPath ); } + catch( ... ) { } + try { this->m_Interface.OpenEnvironments( this->m_RunPath ); } + catch( ... ) { } + try { this->m_Interface.SaveEnvironments( this->m_RunPath ); } + catch( ... ) { } + this->UpdateEnvironment( ); this->m_Workspace.SetInterface( &( this->m_Interface ) ); } @@ -75,7 +79,7 @@ UpdateEnvironment( ) { try { - this->m_Interface.LoadEnvironment( ); + this->m_Interface.LoadEnvironments( ); this->m_Interface.GuessPlugins( ); } catch( std::exception& err ) @@ -147,6 +151,17 @@ _ClearWorkspace( ) this->m_Workspace.Clear( ); } +// ------------------------------------------------------------------------- +void cpBaseQtApplication::MainWindow:: +_AddEnvironments( const std::string& environments ) +{ + try { this->m_Interface.AddEnvironments( environments ); } + catch( ... ) { } + try { this->m_Interface.SaveEnvironments( this->m_RunPath ); } + catch( ... ) { } + this->UpdateEnvironment( ); +} + // ------------------------------------------------------------------------- void cpBaseQtApplication::MainWindow:: _LoadPlugins( const std::string& filename ) @@ -249,26 +264,6 @@ _UpdateLoadedPlugins( ) ); } -// ------------------------------------------------------------------------- -void cpBaseQtApplication::MainWindow:: -_ShowPlugins( ) -{ - auto paths = this->m_Interface.GetPaths( ); - auto plugins = this->m_Interface.GetPlugins( ); - std::stringstream info; - info << "----- PATHS -----" << std::endl; - for( auto i = paths.begin( ); i != paths.end( ); ++i ) - info << " " << *i << std::endl; - info << std::endl << "----- PLUGINS -----" << std::endl; - for( auto i = plugins.begin( ); i != plugins.end( ); ++i ) - info << " " << *i << std::endl; - QMessageBox::information( - this, - "Loaded libraries and plugins information", - info.str( ).c_str( ) - ); -} - // ------------------------------------------------------------------------- void cpBaseQtApplication::MainWindow:: _Block( ) @@ -485,6 +480,26 @@ _InteractiveLoadPluginsFromPath( ) this->_LoadPluginsFromPath( d.selectedFiles( ).begin( )->toStdString( ) ); } +// ------------------------------------------------------------------------- +void cpBaseQtApplication::MainWindow:: +_ShowPlugins( ) +{ + auto paths = this->m_Interface.GetPaths( ); + auto plugins = this->m_Interface.GetPlugins( ); + std::stringstream info; + info << "----- PATHS -----" << std::endl; + for( auto i = paths.begin( ); i != paths.end( ); ++i ) + info << " " << *i << std::endl; + info << std::endl << "----- PLUGINS -----" << std::endl; + for( auto i = plugins.begin( ); i != plugins.end( ); ++i ) + info << " " << *i << std::endl; + QMessageBox::information( + this, + "Loaded libraries and plugins information", + info.str( ).c_str( ) + ); +} + // ------------------------------------------------------------------------- void cpBaseQtApplication::MainWindow:: _InteractiveLoadWorkspace( ) @@ -518,6 +533,24 @@ _InteractiveSaveWorkspace( ) this->_SaveWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) ); } +// ------------------------------------------------------------------------- +void cpBaseQtApplication::MainWindow:: +_InteractiveAddEnviromentPaths( ) +{ + PathsDialog dlg( this ); + dlg.addPaths( this->m_Interface.GetPaths( ) ); + if( dlg.exec( ) ) + { + auto paths = dlg.getPaths( ); + std::stringstream envs; + for( auto p = paths.begin( ); p != paths.end( ); ++p ) + envs << *p << cpPlugins_SEPARATOR; + this->_AddEnvironments( envs.str( ) ); + this->UpdateEnvironment( ); + + } // fi +} + // ------------------------------------------------------------------------- void cpBaseQtApplication::MainWindow:: _ExecFilter( const std::string& filter_name )