Skip to content

Commit

Permalink
More GRASS joy: close button for GRASS shell.
Browse files Browse the repository at this point in the history
Fixes #144.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7426 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Nov 16, 2007
1 parent d1fb582 commit 7506c33
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 33 deletions.
16 changes: 15 additions & 1 deletion src/plugins/grass/qgsgrassshell.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ extern "C" {
} }


QgsGrassShell::QgsGrassShell ( QgsGrassTools *tools, QgsGrassShell::QgsGrassShell ( QgsGrassTools *tools,
QWidget * parent, const char * name ): QTabWidget * parent, const char * name ):
QDialog(parent), QgsGrassShellBase(), mTools(tools) QDialog(parent), QgsGrassShellBase(), mTools(tools)
{ {
mValid = false; mValid = false;
mSkipLines = 2; mSkipLines = 2;
mTabWidget = parent;


#ifdef WIN32 #ifdef WIN32
QMessageBox::warning( 0, "Warning", QMessageBox::warning( 0, "Warning",
Expand All @@ -99,6 +100,8 @@ QDialog(parent), QgsGrassShellBase(), mTools(tools)
mText = new QgsGrassShellText( this, mTextFrame); mText = new QgsGrassShellText( this, mTextFrame);
layout->addWidget ( mText, 0 , 0 ); layout->addWidget ( mText, 0 , 0 );
mText->show(); mText->show();

connect(mCloseButton, SIGNAL(clicked()), this, SLOT(closeShell()));


mFont = QFont ( "Courier", 10 ); mFont = QFont ( "Courier", 10 );


Expand Down Expand Up @@ -939,6 +942,17 @@ void QgsGrassShell::readStderr()
{ {
} }


void QgsGrassShell::closeShell()
{
#ifdef QGISDEBUG
std::cerr << "QgsGrassShell::closeShell()" << std::endl;
#endif

mTabWidget->removePage (this );
delete this;
}


QgsGrassShellText::QgsGrassShellText ( QgsGrassShell *gs, QgsGrassShellText::QgsGrassShellText ( QgsGrassShell *gs,
QWidget * parent, const char *name ) QWidget * parent, const char *name )
: Q3TextEdit (parent,name), : Q3TextEdit (parent,name),
Expand Down
28 changes: 17 additions & 11 deletions src/plugins/grass/qgsgrassshell.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@
* (at your option) any later version. * * (at your option) any later version. *
* * * *
***************************************************************************/ ***************************************************************************/
#include <qstring.h>
#include <q3textedit.h>
#include <q3process.h>
#include <qmessagebox.h>
#include <qsocketnotifier.h>
#include <q3cstring.h>


#include "qgsgrasstools.h" #include <Q3CString>
#include "ui_qgsgrassshellbase.h" #include <Q3Process>
#include <Q3TextEdit>
#include <QDialog> #include <QDialog>
//Added by qt3to4:
#include <QMouseEvent>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMessageBox>
#include <QMouseEvent>
#include <QResizeEvent> #include <QResizeEvent>
#include <QSocketNotifier>
#include <QString>

#include "qgsgrasstools.h"
#include "ui_qgsgrassshellbase.h"

class QTabWidget;


class QgsGrassShellText; class QgsGrassShellText;


Expand Down Expand Up @@ -74,7 +76,7 @@ class QgsGrassShell: public QDialog, private Ui::QgsGrassShellBase


public: public:
QgsGrassShell ( QgsGrassTools *tools, QgsGrassShell ( QgsGrassTools *tools,
QWidget * parent = 0, const char * name = 0 ); QTabWidget * parent = 0, const char * name = 0 );
~QgsGrassShell(); ~QgsGrassShell();


// Modes // Modes
Expand Down Expand Up @@ -146,6 +148,7 @@ public slots:
void keyPressEvent ( QKeyEvent * e ); void keyPressEvent ( QKeyEvent * e );
void keyReleaseEvent ( QKeyEvent * e ); void keyReleaseEvent ( QKeyEvent * e );
void mousePressEvent(QMouseEvent* e); void mousePressEvent(QMouseEvent* e);
void closeShell();


signals: signals:


Expand Down Expand Up @@ -212,6 +215,9 @@ public slots:


// How many lines to skip, used to skip output of first commands sent to shell // How many lines to skip, used to skip output of first commands sent to shell
int mSkipLines; int mSkipLines;

// pointer to tab widget in which is the shell
QTabWidget* mTabWidget;
}; };


class QgsGrassShellText : public Q3TextEdit class QgsGrassShellText : public Q3TextEdit
Expand Down
43 changes: 22 additions & 21 deletions src/plugins/grass/qgsgrassshellbase.ui
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,4 @@
<ui version="4.0" > <ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>QgsGrassShellBase</class> <class>QgsGrassShellBase</class>
<widget class="QWidget" name="QgsGrassShellBase" > <widget class="QWidget" name="QgsGrassShellBase" >
<property name="geometry" > <property name="geometry" >
Expand All @@ -22,18 +19,10 @@
<string>GRASS Shell</string> <string>GRASS Shell</string>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>10</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item> <item>
<widget class="Q3Frame" name="mTextFrame" > <widget class="Q3Frame" name="mTextFrame" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
Expand All @@ -47,26 +36,38 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="Q3ProgressBar" name="mProgressBar" /> <layout class="QHBoxLayout" >
<item>
<widget class="Q3ProgressBar" name="mProgressBar" />
</item>
<item>
<widget class="QPushButton" name="mCloseButton" >
<property name="focusPolicy" >
<enum>Qt::ClickFocus</enum>
</property>
<property name="text" >
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11" /> <layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>Q3ProgressBar</class> <class>Q3Frame</class>
<extends>QWidget</extends> <extends>QFrame</extends>
<header>q3progressbar.h</header> <header>Qt3Support/Q3Frame</header>
<container>1</container> <container>1</container>
<pixmap></pixmap>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>Q3Frame</class> <class>Q3ProgressBar</class>
<extends></extends> <extends>QFrame</extends>
<header>Qt3Support/Q3Frame</header> <header>Qt3Support/Q3ProgressBar</header>
<container>1</container> <container>1</container>
<pixmap></pixmap>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
Expand Down

0 comments on commit 7506c33

Please sign in to comment.