#include <QTreeView>
#include <QMimeData>
#include <QShortcut>
+#include <QRegExp>
#include <utilities.h>
tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) );
- // Help menu:
-
- // - 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++;
}
}
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.
*/