Use application image cache

This commit is contained in:
Marco Hugentobler 2021-06-30 10:48:52 +02:00
parent d76fa2bf3b
commit f287872798
3 changed files with 5 additions and 4 deletions

View File

@ -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 );

View File

@ -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;}

View File

@ -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() )