X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2FPipelineEditor%2FPipelineEditor.cxx;h=9868abc7340bee0a894286470bc52a45a407ad18;hb=f533290f40279617e54e19086dde7c0ba9b07f5b;hp=fcd3f421ec5727b6f9ae1e9c8af045031a554c20;hpb=3d5417d682ae768bf6393f1b0d1f6b1a1755e0bd;p=cpPlugins.git diff --git a/appli/PipelineEditor/PipelineEditor.cxx b/appli/PipelineEditor/PipelineEditor.cxx index fcd3f42..9868abc 100644 --- a/appli/PipelineEditor/PipelineEditor.cxx +++ b/appli/PipelineEditor/PipelineEditor.cxx @@ -61,8 +61,13 @@ PipelineEditor( int argc, char* argv[], QApplication* app, QWidget* parent ) QFileInfo info( argv[ 0 ] ); if( info.exists( ) ) { - this->m_PluginsPath = info.canonicalPath( ).toStdString( ); - this->_LoadPluginsFromPath( this->m_PluginsPath ); + if( !( this->m_Interface.LoadConfiguration( cpPlugins_CONFIG_FILE ) ) ) + { + this->m_PluginsPath = info.canonicalPath( ).toStdString( ); + this->_LoadPluginsFromPath( this->m_PluginsPath ); + } + else + this->_UpdateLoadedPlugins( ); } // fi @@ -113,8 +118,7 @@ PipelineEditor:: { if( this->m_Workspace != NULL ) delete this->m_Workspace; - // TODO: this causes a segfault (?) - // delete this->m_UI; + delete this->m_UI; } // ------------------------------------------------------------------------- @@ -201,6 +205,7 @@ _UpdateLoadedPlugins( ) } // rof this->_UnBlock( ); + this->m_Interface.SaveConfiguration( cpPlugins_CONFIG_FILE ); } // ------------------------------------------------------------------------- @@ -224,15 +229,14 @@ _UnBlock( ) void PipelineEditor:: _ButtonLoadPluginsFile( ) { - /* QFileDialog dlg( this ); dlg.setFileMode( QFileDialog::ExistingFiles ); dlg.setDirectory( "." ); std::stringstream name_filter; - std::string suffix = std::string( cpPlugins_PLUGIN_EXT ).substr( 1 ); - - name_filter << "Plugins file (*" << cpPlugins_PLUGIN_EXT << ");;All files (*)"; + std::string suffix = std::string( cpPlugins_PLUGIN_EXT ); + name_filter + << "Plugins file (*." << cpPlugins_PLUGIN_EXT << ");;All files (*)"; dlg.setNameFilter( name_filter.str( ).c_str( ) ); dlg.setDefaultSuffix( suffix.c_str( ) ); @@ -243,7 +247,18 @@ _ButtonLoadPluginsFile( ) QStringList names = dlg.selectedFiles( ); std::stringstream err_str; for( auto qIt = names.begin( ); qIt != names.end( ); ++qIt ) - err_str << this->m_Interface->Load( qIt->toStdString( ) ); + { + try + { + this->m_Interface.LoadPluginFile( qIt->toStdString( ) ); + } + catch( std::exception& err ) + { + err_str << err.what( ) << std::endl; + + } // yrt + + } // rof // Show an error message std::string err = err_str.str( ); @@ -255,9 +270,8 @@ _ButtonLoadPluginsFile( ) ); // Update view - this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath ); + // TODO: this->m_Interface.SaveDefaultConfiguration( this->m_PluginsPath ); this->_UpdateLoadedPlugins( ); - */ } // ------------------------------------------------------------------------- @@ -265,25 +279,25 @@ void PipelineEditor:: _ButtonLoadPluginsPath( ) { /* - QFileDialog dlg( this ); - dlg.setFileMode( QFileDialog::DirectoryOnly ); - dlg.setDirectory( "." ); - if( !( dlg.exec( ) ) ) + QFileDialog dlg( this ); + dlg.setFileMode( QFileDialog::DirectoryOnly ); + dlg.setDirectory( "." ); + if( !( dlg.exec( ) ) ) return; - // Read - std::string dir = dlg.selectedFiles( ).begin( )->toStdString( ); - std::string err = this->m_Interface->LoadFromFolder( dir, false ); - if( err != "" ) + // Read + std::string dir = dlg.selectedFiles( ).begin( )->toStdString( ); + std::string err = this->m_Interface->LoadFromFolder( dir, false ); + if( err != "" ) QMessageBox::critical( - this, - "Error loading plugins directory", - err.c_str( ) - ); + this, + "Error loading plugins directory", + err.c_str( ) + ); - // Update view - this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath ); - this->_UpdateLoadedPlugins( ); + // Update view + this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath ); + this->_UpdateLoadedPlugins( ); */ }