#include <QTreeView>
#include <QMimeData>
#include <QShortcut>
+#include <QRegExp>
#include <utilities.h>
//since the 'toolbar marker' is not unique, find index of first occurrence of the
//'toolbar marker' in the array and check that next string is name of the toolbar
+void LightAppCleanUpAppResources()
+{
+ if ( LightApp_Application::_prefs_ ) {
+ delete LightApp_Application::_prefs_;
+ LightApp_Application::_prefs_ = 0;
+ }
+}
+
namespace
{
int getToolbarMarkerIndex( QByteArray input, const QStringList& aFlags ) {
savePreferences();
delete mySelMgr;
delete myScreenHelper;
+ myPrefs = 0;
}
/*!Start application.*/
// Preferences
createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
- Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
-
- // Help menu:
+ Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) );
- // - Help for modules
+ // Help menu
int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
- createMenu( separator(), helpMenu, -1, 10 );
+
+ int id = LightApp_Application::UserID + FIRST_HELP_ID;
+
+ // a) Link to web site
+ QString url = resMgr->stringValue("GUI", "site_url");
+ if ( !url.isEmpty() ) {
+ QString title = tr ( "SALOME_SITE" );
+ QAction* as = createAction( id, title,
+ resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
+ title, title,
+ 0, desk, false, this, SLOT( onHelpOnline() ) );
+ as->setData( url );
+ createMenu( as, helpMenu, -1, 0 );
+ id++;
+ }
+
+ // b) Link to Forum
+ url = resMgr->stringValue("GUI", "forum_url");
+ if ( !url.isEmpty() ) {
+ QString title = tr ( "SALOME_FORUM" );
+ QAction* af = createAction( helpMenu, title,
+ resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
+ title, title,
+ 0, desk, false, this, SLOT( onHelpOnline() ) );
+ af->setData( url );
+ createMenu( af, helpMenu, -1, 0 );
+ id++;
+ }
+
+ // c) Link to YouTube channel
+ url = resMgr->stringValue("GUI", "channel_url");
+ if ( !url.isEmpty() ) {
+ createMenu( separator(), helpMenu, -1, 0 );
+ QString title = tr ( "SALOME_VIDEO_TUTORIALS" );
+ QAction* av = createAction( helpMenu, title,
+ resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
+ title, title,
+ 0, desk, false, this, SLOT( onHelpOnline() ) );
+ av->setData( url );
+ createMenu( av, helpMenu, -1, 0 );
+ id++;
+ }
+
+ // d) Help for modules
+
+ // - First create top-level menus to preserve correct order
+ QString userGuide = "User's Guide";
+ QString devGuide = "Developer's Guide";
+ createMenu( userGuide, helpMenu, -1, 5 );
+ createMenu( devGuide, helpMenu, -1, 5 );
+
QStringList aModuleList;
modules( aModuleList, false );
aModuleList.prepend( "GUI" );
aModuleList.prepend( "KERNEL" );
- int id = LightApp_Application::UserID + FIRST_HELP_ID;
-
QString aModule;
foreach( aModule, aModuleList ) {
if ( aModule.isEmpty() ) // module title (user name)
QString helpSubMenu; // help submenu name (empty if not needed)
QString modName = moduleName( aModule ); // module name
if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
- QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
- QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
+ QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir env variable
+ QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir path
QString docSection;
if (resMgr->hasValue( modName, "documentation" ) )
docSection = resMgr->stringValue(modName, "documentation");
helpFileName.replace( "//", "" );
// obtain submenus hierarchy if given
QStringList smenus = helpFileName.split( "/" );
- helpFileName = smenus.last();
- smenus.removeLast();
+ helpFileName = smenus.takeLast();
+ // workaround for User's Guide and Developer's Guide to avoid having single item in module's submenu.
+ if ( helpFileName == userGuide || helpFileName == devGuide ) {
+ QString menuPath = smenus.join( "/" );
+ QStringList allKeys = helpData.keys();
+ QStringList total = allKeys.filter( QRegExp( QString( "^%1" ).arg( menuPath ) ) );
+ if ( total.count() == 1 && smenus.count() > 0 )
+ helpFileName = smenus.takeLast();
+ }
QAction* a = createAction( id, helpFileName,
resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
helpFileName, helpFileName,
}
// create sub-menus hierarchy
int menuId = helpMenu;
- foreach ( QString subMenu, smenus ) {
- menuId = createMenu( subMenu, menuId, -1, 0 );
- }
- createMenu( a, menuId, -1, 0 );
+ foreach ( QString subMenu, smenus )
+ menuId = createMenu( subMenu, menuId, -1, 5 );
+ createMenu( a, menuId, -1, ( menuId != helpMenu && (helpFileName == userGuide || helpFileName == devGuide) ) ? 0 : 5 );
id++;
}
}
// - Additional help items
- createMenu( separator(), helpMenu, -1, 5 );
+ createMenu( separator(), helpMenu, -1, 10 );
QStringList addHelpItems = resMgr->parameters( "add_help" );
foreach ( QString addHelpItem, addHelpItems ) {
addHelpItem, addHelpItem,
0, desk, false, this, SLOT( onHelpContentsModule() ) );
a->setData( valueStr );
- createMenu( a, helpMenu, -1, 5 );
+ createMenu( a, helpMenu, -1, 10 );
id++;
}
}
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 );
const QString& theApp,
const QString& theParams,
const QString& theHelpFile,
- const QString& theContext = QString() )
+ const QString& theContext = QString(),
+ //For the external browser always specify 'file://' protocol,
+ //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
+ const QString& theProtocol = QString("file://"),
+ const bool isFile = true)
: myApp( theApp ),
myParams( theParams ),
myContext( theContext ),
myStatus(0),
myLApp( app )
{
- //For the external browser always specify 'file://' protocol,
- //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
- myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
+ QString path_begin = theProtocol+"%1";
+ QString path_end = theHelpFile;
+ if( isFile ) {
+ path_end = QFileInfo( theHelpFile ).canonicalFilePath();
+ }
+ myHelpFile = path_begin.arg( path_end );
}
virtual void run()
}
}
+/*!
+ SLOT: Displays help contents for choosen module
+*/
+void LightApp_Application::onHelpOnline()
+{
+ const QAction* a = (QAction*) sender();
+ QString url = a->data().toString();
+ if ( url.isEmpty() ) return;
+
+ SUIT_ResourceMgr* resMgr = resourceMgr();
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ QString anApp = resMgr->stringValue("ExternalBrowser", platform);
+#ifdef WIN32
+ QString quote("\"");
+ anApp.prepend( quote );
+ anApp.append( quote );
+#endif
+ QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
+#if DISABLE_QTXWEBBROWSER
+ bool useExtBrowser = true;
+#else
+ bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
+#endif
+
+ if( useExtBrowser ) {
+ if ( !anApp.isEmpty() ) {
+ RunBrowser* rs = new RunBrowser( this, anApp, aParams, url, "", "http://", false );
+ rs->start();
+ }
+ else {
+ if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
+
+ showPreferences( tr( "PREF_APP" ) );
+ }
+ }
+ else {
+ QStringList parameters;
+ parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
+ parameters << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
+ parameters << "http://" + url;
+ QProcess::startDetached( "HelpBrowser", parameters );
+ }
+}
+
/*!
Sets enable or disable some actions on selection changed.
*/
resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) );
- #if OCC_VERSION_LARGE > 0x06090000
vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_type", vm->stereoType() ) );
vm->setAnaglyphFilter( resMgr->integerValue( "OCCViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
vm->setStereographicFocus( resMgr->integerValue( "OCCViewer", "focus_type", vm->stereographicFocusType() ),
vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) );
vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) );
vm->setQuadBufferSupport( resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
- #endif
vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
{
_prefs_ = new LightApp_Preferences( resourceMgr() );
that->createPreferences( _prefs_ );
+ qAddPostRoutine( LightAppCleanUpAppResources );
}
that->myPrefs = _prefs_;
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 );
anIndicesList << 0 << 1;
pref->setItemProperty( "strings", aValuesList, occProjMode );
pref->setItemProperty( "indexes", anIndicesList, occProjMode );
-#if OCC_VERSION_LARGE > 0x06090000
+
// .... -> Stereo group
int stereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), occGroup);
pref->setItemProperty( "columns", 2, stereoGroup );
// .... -> Enable quad-buffer support
pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup,
LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" );
-#endif
+
// ... "Background" group <<start>>
int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
// pref->setItemProperty( "columns", 2, bgGroup );
}
}
#endif
-#if OCC_VERSION_LARGE > 0x06090000
+
#ifndef DISABLE_OCCVIEWER
if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) )
{
}
}
#endif
-#endif
+
if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
{
int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
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
*/