Skip to content

Commit

Permalink
add mesh & raster backup crs
Browse files Browse the repository at this point in the history
  • Loading branch information
roya0045 authored and github-actions[bot] committed Dec 22, 2021
1 parent 38a2343 commit 0e5b1af
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/gui/mesh/qgsmeshlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ QgsMeshLayerProperties::QgsMeshLayerProperties( QgsMapLayer *lyr, QgsMapCanvas *
connect( lyr->styleManager(), &QgsMapLayerStyleManager::currentStyleChanged, this, &QgsMeshLayerProperties::syncAndRepaint );

connect( this, &QDialog::accepted, this, &QgsMeshLayerProperties::apply );
connect( this, &QDialog::rejected, this, &QgsMeshLayerProperties::onCancel );
connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsMeshLayerProperties::apply );

connect( mMeshLayer, &QgsMeshLayer::dataChanged, this, &QgsMeshLayerProperties::syncAndRepaint );
Expand All @@ -104,6 +105,7 @@ QgsMeshLayerProperties::QgsMeshLayerProperties( QgsMapLayer *lyr, QgsMapCanvas *
layout->addWidget( mMetadataWidget );
metadataFrame->setLayout( layout );
mOptsPage_Metadata->setContentsMargins( 0, 0, 0, 0 );
mBackupCrs = mMeshLayer->crs();

mTemporalDateTimeStart->setDisplayFormat( "yyyy-MM-dd HH:mm:ss" );
mTemporalDateTimeEnd->setDisplayFormat( "yyyy-MM-dd HH:mm:ss" );
Expand Down Expand Up @@ -394,6 +396,8 @@ void QgsMeshLayerProperties::apply()

mMetadataWidget->acceptMetadata();

mBackupCrs = mMeshLayer->crs();

if ( needMeshUpdating )
mMeshLayer->reload();

Expand Down Expand Up @@ -547,3 +551,9 @@ void QgsMeshLayerProperties::saveMetadataAs()
else
QMessageBox::information( this, tr( "Save Metadata" ), message );
}

void QgsMeshLayerProperties::onCancel()
{
if ( mBackupCrs != mMeshLayer->crs() )
mMeshLayer->setCrs( mBackupCrs );
}
4 changes: 4 additions & 0 deletions src/gui/mesh/qgsmeshlayerproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class GUI_EXPORT QgsMeshLayerProperties : public QgsOptionsDialogBase, private U
void aboutToShowStyleMenu();
//! Reloads temporal properties from the provider
void reloadTemporalProperties();
//! \brief Called when cancel button is pressed
void onCancel();

void onTimeReferenceChange();

Expand Down Expand Up @@ -122,6 +124,8 @@ class GUI_EXPORT QgsMeshLayerProperties : public QgsOptionsDialogBase, private U
friend class TestQgsMeshLayerPropertiesDialog;

void showHelp();

QgsCoordinateReferenceSystem mBackupCrs;
};


Expand Down
5 changes: 5 additions & 0 deletions src/gui/raster/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
return;
}

mBackupCrs = mRasterLayer->crs();

// Handles window modality raising canvas
if ( mMapCanvas && mRasterTransparencyWidget->pixelSelectorTool() )
{
Expand Down Expand Up @@ -880,6 +882,7 @@ void QgsRasterLayerProperties::apply()
mRasterLayer->setRenderer( rendererWidget->renderer() );
}

mBackupCrs = mRasterLayer->crs();
mMetadataWidget->acceptMetadata();
mMetadataFilled = false;

Expand Down Expand Up @@ -1795,6 +1798,8 @@ void QgsRasterLayerProperties::onCancel()
mRasterLayer->importNamedStyle( doc, myMessage );
syncToLayer();
}
if ( mBackupCrs != mRasterLayer->crs() )
mRasterLayer->setCrs( mBackupCrs );
}

void QgsRasterLayerProperties::showHelp()
Expand Down
2 changes: 2 additions & 0 deletions src/gui/raster/qgsrasterlayerproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,7 @@ class GUI_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
QgsExpressionContext mContext;

friend class QgsAppScreenShots;

QgsCoordinateReferenceSystem mBackupCrs;
};
#endif

0 comments on commit 0e5b1af

Please sign in to comment.