From 143fd16d0cd5db097bfdbebdc079f16aa32fc8df Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 18 Dec 2021 16:37:16 -0500 Subject: [PATCH] remember and revert crs change --- src/gui/vector/qgsvectorlayerproperties.cpp | 9 +++++++-- src/gui/vector/qgsvectorlayerproperties.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/vector/qgsvectorlayerproperties.cpp b/src/gui/vector/qgsvectorlayerproperties.cpp index ce699f29b06f..50d4336e24a8 100644 --- a/src/gui/vector/qgsvectorlayerproperties.cpp +++ b/src/gui/vector/qgsvectorlayerproperties.cpp @@ -300,6 +300,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties( } } + mCrsSelector->setCrs( mLayer->crs() ); //insert existing join info @@ -557,7 +558,7 @@ void QgsVectorLayerProperties::syncToLayer() // populate the general information mLayerOrigNameLineEdit->setText( mLayer->name() ); - + mBackupCrs = mLayer->crs(); //see if we are dealing with a pg layer here mSubsetGroupBox->setEnabled( true ); txtSubsetSQL->setText( mLayer->subsetString() ); @@ -691,7 +692,7 @@ void QgsVectorLayerProperties::apply() { labelingDialog->writeSettingsToLayer(); } - + mBackupCrs = mLayer->crs(); // apply legend settings mLegendWidget->applyToLayer(); mLegendConfigEmbeddedWidget->applyToLayer(); @@ -917,6 +918,9 @@ void QgsVectorLayerProperties::onCancel() doc.setContent( mOldStyle.xmlData(), false, &myMessage, &errorLine, &errorColumn ); mLayer->importNamedStyle( doc, myMessage ); } + + if ( mBackupCrs != mLayer->crs() ) + mLayer->setCrs( mBackupCrs ); } void QgsVectorLayerProperties::urlClicked( const QUrl &url ) @@ -979,6 +983,7 @@ QString QgsVectorLayerProperties::htmlMetadata() void QgsVectorLayerProperties::mCrsSelector_crsChanged( const QgsCoordinateReferenceSystem &crs ) { + QgsDatumTransformDialog::run( crs, QgsProject::instance()->crs(), this, mCanvas, tr( "Select Transformation for the vector layer" ) ); mLayer->setCrs( crs ); mMetadataFilled = false; diff --git a/src/gui/vector/qgsvectorlayerproperties.h b/src/gui/vector/qgsvectorlayerproperties.h index 44b68affdcec..d387710b1501 100644 --- a/src/gui/vector/qgsvectorlayerproperties.h +++ b/src/gui/vector/qgsvectorlayerproperties.h @@ -251,6 +251,8 @@ class GUI_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private QgsVectorLayerTemporalPropertiesWidget *mTemporalWidget = nullptr; QgsProviderSourceWidget *mSourceWidget = nullptr; + + QgsCoordinateReferenceSystem mBackupCrs; private slots: void openPanel( QgsPanelWidget *panel );