Skip to content
Permalink
Browse files

[ui] Fix SVG marker widget not properly restoring colors

  • Loading branch information
nirvn committed Aug 20, 2020
1 parent 05d632c commit 1386474e3cab2161f2b982a1b604efeadd985270
@@ -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


};
@@ -2400,7 +2400,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 )
{
@@ -2427,7 +2427,7 @@ void QgsSvgMarkerSymbolLayerWidget::setGuiForSvg( const QgsSvgMarkerSymbolLayer
{
QColor fill = layer->fillColor();
double existingOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
if ( hasDefaultFillColor )
if ( hasDefaultFillColor && !skipDefaultColors )
{
fill = defaultFill;
}
@@ -2438,7 +2438,7 @@ void QgsSvgMarkerSymbolLayerWidget::setGuiForSvg( const QgsSvgMarkerSymbolLayer
{
QColor stroke = layer->strokeColor();
double existingOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
if ( hasDefaultStrokeColor )
if ( hasDefaultStrokeColor && !skipDefaultColors )
{
stroke = defaultStroke;
}
@@ -2545,7 +2545,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 );
@@ -601,8 +601,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 1386474

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