Skip to content
Permalink
Browse files

fixed restore position, must not use Qt::WType_Dialog

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5201 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Apr 6, 2006
1 parent 336dc01 commit 8cd51e9da874c19ffbc04320b88eb8071c093a06
@@ -136,6 +136,7 @@ void QgsGrassPlugin::initGui()
toolBarPointer = 0;
mTools = 0;
mNewMapset = 0;
mRegion = 0;

QSettings settings("QuantumGIS", "qgis");

@@ -148,9 +149,9 @@ void QgsGrassPlugin::initGui()
connect( mQgis, SIGNAL( newProject() ), this, SLOT(newProject()));

// Create region rubber band
mRegion = new QgsRubberBand(mCanvas, 1);
mRegion->setZ(20);
mRegion->hide();
mRegionBand = new QgsRubberBand(mCanvas, 1);
mRegionBand->setZ(20);
mRegionBand->hide();

// Create the action for tool
mOpenMapsetAction = new QAction( "Open mapset", this );
@@ -231,8 +232,8 @@ void QgsGrassPlugin::initGui()
// Init Region symbology
mRegionPen.setColor( QColor ( settings.readEntry ("/GRASS/region/color", "#ff0000" ) ) );
mRegionPen.setWidth( settings.readNumEntry ("/GRASS/region/width", 0 ) );
mRegion->setColor ( mRegionPen.color() );
mRegion->setWidth ( mRegionPen.width() );
mRegionBand->setColor ( mRegionPen.color() );
mRegionBand->setWidth ( mRegionPen.width() );

mapsetChanged();
}
@@ -264,7 +265,7 @@ void QgsGrassPlugin::mapsetChanged ()
bool on = settings.readBoolEntry ("/GRASS/region/on", true );
mRegionAction->setOn(on);
if ( on ) {
mRegion->show();
mRegionBand->show();
}

if ( mTools )
@@ -564,7 +565,7 @@ void QgsGrassPlugin::displayRegion()
std::cout << "QgsGrassPlugin::displayRegion()" << std::endl;
#endif

mRegion->reset();
mRegionBand->reset();

// Display region of current mapset if in active mode
if ( !QgsGrass::activeMode() ) return;
@@ -600,7 +601,7 @@ void QgsGrassPlugin::displayRegion()

for ( int i = 0; i < 5; i++ )
{
mRegion->addPoint( points[i] );
mRegionBand->addPoint( points[i] );
}
}

@@ -615,9 +616,9 @@ void QgsGrassPlugin::switchRegion(bool on)

if ( on ) {
displayRegion();
mRegion->show();
mRegionBand->show();
} else {
mRegion->hide();
mRegionBand->hide();
}
}

@@ -638,15 +639,23 @@ void QgsGrassPlugin::changeRegion(void)
std::cout << "QgsGrassPlugin::changeRegion()" << std::endl;
#endif

if ( QgsGrassRegion::isRunning() ) {
QMessageBox::warning( 0, "Warning", "The Region tool is already running." );
return;
if ( mRegion ) { // running
mRegion->show();
return;
}

QgsGrassRegion *reg = new QgsGrassRegion(this, mQgis, qGisInterface,
mQgis, Qt::WType_Dialog );
// Warning: don't use Qt::WType_Dialog, it would ignore restorePosition
mRegion = new QgsGrassRegion(this, mQgis, qGisInterface,
mQgis, Qt::Window );

connect ( mRegion, SIGNAL(destroyed(QObject *)), this, SLOT( regionClosed() ));

reg->show();
mRegion->show();
}

void QgsGrassPlugin::regionClosed()
{
mRegion = 0;
}

QPen & QgsGrassPlugin::regionPen()
@@ -658,8 +667,8 @@ void QgsGrassPlugin::setRegionPen(QPen & pen)
{
mRegionPen = pen;

mRegion->setColor ( mRegionPen.color() );
mRegion->setWidth ( mRegionPen.width() );
mRegionBand->setColor ( mRegionPen.color() );
mRegionBand->setWidth ( mRegionPen.width() );

QSettings settings("QuantumGIS", "qgis");
settings.writeEntry ("/GRASS/region/color", mRegionPen.color().name() );
@@ -28,6 +28,7 @@ class QgsRubberBand;

class QgsGrassTools;
class QgsGrassNewMapset;
class QgsGrassRegion;
class QToolBar;
/**
* \class QgsGrassPlugin
@@ -88,6 +89,8 @@ public slots:
void switchRegion(bool on);
//! Change region
void changeRegion(void);
//! Region dialog closed
void regionClosed();
//! Redraw region
void redrawRegion(void);
//! Post render
@@ -136,8 +139,10 @@ public slots:
QAction *mRegionAction;
//! Region width
QPen mRegionPen;
//! Region dialog
QgsGrassRegion *mRegion;
// Region rubber band
QgsRubberBand *mRegion;
QgsRubberBand *mRegionBand;
//! GRASS tools
QgsGrassTools *mTools;
//! Pointer to QgsGrassNewMapset
@@ -62,8 +62,6 @@ extern "C" {
#include "qgsgrassplugin.h"
#include "qgsgrassregion.h"

bool QgsGrassRegion::mRunning = false;

/** map tool which uses rubber band for changing grass region */
class QgsGrassRegionEdit : public QgsMapTool
{
@@ -156,7 +154,6 @@ QgsGrassRegion::QgsGrassRegion ( QgsGrassPlugin *plugin, QgisApp *qgisApp, Qgis

setupUi(this);

mRunning = true;
mPlugin = plugin;
mQgisApp = qgisApp;
mInterface = iface;
@@ -293,12 +290,6 @@ void QgsGrassRegion::setGuiValues( bool north, bool south, bool east, bool west,

QgsGrassRegion::~QgsGrassRegion ()
{
mRunning = false;
}

bool QgsGrassRegion::isRunning(void)
{
return mRunning;
}

void QgsGrassRegion::northChanged(const QString &str)
@@ -482,18 +473,14 @@ void QgsGrassRegion::accept()

saveWindowLocation();
mQgisApp->pan(); // change to pan tool
mRunning = false;
close();
//delete this;
delete this;
}

void QgsGrassRegion::reject()
{
saveWindowLocation();
mQgisApp->pan(); // change to pan tool
mRunning = false;
close();
//delete this;
delete this;
}

void QgsGrassRegion::restorePosition()
@@ -50,9 +50,6 @@ class QgsGrassRegion: public QDialog, private Ui::QgsGrassRegionBase
//! Destructor
~QgsGrassRegion();

//! Is Running
static bool isRunning (void);

public slots:
//! OK
void on_acceptButton_clicked() { accept(); }
@@ -89,10 +86,9 @@ public slots:
void changeColor ( void ) ;
void changeWidth ( void ) ;

void restorePosition(void);

private:
//! Editing is already running
static bool mRunning;

//! Pointer to plugin
QgsGrassPlugin *mPlugin;

@@ -131,8 +127,6 @@ public slots:
void setGuiValues( bool north = true, bool south = true, bool east = true, bool west = true,
bool nsres = true, bool ewres = true, bool rows = true, bool cols = true );


void restorePosition(void);

void saveWindowLocation(void);

0 comments on commit 8cd51e9

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