Skip to content

Commit c777c8d

Browse files
author
rblazek
committed
default browser starter
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12915 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e1713f2 commit c777c8d

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/plugins/grass/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ ENDIF(NOT WIN32)
110110

111111
SET (GRASS_PLUGIN_RCCS qgsgrass_plugin.qrc)
112112

113+
SET (GRASS_BROWSER_SRCS qgis.g.browser.cpp)
113114

114115
########################################################
115116
# Build
@@ -153,6 +154,12 @@ TARGET_LINK_LIBRARIES(grassplugin
153154
${OPENPTY_LIBRARY}
154155
)
155156

157+
ADD_EXECUTABLE(qgis.g.browser ${GRASS_BROWSER_SRCS})
158+
159+
TARGET_LINK_LIBRARIES (qgis.g.browser
160+
${QT_QTGUI_LIBRARY}
161+
${QT_QTCORE_LIBRARY}
162+
)
156163

157164
########################################################
158165
# Install
@@ -165,3 +172,8 @@ INSTALL(TARGETS grassplugin
165172
FILE (GLOB GMLS *.gml)
166173
INSTALL (FILES ${GMLS} images/world.png
167174
DESTINATION ${QGIS_DATA_DIR}/grass)
175+
176+
INSTALL(TARGETS qgis.g.browser
177+
RUNTIME DESTINATION ${QGIS_DATA_DIR}/grass/bin
178+
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
179+
)

src/plugins/grass/qgis.g.browser.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdlib.h>
2+
#include <stdio.h>
3+
#include <unistd.h>
4+
#include <QUrl>
5+
#include <QDesktopServices>
6+
7+
// Open a URL by default browser
8+
int main(int argc, char **argv)
9+
{
10+
if ( argc < 2 )
11+
{
12+
fprintf ( stderr, "URL argument missing\n" );
13+
exit (1);
14+
}
15+
QDesktopServices::openUrl ( QUrl ( argv[1] ) );
16+
sleep(1); // not nice but if it exits immediately the page sometimes does not open
17+
exit ( 0 );
18+
}

src/plugins/grass/qgsgrassmodule.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1273,13 +1273,14 @@ void QgsGrassModule::run()
12731273
commandHtml.replace( ">", "&gt;" );
12741274
mOutputTextBrowser->append( "<B>" + commandHtml + "</B>" );
12751275

1276+
QStringList environment = QProcess::systemEnvironment();
1277+
environment.append( "GRASS_HTML_BROWSER=" + QgsApplication::pkgDataPath() + "/grass/bin/qgis.g.browser" );
1278+
12761279
// Warning: it is not useful to write requested region to WIND file and
12771280
// reset then to original beacuse it is reset before
12781281
// the region is read by a module even if waitForStarted() is used
12791282
// -> necessary to pass region as environment variable
12801283
// but the feature is available in GRASS 6.1 only since 23.3.2006
1281-
1282-
QStringList environment = QProcess::systemEnvironment();
12831284
if ( resetRegion )
12841285
{
12851286
QString reg = QgsGrass::regionString( &tempWindow );

0 commit comments

Comments
 (0)