Skip to content

Commit c51e0e1

Browse files
author
wonder
committed
More GRASS joy: close button for GRASS shell.
Fixes #144. git-svn-id: http://svn.osgeo.org/qgis/trunk@7426 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 21b8c97 commit c51e0e1

File tree

3 files changed

+54
-33
lines changed

3 files changed

+54
-33
lines changed

src/plugins/grass/qgsgrassshell.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ extern "C" {
8181
}
8282

8383
QgsGrassShell::QgsGrassShell ( QgsGrassTools *tools,
84-
QWidget * parent, const char * name ):
84+
QTabWidget * parent, const char * name ):
8585
QDialog(parent), QgsGrassShellBase(), mTools(tools)
8686
{
8787
mValid = false;
8888
mSkipLines = 2;
89+
mTabWidget = parent;
8990

9091
#ifdef WIN32
9192
QMessageBox::warning( 0, "Warning",
@@ -99,6 +100,8 @@ QDialog(parent), QgsGrassShellBase(), mTools(tools)
99100
mText = new QgsGrassShellText( this, mTextFrame);
100101
layout->addWidget ( mText, 0 , 0 );
101102
mText->show();
103+
104+
connect(mCloseButton, SIGNAL(clicked()), this, SLOT(closeShell()));
102105

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

@@ -939,6 +942,17 @@ void QgsGrassShell::readStderr()
939942
{
940943
}
941944

945+
void QgsGrassShell::closeShell()
946+
{
947+
#ifdef QGISDEBUG
948+
std::cerr << "QgsGrassShell::closeShell()" << std::endl;
949+
#endif
950+
951+
mTabWidget->removePage (this );
952+
delete this;
953+
}
954+
955+
942956
QgsGrassShellText::QgsGrassShellText ( QgsGrassShell *gs,
943957
QWidget * parent, const char *name )
944958
: Q3TextEdit (parent,name),

src/plugins/grass/qgsgrassshell.h

+17-11
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@
1212
* (at your option) any later version. *
1313
* *
1414
***************************************************************************/
15-
#include <qstring.h>
16-
#include <q3textedit.h>
17-
#include <q3process.h>
18-
#include <qmessagebox.h>
19-
#include <qsocketnotifier.h>
20-
#include <q3cstring.h>
2115

22-
#include "qgsgrasstools.h"
23-
#include "ui_qgsgrassshellbase.h"
16+
#include <Q3CString>
17+
#include <Q3Process>
18+
#include <Q3TextEdit>
2419
#include <QDialog>
25-
//Added by qt3to4:
26-
#include <QMouseEvent>
2720
#include <QKeyEvent>
21+
#include <QMessageBox>
22+
#include <QMouseEvent>
2823
#include <QResizeEvent>
24+
#include <QSocketNotifier>
25+
#include <QString>
26+
27+
#include "qgsgrasstools.h"
28+
#include "ui_qgsgrassshellbase.h"
29+
30+
class QTabWidget;
2931

3032
class QgsGrassShellText;
3133

@@ -74,7 +76,7 @@ class QgsGrassShell: public QDialog, private Ui::QgsGrassShellBase
7476

7577
public:
7678
QgsGrassShell ( QgsGrassTools *tools,
77-
QWidget * parent = 0, const char * name = 0 );
79+
QTabWidget * parent = 0, const char * name = 0 );
7880
~QgsGrassShell();
7981

8082
// Modes
@@ -146,6 +148,7 @@ public slots:
146148
void keyPressEvent ( QKeyEvent * e );
147149
void keyReleaseEvent ( QKeyEvent * e );
148150
void mousePressEvent(QMouseEvent* e);
151+
void closeShell();
149152

150153
signals:
151154

@@ -212,6 +215,9 @@ public slots:
212215

213216
// How many lines to skip, used to skip output of first commands sent to shell
214217
int mSkipLines;
218+
219+
// pointer to tab widget in which is the shell
220+
QTabWidget* mTabWidget;
215221
};
216222

217223
class QgsGrassShellText : public Q3TextEdit

src/plugins/grass/qgsgrassshellbase.ui

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<ui version="4.0" >
2-
<author></author>
3-
<comment></comment>
4-
<exportmacro></exportmacro>
52
<class>QgsGrassShellBase</class>
63
<widget class="QWidget" name="QgsGrassShellBase" >
74
<property name="geometry" >
@@ -22,18 +19,10 @@
2219
<string>GRASS Shell</string>
2320
</property>
2421
<layout class="QVBoxLayout" >
25-
<property name="margin" >
26-
<number>10</number>
27-
</property>
28-
<property name="spacing" >
29-
<number>6</number>
30-
</property>
3122
<item>
3223
<widget class="Q3Frame" name="mTextFrame" >
3324
<property name="sizePolicy" >
34-
<sizepolicy>
35-
<hsizetype>7</hsizetype>
36-
<vsizetype>7</vsizetype>
25+
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
3726
<horstretch>0</horstretch>
3827
<verstretch>0</verstretch>
3928
</sizepolicy>
@@ -47,26 +36,38 @@
4736
</widget>
4837
</item>
4938
<item>
50-
<widget class="Q3ProgressBar" name="mProgressBar" />
39+
<layout class="QHBoxLayout" >
40+
<item>
41+
<widget class="Q3ProgressBar" name="mProgressBar" />
42+
</item>
43+
<item>
44+
<widget class="QPushButton" name="mCloseButton" >
45+
<property name="focusPolicy" >
46+
<enum>Qt::ClickFocus</enum>
47+
</property>
48+
<property name="text" >
49+
<string>Close</string>
50+
</property>
51+
</widget>
52+
</item>
53+
</layout>
5154
</item>
5255
</layout>
5356
</widget>
5457
<layoutdefault spacing="6" margin="11" />
5558
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
5659
<customwidgets>
5760
<customwidget>
58-
<class>Q3ProgressBar</class>
59-
<extends>QWidget</extends>
60-
<header>q3progressbar.h</header>
61+
<class>Q3Frame</class>
62+
<extends>QFrame</extends>
63+
<header>Qt3Support/Q3Frame</header>
6164
<container>1</container>
62-
<pixmap></pixmap>
6365
</customwidget>
6466
<customwidget>
65-
<class>Q3Frame</class>
66-
<extends></extends>
67-
<header>Qt3Support/Q3Frame</header>
67+
<class>Q3ProgressBar</class>
68+
<extends>QFrame</extends>
69+
<header>Qt3Support/Q3ProgressBar</header>
6870
<container>1</container>
69-
<pixmap></pixmap>
7071
</customwidget>
7172
</customwidgets>
7273
<resources/>

0 commit comments

Comments
 (0)