Skip to content
Permalink
Browse files

Ensure necessary updates happen when image cache is changed

  • Loading branch information
nyalldawson authored and nirvn committed Dec 5, 2018
1 parent 84838d1 commit e0a6a046b7c5a5c20b7276b8d50dc579e68168ae
Showing with 17 additions and 2 deletions.
  1. +3 −1 src/core/symbology/qgsstylemodel.cpp
  2. +3 −1 src/gui/qgsmapcanvas.cpp
  3. +11 −0 src/gui/symbology/qgssymbolselectordialog.cpp
@@ -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
@@ -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;
@@ -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()

0 comments on commit e0a6a04

Please sign in to comment.
You can’t perform that action at this time.