[copyright decorator] improve default label string

- Instead of using (c) QGIS YYYY, rely on the project metadata
to insert the author name. It's a more useful default string,
and might help avoid a misconception about ownership of maps
produced in QGIS.
This commit is contained in:
Mathieu Pellerin 2018-03-26 16:33:30 +07:00 committed by GitHub
parent 2b8519c017
commit 3f153e91b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -59,14 +59,11 @@ void QgsDecorationCopyright::projectRead()
{
QgsDecorationItem::projectRead();
QDate now = QDate::currentDate();
QString defString = "© QGIS " + now.toString( QStringLiteral( "yyyy" ) );
// there is no font setting in the UI, so just use the Qt/QGIS default font (what mQFont gets when created)
// mQFont.setFamily( QgsProject::instance()->readEntry( "CopyrightLabel", "/FontName", "Sans Serif" ) );
// mQFont.setPointSize( QgsProject::instance()->readNumEntry( "CopyrightLabel", "/FontSize", 9 ) );
mLabelText = QgsProject::instance()->readEntry( mNameConfig, QStringLiteral( "/Label" ), defString );
mLabelText = QgsProject::instance()->readEntry( mNameConfig, QStringLiteral( "/Label" ), QString() );
mMarginHorizontal = QgsProject::instance()->readNumEntry( mNameConfig, QStringLiteral( "/MarginH" ), 0 );
mMarginVertical = QgsProject::instance()->readNumEntry( mNameConfig, QStringLiteral( "/MarginV" ), 0 );
mColor = QgsSymbolLayerUtils::decodeColor( QgsProject::instance()->readEntry( mNameConfig, QStringLiteral( "/Color" ), QStringLiteral( "#000000" ) ) );

View File

@ -46,8 +46,19 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig
connect( applyButton, &QAbstractButton::clicked, this, &QgsDecorationCopyrightDialog::apply );
grpEnable->setChecked( mDeco.enabled() );
// text
txtCopyrightText->setPlainText( mDeco.mLabelText );
// label text
if ( !mDeco.enabled() && mDeco.mLabelText.isEmpty() )
{
QDate now = QDate::currentDate();
QString defaultString = QString( "%1 %2 %3" ).arg( QChar( 0x00A9 ), QgsProject::instance()->metadata().author(), now.toString( QStringLiteral( "yyyy" ) ) );
txtCopyrightText->setPlainText( defaultString );
}
else
{
txtCopyrightText->setPlainText( mDeco.mLabelText );
}
// placement
cboPlacement->addItem( tr( "Top left" ), QgsDecorationItem::TopLeft );
cboPlacement->addItem( tr( "Top right" ), QgsDecorationItem::TopRight );