Skip to content

Commit

Permalink
Add settings key to anonymize new projects
Browse files Browse the repository at this point in the history
Defaults to false, but if set will not automatically set
metadata for newly created projects such as author
and creation date.
  • Loading branch information
nyalldawson committed Mar 22, 2018
1 parent 2eacc4c commit 37c5dd9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions resources/qgis_global_settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ connections-xyz\OpenStreetMap\username=
connections-xyz\OpenStreetMap\zmax=19
connections-xyz\OpenStreetMap\zmin=0

[core]
# Whether or not to anonymize newly created projects
# If set to 1, then project metadata items like AUTHOR and CREATION DATE
# will not be automatically populated when a new project is created.
projects\anonymize_new_projects=false


[colors]
# These colors are used in logs.
default=
Expand Down
10 changes: 7 additions & 3 deletions src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ void QgsProject::setTransformContext( const QgsCoordinateTransformContext &conte

void QgsProject::clear()
{
QgsSettings s;

mFile.setFileName( QString() );
mProperties.clearKeys();
mHomePath.clear();
Expand All @@ -510,8 +512,11 @@ void QgsProject::clear()
mTrustLayerMetadata = false;
mCustomVariables.clear();
mMetadata = QgsProjectMetadata();
mMetadata.setCreationDateTime( QDateTime::currentDateTime() );
mMetadata.setAuthor( QgsApplication::userFullName() );
if ( !s.value( QStringLiteral( "projects/anonymize_new_projects" ), false, QgsSettings::Core ).toBool() )
{
mMetadata.setCreationDateTime( QDateTime::currentDateTime() );
mMetadata.setAuthor( QgsApplication::userFullName() );
}
emit metadataChanged();

QgsCoordinateTransformContext context;
Expand Down Expand Up @@ -542,7 +547,6 @@ void QgsProject::clear()
writeEntry( QStringLiteral( "Paths" ), QStringLiteral( "/Absolute" ), false );

//copy default units to project
QgsSettings s;
writeEntry( QStringLiteral( "Measurement" ), QStringLiteral( "/DistanceUnits" ), s.value( QStringLiteral( "/qgis/measure/displayunits" ) ).toString() );
writeEntry( QStringLiteral( "Measurement" ), QStringLiteral( "/AreaUnits" ), s.value( QStringLiteral( "/qgis/measure/areaunits" ) ).toString() );

Expand Down

0 comments on commit 37c5dd9

Please sign in to comment.