Skip to content
Permalink
Browse files

Fix svg fills losing fill and border color and border width settings …

…when loading symbol dialog (fix #9945)
  • Loading branch information
nyalldawson committed May 4, 2014
1 parent 639d4c4 commit c1d3958d8b84f1730027ce2164fe5cfcc6c7b982
@@ -270,7 +270,13 @@ class QgsSVGFillSymbolLayerWidget : QgsSymbolLayerV2Widget

protected:
void insertIcons();
void updateParamGui();

/**Enables or disables svg fill color, border color and border width based on whether the
* svg file supports custom parameters.
* @param resetValues set to true to overwrite existing layer fill color, border color and border width
* with default values from svg file
*/
void updateParamGui( bool resetValues = true );
};

//////////
@@ -1559,11 +1559,11 @@ QgsSymbolLayerV2* QgsSVGFillSymbolLayer::create( const QgsStringMap& properties
//svg parameters
if ( properties.contains( "svgFillColor" ) )
{
symbolLayer->setSvgFillColor( QColor( properties["svgFillColor"] ) );
symbolLayer->setSvgFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["svgFillColor"] ) );
}
if ( properties.contains( "svgOutlineColor" ) )
{
symbolLayer->setSvgOutlineColor( QColor( properties["svgOutlineColor"] ) );
symbolLayer->setSvgOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["svgOutlineColor"] ) );
}
if ( properties.contains( "svgOutlineWidth" ) )
{
@@ -1698,8 +1698,8 @@ QgsStringMap QgsSVGFillSymbolLayer::properties() const
map.insert( "angle", QString::number( mAngle ) );

//svg parameters
map.insert( "svgFillColor", mSvgFillColor.name() );
map.insert( "svgOutlineColor", mSvgOutlineColor.name() );
map.insert( "svgFillColor", QgsSymbolLayerV2Utils::encodeColor( mSvgFillColor ) );
map.insert( "svgOutlineColor", QgsSymbolLayerV2Utils::encodeColor( mSvgOutlineColor ) );
map.insert( "svgOutlineWidth", QString::number( mSvgOutlineWidth ) );

//units
@@ -1999,8 +1999,17 @@ void QgsSVGFillSymbolLayerWidget::setSymbolLayer( QgsSymbolLayerV2* layer )
mSvgOutlineWidthUnitComboBox->blockSignals( true );
mSvgOutlineWidthUnitComboBox->setCurrentIndex( mLayer->svgOutlineWidthUnit() );
mSvgOutlineWidthUnitComboBox->blockSignals( false );
mChangeColorButton->blockSignals( true );
mChangeColorButton->setColor( mLayer->svgFillColor() );
mChangeColorButton->blockSignals( false );
mChangeBorderColorButton->blockSignals( true );
mChangeBorderColorButton->setColor( mLayer->svgOutlineColor() );
mChangeBorderColorButton->blockSignals( false );
mBorderWidthSpinBox->blockSignals( true );
mBorderWidthSpinBox->setValue( mLayer->svgOutlineWidth() );
mBorderWidthSpinBox->blockSignals( false );
}
updateParamGui();
updateParamGui( false );
}

QgsSymbolLayerV2* QgsSVGFillSymbolLayerWidget::symbolLayer()
@@ -2115,19 +2124,27 @@ void QgsSVGFillSymbolLayerWidget::on_mRotationSpinBox_valueChanged( double d )
}
}

void QgsSVGFillSymbolLayerWidget::updateParamGui()
void QgsSVGFillSymbolLayerWidget::updateParamGui( bool resetValues )
{
//activate gui for svg parameters only if supported by the svg file
bool hasFillParam, hasOutlineParam, hasOutlineWidthParam;
QColor defaultFill, defaultOutline;
double defaultOutlineWidth;
QgsSvgCache::instance()->containsParams( mSVGLineEdit->text(), hasFillParam, defaultFill, hasOutlineParam, defaultOutline, hasOutlineWidthParam, defaultOutlineWidth );
if ( hasFillParam )
if ( hasFillParam && resetValues )
{
mChangeColorButton->setColor( defaultFill );
}
mChangeColorButton->setEnabled( hasFillParam );
if ( hasOutlineParam )
if ( hasOutlineParam && resetValues )
{
mChangeBorderColorButton->setColor( defaultOutline );
}
mChangeBorderColorButton->setEnabled( hasOutlineParam );
if ( hasOutlineWidthParam && resetValues )
{
mBorderWidthSpinBox->setValue( defaultOutlineWidth );
}
mBorderWidthSpinBox->setEnabled( hasOutlineWidthParam );
}

@@ -340,7 +340,12 @@ class GUI_EXPORT QgsSVGFillSymbolLayerWidget : public QgsSymbolLayerV2Widget, pr
protected:
QgsSVGFillSymbolLayer* mLayer;
void insertIcons();
void updateParamGui();
/**Enables or disables svg fill color, border color and border width based on whether the
* svg file supports custom parameters.
* @param resetValues set to true to overwrite existing layer fill color, border color and border width
* with default values from svg file
*/
void updateParamGui( bool resetValues = true );

private slots:
void on_mBrowseToolButton_clicked();

0 comments on commit c1d3958

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