Skip to content

Commit

Permalink
fix capture coordinate plugin: refs pull request #803
Browse files Browse the repository at this point in the history
  • Loading branch information
slarosa committed Aug 27, 2013
1 parent c2310fd commit d51ea41
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/plugins/coordinate_capture/coordinatecapture.cpp
Expand Up @@ -92,13 +92,22 @@ void CoordinateCapture::initGui()
mTransform.setDestCRS( mCrs ); // set the CRS in the transform
mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QGis::Degrees ) ? 5 : 3; // precision depends on CRS units

//create the dock widget
mpDockWidget = new QDockWidget( tr( "Coordinate Capture" ), mQGisIface->mainWindow() );
mpDockWidget->setObjectName( "CoordinateCapture" );
mpDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
mQGisIface->addDockWidget( Qt::LeftDockWidgetArea, mpDockWidget );

// Create the action for tool
mQActionPointer = new QAction( QIcon(), tr( "Coordinate Capture" ), this );
mQActionPointer->setCheckable( true );
mQActionPointer->setChecked( mpDockWidget->isVisible() );
// Set the what's this text
mQActionPointer->setWhatsThis( tr( "Click on the map to view coordinates and capture to clipboard." ) );
// Connect the action to the run
connect( mQActionPointer, SIGNAL( triggered() ), this, SLOT( run() ) );
connect( mQActionPointer, SIGNAL( triggered() ), this, SLOT( showOrHide() ) );
mQGisIface->addPluginToVectorMenu( tr( "&Coordinate Capture" ), mQActionPointer );
mQGisIface->addVectorToolBarIcon( mQActionPointer );

// create our map tool
mpMapTool = new CoordinateCaptureMapTool( mQGisIface->mapCanvas() );
Expand Down Expand Up @@ -155,16 +164,9 @@ void CoordinateCapture::initGui()
mypLayout->addWidget( mypCopyButton, 2, 1 );
mypLayout->addWidget( mpCaptureButton, 3, 1 );


//create the dock widget
mpDockWidget = new QDockWidget( tr( "Coordinate Capture" ), mQGisIface->mainWindow() );
mpDockWidget->setObjectName( "CoordinateCapture" );
mpDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
mQGisIface->addDockWidget( Qt::LeftDockWidgetArea, mpDockWidget );

// now add our custom widget to the dock - ownership of the widget is passed to the dock
mpDockWidget->setWidget( mypWidget );

connect( mpDockWidget, SIGNAL( visibilityChanged( bool ) ), mQActionPointer, SLOT( setChecked( bool ) ) );
}

//method defined in interface
Expand Down Expand Up @@ -243,12 +245,23 @@ void CoordinateCapture::run()
//myPluginGui->show();
}

void CoordinateCapture::showOrHide()
{
if ( !mpDockWidget )
run();
else
if ( mQActionPointer->isChecked() )
mpDockWidget->show();
else
mpDockWidget->hide();
}

// Unload the plugin by cleaning up the GUI
void CoordinateCapture::unload()
{
// remove the GUI
mQGisIface->removePluginMenu( "&Coordinate Capture", mQActionPointer );
//mQGisIface->removeToolBarIcon( mQActionPointer );
mQGisIface->removePluginVectorMenu( "&Coordinate Capture", mQActionPointer );
mQGisIface->removeVectorToolBarIcon( mQActionPointer );
mpMapTool->deactivate();
delete mpMapTool;
delete mpDockWidget;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/coordinate_capture/coordinatecapture.h
Expand Up @@ -90,6 +90,8 @@ class CoordinateCapture: public QObject, public QgisPlugin
void run();
//! unload the plugin
void unload();
//! Show/hide the dockwidget
void showOrHide();
//! show the help document
void help();
//! Set the Coordinate Reference System used for displaying non canvas CRS coord
Expand Down

0 comments on commit d51ea41

Please sign in to comment.