Skip to content

Commit

Permalink
Ensure necessary updates happen when image cache is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson authored and nirvn committed Dec 5, 2018
1 parent 84838d1 commit e0a6a04
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/core/symbology/qgsstylemodel.cpp
Expand Up @@ -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;
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/gui/qgsmapcanvas.cpp
Expand Up @@ -68,6 +68,7 @@ email : sherman at mrcc.com
#include "qgsmapthemecollection.h"
#include "qgscoordinatetransformcontext.h"
#include "qgssvgcache.h"
#include "qgsimagecache.h"
#include <cmath>

/**
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions src/gui/symbology/qgssymbolselectordialog.cpp
Expand Up @@ -34,6 +34,7 @@
#include "qgsfeatureiterator.h"
#include "qgsvectorlayer.h"
#include "qgssvgcache.h"
#include "qgsimagecache.h"

#include <QColorDialog>
#include <QPainter>
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit e0a6a04

Please sign in to comment.