Skip to content

Commit

Permalink
Add export quality setting
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ committed Oct 22, 2024
1 parent 24e8ee6 commit 4345210
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Handles rendering and exports of layouts to various formats.




struct PageExportDetails
{
QString directory;
Expand Down
1 change: 1 addition & 0 deletions python/core/auto_generated/layout/qgslayoutexporter.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Handles rendering and exports of layouts to various formats.




struct PageExportDetails
{
QString directory;
Expand Down
5 changes: 5 additions & 0 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4375,6 +4375,7 @@ bool QgsLayoutDesignerDialog::getRasterExportSettings( QgsLayoutExporter::ImageE
imageDlg.setGenerateWorldFile( mLayout->customProperty( QStringLiteral( "exportWorldFile" ), false ).toBool() );
imageDlg.setAntialiasing( antialias );
imageDlg.setOpenAfterExporting( QgsLayoutExporter::settingOpenAfterExportingImage->value() );
imageDlg.setQuality( QgsLayoutExporter::settingImageQuality->value() );

if ( !imageDlg.exec() )
return false;
Expand Down Expand Up @@ -4410,6 +4411,10 @@ bool QgsLayoutDesignerDialog::getRasterExportSettings( QgsLayoutExporter::ImageE
settings.flags &= ~QgsLayoutRenderContext::FlagAntialiasing;

settings.quality = imageDlg.quality();
if ( settings.quality != -1 )
{
QgsLayoutExporter::settingImageQuality->setValue( imageDlg.quality() );
}

return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/core/layout/qgslayoutexporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class LayoutItemHider
const QgsSettingsEntryBool *QgsLayoutExporter::settingOpenAfterExportingImage = new QgsSettingsEntryBool( QStringLiteral( "open-after-exporting-image" ), QgsSettingsTree::sTreeLayout, false, QObject::tr( "Whether to open the exported image file with the default viewer after exporting a print layout" ) );
const QgsSettingsEntryBool *QgsLayoutExporter::settingOpenAfterExportingPdf = new QgsSettingsEntryBool( QStringLiteral( "open-after-exporting-pdf" ), QgsSettingsTree::sTreeLayout, false, QObject::tr( "Whether to open the exported PDF file with the default viewer after exporting a print layout" ) );
const QgsSettingsEntryBool *QgsLayoutExporter::settingOpenAfterExportingSvg = new QgsSettingsEntryBool( QStringLiteral( "open-after-exporting-svg" ), QgsSettingsTree::sTreeLayout, false, QObject::tr( "Whether to open the exported SVG file with the default viewer after exporting a print layout" ) );
const QgsSettingsEntryInteger *QgsLayoutExporter::settingImageQuality = new QgsSettingsEntryInteger( QStringLiteral( "image-quality" ), QgsSettingsTree::sTreeLayout, 90, QObject::tr( "Image quality for lossy formats (e.g. JPEG)" ) );

QgsLayoutExporter::QgsLayoutExporter( QgsLayout *layout )
: mLayout( layout )
Expand Down
4 changes: 4 additions & 0 deletions src/core/layout/qgslayoutexporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class QgsAbstractLayoutIterator;
class QgsFeedback;
class QgsLabelingResults;
class QgsSettingsEntryBool;
class QgsSettingsEntryInteger;

/**
* \ingroup core
Expand All @@ -61,6 +62,9 @@ class CORE_EXPORT QgsLayoutExporter
//! Settings entry - Whether to automatically open svgs after exporting them \since QGIS 3.34
static const QgsSettingsEntryBool *settingOpenAfterExportingSvg SIP_SKIP;

//! Settings entry - Image quality for lossy formats \since QGIS 3.42
static const QgsSettingsEntryInteger *settingImageQuality SIP_SKIP;

//! Contains details of a page being exported by the class
struct PageExportDetails
{
Expand Down

0 comments on commit 4345210

Please sign in to comment.