34#include "moc_qgslayoutpdfexportoptionsdialog.cpp"
36using namespace Qt::StringLiterals;
39 : QDialog( parent, flags )
43 mGeospatialPdfStructureTreeMenu =
new QMenu(
this );
50 mGeospatialPDFGroupBox->setEnabled( mGeospatialPdfAvailable );
51 mGeospatialPDFGroupBox->setChecked(
false );
52 if ( !mGeospatialPdfAvailable )
54 mGeospatialPDFOptionsStackedWidget->setCurrentIndex( 0 );
57 QPalette p = mGeospatialPdfUnavailableReason->palette();
58 p.setColor( QPalette::Disabled, QPalette::WindowText, QPalette::WindowText );
59 mGeospatialPdfUnavailableReason->setPalette( p );
60 mGeospatialPDFOptionsStackedWidget->removeWidget( mGeospatialPDFOptionsStackedWidget->widget( 1 ) );
64 mGeospatialPDFOptionsStackedWidget->setCurrentIndex( 1 );
67 mComboImageCompression->addItem( tr(
"Lossy (JPEG)" ),
false );
68 mComboImageCompression->addItem( tr(
"Lossless" ),
true );
71 for (
const QString &theme : themes )
73 QListWidgetItem *item =
new QListWidgetItem( theme );
74 item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
75 item->setCheckState( Qt::Unchecked );
76 mThemesList->addItem( item );
82 for (
int i = 0; i < order.size(); ++i )
84 if ( order.at( i )->id() == *it )
92 mGeospatialPdfStructureProxyModel =
new QgsGeospatialPdfLayerFilteredTreeModel( mGeospatialPdfStructureModel,
this );
93 mGeospatialPdfStructureTree->setModel( mGeospatialPdfStructureProxyModel );
94 mGeospatialPdfStructureTree->resizeColumnToContents( 0 );
95 mGeospatialPdfStructureTree->header()->show();
96 mGeospatialPdfStructureTree->setSelectionMode( QAbstractItemView::SingleSelection );
97 mGeospatialPdfStructureTree->setSelectionBehavior( QAbstractItemView::SelectRows );
99 mGeospatialPdfStructureTree->setDragEnabled(
true );
100 mGeospatialPdfStructureTree->setAcceptDrops(
true );
101 mGeospatialPdfStructureTree->setDragDropMode( QAbstractItemView::InternalMove );
102 mGeospatialPdfStructureTree->setDefaultDropAction( Qt::MoveAction );
104 mGeospatialPdfStructureTree->setContextMenuPolicy( Qt::CustomContextMenu );
105 connect( mGeospatialPdfStructureTree, &QTreeView::customContextMenuRequested,
this, [
this](
const QPoint &point ) {
106 const QModelIndex index = mGeospatialPdfStructureTree->indexAt( point );
107 if ( index.isValid() )
108 showContextMenuForGeospatialPdfStructure( point, mGeospatialPdfStructureProxyModel->mapToSource( index ) );
111 connect( mHelpButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutPdfExportOptionsDialog::showHelp );
117 mTextRenderFormatComboBox->setCurrentIndex( mTextRenderFormatComboBox->findData(
static_cast<int>( format ) ) );
127 mForceVectorCheckBox->setChecked( force );
132 return mForceVectorCheckBox->isChecked();
137 mAppendGeoreferenceCheckbox->setEnabled( enabled );
142 mAppendGeoreferenceCheckbox->setChecked( enabled );
147 return mAppendGeoreferenceCheckbox->isChecked();
152 mIncludeMetadataCheckbox->setChecked( enabled );
157 return mIncludeMetadataCheckbox->isChecked();
162 mDisableRasterTilingCheckBox->setChecked( disabled );
167 return mDisableRasterTilingCheckBox->isChecked();
172 mSimplifyGeometriesCheckbox->setChecked( enabled );
177 return mSimplifyGeometriesCheckbox->isChecked();
182 mComboImageCompression->setCurrentIndex( mComboImageCompression->findData( enabled ) );
187 return mComboImageCompression->currentData().toBool();
192 if ( !mGeospatialPdfAvailable )
195 mGeospatialPDFGroupBox->setChecked( enabled );
200 if ( !mGeospatialPdfAvailable )
203 return mGeospatialPDFGroupBox->isChecked();
208 if ( !mGeospatialPdfAvailable )
211 mIncludeMapThemesCheck->setChecked( !themes.isEmpty() );
212 for (
int i = 0; i < mThemesList->count(); ++i )
214 QListWidgetItem *item = mThemesList->item( i );
215 item->setCheckState( themes.contains( item->text() ) ? Qt::Checked : Qt::Unchecked );
222 if ( !mGeospatialPdfAvailable )
225 if ( !mIncludeMapThemesCheck || !mIncludeMapThemesCheck->isChecked() )
228 res.reserve( mThemesList->count() );
229 for (
int i = 0; i < mThemesList->count(); ++i )
231 QListWidgetItem *item = mThemesList->item( i );
232 if ( item->checkState() == Qt::Checked )
241 for (
int row = 0; row < mGeospatialPdfStructureProxyModel->rowCount(); ++row )
253 QStringList groupOrder;
254 for (
int row = 0; row < mGeospatialPdfStructureProxyModel->rowCount(); ++row )
257 if ( !group.isEmpty() && !groupOrder.contains( group ) )
265 mOpenAfterExportingCheckBox->setChecked( enabled );
270 return mOpenAfterExportingCheckBox->isChecked();
273void QgsLayoutPdfExportOptionsDialog::showHelp()
278void QgsLayoutPdfExportOptionsDialog::showContextMenuForGeospatialPdfStructure( QPoint point,
const QModelIndex &index )
280 mGeospatialPdfStructureTreeMenu->clear();
282 switch ( index.column() )
287 QAction *selectAll =
new QAction( tr(
"Select All" ), mGeospatialPdfStructureTreeMenu );
288 mGeospatialPdfStructureTreeMenu->addAction( selectAll );
289 connect( selectAll, &QAction::triggered,
this, [
this, index] {
290 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] {
295 mGeospatialPdfStructureModel->checkAll(
false, QModelIndex(), index.column() );
304 if ( !mGeospatialPdfStructureTreeMenu->actions().empty() )
306 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.