QStringList::Iterator it;
for ( it = modList.begin(); it != modList.end(); ++it )
{
- if ( !isLibExists( *it ) )
+ if ( !isModuleAccessible( *it ) )
continue;
QString modName = moduleName( *it );
- if ( !isModuleAccessible( *it ) )
- continue;
-
QString iconName;
if ( iconMap.contains( *it ) )
iconName = iconMap[*it];
if ( icon.isNull() )
{
icon = modIcon;
- INFOS ( "\n****************************************************************" << std::endl
- << "* Icon for " << (*it).toLatin1().constData()
- << " not found. Using the default one." << std::endl
- << "****************************************************************" << std::endl );
+ INFOS( std::endl <<
+ "****************************************************************" << std::endl <<
+ " Warning: icon for " << qPrintable(*it) << " is not found!" << std::endl <<
+ " Using the default icon." << std::endl <<
+ "****************************************************************" << std::endl);
}
-
icon = Qtx::scaleIcon( icon, iconSize );
moduleAction->insertModule( *it, icon );
for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
{
- if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
+ if ( !app->isModuleAccessible( *it ) || _prefs_->hasModule( *it ) )
continue;
int modId = _prefs_->addPreference( *it );
moduleAction->removeModule( modName );
}
+bool LightApp_Application::checkModule( const QString& title )
+{
+ if ( title.isEmpty() )
+ return false;
+
+ QString library = moduleLibrary( title, true );
+ if ( library.isEmpty() )
+ return false;
+
+ QString name = moduleName( title );
+
+ bool isPyModule = library.contains( "SalomePyQtGUI" ) || library.contains( "SalomePyQtGUILight" );
+
+ QStringList paths;
+#if defined(WIN32)
+ paths = QString( ::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
+#elif defined(__APPLE__)
+ paths = QString( ::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
+#else
+ paths = QString( ::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
+#endif
+
+ bool isFound = false;
+ QStringList::const_iterator it;
+ for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
+ {
+ isFound = QFileInfo( Qtx::addSlash( *it ) + library ).exists();
+ }
+
+ if ( !isFound )
+ {
+ INFOS( std::endl <<
+ "****************************************************************" << std::endl <<
+ " Warning: library " << qPrintable( library ) << " is not found!" << std::endl <<
+ " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
+ "****************************************************************" << std::endl);
+ return false;
+ }
+
+ if ( isPyModule )
+ {
+ QString pyModule = QString( "%1GUI.py" ).arg( name );
+ paths = QString( ::getenv( "PYTHONPATH" ) ).split( ":", QString::SkipEmptyParts );
+
+ isFound = false;
+ for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
+ {
+ isFound = QFileInfo( Qtx::addSlash( *it ) + pyModule ).exists();
+ }
+
+ if ( !isFound )
+ {
+ INFOS( std::endl <<
+ "****************************************************************" << std::endl <<
+ " Warning: Python module " << qPrintable( pyModule ) << " is not found!" << std::endl <<
+ " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
+ "****************************************************************" << std::endl);
+ return false;
+ }
+ }
+
+ return true;
+}
+
/*!
Gets current windows.
\param winMap - output current windows map.
wgStack->stack();
}
-/*!
- \return if the library of module exists
- \param moduleTitle - title of module
-*/
-bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
-{
- if( moduleTitle.isEmpty() )
- return false;
-
- QString lib = moduleLibrary( moduleTitle );
-
- //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
- bool isPythonModule = lib.contains("SalomePyQtGUI");
- bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
-
- QStringList paths;
-#if defined(WIN32)
- paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
-#elif defined(__APPLE__)
- paths = QString(::getenv( "DYLD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
-#else
- paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
-#endif
-
- bool isLibFound = false;
- QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
- for( ; anIt!=aLast; anIt++ )
- {
- QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
-
- if( inf.exists() )
- {
- isLibFound = true;
- break;
- }
- }
-
- if ( !isLibFound )
- {
- INFOS( "\n****************************************************************" << std::endl
- << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
- << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
- << "****************************************************************" << std::endl );
- }
- else if ( !isPythonModule && !isPythonLightModule)
- return true;
-
- if ( isPythonModule || isPythonLightModule)
- {
- QString pylib = moduleName( moduleTitle ) + QString(".py");
- QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
-
- // Check the python library
-// #ifdef WIN32
-// paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
-// #else
- paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
-// #endif
- bool isPyLib = false, isPyGuiLib = false;
- QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
- for( ; anIt!=aLast; anIt++ )
- {
- QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
- QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
-
- if(!isPythonLightModule)
- if( !isPyLib && inf.exists() )
- isPyLib = true;
-
- if( !isPyGuiLib && infgui.exists() )
- isPyGuiLib = true;
-
- if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
- return true;
- }
-
- printf( "\n****************************************************************\n" );
- printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
- if (!isPyLib)
- printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
- if (!isPyGuiLib)
- printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
- printf( "****************************************************************\n" );
- return true;
- }
- return false;
-}
-
/*!
\return default name for an active study
*/