Skip to content
Permalink
Browse files

reset GRASS_GUI in term

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12919 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Feb 10, 2010
1 parent 5c38225 commit 1c3ebce9fb7856b03ff2d2d2d799ef1a593f8547
Showing with 41 additions and 0 deletions.
  1. +24 −0 src/plugins/grass/qgsgrassshell.cpp
  2. +14 −0 src/providers/grass/qgsgrass.cpp
  3. +3 −0 src/providers/grass/qgsgrass.h
@@ -17,6 +17,7 @@
#include <QShortcut>
#include <QKeySequence>

#include "qgslogger.h"
#include "qtermwidget/qtermwidget.h"
#include "qgsgrass.h"

@@ -53,6 +54,29 @@ QgsGrassShell::QgsGrassShell( QgsGrassTools *tools, QTabWidget *parent, const ch

mTerminal->setSize( 80, 25 );
mTerminal->startShellProgram();
// using -text option GRASS_GUI is owerridden so we have to reset it
QgsDebugMsg ( "gisrc = " + QgsGrass::gisrcFilePath() );
QFile in( QgsGrass::gisrcFilePath() );
if ( in.open( QIODevice::ReadOnly ) )
{
char buf[1000];
QString oldGui;
while ( in.readLine( buf, 1000 ) != -1 )
{
QString line = buf;
QStringList kv = line.split ( ':' );
if ( kv.length() == 2 && kv.at(0) == "GRASS_GUI" )
{
oldGui = kv.at(1).trimmed ();
break;
}
}
if ( ! oldGui.isEmpty() )
{
QString cmd = QString("g.gisenv set=GRASS_GUI=") + oldGui + "\n";
mTerminal->sendText( cmd );
}
}
mTerminal->setFocus( Qt::MouseFocusReason );
}

@@ -1242,3 +1242,17 @@ QString GRASS_EXPORT QgsGrass::lockFilePath()
{
return mMapsetLock;
}

QString GRASS_EXPORT QgsGrass::gisrcFilePath()
{
if ( mGisrc.isEmpty() )
{
// Started from GRASS shell
if ( getenv( "GISRC" ) )
{
return QString ( getenv( "GISRC" ) );
}
}
return mGisrc;
}

@@ -160,6 +160,9 @@ class QgsGrass
// ! Get the lock file
static GRASS_EXPORT QString lockFilePath();

// ! Get current gisrc path
static QString gisrcFilePath();

// ! Run a GRASS module in any gisdbase/location
static GRASS_EXPORT QByteArray runModule( QString gisdbase, QString location, QString module, QStringList arguments );

0 comments on commit 1c3ebce

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