Skip to content
Permalink
Browse files
Use application image cache
  • Loading branch information
mhugent committed Jul 2, 2021
1 parent d76fa2b commit f2878727984d76e55c3881cf5ee728b939a847a9
Showing with 5 additions and 4 deletions.
  1. +2 −0 python/core/auto_generated/qgsmaplayer.sip.in
  2. +1 −0 src/core/qgsmaplayer.h
  3. +2 −4 src/core/qgsmaplayerlegend.cpp
@@ -1436,6 +1436,8 @@ Returns the layer's elevation properties. This may be ``None``, depending on the
Returns path to the placeholder image or an empty string if a generated legend is shown

:return: placholder image path

.. versionadded:: 3.22
%End

void setLegendPlaceholderImage( const QString &imgPath );
@@ -1282,6 +1282,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
/**
* Returns path to the placeholder image or an empty string if a generated legend is shown
* \return placholder image path
* \since QGIS 3.22
*/
QString legendPlaceholderImage() const { return mLegendPlaceholderImage;}

@@ -365,9 +365,8 @@ QList<QgsLayerTreeModelLegendNode *> QgsDefaultVectorLayerLegend::createLayerTre
QString placeholderImage = mLayer->legendPlaceholderImage();
if ( !placeholderImage.isEmpty() )
{
QgsImageCache ic;
bool fitsInCache;
QImage img = ic.pathAsImage( placeholderImage, QSize(), false, 1.0, fitsInCache );
QImage img = QgsApplication::imageCache()->pathAsImage( placeholderImage, QSize(), false, 1.0, fitsInCache );
nodes << new QgsImageLegendNode( nodeLayer, img );
return nodes;
}
@@ -519,9 +518,8 @@ QList<QgsLayerTreeModelLegendNode *> QgsDefaultRasterLayerLegend::createLayerTre
QString placeholderImage = mLayer->legendPlaceholderImage();
if ( !placeholderImage.isEmpty() )
{
QgsImageCache ic;
bool fitsInCache;
QImage img = ic.pathAsImage( placeholderImage, QSize(), false, 1.0, fitsInCache );
QImage img = QgsApplication::imageCache()->pathAsImage( placeholderImage, QSize(), false, 1.0, fitsInCache );
nodes << new QgsImageLegendNode( nodeLayer, img );
}
else if ( mLayer->renderer() )

0 comments on commit f287872

Please sign in to comment.