@@ -631,6 +631,11 @@ void QgsComposer::on_mActionExportAsPDF_triggered()
631
631
showWMSPrintingWarning ();
632
632
}
633
633
634
+ if ( containsBlendModes () )
635
+ {
636
+ showBlendModePrintingWarning ();
637
+ }
638
+
634
639
bool hasAnAtlas = mComposition ->atlasComposition ().enabled ();
635
640
bool atlasOnASingleFile = hasAnAtlas && mComposition ->atlasComposition ().singleFile ();
636
641
QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
@@ -805,6 +810,11 @@ void QgsComposer::on_mActionPrint_triggered()
805
810
showWMSPrintingWarning ();
806
811
}
807
812
813
+ if ( containsBlendModes () )
814
+ {
815
+ showBlendModePrintingWarning ();
816
+ }
817
+
808
818
// orientation and page size are already set to QPrinter in the page setup dialog
809
819
QPrintDialog printDialog ( &mPrinter , 0 );
810
820
if ( printDialog.exec () != QDialog::Accepted )
@@ -2010,6 +2020,42 @@ bool QgsComposer::containsWMSLayer() const
2010
2020
return false ;
2011
2021
}
2012
2022
2023
+ bool QgsComposer::containsBlendModes () const
2024
+ {
2025
+ // Check if composer contains any blend modes
2026
+ QMap<QgsComposerItem*, QWidget*>::const_iterator item_it = mItemWidgetMap .constBegin ();
2027
+ QgsComposerItem* currentItem = 0 ;
2028
+ QgsComposerMap* currentMap = 0 ;
2029
+
2030
+ for ( ; item_it != mItemWidgetMap .constEnd (); ++item_it )
2031
+ {
2032
+ currentItem = item_it.key ();
2033
+ // Check composer item's blend mode
2034
+ if ( currentItem->blendMode () != QPainter::CompositionMode_SourceOver )
2035
+ {
2036
+ return true ;
2037
+ }
2038
+ // If item is a composer map, check if it contains any blended layers
2039
+ currentMap = dynamic_cast <QgsComposerMap *>( currentItem );
2040
+ if ( currentMap )
2041
+ {
2042
+ if ( currentMap->containsBlendModes () )
2043
+ {
2044
+ return true ;
2045
+ }
2046
+ if ( currentMap->overviewFrameMapId () != -1 )
2047
+ {
2048
+ // map contains an overview, check its blend mode
2049
+ if ( currentMap->overviewBlendMode () != QPainter::CompositionMode_SourceOver )
2050
+ {
2051
+ return true ;
2052
+ }
2053
+ }
2054
+ }
2055
+ }
2056
+ return false ;
2057
+ }
2058
+
2013
2059
void QgsComposer::showWMSPrintingWarning ()
2014
2060
{
2015
2061
QString myQSettingsLabel = " /UI/displayComposerWMSWarning" ;
@@ -2029,6 +2075,31 @@ void QgsComposer::showWMSPrintingWarning()
2029
2075
}
2030
2076
}
2031
2077
2078
+ void QgsComposer::showBlendModePrintingWarning ()
2079
+ {
2080
+ if ( ! mComposition ->printAsRaster () )
2081
+ {
2082
+ QgsMessageViewer* m = new QgsMessageViewer ( this );
2083
+ m->setWindowTitle ( tr ( " Project contains blend modes" ) );
2084
+ m->setMessage ( tr ( " Blend modes are enabled in this project, which cannot be printed as vectors. Printing as a raster is recommended." ), QgsMessageOutput::MessageText );
2085
+ m->setCheckBoxText ( tr ( " Print as raster" ) );
2086
+ m->setCheckBoxState ( Qt::Checked );
2087
+ m->setCheckBoxVisible ( true );
2088
+ m->showMessage ( true );
2089
+
2090
+ // TODO - fix this - checkBoxState is never true
2091
+ // also need to make sure composer print as raster checkbox is updated
2092
+ if ( m->checkBoxState () == Qt::Checked )
2093
+ {
2094
+ mComposition ->setPrintAsRaster ( true );
2095
+ }
2096
+ else
2097
+ {
2098
+ mComposition ->setPrintAsRaster ( true );
2099
+ }
2100
+ }
2101
+ }
2102
+
2032
2103
void QgsComposer::cleanupAfterTemplateRead ()
2033
2104
{
2034
2105
QMap<QgsComposerItem*, QWidget*>::const_iterator itemIt = mItemWidgetMap .constBegin ();
0 commit comments