Skip to content

Commit

Permalink
[layouts] Fix memory of "force vector" export setting
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 11, 2018
1 parent 7f5441c commit cf47316
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3969,7 +3969,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
double marginRight = 0.0; double marginRight = 0.0;
double marginBottom = 0.0; double marginBottom = 0.0;
double marginLeft = 0.0; double marginLeft = 0.0;
bool previousForceVector = false; bool forceVector = false;
bool layersAsGroup = false; bool layersAsGroup = false;
bool cropToContents = false; bool cropToContents = false;
double topMargin = 0.0; double topMargin = 0.0;
Expand All @@ -3979,7 +3979,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
bool includeMetadata = true; bool includeMetadata = true;
if ( mLayout ) if ( mLayout )
{ {
mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool(); forceVector = mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool();
layersAsGroup = mLayout->customProperty( QStringLiteral( "svgGroupLayers" ), false ).toBool(); layersAsGroup = mLayout->customProperty( QStringLiteral( "svgGroupLayers" ), false ).toBool();
cropToContents = mLayout->customProperty( QStringLiteral( "svgCropToContents" ), false ).toBool(); cropToContents = mLayout->customProperty( QStringLiteral( "svgCropToContents" ), false ).toBool();
topMargin = mLayout->customProperty( QStringLiteral( "svgCropMarginTop" ), 0 ).toInt(); topMargin = mLayout->customProperty( QStringLiteral( "svgCropMarginTop" ), 0 ).toInt();
Expand All @@ -4006,7 +4006,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
options.mTextRenderFormatComboBox->setCurrentIndex( options.mTextRenderFormatComboBox->findData( prevTextRenderFormat ) ); options.mTextRenderFormatComboBox->setCurrentIndex( options.mTextRenderFormatComboBox->findData( prevTextRenderFormat ) );
options.chkMapLayersAsGroup->setChecked( layersAsGroup ); options.chkMapLayersAsGroup->setChecked( layersAsGroup );
options.mClipToContentGroupBox->setChecked( cropToContents ); options.mClipToContentGroupBox->setChecked( cropToContents );
options.mForceVectorCheckBox->setChecked( previousForceVector ); options.mForceVectorCheckBox->setChecked( forceVector );
options.mTopMarginSpinBox->setValue( topMargin ); options.mTopMarginSpinBox->setValue( topMargin );
options.mRightMarginSpinBox->setValue( rightMargin ); options.mRightMarginSpinBox->setValue( rightMargin );
options.mBottomMarginSpinBox->setValue( bottomMargin ); options.mBottomMarginSpinBox->setValue( bottomMargin );
Expand All @@ -4023,6 +4023,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
marginBottom = options.mBottomMarginSpinBox->value(); marginBottom = options.mBottomMarginSpinBox->value();
marginLeft = options.mLeftMarginSpinBox->value(); marginLeft = options.mLeftMarginSpinBox->value();
includeMetadata = options.mIncludeMetadataCheckbox->isChecked(); includeMetadata = options.mIncludeMetadataCheckbox->isChecked();
forceVector = options.mForceVectorCheckBox->isChecked();
QgsRenderContext::TextRenderFormat textRenderFormat = static_cast< QgsRenderContext::TextRenderFormat >( options.mTextRenderFormatComboBox->currentData().toInt() ); QgsRenderContext::TextRenderFormat textRenderFormat = static_cast< QgsRenderContext::TextRenderFormat >( options.mTextRenderFormatComboBox->currentData().toInt() );


if ( mLayout ) if ( mLayout )
Expand All @@ -4035,12 +4036,13 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
mLayout->setCustomProperty( QStringLiteral( "svgCropMarginBottom" ), marginBottom ); mLayout->setCustomProperty( QStringLiteral( "svgCropMarginBottom" ), marginBottom );
mLayout->setCustomProperty( QStringLiteral( "svgCropMarginLeft" ), marginLeft ); mLayout->setCustomProperty( QStringLiteral( "svgCropMarginLeft" ), marginLeft );
mLayout->setCustomProperty( QStringLiteral( "svgIncludeMetadata" ), includeMetadata ? 1 : 0 ); mLayout->setCustomProperty( QStringLiteral( "svgIncludeMetadata" ), includeMetadata ? 1 : 0 );
mLayout->setCustomProperty( QStringLiteral( "forceVector" ), forceVector ? 1 : 0 );
mLayout->setCustomProperty( QStringLiteral( "svgTextFormat" ), static_cast< int >( textRenderFormat ) ); mLayout->setCustomProperty( QStringLiteral( "svgTextFormat" ), static_cast< int >( textRenderFormat ) );
} }


