19 #include "qgssettings.h"
29 #include <QPushButton>
33 : QDialog( parent, flags )
37 mGeoPdfStructureTreeMenu =
new QMenu(
this );
43 mGeoPDFGroupBox->setEnabled( mGeopdfAvailable );
44 mGeoPDFGroupBox->setChecked(
false );
45 if ( !mGeopdfAvailable )
47 mGeoPDFOptionsStackedWidget->setCurrentIndex( 0 );
50 QPalette p = mGeoPdfUnavailableReason->palette();
51 p.setColor( QPalette::Disabled, QPalette::WindowText, QPalette::WindowText );
52 mGeoPdfUnavailableReason->setPalette( p );
53 mGeoPDFOptionsStackedWidget->removeWidget( mGeoPDFOptionsStackedWidget->widget( 1 ) );
57 mGeoPDFOptionsStackedWidget->setCurrentIndex( 1 );
58 mGeoPdfFormatComboBox->addItem( tr(
"ISO 32000 Extension (recommended)" ) );
59 mGeoPdfFormatComboBox->addItem( tr(
"OGC Best Practice" ) );
62 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
63 mComboImageCompression->addItem( tr(
"Lossy (JPEG)" ),
false );
64 mComboImageCompression->addItem( tr(
"Lossless" ),
true );
66 mComboImageCompression->setDisabled(
true );
67 mComboImageCompression->addItem( tr(
"Lossy (JPEG)" ) );
68 mComboImageCompression->setCurrentIndex( 0 );
69 mComboImageCompression->setToolTip( tr(
"Lossless image compression is available only with QGIS builds using Qt 5.13 or later" ) );
74 for (
const QString &theme : themes )
76 QListWidgetItem *item =
new QListWidgetItem( theme );
77 item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
78 item->setCheckState( Qt::Unchecked );
79 mThemesList->addItem( item );
85 for (
int i = 0; i < order.size(); ++i )
87 if ( order.at( i )->id() == *it )
95 mGeoPdfStructureProxyModel =
new QgsGeoPdfLayerFilteredTreeModel( mGeoPdfStructureModel,
this );
96 mGeoPdfStructureTree->setModel( mGeoPdfStructureProxyModel );
97 mGeoPdfStructureTree->resizeColumnToContents( 0 );
98 mGeoPdfStructureTree->header()->show();
99 mGeoPdfStructureTree->setSelectionMode( QAbstractItemView::SingleSelection );
100 mGeoPdfStructureTree->setSelectionBehavior( QAbstractItemView::SelectRows );
102 mGeoPdfStructureTree->setDragEnabled(
true );
103 mGeoPdfStructureTree->setAcceptDrops(
true );
104 mGeoPdfStructureTree->setDragDropMode( QAbstractItemView::InternalMove );
105 mGeoPdfStructureTree->setDefaultDropAction( Qt::MoveAction );
107 mGeoPdfStructureTree->setContextMenuPolicy( Qt::CustomContextMenu );
108 connect( mGeoPdfStructureTree, &QTreeView::customContextMenuRequested,
this, [ = ](
const QPoint & point )
110 const QModelIndex index = mGeoPdfStructureTree->indexAt( point );
111 if ( index.isValid() )
112 showContextMenuForGeoPdfStructure( point, mGeoPdfStructureProxyModel->mapToSource( index ) );
115 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutPdfExportOptionsDialog::showHelp );
121 mTextRenderFormatComboBox->setCurrentIndex( mTextRenderFormatComboBox->findData( format ) );
131 mForceVectorCheckBox->setChecked( force );
136 return mForceVectorCheckBox->isChecked();
141 mAppendGeoreferenceCheckbox->setEnabled( enabled );
146 mAppendGeoreferenceCheckbox->setChecked( enabled );
151 return mAppendGeoreferenceCheckbox->isChecked();
156 mIncludeMetadataCheckbox->setChecked( enabled );
161 return mIncludeMetadataCheckbox->isChecked();
166 mDisableRasterTilingCheckBox->setChecked( disabled );
171 return mDisableRasterTilingCheckBox->isChecked();
176 mSimplifyGeometriesCheckbox->setChecked( enabled );
181 return mSimplifyGeometriesCheckbox->isChecked();
186 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
187 mComboImageCompression->setCurrentIndex( mComboImageCompression->findData( enabled ) );
195 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
196 return mComboImageCompression->currentData().toBool();
204 if ( !mGeopdfAvailable )
207 mGeoPDFGroupBox->setChecked( enabled );
212 if ( !mGeopdfAvailable )
215 return mGeoPDFGroupBox->isChecked();
220 if ( !mGeopdfAvailable )
224 mGeoPdfFormatComboBox->setCurrentIndex( 1 );
226 mGeoPdfFormatComboBox->setCurrentIndex( 0 );
231 if ( !mGeopdfAvailable )
234 return mGeoPdfFormatComboBox->currentIndex() == 1;
240 if ( !mGeopdfAvailable )
243 mIncludeMapThemesCheck->setChecked( !themes.isEmpty() );
244 for (
int i = 0; i < mThemesList->count(); ++i )
246 QListWidgetItem *item = mThemesList->item( i );
247 item->setCheckState( themes.contains( item->text() ) ? Qt::Checked : Qt::Unchecked );
254 if ( !mGeopdfAvailable )
257 if ( !mIncludeMapThemesCheck || !mIncludeMapThemesCheck->isChecked() )
260 res.reserve( mThemesList->count() );
261 for (
int i = 0; i < mThemesList->count(); ++i )
263 QListWidgetItem *item = mThemesList->item( i );
264 if ( item->checkState() == Qt::Checked )
273 for (
int row = 0; row < mGeoPdfStructureProxyModel->rowCount(); ++row )
280 void QgsLayoutPdfExportOptionsDialog::showHelp()
285 void QgsLayoutPdfExportOptionsDialog::showContextMenuForGeoPdfStructure( QPoint point,
const QModelIndex &index )
287 mGeoPdfStructureTreeMenu->clear();
289 switch ( index.column() )
294 QAction *selectAll =
new QAction( tr(
"Select All" ), mGeoPdfStructureTreeMenu );
295 mGeoPdfStructureTreeMenu->addAction( selectAll );
296 connect( selectAll, &QAction::triggered,
this, [ = ]
298 mGeoPdfStructureModel->
checkAll(
true, QModelIndex(), index.column() );
300 QAction *deselectAll =
new QAction( tr(
"Deselect All" ), mGeoPdfStructureTreeMenu );
301 mGeoPdfStructureTreeMenu->addAction( deselectAll );
302 connect( deselectAll, &QAction::triggered,
this, [ = ]
304 mGeoPdfStructureModel->
checkAll(
false, QModelIndex(), index.column() );
313 if ( !mGeoPdfStructureTreeMenu->actions().empty() )
315 mGeoPdfStructureTreeMenu->exec( mGeoPdfStructureTree->mapToGlobal( point ) );
static bool geoPDFCreationAvailable()
Returns true if the current QGIS build is capable of GeoPDF support.
static QString geoPDFAvailabilityExplanation()
Returns a user-friendly, translated string explaining why GeoPDF export support is not available on t...
Layer tree model for Geo-PDF layers.
@ InitiallyVisible
Initial visiblity 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.
QgsLayoutPdfExportOptionsDialog(QWidget *parent=nullptr, bool allowGeoPdfExport=true, const QString &geoPdfReason=QString(), const QStringList &geoPdfLayerOrder=QStringList(), Qt::WindowFlags flags=Qt::WindowFlags())
Constructor for QgsLayoutPdfExportOptionsDialog.
QStringList exportThemes() const
Returns the list of export themes.
bool useOgcBestPracticeFormat() const
Returns whether use of OGC best-practice format is enabled.
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.
void setTextRenderFormat(QgsRenderContext::TextRenderFormat format)
Sets the text render format.
void setUseOgcBestPracticeFormat(bool enabled)
Sets whether to use OGC best-practice format.
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.
QgsRenderContext::TextRenderFormat textRenderFormat() const
Returns the current text render format.
bool exportGeoPdf() const
Returns whether Geo-PDF export is enabled.
void setExportGeoPdf(bool enabled)
Sets whether to export a Geo-PDF.
QStringList geoPdfLayerOrder() const
Returns a list of map layer IDs in the desired order they should appear in a generated GeoPDF file.
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.
@ LayerIdRole
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.
TextRenderFormat
Options for rendering text.
@ TextFormatAlwaysText
Always render text as text objects.
@ TextFormatAlwaysOutlines
Always render text using path objects (AKA outlines/curves).