Skip to content

Commit

Permalink
Address review comments, don't store username if anonymize_saved_proj…
Browse files Browse the repository at this point in the history
…ects is true
  • Loading branch information
nyalldawson committed Jan 21, 2020
1 parent 8f1a5f7 commit b14997d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 4 additions & 0 deletions resources/qgis_global_settings.ini
Expand Up @@ -111,6 +111,10 @@ gps\stop_bits=OneStop
# will not be automatically populated when a new project is created. # will not be automatically populated when a new project is created.
projects\anonymize_new_projects=false projects\anonymize_new_projects=false


# Whether or not to anonymize projects when saving
# If set to 1, then username information will not be stored in saved projects
projects\anonymize_saved_projects=false

# News feed settings # News feed settings
# Set to true to disable the QGIS news feed on the welcome page # Set to true to disable the QGIS news feed on the welcome page
NewsFeed\http00008000\disabled=false NewsFeed\http00008000\disabled=false
Expand Down
21 changes: 13 additions & 8 deletions src/core/qgsproject.cpp
Expand Up @@ -912,7 +912,7 @@ static void _getTitle( const QDomDocument &doc, QString &title )


} }


static void getProjectMetadata( const QDomDocument &doc, QString &lastUser, QString &lastUserFull ) static void readProjectFileMetadata( const QDomDocument &doc, QString &lastUser, QString &lastUserFull )
{ {
QDomNodeList nl = doc.elementsByTagName( QStringLiteral( "qgis" ) ); QDomNodeList nl = doc.elementsByTagName( QStringLiteral( "qgis" ) );


Expand All @@ -925,8 +925,8 @@ static void getProjectMetadata( const QDomDocument &doc, QString &lastUser, QStr
QDomNode qgisNode = nl.item( 0 ); // there should only be one, so zeroth element OK QDomNode qgisNode = nl.item( 0 ); // there should only be one, so zeroth element OK


QDomElement qgisElement = qgisNode.toElement(); // qgis node should be element QDomElement qgisElement = qgisNode.toElement(); // qgis node should be element
lastUser = qgisElement.attribute( QStringLiteral( "save-user" ), QString() ); lastUser = qgisElement.attribute( QStringLiteral( "saveUser" ), QString() );
lastUserFull = qgisElement.attribute( QStringLiteral( "save-user-full" ), QString() ); lastUserFull = qgisElement.attribute( QStringLiteral( "saveUserFull" ), QString() );
} }




Expand Down Expand Up @@ -1265,7 +1265,7 @@ bool QgsProject::readProjectFile( const QString &filename, QgsProject::ReadFlags
QString oldTitle; QString oldTitle;
_getTitle( *doc, oldTitle ); _getTitle( *doc, oldTitle );


getProjectMetadata( *doc, mSaveUser, mSaveUserFull ); readProjectFileMetadata( *doc, mSaveUser, mSaveUserFull );


QDomNodeList homePathNl = doc->elementsByTagName( QStringLiteral( "homePath" ) ); QDomNodeList homePathNl = doc->elementsByTagName( QStringLiteral( "homePath" ) );
if ( homePathNl.count() > 0 ) if ( homePathNl.count() > 0 )
Expand Down Expand Up @@ -1986,10 +1986,15 @@ bool QgsProject::writeProjectFile( const QString &filename )
QDomElement qgisNode = doc->createElement( QStringLiteral( "qgis" ) ); QDomElement qgisNode = doc->createElement( QStringLiteral( "qgis" ) );
qgisNode.setAttribute( QStringLiteral( "projectname" ), title() ); qgisNode.setAttribute( QStringLiteral( "projectname" ), title() );
qgisNode.setAttribute( QStringLiteral( "version" ), QStringLiteral( "%1" ).arg( Qgis::version() ) ); qgisNode.setAttribute( QStringLiteral( "version" ), QStringLiteral( "%1" ).arg( Qgis::version() ) );
QString newSaveUser = QgsApplication::userLoginName();
QString newSaveUserFull = QgsApplication::userFullName(); QgsSettings settings;
qgisNode.setAttribute( QStringLiteral( "save-user" ), newSaveUser ); if ( !settings.value( QStringLiteral( "projects/anonymize_saved_projects" ), false, QgsSettings::Core ).toBool() )
qgisNode.setAttribute( QStringLiteral( "save-user-full" ), newSaveUserFull ); {
QString newSaveUser = QgsApplication::userLoginName();
QString newSaveUserFull = QgsApplication::userFullName();
qgisNode.setAttribute( QStringLiteral( "saveUser" ), newSaveUser );
qgisNode.setAttribute( QStringLiteral( "saveUserFull" ), newSaveUserFull );
}
doc->appendChild( qgisNode ); doc->appendChild( qgisNode );


QDomElement homePathNode = doc->createElement( QStringLiteral( "homePath" ) ); QDomElement homePathNode = doc->createElement( QStringLiteral( "homePath" ) );
Expand Down

0 comments on commit b14997d

Please sign in to comment.