Skip to content
Permalink
Browse files

Auto update canvas, symbol preview, when project colors change

Symbols may be using project colors, so the layers and previews
need to be updated when project color changes occur
  • Loading branch information
nyalldawson committed Jan 12, 2019
1 parent b0de40d commit da53f145f2fb1eda9bf41591ddb5d1176e1488d6
@@ -19,6 +19,7 @@
#include "qgsapplication.h"
#include "qgssvgcache.h"
#include "qgsimagecache.h"
#include "qgsproject.h"
#include <QIcon>

const double ICON_PADDING_FACTOR = 0.16;
@@ -49,6 +50,10 @@ QgsStyleModel::QgsStyleModel( QgsStyle *style, QObject *parent )
// svg
connect( QgsApplication::svgCache(), &QgsSvgCache::remoteSvgFetched, this, &QgsStyleModel::rebuildSymbolIcons );
connect( QgsApplication::imageCache(), &QgsImageCache::remoteImageFetched, this, &QgsStyleModel::rebuildSymbolIcons );

// if project color scheme changes, we need to redraw symbols - they may use project colors and accordingly
// need updating to reflect the new colors
connect( QgsProject::instance(), &QgsProject::projectColorsChanged, this, &QgsStyleModel::rebuildSymbolIcons );
}

QVariant QgsStyleModel::data( const QModelIndex &index, int role ) const
@@ -155,6 +155,8 @@ QgsMapCanvas::QgsMapCanvas( QWidget *parent )
// 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 );
// refresh canvas when project color scheme is changed -- if layers use project colors, they need to be redrawn
connect( QgsProject::instance(), &QgsProject::projectColorsChanged, this, &QgsMapCanvas::refreshAllLayers );

//segmentation parameters
QgsSettings settings;
@@ -35,6 +35,7 @@
#include "qgsvectorlayer.h"
#include "qgssvgcache.h"
#include "qgsimagecache.h"
#include "qgsproject.h"

#include <QColorDialog>
#include <QPainter>
@@ -314,6 +315,14 @@ QgsSymbolSelectorWidget::QgsSymbolSelectorWidget( QgsSymbol *symbol, QgsStyle *s
symbolChanged();
updatePreview();
} );

connect( QgsProject::instance(), &QgsProject::projectColorsChanged, this, [ = ]
{
// if project color scheme changes, we need to redraw symbols - they may use project colors and accordingly
// need updating to reflect the new colors
symbolChanged();
updatePreview();
} );
}

QMenu *QgsSymbolSelectorWidget::advancedMenu()

0 comments on commit da53f14

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