Skip to content

Commit

Permalink
Fix widget for data defined line color in lineburst symbol layer
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 29, 2021
1 parent 957f898 commit ccf5ff0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/gui/symbology/qgssymbollayerwidget.cpp
Expand Up @@ -4662,7 +4662,7 @@ void QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType()
QgsSymbolLayerList layers;
for ( int i = 0; i < subSymbol->symbolLayerCount(); ++i )
{
if ( const QgsLineSymbolLayer *lineLayer = dynamic_cast< const QgsLineSymbolLayer * >( subSymbol->symbolLayer( i ) ) )
if ( dynamic_cast< const QgsLineSymbolLayer * >( subSymbol->symbolLayer( i ) ) )
layers << subSymbol->symbolLayer( i )->clone();
}

Expand Down Expand Up @@ -4996,7 +4996,7 @@ void QgsLineburstSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer *layer )
whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
whileBlocking( cboCapStyle )->setPenCapStyle( mLayer->penCapStyle() );

registerDataDefinedButton( mStartColorDDBtn, QgsSymbolLayer::PropertyFillColor );
registerDataDefinedButton( mStartColorDDBtn, QgsSymbolLayer::PropertyStrokeColor );
registerDataDefinedButton( mEndColorDDBtn, QgsSymbolLayer::PropertySecondaryColor );
registerDataDefinedButton( mPenWidthDDBtn, QgsSymbolLayer::PropertyStrokeWidth );
registerDataDefinedButton( mJoinStyleDDBtn, QgsSymbolLayer::PropertyJoinStyle );
Expand Down
21 changes: 20 additions & 1 deletion tests/src/python/test_qgslineburstsymbollayer.py
Expand Up @@ -33,7 +33,9 @@
QgsGradientColorRamp,
QgsGradientStop,
QgsLineSymbol,
QgsLineburstSymbolLayer
QgsLineburstSymbolLayer,
QgsSymbolLayer,
QgsProperty
)
from qgis.testing import unittest, start_app

Expand Down Expand Up @@ -68,6 +70,23 @@ def testTwoColor(self):
rendered_image = self.renderGeometry(s, g)
self.assertTrue(self.imageCheck('lineburst_two_color', 'lineburst_two_color', rendered_image))

def testDataDefinedColors(self):
s = QgsLineSymbol()
s.deleteSymbolLayer(0)

line = QgsLineburstSymbolLayer()
line.setColor(QColor(255, 0, 0))
line.setColor2(QColor(0, 255, 0))
line.setWidth(8)
line.setDataDefinedProperty(QgsSymbolLayer.PropertyStrokeColor, QgsProperty.fromExpression("'orange'"))
line.setDataDefinedProperty(QgsSymbolLayer.PropertySecondaryColor, QgsProperty.fromExpression("'purple'"))

s.appendSymbolLayer(line.clone())

g = QgsGeometry.fromWkt('LineString(0 0, 10 10, 10 0)')
rendered_image = self.renderGeometry(s, g)
self.assertTrue(self.imageCheck('lineburst_datadefined_color', 'lineburst_datadefined_color', rendered_image))

def testColorRamp(self):
s = QgsLineSymbol()
s.deleteSymbolLayer(0)
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ccf5ff0

Please sign in to comment.