Skip to content
Permalink
Browse files

help viewer: report errors and make it work from windows build directory

  • Loading branch information
jef-n committed Jul 8, 2013
1 parent 9ca0354 commit 86eda3d1593c73842a99801259a0956562e8a7f4
Showing with 19 additions and 11 deletions.
  1. +17 −1 src/core/qgscontexthelp.cpp
  2. +2 −10 src/core/qgscontexthelp.h
@@ -22,6 +22,7 @@
#include <QTextStream>

#include "qgscontexthelp.h"
#include "qgsmessagelog.h"
#include "qgsapplication.h"
#include "qgslogger.h"

@@ -56,17 +57,32 @@ QProcess *QgsContextHelp::start()
QgsDebugMsg( QString( "Help path is %1" ).arg( helpPath ) );

QProcess *process = new QProcess;
process->start( helpPath );

// Delete this object if the process terminates
connect( process, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( processExited() ) );

// Delete the process if the application quits
connect( qApp, SIGNAL( aboutToQuit() ), process, SLOT( terminate() ) );

connect( process, SIGNAL( error( QProcess::ProcessError ) ), this, SLOT( error( QProcess::ProcessError ) ) );

#ifdef Q_OS_WIN
if ( QgsApplication::isRunningFromBuildDir() )
{
process->setEnvironment( QStringList() << QString( "PATH=%1;%2" ).arg( getenv( "PATH" ) ).arg( QApplication::applicationDirPath() ) );
}
#endif

process->start( helpPath );

return process;
}

void QgsContextHelp::error( QProcess::ProcessError error )
{
QgsMessageLog::logMessage( tr( "Error starting help viewer [%1]" ).arg( error ), tr( "Context help" ) );
}

void QgsContextHelp::showContext( QString context )
{
init();
@@ -21,12 +21,8 @@

#include <QObject>
#include <QHash>
#include <QProcess>

class QProcess;

#ifdef Q_OS_MACX
#define QGSCONTEXTHELP_REUSE 1
#endif
/** \ingroup core
* Provides a context based help browser for a dialog.
*
@@ -35,11 +31,6 @@ class QProcess;
* viewer using QProcess and ensures that only one viewer is open.
* The viewer will be terminated if open when the main application quits.
*
* If the compile-time flag QGSCONTEXTHELP_REUSE is defined, the help viewer
* will be reused if it is still open. If this flag is not set, the viewer
* process will be terminated if open and restarted; this makes it the top
* window for window managers such as Linux/GNOME which will make a window
* active but not bring it to the top if raised programatically.
*/
class CORE_EXPORT QgsContextHelp : public QObject
{
@@ -49,6 +40,7 @@ class CORE_EXPORT QgsContextHelp : public QObject

private slots:
void processExited();
void error( QProcess::ProcessError error );

private:
//! Constructor

0 comments on commit 86eda3d

Please sign in to comment.
You can’t perform that action at this time.