[cad] Listen out for CRS changes and enable if appropriate

Avoids having to manually switch on and off cad tools after changing
CRS from geographic->metres based
This commit is contained in:
Nyall Dawson 2017-04-19 10:31:34 +10:00
parent 3e2d60e712
commit 1962c54ee8

View File

@ -1210,6 +1210,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
void QgsAdvancedDigitizingDockWidget::enable()
{
connect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsAdvancedDigitizingDockWidget::enable, Qt::UniqueConnection );
if ( mMapCanvas->mapSettings().destinationCrs().isGeographic() )
{
mErrorLabel->setText( tr( "CAD tools can not be used on geographic coordinates. Change the coordinates system in the project properties." ) );
@ -1236,6 +1237,8 @@ void QgsAdvancedDigitizingDockWidget::enable()
void QgsAdvancedDigitizingDockWidget::disable()
{
disconnect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsAdvancedDigitizingDockWidget::enable );
mEnableAction->setEnabled( false );
mErrorLabel->setText( tr( "CAD tools are not enabled for the current map tool" ) );
mErrorLabel->show();