Skip to content

Commit

Permalink
default browser starter
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12915 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Feb 10, 2010
1 parent dcf060a commit 59ad155
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/plugins/grass/CMakeLists.txt
Expand Up @@ -110,6 +110,7 @@ ENDIF(NOT WIN32)

SET (GRASS_PLUGIN_RCCS qgsgrass_plugin.qrc)

SET (GRASS_BROWSER_SRCS qgis.g.browser.cpp)

########################################################
# Build
Expand Down Expand Up @@ -153,6 +154,12 @@ TARGET_LINK_LIBRARIES(grassplugin
${OPENPTY_LIBRARY}
)

ADD_EXECUTABLE(qgis.g.browser ${GRASS_BROWSER_SRCS})

TARGET_LINK_LIBRARIES (qgis.g.browser
${QT_QTGUI_LIBRARY}
${QT_QTCORE_LIBRARY}
)

########################################################
# Install
Expand All @@ -165,3 +172,8 @@ INSTALL(TARGETS grassplugin
FILE (GLOB GMLS *.gml)
INSTALL (FILES ${GMLS} images/world.png
DESTINATION ${QGIS_DATA_DIR}/grass)

INSTALL(TARGETS qgis.g.browser
RUNTIME DESTINATION ${QGIS_DATA_DIR}/grass/bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
18 changes: 18 additions & 0 deletions src/plugins/grass/qgis.g.browser.cpp
@@ -0,0 +1,18 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <QUrl>
#include <QDesktopServices>

// Open a URL by default browser
int main(int argc, char **argv)
{
if ( argc < 2 )
{
fprintf ( stderr, "URL argument missing\n" );
exit (1);
}
QDesktopServices::openUrl ( QUrl ( argv[1] ) );
sleep(1); // not nice but if it exits immediately the page sometimes does not open
exit ( 0 );
}
5 changes: 3 additions & 2 deletions src/plugins/grass/qgsgrassmodule.cpp
Expand Up @@ -1273,13 +1273,14 @@ void QgsGrassModule::run()
commandHtml.replace( ">", "&gt;" );
mOutputTextBrowser->append( "<B>" + commandHtml + "</B>" );

QStringList environment = QProcess::systemEnvironment();
environment.append( "GRASS_HTML_BROWSER=" + QgsApplication::pkgDataPath() + "/grass/bin/qgis.g.browser" );

// Warning: it is not useful to write requested region to WIND file and
// reset then to original beacuse it is reset before
// the region is read by a module even if waitForStarted() is used
// -> necessary to pass region as environment variable
// but the feature is available in GRASS 6.1 only since 23.3.2006

QStringList environment = QProcess::systemEnvironment();
if ( resetRegion )
{
QString reg = QgsGrass::regionString( &tempWindow );
Expand Down

0 comments on commit 59ad155

Please sign in to comment.