[layouts] Default svg export setting for label text as outlines/text to use project setting

This commit is contained in:
Nyall Dawson 2018-11-28 18:00:28 +10:00
parent a4509bd4b3
commit cd8b91bdfe

View File

@ -39,6 +39,7 @@
#include "qgslayoutitemmap.h"
#include "qgsprintlayout.h"
#include "qgsmapcanvas.h"
#include "qgsrendercontext.h"
#include "qgsmessagebar.h"
#include "qgsmessageviewer.h"
#include "qgsgui.h"
@ -3961,7 +3962,7 @@ bool QgsLayoutDesignerDialog::getRasterExportSettings( QgsLayoutExporter::ImageE
bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExportSettings &settings )
{
bool groupLayers = false;
bool prevSettingLabelsAsOutlines = false;
QgsRenderContext::TextRenderFormat prevTextRenderFormat = mMasterLayout->layoutProject()->labelingEngineSettings().defaultTextRenderFormat();
bool clipToContent = false;
double marginTop = 0.0;
double marginRight = 0.0;
@ -3985,14 +3986,19 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
bottomMargin = mLayout->customProperty( QStringLiteral( "svgCropMarginBottom" ), 0 ).toInt();
leftMargin = mLayout->customProperty( QStringLiteral( "svgCropMarginLeft" ), 0 ).toInt();
includeMetadata = mLayout->customProperty( QStringLiteral( "svgIncludeMetadata" ), 1 ).toBool();
prevSettingLabelsAsOutlines = mLayout->customProperty( QStringLiteral( "svgRenderTextAsOutlines" ), 1 ).toBool();
const int prevLayoutSettingLabelsAsOutlines = mLayout->customProperty( QStringLiteral( "svgTextFormat" ), -1 ).toInt();
if ( prevLayoutSettingLabelsAsOutlines >= 0 )
{
// previous layout setting takes default over project setting
prevTextRenderFormat = static_cast< QgsRenderContext::TextRenderFormat >( prevLayoutSettingLabelsAsOutlines );
}
}
// open options dialog
QDialog dialog;
Ui::QgsSvgExportOptionsDialog options;
options.setupUi( &dialog );
options.chkTextAsOutline->setChecked( prevSettingLabelsAsOutlines );
options.chkTextAsOutline->setChecked( prevTextRenderFormat == QgsRenderContext::TextFormatAlwaysOutlines );
options.chkMapLayersAsGroup->setChecked( layersAsGroup );
options.mClipToContentGroupBox->setChecked( cropToContents );
options.mForceVectorCheckBox->setChecked( previousForceVector );
@ -4024,7 +4030,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
mLayout->setCustomProperty( QStringLiteral( "svgCropMarginBottom" ), marginBottom );
mLayout->setCustomProperty( QStringLiteral( "svgCropMarginLeft" ), marginLeft );
mLayout->setCustomProperty( QStringLiteral( "svgIncludeMetadata" ), includeMetadata ? 1 : 0 );
mLayout->setCustomProperty( QStringLiteral( "svgRenderTextAsOutlines" ), textRenderFormat == QgsRenderContext::TextFormatAlwaysOutlines ? 1 : 0 );
mLayout->setCustomProperty( QStringLiteral( "svgTextFormat" ), static_cast< int >( textRenderFormat ) );
}
settings.cropToContents = clipToContent;