18#include "moc_qgslayoutpdfexportoptionsdialog.cpp"
34 : QDialog( parent, flags )
38 mGeospatialPdfStructureTreeMenu =
new QMenu(
this );
45 mGeospatialPDFGroupBox->setEnabled( mGeospatialPdfAvailable );
46 mGeospatialPDFGroupBox->setChecked(
false );
47 if ( !mGeospatialPdfAvailable )
49 mGeospatialPDFOptionsStackedWidget->setCurrentIndex( 0 );
52 QPalette p = mGeospatialPdfUnavailableReason->palette();
53 p.setColor( QPalette::Disabled, QPalette::WindowText, QPalette::WindowText );
54 mGeospatialPdfUnavailableReason->setPalette( p );
55 mGeospatialPDFOptionsStackedWidget->removeWidget( mGeospatialPDFOptionsStackedWidget->widget( 1 ) );
59 mGeospatialPDFOptionsStackedWidget->setCurrentIndex( 1 );
62 mComboImageCompression->addItem( tr(
"Lossy (JPEG)" ), false );
63 mComboImageCompression->addItem( tr(
"Lossless" ), true );
66 for (
const QString &theme : themes )
68 QListWidgetItem *item =
new QListWidgetItem( theme );
69 item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
70 item->setCheckState( Qt::Unchecked );
71 mThemesList->addItem( item );
77 for (
int i = 0; i < order.size(); ++i )
79 if ( order.at( i )->id() == *it )
87 mGeospatialPdfStructureProxyModel =
new QgsGeospatialPdfLayerFilteredTreeModel( mGeospatialPdfStructureModel,
this );
88 mGeospatialPdfStructureTree->setModel( mGeospatialPdfStructureProxyModel );
89 mGeospatialPdfStructureTree->resizeColumnToContents( 0 );
90 mGeospatialPdfStructureTree->header()->show();
91 mGeospatialPdfStructureTree->setSelectionMode( QAbstractItemView::SingleSelection );
92 mGeospatialPdfStructureTree->setSelectionBehavior( QAbstractItemView::SelectRows );
94 mGeospatialPdfStructureTree->setDragEnabled(
true );
95 mGeospatialPdfStructureTree->setAcceptDrops(
true );
96 mGeospatialPdfStructureTree->setDragDropMode( QAbstractItemView::InternalMove );
97 mGeospatialPdfStructureTree->setDefaultDropAction( Qt::MoveAction );
99 mGeospatialPdfStructureTree->setContextMenuPolicy( Qt::CustomContextMenu );
100 connect( mGeospatialPdfStructureTree, &QTreeView::customContextMenuRequested,
this, [=](
const QPoint &point ) {
101 const QModelIndex index = mGeospatialPdfStructureTree->indexAt( point );
102 if ( index.isValid() )
103 showContextMenuForGeospatialPdfStructure( point, mGeospatialPdfStructureProxyModel->mapToSource( index ) );
106 connect( mHelpButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutPdfExportOptionsDialog::showHelp );
112 mTextRenderFormatComboBox->setCurrentIndex( mTextRenderFormatComboBox->findData(
static_cast<int>( format ) ) );
122 mForceVectorCheckBox->setChecked( force );
127 return mForceVectorCheckBox->isChecked();
132 mAppendGeoreferenceCheckbox->setEnabled( enabled );
137 mAppendGeoreferenceCheckbox->setChecked( enabled );
142 return mAppendGeoreferenceCheckbox->isChecked();
147 mIncludeMetadataCheckbox->setChecked( enabled );
152 return mIncludeMetadataCheckbox->isChecked();
157 mDisableRasterTilingCheckBox->setChecked( disabled );
162 return mDisableRasterTilingCheckBox->isChecked();
167 mSimplifyGeometriesCheckbox->setChecked( enabled );
172 return mSimplifyGeometriesCheckbox->isChecked();
177 mComboImageCompression->setCurrentIndex( mComboImageCompression->findData( enabled ) );
182 return mComboImageCompression->currentData().toBool();
187 if ( !mGeospatialPdfAvailable )
190 mGeospatialPDFGroupBox->setChecked( enabled );
195 if ( !mGeospatialPdfAvailable )
198 return mGeospatialPDFGroupBox->isChecked();
203 if ( !mGeospatialPdfAvailable )
206 mIncludeMapThemesCheck->setChecked( !themes.isEmpty() );
207 for (
int i = 0; i < mThemesList->count(); ++i )
209 QListWidgetItem *item = mThemesList->item( i );
210 item->setCheckState( themes.contains( item->text() ) ? Qt::Checked : Qt::Unchecked );
217 if ( !mGeospatialPdfAvailable )
220 if ( !mIncludeMapThemesCheck || !mIncludeMapThemesCheck->isChecked() )
223 res.reserve( mThemesList->count() );
224 for (
int i = 0; i < mThemesList->count(); ++i )
226 QListWidgetItem *item = mThemesList->item( i );
227 if ( item->checkState() == Qt::Checked )
236 for (
int row = 0; row < mGeospatialPdfStructureProxyModel->rowCount(); ++row )
248 QStringList groupOrder;
249 for (
int row = 0; row < mGeospatialPdfStructureProxyModel->rowCount(); ++row )
252 if ( !group.isEmpty() && !groupOrder.contains( group ) )
260 mOpenAfterExportingCheckBox->setChecked( enabled );
265 return mOpenAfterExportingCheckBox->isChecked();
268void QgsLayoutPdfExportOptionsDialog::showHelp()
273void QgsLayoutPdfExportOptionsDialog::showContextMenuForGeospatialPdfStructure( QPoint point,
const QModelIndex &index )
275 mGeospatialPdfStructureTreeMenu->clear();
277 switch ( index.column() )
282 QAction *selectAll =
new QAction( tr(
"Select All" ), mGeospatialPdfStructureTreeMenu );
283 mGeospatialPdfStructureTreeMenu->addAction( selectAll );
284 connect( selectAll, &QAction::triggered,
this, [=] {
285 mGeospatialPdfStructureModel->
checkAll(
true, QModelIndex(), index.column() );
287 QAction *deselectAll =
new QAction( tr(
"Deselect All" ), mGeospatialPdfStructureTreeMenu );
288 mGeospatialPdfStructureTreeMenu->addAction( deselectAll );
289 connect( deselectAll, &QAction::triggered,
this, [=] {
290 mGeospatialPdfStructureModel->
checkAll(
false, QModelIndex(), index.column() );
299 if ( !mGeospatialPdfStructureTreeMenu->actions().empty() )
301 mGeospatialPdfStructureTreeMenu->exec( mGeospatialPdfStructureTree->mapToGlobal( point ) );
TextRenderFormat
Options for rendering text.
@ PreferText
Render text as text objects, unless doing so results in rendering artifacts or poor quality rendering...
@ AlwaysOutlines
Always render text using path objects (AKA outlines/curves). This setting guarantees the best quality...
@ AlwaysText
Always render text as text objects. While this mode preserves text objects as text for post-processin...
static QString geospatialPDFAvailabilityExplanation()
Returns a user-friendly, translated string explaining why Geospatial PDF export support is not availa...
static bool geospatialPDFCreationAvailable()
Returns true if the current QGIS build is capable of Geospatial PDF support.
Layer tree model for Geo-PDF layers.
@ InitiallyVisible
Initial visibility state.
@ IncludeVectorAttributes
Vector attribute.
void checkAll(bool checked, const QModelIndex &parent=QModelIndex(), int column=IncludeVectorAttributes)
Checks (or unchecks) all rows and children from the specified parent index.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
QList< QgsMapLayer * > layerOrder() const
The order in which layers will be rendered on the canvas.
void setExportGeospatialPdf(bool enabled)
Sets whether to export a Geospatial PDF.
void setOpenAfterExporting(bool enabled)
Sets whether to open the pdf after exporting it.
QStringList exportThemes() const
Returns the list of export themes.
bool geometriesSimplified() const
Returns whether geometry simplification is enabled.
bool losslessImageExport() const
Returns whether lossless image compression is enabled.
void setLosslessImageExport(bool enabled)
Sets whether to use lossless image compression.
bool exportGeospatialPdf() const
Returns whether Geospatial PDF export is enabled.
bool openAfterExporting() const
Returns whether the pdf should be opened after exporting it.
bool georeferencingEnabled() const
Returns whether georeferencing is enabled.
void setRasterTilingDisabled(bool disabled)
Sets whether to disable raster tiling.
bool forceVector() const
Returns whether vector output is being forced.
void setGeometriesSimplified(bool enabled)
Sets whether to simplify geometries.
bool metadataEnabled() const
Returns whether metadata is enabled.
void setGeoreferencingEnabled(bool enabled)
Sets whether to enable georeferencing.
void setMetadataEnabled(bool enabled)
Sets whether to enable metadata.
void enableGeoreferencingOptions(bool enabled)
Sets whether to enable georeferencing options.
QStringList geospatialPdfGroupOrder() const
Returns a list of groups in the desired order they should appear in a generated Geospatial PDF file.
QgsLayoutPdfExportOptionsDialog(QWidget *parent=nullptr, bool allowGeospatialPdfExport=true, const QString &geospatialPdfReason=QString(), const QStringList &geospatialPdfLayerOrder=QStringList(), Qt::WindowFlags flags=Qt::WindowFlags())
Constructor for QgsLayoutPdfExportOptionsDialog.
QStringList geospatialPdfLayerOrder() const
Returns a list of map layer IDs in the desired order they should appear in a generated Geospatial PDF...
void setTextRenderFormat(Qgis::TextRenderFormat format)
Sets the text render format.
Qgis::TextRenderFormat textRenderFormat() const
Returns the current text render format.
bool rasterTilingDisabled() const
Returns whether raster tiling is disabled.
void setForceVector(bool force)
Set whether to force vector output.
void setExportThemes(const QStringList &themes)
Sets the list of export themes.
@ LayerId
Stores the map layer ID.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapThemeCollection * mapThemeCollection
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.