mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Display name of layers in need of rasterization when saving as PDF (#4539)
This commit is contained in:
parent
ad5054bfd9
commit
418084698d
@ -22,11 +22,11 @@ class QgsMapSettingsUtils
|
||||
%End
|
||||
public:
|
||||
|
||||
static bool containsAdvancedEffects( const QgsMapSettings &mapSettings );
|
||||
static const QStringList containsAdvancedEffects( const QgsMapSettings &mapSettings );
|
||||
%Docstring
|
||||
Checks whether any of the layers attached to a map settings object contain advanced effects
|
||||
\param mapSettings map settings
|
||||
:rtype: bool
|
||||
:rtype: list of str
|
||||
%End
|
||||
|
||||
static QString worldFileContent( const QgsMapSettings &mapSettings );
|
||||
|
@ -66,7 +66,23 @@ QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, co
|
||||
{
|
||||
mSaveWorldFile->setVisible( false );
|
||||
|
||||
mSaveAsRaster->setChecked( QgsMapSettingsUtils::containsAdvancedEffects( mapCanvas->mapSettings() ) );
|
||||
QStringList layers = QgsMapSettingsUtils::containsAdvancedEffects( mapCanvas->mapSettings() );
|
||||
if ( !layers.isEmpty() )
|
||||
{
|
||||
// Limit number of items to avoid extreme dialog height
|
||||
if ( layers.count() >= 10 )
|
||||
{
|
||||
layers = layers.mid( 0, 9 );
|
||||
layers << QChar( 0x2026 );
|
||||
}
|
||||
mInfo->setText( tr( "The following layer(s) use advanced effects:\n%1\nRasterizing map is recommended for proper rendering." ).arg(
|
||||
QChar( 0x2022 ) + QString( " " ) + layers.join( QString( "\n" ) + QChar( 0x2022 ) + QString( " " ) ) ) );
|
||||
mSaveAsRaster->setChecked( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mSaveAsRaster->setChecked( false );
|
||||
}
|
||||
mSaveAsRaster->setVisible( true );
|
||||
|
||||
this->setWindowTitle( tr( "Save map as PDF" ) );
|
||||
|
@ -1082,7 +1082,7 @@ bool QgsComposerMap::containsAdvancedEffects() const
|
||||
|
||||
QgsMapSettings ms;
|
||||
ms.setLayers( layersToRender() );
|
||||
return QgsMapSettingsUtils::containsAdvancedEffects( ms );
|
||||
return ( !QgsMapSettingsUtils::containsAdvancedEffects( ms ).isEmpty() );
|
||||
}
|
||||
|
||||
void QgsComposerMap::connectUpdateSlot()
|
||||
|
@ -23,8 +23,10 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
bool QgsMapSettingsUtils::containsAdvancedEffects( const QgsMapSettings &mapSettings )
|
||||
const QStringList QgsMapSettingsUtils::containsAdvancedEffects( const QgsMapSettings &mapSettings )
|
||||
{
|
||||
QSet< QString > layers;
|
||||
|
||||
QgsTextFormat layerFormat;
|
||||
Q_FOREACH ( QgsMapLayer *layer, mapSettings.layers() )
|
||||
{
|
||||
@ -32,7 +34,7 @@ bool QgsMapSettingsUtils::containsAdvancedEffects( const QgsMapSettings &mapSett
|
||||
{
|
||||
if ( layer->blendMode() != QPainter::CompositionMode_SourceOver )
|
||||
{
|
||||
return true;
|
||||
layers << layer->name();
|
||||
}
|
||||
// if vector layer, check labels and feature blend mode
|
||||
QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( layer );
|
||||
@ -40,11 +42,11 @@ bool QgsMapSettingsUtils::containsAdvancedEffects( const QgsMapSettings &mapSett
|
||||
{
|
||||
if ( currentVectorLayer->layerTransparency() != 0 )
|
||||
{
|
||||
return true;
|
||||
layers << layer->name();
|
||||
}
|
||||
if ( currentVectorLayer->featureBlendMode() != QPainter::CompositionMode_SourceOver )
|
||||
{
|
||||
return true;
|
||||
layers << layer->name();
|
||||
}
|
||||
// check label blend modes
|
||||
if ( QgsPalLabeling::staticWillUseLayer( currentVectorLayer ) )
|
||||
@ -52,12 +54,15 @@ bool QgsMapSettingsUtils::containsAdvancedEffects( const QgsMapSettings &mapSett
|
||||
// Check all label blending properties
|
||||
layerFormat.readFromLayer( currentVectorLayer );
|
||||
if ( layerFormat.containsAdvancedEffects() )
|
||||
return true;
|
||||
{
|
||||
layers << layer->name();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
return layers.toList();
|
||||
}
|
||||
|
||||
QString QgsMapSettingsUtils::worldFileContent( const QgsMapSettings &mapSettings )
|
||||
|
@ -35,7 +35,7 @@ class CORE_EXPORT QgsMapSettingsUtils
|
||||
/** Checks whether any of the layers attached to a map settings object contain advanced effects
|
||||
* \param mapSettings map settings
|
||||
*/
|
||||
static bool containsAdvancedEffects( const QgsMapSettings &mapSettings );
|
||||
static const QStringList containsAdvancedEffects( const QgsMapSettings &mapSettings );
|
||||
|
||||
/** Creates the content of a world file.
|
||||
* \param mapSettings map settings
|
||||
|
@ -16,6 +16,13 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="QLabel" name="mInfo">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="mSaveAsRaster">
|
||||
<property name="text">
|
||||
|
Loading…
x
Reference in New Issue
Block a user