From 77f307d5db2ad9b48283b36af435e6de42959c83 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 17 Dec 2013 07:28:03 +0000 Subject: [PATCH] refs #207 - "Help" button doesn't work --- CMakeLists.txt | 6 +- doc/CMakeLists.txt | 23 ++++ doc/salome/CMakeLists.txt | 23 ++++ doc/salome/gui/CMakeLists.txt | 23 ++++ doc/salome/gui/HYDRO/CMakeLists.txt | 23 ++++ doc/salome/gui/HYDRO/create_polyline.html | 9 ++ doc/salome/gui/HYDRO/create_profile.html | 9 ++ src/HYDROGUI/CMakeLists.txt | 2 + src/HYDROGUI/HYDROGUI_InputPanel.cxx | 16 +++ src/HYDROGUI/HYDROGUI_RunBrowser.cxx | 124 ++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_RunBrowser.h | 60 +++++++++++ src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 13 +++ 12 files changed, 328 insertions(+), 3 deletions(-) create mode 100644 doc/CMakeLists.txt create mode 100644 doc/salome/CMakeLists.txt create mode 100644 doc/salome/gui/CMakeLists.txt create mode 100644 doc/salome/gui/HYDRO/CMakeLists.txt create mode 100644 doc/salome/gui/HYDRO/create_polyline.html create mode 100644 doc/salome/gui/HYDRO/create_profile.html create mode 100644 src/HYDROGUI/HYDROGUI_RunBrowser.cxx create mode 100644 src/HYDROGUI/HYDROGUI_RunBrowser.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c6f8487..1f2d9d31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,9 +176,9 @@ ADD_SUBDIRECTORY (src/HYDROCurveCreator) ADD_SUBDIRECTORY (src/HYDROData) ADD_SUBDIRECTORY (src/HYDROGUI) ADD_SUBDIRECTORY (src/HYDROPy) -IF(SALOME_BUILD_DOC) - #ADD_SUBDIRECTORY(doc) -ENDIF() +#IF(SALOME_BUILD_DOC) + ADD_SUBDIRECTORY(doc) +#ENDIF() # Header configuration # ==================== diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 00000000..cedf6566 --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +ADD_SUBDIRECTORY(salome) diff --git a/doc/salome/CMakeLists.txt b/doc/salome/CMakeLists.txt new file mode 100644 index 00000000..c4b6fb90 --- /dev/null +++ b/doc/salome/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +ADD_SUBDIRECTORY(gui) diff --git a/doc/salome/gui/CMakeLists.txt b/doc/salome/gui/CMakeLists.txt new file mode 100644 index 00000000..047df8e1 --- /dev/null +++ b/doc/salome/gui/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +ADD_SUBDIRECTORY(HYDRO) diff --git a/doc/salome/gui/HYDRO/CMakeLists.txt b/doc/salome/gui/HYDRO/CMakeLists.txt new file mode 100644 index 00000000..6e460373 --- /dev/null +++ b/doc/salome/gui/HYDRO/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SET(docdir ${CMAKE_INSTALL_PREFIX}/share/doc/salome) +FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.py") +INSTALL(FILES ${files} DESTINATION ${docdir}/gui/HYDRO) + diff --git a/doc/salome/gui/HYDRO/create_polyline.html b/doc/salome/gui/HYDRO/create_polyline.html new file mode 100644 index 00000000..acaca457 --- /dev/null +++ b/doc/salome/gui/HYDRO/create_polyline.html @@ -0,0 +1,9 @@ + + + + + +

Create Polyline help page

+ + + diff --git a/doc/salome/gui/HYDRO/create_profile.html b/doc/salome/gui/HYDRO/create_profile.html new file mode 100644 index 00000000..44aec901 --- /dev/null +++ b/doc/salome/gui/HYDRO/create_profile.html @@ -0,0 +1,9 @@ + + + + + +

Create Profile help page

+ + + diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index e7adb3cd..5e08a656 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -51,6 +51,7 @@ set(PROJECT_HEADERS HYDROGUI_PrsZoneDriver.h HYDROGUI_Region.h HYDROGUI_RemoveImageRefsOp.h + HYDROGUI_RunBrowser.h HYDROGUI_Shape.h HYDROGUI_ShowHideOp.h HYDROGUI_StreamDlg.h @@ -132,6 +133,7 @@ set(PROJECT_SOURCES HYDROGUI_PrsZoneDriver.cxx HYDROGUI_Region.cxx HYDROGUI_RemoveImageRefsOp.cxx + HYDROGUI_RunBrowser.cxx HYDROGUI_Shape.cxx HYDROGUI_ShowHideOp.cxx HYDROGUI_StreamDlg.cxx diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx index d569896e..ceb9f28d 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -22,12 +22,14 @@ #include "HYDROGUI_InputPanel.h" #include "HYDROGUI_Module.h" +#include "HYDROGUI_RunBrowser.h" #include #include #include #include +#include HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle, bool doInitLayout ) : QDockWidget( theModule->application()->desktop() ), @@ -94,6 +96,20 @@ void HYDROGUI_InputPanel::onCancel() void HYDROGUI_InputPanel::onHelp() { + QString aModuleName = myModule->moduleName(); + + QString aPagePath = HYDROGUI_RunBrowser::getPagePath( aModuleName ); + + QString aPageName = ""; + QString aWindowTitle = windowTitle(); + if ( !aWindowTitle.isEmpty() ) + { + aPageName = QStringList( aWindowTitle.split( " " ) ).join( "_" ).append( ".html" ); + aPageName.toLower(); + } + + QString aPage = aPagePath + QDir::separator() + aPageName; + HYDROGUI_RunBrowser::showPage( myModule->getApp(), aPage ); } void HYDROGUI_InputPanel::closeEvent ( QCloseEvent * event ) diff --git a/src/HYDROGUI/HYDROGUI_RunBrowser.cxx b/src/HYDROGUI/HYDROGUI_RunBrowser.cxx new file mode 100644 index 00000000..fe58c549 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_RunBrowser.cxx @@ -0,0 +1,124 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include + +HYDROGUI_RunBrowser::HYDROGUI_RunBrowser( LightApp_Application* app, + const QString& theApp, + const QString& theParams, + const QString& theHelpFile, + const QString& theContext ) +: 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() ); +} + +void HYDROGUI_RunBrowser::run() +{ + if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) { + QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) ); + + QProcess* proc = new QProcess(); + + //proc->start( aCommand ); + if ( true || !proc->waitForStarted() ) { + SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 ); + QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) ); + ce2000->setData( msg ); + QApplication::postEvent( myLApp, ce2000 ); + } + } +} + +void HYDROGUI_RunBrowser::showPage( LightApp_Application* theApp, + const QString& thePage ) +{ + SUIT_ResourceMgr* resMgr = theApp->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" ); + bool useExtBrowser = resMgr->booleanValue( "ExternalBrowser", "use_external_browser", false ); + + if( useExtBrowser ) { + if ( !anApp.isEmpty() ) { + HYDROGUI_RunBrowser* rs = new HYDROGUI_RunBrowser( theApp, anApp, aParams, thePage ); + rs->start(); + } + else + SUIT_MessageBox::warning(theApp->desktop(), tr( "WRN_WARNING" ), tr( "WRN_DEFINE_EXTERNAL_BROWSER" )); + } + else { +#ifdef WIN32 + // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol + // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol. + QtxWebBrowser::loadUrl( thePage ); +#else + QtxWebBrowser::loadUrl( QString( "file://%1" ).arg( helpFile ) ); +#endif + } +} + +QString HYDROGUI_RunBrowser::getPagePath( const QString& theModuleName ) +{ + QString aPagePath; + + QString rootDir = QString( "%1_ROOT_DIR" ).arg( theModuleName ); // module root dir variable + QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir + if ( !modDir.isEmpty() ) { + QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" + << "gui" << theModuleName; + QString indexFile = idxLst.join( QDir::separator() ); // index file + if ( QFile::exists( indexFile ) ) + aPagePath = indexFile; + } + return aPagePath; +} diff --git a/src/HYDROGUI/HYDROGUI_RunBrowser.h b/src/HYDROGUI/HYDROGUI_RunBrowser.h new file mode 100644 index 00000000..b2507c7d --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_RunBrowser.h @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_HYDROGUI_RunBrowser_H +#define HYDROGUI_HYDROGUI_RunBrowser_H + +#include + +class LightApp_Application; + +/*! + \class HYDROGUI_RunBrowser + Runs system command in separate thread +*/ +class HYDROGUI_RunBrowser : public QThread +{ +public: + HYDROGUI_RunBrowser( LightApp_Application* app, + const QString& theApp, + const QString& theParams, + const QString& theHelpFile, + const QString& theContext = QString() ); + ~HYDROGUI_RunBrowser() {} + + virtual void run(); + + static void showPage( LightApp_Application* theApp, + const QString& thePage ); + + static QString getPagePath( const QString& theModuleName ); + +private: + QString myApp; + QString myParams; + QString myHelpFile; + QString myContext; + int myStatus; + LightApp_Application* myLApp; +}; + +#endif diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index b6093740..e2faf2ec 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1803,4 +1803,17 @@ Do you want to remove these profiles and continue? + + + HYDROGUI_RunBrowser + + EXTERNAL_BROWSER_CANNOT_SHOW_PAGE + External browser "%1" can not show help page "%2". You could change it in preferences. + + + WRN_DEFINE_EXTERNAL_BROWSER + External browser is not found. Do you want to define it in preferences? + + + -- 2.39.2