From 0b8d752ba4c36654eddcf07911d57f3d86a67163 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 17 Dec 2013 10:05:18 +0000 Subject: [PATCH] refs #207 - "Help" button doesn't work --- CMakeLists.txt | 4 +- src/HYDROGUI/CMakeLists.txt | 2 - src/HYDROGUI/HYDROGUI_InputPanel.cxx | 16 +--- src/HYDROGUI/HYDROGUI_InputPanel.h | 1 + src/HYDROGUI/HYDROGUI_Operation.cxx | 28 ++++++ src/HYDROGUI/HYDROGUI_Operation.h | 8 ++ src/HYDROGUI/HYDROGUI_RunBrowser.cxx | 124 --------------------------- src/HYDROGUI/HYDROGUI_RunBrowser.h | 60 ------------- 8 files changed, 40 insertions(+), 203 deletions(-) delete mode 100644 src/HYDROGUI/HYDROGUI_RunBrowser.cxx delete mode 100644 src/HYDROGUI/HYDROGUI_RunBrowser.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f2d9d31..132e4a90 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) +IF(SALOME_BUILD_DOC) ADD_SUBDIRECTORY(doc) -#ENDIF() +ENDIF() # Header configuration # ==================== diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 5e08a656..e7adb3cd 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -51,7 +51,6 @@ set(PROJECT_HEADERS HYDROGUI_PrsZoneDriver.h HYDROGUI_Region.h HYDROGUI_RemoveImageRefsOp.h - HYDROGUI_RunBrowser.h HYDROGUI_Shape.h HYDROGUI_ShowHideOp.h HYDROGUI_StreamDlg.h @@ -133,7 +132,6 @@ 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 ceb9f28d..03831fc4 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -22,7 +22,6 @@ #include "HYDROGUI_InputPanel.h" #include "HYDROGUI_Module.h" -#include "HYDROGUI_RunBrowser.h" #include #include @@ -96,20 +95,7 @@ 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 ); + emit panelHelp(); } void HYDROGUI_InputPanel::closeEvent ( QCloseEvent * event ) diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h index 00c2c710..da05247f 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.h +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -52,6 +52,7 @@ public: signals: void panelApply(); void panelCancel(); + void panelHelp(); protected slots: void onApply(); diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index 1f308ea3..ed01027c 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -43,6 +43,10 @@ HYDROGUI_Operation::HYDROGUI_Operation( HYDROGUI_Module* theModule ) myModule( theModule ), myPanel( 0 ) { + connect( this, SIGNAL( helpContextModule( const QString&, const QString&, + const QString& ) ), + theModule->application(), SLOT( onHelpContextModule( const QString&, + const QString&, const QString& ) ) ); } HYDROGUI_Operation::~HYDROGUI_Operation() @@ -66,6 +70,7 @@ HYDROGUI_InputPanel* HYDROGUI_Operation::inputPanel() const ( ( HYDROGUI_Operation* )this )->myPanel = createInputPanel(); connect( myPanel, SIGNAL( panelApply() ), this, SLOT( onApply() ) ); connect( myPanel, SIGNAL( panelCancel() ), this, SLOT( onCancel() ) ); + connect( myPanel, SIGNAL( panelHelp() ), this, SLOT( onHelp() ) ); } return myPanel; } @@ -217,3 +222,26 @@ void HYDROGUI_Operation::onCancel() processCancel(); abort(); } + +void HYDROGUI_Operation::onHelp() +{ + emit helpContextModule( getHelpComponent(), getHelpFile(), getHelpContext() ); +} + +QString HYDROGUI_Operation::getHelpComponent() const +{ + return module()->moduleName(); +} + +QString HYDROGUI_Operation::getHelpFile() const +{ + QString aFileName = ((myName.isEmpty())? operationName() : myName); + return aFileName.replace(QRegExp("\\s"), "_").append(".html"); +} + +QString HYDROGUI_Operation::getHelpContext() const +{ + return QString(); +} + + diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index 5bce481f..7cf1b464 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -46,6 +46,8 @@ public: SUIT_SelectionMgr* selectionMgr() const; HYDROGUI_Module* module() const; +signals: + void helpContextModule( const QString&, const QString&, const QString& ); protected: virtual void startOperation(); virtual void abortOperation(); @@ -67,6 +69,12 @@ protected: protected slots: virtual void onApply(); virtual void onCancel(); + virtual void onHelp(); + +protected: + QString getHelpComponent() const; + QString getHelpFile() const; + QString getHelpContext() const; private: HYDROGUI_Module* myModule; diff --git a/src/HYDROGUI/HYDROGUI_RunBrowser.cxx b/src/HYDROGUI/HYDROGUI_RunBrowser.cxx deleted file mode 100644 index fe58c549..00000000 --- a/src/HYDROGUI/HYDROGUI_RunBrowser.cxx +++ /dev/null @@ -1,124 +0,0 @@ -// 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 deleted file mode 100644 index b2507c7d..00000000 --- a/src/HYDROGUI/HYDROGUI_RunBrowser.h +++ /dev/null @@ -1,60 +0,0 @@ -// 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 -- 2.39.2