Ensure necessary updates happen when image cache is changed

This commit is contained in:
Nyall Dawson 2018-12-03 12:27:49 +10:00 committed by Mathieu Pellerin
parent 84838d1ec6
commit e0a6a046b7
3 changed files with 17 additions and 2 deletions

View File

@ -18,6 +18,7 @@
#include "qgssymbollayerutils.h"
#include "qgsapplication.h"
#include "qgssvgcache.h"
#include "qgsimagecache.h"
#include <QIcon>
const double ICON_PADDING_FACTOR = 0.16;
@ -41,12 +42,13 @@ QgsStyleModel::QgsStyleModel( QgsStyle *style, QObject *parent )
connect( mStyle, &QgsStyle::entityTagsChanged, this, &QgsStyleModel::onTagsChanged );
// when a remote svg has been fetched, update the model's decorations.
// when a remote svg or image has been fetched, update the model's decorations.
// this is required if a symbol utilizes remote svgs, and the current icons
// have been generated using the temporary "downloading" svg. In this case
// we require the preview to be regenerated to use the correct fetched
// svg
connect( QgsApplication::svgCache(), &QgsSvgCache::remoteSvgFetched, this, &QgsStyleModel::rebuildSymbolIcons );
connect( QgsApplication::imageCache(), &QgsImageCache::remoteImageFetched, this, &QgsStyleModel::rebuildSymbolIcons );
}
QVariant QgsStyleModel::data( const QModelIndex &index, int role ) const

View File

@ -68,6 +68,7 @@ email : sherman at mrcc.com
#include "qgsmapthemecollection.h"
#include "qgscoordinatetransformcontext.h"
#include "qgssvgcache.h"
#include "qgsimagecache.h"
#include <cmath>
/**
@ -151,8 +152,9 @@ QgsMapCanvas::QgsMapCanvas( QWidget *parent )
refresh();
} );
// refresh canvas when a remote svg has finished downloading
// refresh canvas when a remote svg/image has finished downloading
connect( QgsApplication::svgCache(), &QgsSvgCache::remoteSvgFetched, this, &QgsMapCanvas::refreshAllLayers );
connect( QgsApplication::imageCache(), &QgsImageCache::remoteImageFetched, this, &QgsMapCanvas::refreshAllLayers );
//segmentation parameters
QgsSettings settings;

View File

@ -34,6 +34,7 @@
#include "qgsfeatureiterator.h"
#include "qgsvectorlayer.h"
#include "qgssvgcache.h"
#include "qgsimagecache.h"
#include <QColorDialog>
#include <QPainter>
@ -303,6 +304,16 @@ QgsSymbolSelectorWidget::QgsSymbolSelectorWidget( QgsSymbol *symbol, QgsStyle *s
symbolChanged();
updatePreview();
} );
connect( QgsApplication::imageCache(), &QgsImageCache::remoteImageFetched, this, [ = ]
{
// when a remote image has been fetched, update the widget's previews
// this is required if the symbol utilizes remote images, and the current previews
// have been generated using the temporary "downloading" image. In this case
// we require the preview to be regenerated to use the correct fetched
// image
symbolChanged();
updatePreview();
} );
}
QMenu *QgsSymbolSelectorWidget::advancedMenu()