34#include "moc_qgslayoutpdfexportoptionsdialog.cpp"
36using namespace Qt::StringLiterals;
39 QWidget *parent,
bool allowGeospatialPdfExport,
const QString &geospatialPdfReason,
const QStringList &
geospatialPdfLayerOrder, Qt::WindowFlags flags
41 : QDialog( parent, flags )
45 mGeospatialPdfStructureTreeMenu =
new QMenu(
this );
52 mGeospatialPDFGroupBox->setEnabled( mGeospatialPdfAvailable );
53 mGeospatialPDFGroupBox->setChecked(
false );
54 if ( !mGeospatialPdfAvailable )
56 mGeospatialPDFOptionsStackedWidget->setCurrentIndex( 0 );
59 QPalette p = mGeospatialPdfUnavailableReason->palette();
60 p.setColor( QPalette::Disabled, QPalette::WindowText, QPalette::WindowText );
61 mGeospatialPdfUnavailableReason->setPalette( p );
62 mGeospatialPDFOptionsStackedWidget->removeWidget( mGeospatialPDFOptionsStackedWidget->widget( 1 ) );
66 mGeospatialPDFOptionsStackedWidget->setCurrentIndex( 1 );
69 mComboImageCompression->addItem( tr(
"Lossy (JPEG)" ),
false );
70 mComboImageCompression->addItem( tr(
"Lossless" ),
true );
73 for (
const QString &theme : themes )
75 QListWidgetItem *item =
new QListWidgetItem( theme );
76 item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
77 item->setCheckState( Qt::Unchecked );
78 mThemesList->addItem( item );
84 for (
int i = 0; i < order.size(); ++i )
86 if ( order.at( i )->id() == *it )
94 mGeospatialPdfStructureProxyModel =
new QgsGeospatialPdfLayerFilteredTreeModel( mGeospatialPdfStructureModel,
this );
95 mGeospatialPdfStructureTree->setModel( mGeospatialPdfStructureProxyModel );
96 mGeospatialPdfStructureTree->resizeColumnToContents( 0 );
97 mGeospatialPdfStructureTree->header()->show();
98 mGeospatialPdfStructureTree->setSelectionMode( QAbstractItemView::SingleSelection );
99 mGeospatialPdfStructureTree->setSelectionBehavior( QAbstractItemView::SelectRows );
101 mGeospatialPdfStructureTree->setDragEnabled(
true );
102 mGeospatialPdfStructureTree->setAcceptDrops(
true );
103 mGeospatialPdfStructureTree->setDragDropMode( QAbstractItemView::InternalMove );
104 mGeospatialPdfStructureTree->setDefaultDropAction( Qt::MoveAction );
106 mGeospatialPdfStructureTree->setContextMenuPolicy( Qt::CustomContextMenu );
107 connect( mGeospatialPdfStructureTree, &QTreeView::customContextMenuRequested,
this, [
this](
const QPoint &point ) {
108 const QModelIndex index = mGeospatialPdfStructureTree->indexAt( point );
109 if ( index.isValid() )
110 showContextMenuForGeospatialPdfStructure( point, mGeospatialPdfStructureProxyModel->mapToSource( index ) );
113 connect( mHelpButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutPdfExportOptionsDialog::showHelp );
119 mTextRenderFormatComboBox->setCurrentIndex( mTextRenderFormatComboBox->findData(
static_cast<int>( format ) ) );
129 mForceVectorCheckBox->setChecked( force );
134 return mForceVectorCheckBox->isChecked();
139 mAppendGeoreferenceCheckbox->setEnabled( enabled );
144 mAppendGeoreferenceCheckbox->setChecked( enabled );
149 return mAppendGeoreferenceCheckbox->isChecked();
154 mIncludeMetadataCheckbox->setChecked( enabled );
159 return mIncludeMetadataCheckbox->isChecked();
164 mDisableRasterTilingCheckBox->setChecked( disabled );
169 return mDisableRasterTilingCheckBox->isChecked();
174 mSimplifyGeometriesCheckbox->setChecked( enabled );
179 return mSimplifyGeometriesCheckbox->isChecked();
184 mComboImageCompression->setCurrentIndex( mComboImageCompression->findData( enabled ) );
189 return mComboImageCompression->currentData().toBool();
194 if ( !mGeospatialPdfAvailable )
197 mGeospatialPDFGroupBox->setChecked( enabled );
202 if ( !mGeospatialPdfAvailable )
205 return mGeospatialPDFGroupBox->isChecked();
210 if ( !mGeospatialPdfAvailable )
213 mIncludeMapThemesCheck->setChecked( !themes.isEmpty() );
214 for (
int i = 0; i < mThemesList->count(); ++i )
216 QListWidgetItem *item = mThemesList->item( i );
217 item->setCheckState( themes.contains( item->text() ) ? Qt::Checked : Qt::Unchecked );
224 if ( !mGeospatialPdfAvailable )
227 if ( !mIncludeMapThemesCheck || !mIncludeMapThemesCheck->isChecked() )
230 res.reserve( mThemesList->count() );
231 for (
int i = 0; i < mThemesList->count(); ++i )
233 QListWidgetItem *item = mThemesList->item( i );
234 if ( item->checkState() == Qt::Checked )
243 for (
int row = 0; row < mGeospatialPdfStructureProxyModel->rowCount(); ++row )
255 QStringList groupOrder;
256 for (
int row = 0; row < mGeospatialPdfStructureProxyModel->rowCount(); ++row )
259 if ( !group.isEmpty() && !groupOrder.contains( group ) )
267 mOpenAfterExportingCheckBox->setChecked( enabled );
272 return mOpenAfterExportingCheckBox->isChecked();
275void QgsLayoutPdfExportOptionsDialog::showHelp()
280void QgsLayoutPdfExportOptionsDialog::showContextMenuForGeospatialPdfStructure( QPoint point,
const QModelIndex &index )
282 mGeospatialPdfStructureTreeMenu->clear();
284 switch ( index.column() )
289 QAction *selectAll =
new QAction( tr(
"Select All" ), mGeospatialPdfStructureTreeMenu );
290 mGeospatialPdfStructureTreeMenu->addAction( selectAll );
291 connect( selectAll, &QAction::triggered,
this, [
this, index] { mGeospatialPdfStructureModel->checkAll(
true, QModelIndex(), index.column() ); } );
292 QAction *deselectAll =
new QAction( tr(
"Deselect All" ), mGeospatialPdfStructureTreeMenu );
293 mGeospatialPdfStructureTreeMenu->addAction( deselectAll );
294 connect( deselectAll, &QAction::triggered,
this, [
this, index] { mGeospatialPdfStructureModel->checkAll(
false, QModelIndex(), index.column() ); } );
302 if ( !mGeospatialPdfStructureTreeMenu->actions().empty() )
304 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.
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.