settings.cropToContents = clipToContent; settings.cropToContents = clipToContent;
settings.cropMargins = QgsMargins( marginLeft, marginTop, marginRight, marginBottom ); settings.cropMargins = QgsMargins( marginLeft, marginTop, marginRight, marginBottom );
settings.forceVectorOutput = options.mForceVectorCheckBox->isChecked(); settings.forceVectorOutput = forceVector;
settings.exportAsLayers = groupLayers; settings.exportAsLayers = groupLayers;
settings.exportMetadata = includeMetadata; settings.exportMetadata = includeMetadata;
settings.textRenderFormat = textRenderFormat; settings.textRenderFormat = textRenderFormat;
Expand All @@ -4051,11 +4053,11 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport
bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExportSettings &settings ) bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExportSettings &settings )
{ {
QgsRenderContext::TextRenderFormat prevTextRenderFormat = mMasterLayout->layoutProject()->labelingEngineSettings().defaultTextRenderFormat(); QgsRenderContext::TextRenderFormat prevTextRenderFormat = mMasterLayout->layoutProject()->labelingEngineSettings().defaultTextRenderFormat();
bool previousForceVector = false; bool forceVector = false;
bool includeMetadata = true; bool includeMetadata = true;
if ( mLayout ) if ( mLayout )
{ {
mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool(); forceVector = mLayout->customProperty( QStringLiteral( "forceVector" ), 0 ).toBool();
includeMetadata = mLayout->customProperty( QStringLiteral( "pdfIncludeMetadata" ), 1 ).toBool(); includeMetadata = mLayout->customProperty( QStringLiteral( "pdfIncludeMetadata" ), 1 ).toBool();
const int prevLayoutSettingLabelsAsOutlines = mLayout->customProperty( QStringLiteral( "pdfTextFormat" ), -1 ).toInt(); const int prevLayoutSettingLabelsAsOutlines = mLayout->customProperty( QStringLiteral( "pdfTextFormat" ), -1 ).toInt();
if ( prevLayoutSettingLabelsAsOutlines >= 0 ) if ( prevLayoutSettingLabelsAsOutlines >= 0 )
Expand All @@ -4074,23 +4076,25 @@ bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExport
options.mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Text Objects" ), QgsRenderContext::TextFormatAlwaysText ); options.mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Text Objects" ), QgsRenderContext::TextFormatAlwaysText );


options.mTextRenderFormatComboBox->setCurrentIndex( options.mTextRenderFormatComboBox->findData( prevTextRenderFormat ) ); options.mTextRenderFormatComboBox->setCurrentIndex( options.mTextRenderFormatComboBox->findData( prevTextRenderFormat ) );
options.mForceVectorCheckBox->setChecked( previousForceVector ); options.mForceVectorCheckBox->setChecked( forceVector );
options.mIncludeMetadataCheckbox->setChecked( includeMetadata ); options.mIncludeMetadataCheckbox->setChecked( includeMetadata );


if ( dialog.exec() != QDialog::Accepted ) if ( dialog.exec() != QDialog::Accepted )
return false; return false;


includeMetadata = options.mIncludeMetadataCheckbox->isChecked(); includeMetadata = options.mIncludeMetadataCheckbox->isChecked();
forceVector = options.mForceVectorCheckBox->isChecked();
QgsRenderContext::TextRenderFormat textRenderFormat = static_cast< QgsRenderContext::TextRenderFormat >( options.mTextRenderFormatComboBox->currentData().toInt() ); QgsRenderContext::TextRenderFormat textRenderFormat = static_cast< QgsRenderContext::TextRenderFormat >( options.mTextRenderFormatComboBox->currentData().toInt() );


if ( mLayout ) if ( mLayout )
{ {
//save dialog settings //save dialog settings
mLayout->setCustomProperty( QStringLiteral( "forceVector" ), forceVector ? 1 : 0 );
mLayout->setCustomProperty( QStringLiteral( "pdfIncludeMetadata" ), includeMetadata ? 1 : 0 ); mLayout->setCustomProperty( QStringLiteral( "pdfIncludeMetadata" ), includeMetadata ? 1 : 0 );
mLayout->setCustomProperty( QStringLiteral( "pdfTextFormat" ), static_cast< int >( textRenderFormat ) ); mLayout->setCustomProperty( QStringLiteral( "pdfTextFormat" ), static_cast< int >( textRenderFormat ) );
} }


settings.forceVectorOutput = options.mForceVectorCheckBox->isChecked(); settings.forceVectorOutput = forceVector;
settings.exportMetadata = includeMetadata; settings.exportMetadata = includeMetadata;
settings.textRenderFormat = textRenderFormat; settings.textRenderFormat = textRenderFormat;


Expand Down

0 comments on commit cf47316

Please sign in to comment.