Skip to content

Commit

Permalink
[ui] Fix SVG marker widget not properly restoring colors
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Aug 20, 2020
1 parent 05d632c commit 1386474
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
10 changes: 9 additions & 1 deletion python/gui/auto_generated/symbology/qgssymbollayerwidget.sip.in
Expand Up @@ -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


};
Expand Down
8 changes: 4 additions & 4 deletions src/gui/symbology/qgssymbollayerwidget.cpp
Expand Up @@ -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 )
{
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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 );
Expand Down
10 changes: 8 additions & 2 deletions src/gui/symbology/qgssymbollayerwidget.h
Expand Up @@ -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;

Expand Down

0 comments on commit 1386474

Please sign in to comment.