Skip to content
Permalink
Browse files

[ui] Fix SVG marker widget not properly restoring colors

(cherry picked from commit 1386474)
  • Loading branch information
nirvn authored and nyalldawson committed Sep 11, 2020
1 parent ed04841 commit 49410542184153e734d13424e7a7c5db54f52ca5
@@ -452,7 +452,15 @@ Creates a new QgsSvgMarkerSymbolLayerWidget.
protected:

void populateList();
void setGuiForSvg( const QgsSvgMarkerSymbolLayer *layer );

void setGuiForSvg( const QgsSvgMarkerSymbolLayer *layer, bool skipDefaultColors = false );
%Docstring
Updates the GUI to reflect the SVG marker symbol ``layer``.

:param layer: SVG marker symbol layer
:param skipDefaultColors: if ``True``, the default fill and outline colors of the SVG file will not overwrite
the ones from the symbol layer
%End


};
@@ -2325,7 +2325,7 @@ void QgsSvgMarkerSymbolLayerWidget::populateIcons( const QModelIndex &idx )
connect( viewImages->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSvgMarkerSymbolLayerWidget::setName );
}

void QgsSvgMarkerSymbolLayerWidget::setGuiForSvg( const QgsSvgMarkerSymbolLayer *layer )
void QgsSvgMarkerSymbolLayerWidget::setGuiForSvg( const QgsSvgMarkerSymbolLayer *layer, bool skipDefaultColors )
{
if ( !layer )
{
@@ -2352,7 +2352,7 @@ void QgsSvgMarkerSymbolLayerWidget::setGuiForSvg( const QgsSvgMarkerSymbolLayer
{
QColor fill = layer->fillColor();
double existingOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
if ( hasDefaultFillColor )
if ( hasDefaultFillColor && !skipDefaultColors )
{
fill = defaultFill;
}
@@ -2363,7 +2363,7 @@ void QgsSvgMarkerSymbolLayerWidget::setGuiForSvg( const QgsSvgMarkerSymbolLayer
{
QColor stroke = layer->strokeColor();
double existingOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
if ( hasDefaultStrokeColor )
if ( hasDefaultStrokeColor && !skipDefaultColors )
{
stroke = defaultStroke;
}
@@ -2470,7 +2470,7 @@ void QgsSvgMarkerSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer *layer )
mHorizontalAnchorComboBox->blockSignals( false );
mVerticalAnchorComboBox->blockSignals( false );

setGuiForSvg( mLayer );
setGuiForSvg( mLayer, true );

registerDataDefinedButton( mWidthDDBtn, QgsSymbolLayer::PropertyWidth );
registerDataDefinedButton( mHeightDDBtn, QgsSymbolLayer::PropertyHeight );
@@ -599,8 +599,14 @@ class GUI_EXPORT QgsSvgMarkerSymbolLayerWidget : public QgsSymbolLayerWidget, pr
protected:

void populateList();
//update gui for svg file (insert new path, update activation of gui elements for svg params)
void setGuiForSvg( const QgsSvgMarkerSymbolLayer *layer );

/**
* Updates the GUI to reflect the SVG marker symbol \a layer.
* \param layer SVG marker symbol layer
* \param skipDefaultColors if TRUE, the default fill and outline colors of the SVG file will not overwrite
* the ones from the symbol layer
*/
void setGuiForSvg( const QgsSvgMarkerSymbolLayer *layer, bool skipDefaultColors = false );

QgsSvgMarkerSymbolLayer *mLayer = nullptr;

0 comments on commit 4941054

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