Skip to content

Commit a380bda

Browse files
committed
Show size assistant for stroke width properties
1 parent 2aae6e4 commit a380bda

11 files changed

+29
-24
lines changed

python/core/qgsproperty.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class QgsPropertyDefinition
2525
Size,
2626
Size2D,
2727
LineStyle,
28+
StrokeWidth,
2829
FillStyle,
2930
CapStyle,
3031
HorizontalAnchor,

src/core/composer/qgscomposerobject.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ void QgsComposerObject::initPropertyDefinitions()
6666
{ QgsComposerObject::SourceUrl, QgsPropertyDefinition( "dataDefinedSourceUrl" , QObject::tr( "Source URL" ), QgsPropertyDefinition::String ) },
6767
{ QgsComposerObject::PictureSvgBackgroundColor, QgsPropertyDefinition( "dataDefinedSvgBackgroundColor" , QObject::tr( "SVG background color" ), QgsPropertyDefinition::ColorWithAlpha ) },
6868
{ QgsComposerObject::PictureSvgOutlineColor, QgsPropertyDefinition( "dataDefinedSvgOutlineColor" , QObject::tr( "SVG outline color" ), QgsPropertyDefinition::ColorWithAlpha ) },
69-
{ QgsComposerObject::PictureSvgOutlineWidth, QgsPropertyDefinition( "dataDefinedSvgOutlineWidth" , QObject::tr( "SVG outline width" ), QgsPropertyDefinition::DoublePositive ) },
69+
{ QgsComposerObject::PictureSvgOutlineWidth, QgsPropertyDefinition( "dataDefinedSvgOutlineWidth" , QObject::tr( "SVG outline width" ), QgsPropertyDefinition::StrokeWidth ) },
7070
{ QgsComposerObject::LegendTitle, QgsPropertyDefinition( "dataDefinedLegendTitle" , QObject::tr( "Legend title" ), QgsPropertyDefinition::String ) },
7171
{ QgsComposerObject::LegendColumnCount, QgsPropertyDefinition( "dataDefinedLegendColumns" , QObject::tr( "Number of columns" ), QgsPropertyDefinition::IntegerPositiveGreaterZero ) },
7272
{ QgsComposerObject::ScalebarFillColor, QgsPropertyDefinition( "dataDefinedScalebarFill" , QObject::tr( "Fill color" ), QgsPropertyDefinition::ColorWithAlpha ) },
7373
{ QgsComposerObject::ScalebarFillColor2, QgsPropertyDefinition( "dataDefinedScalebarFill2" , QObject::tr( "Secondary fill color" ), QgsPropertyDefinition::ColorWithAlpha ) },
7474
{ QgsComposerObject::ScalebarLineColor, QgsPropertyDefinition( "dataDefinedScalebarLineColor" , QObject::tr( "Line color" ), QgsPropertyDefinition::ColorWithAlpha ) },
75-
{ QgsComposerObject::ScalebarLineWidth, QgsPropertyDefinition( "dataDefinedScalebarLineWidth" , QObject::tr( "Line width" ), QgsPropertyDefinition::DoublePositive ) },
75+
{ QgsComposerObject::ScalebarLineWidth, QgsPropertyDefinition( "dataDefinedScalebarLineWidth" , QObject::tr( "Line width" ), QgsPropertyDefinition::StrokeWidth ) },
7676
};
7777
}
7878

src/core/qgsdiagramrenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void QgsDiagramLayerSettings::initPropertyDefinitions()
3636
{
3737
{ QgsDiagramLayerSettings::BackgroundColor, QgsPropertyDefinition( "backgroundColor", QObject::tr( "Background color" ), QgsPropertyDefinition::ColorWithAlpha ) },
3838
{ QgsDiagramLayerSettings::OutlineColor, QgsPropertyDefinition( "outlineColor", QObject::tr( "Outline color" ), QgsPropertyDefinition::ColorWithAlpha ) },
39-
{ QgsDiagramLayerSettings::OutlineWidth, QgsPropertyDefinition( "outlineWidth", QObject::tr( "Outline width" ), QgsPropertyDefinition::DoublePositive ) },
39+
{ QgsDiagramLayerSettings::OutlineWidth, QgsPropertyDefinition( "outlineWidth", QObject::tr( "Outline width" ), QgsPropertyDefinition::StrokeWidth ) },
4040
{ QgsDiagramLayerSettings::PositionX, QgsPropertyDefinition( "positionX", QObject::tr( "Position (X)" ), QgsPropertyDefinition::Double ) },
4141
{ QgsDiagramLayerSettings::PositionY, QgsPropertyDefinition( "positionY", QObject::tr( "Position (Y)" ), QgsPropertyDefinition::Double ) },
4242
{ QgsDiagramLayerSettings::Distance, QgsPropertyDefinition( "distance", QObject::tr( "Placement distance" ), QgsPropertyDefinition::DoublePositive ) },

src/core/qgspallabeling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void QgsPalLayerSettings::initPropertyDefinitions()
151151
{ QgsPalLayerSettings::ShapeBlendMode, QgsPropertyDefinition( "ShapeBlendMode", QObject::tr( "Shape blend mode" ), QgsPropertyDefinition::BlendMode ) },
152152
{ QgsPalLayerSettings::ShapeFillColor, QgsPropertyDefinition( "ShapeFillColor", QObject::tr( "Shape fill color" ), QgsPropertyDefinition::ColorWithAlpha ) },
153153
{ QgsPalLayerSettings::ShapeBorderColor, QgsPropertyDefinition( "ShapeBorderColor", QObject::tr( "Shape border color" ), QgsPropertyDefinition::ColorWithAlpha ) },
154-
{ QgsPalLayerSettings::ShapeBorderWidth, QgsPropertyDefinition( "ShapeBorderWidth", QObject::tr( "Shape border width" ), QgsPropertyDefinition::DoublePositive ) },
154+
{ QgsPalLayerSettings::ShapeBorderWidth, QgsPropertyDefinition( "ShapeBorderWidth", QObject::tr( "Shape border width" ), QgsPropertyDefinition::StrokeWidth ) },
155155
{ QgsPalLayerSettings::ShapeBorderWidthUnits, QgsPropertyDefinition( "ShapeBorderWidthUnits", QObject::tr( "Shape border width units" ), QgsPropertyDefinition::RenderUnits ) },
156156
{ QgsPalLayerSettings::ShapeJoinStyle, QgsPropertyDefinition( "ShapeJoinStyle", QObject::tr( "Shape join style" ), QgsPropertyDefinition::PenJoinStyle ) },
157157
{ QgsPalLayerSettings::ShadowDraw, QgsPropertyDefinition( "ShadowDraw", QObject::tr( "Draw shadow" ), QgsPropertyDefinition::Boolean ) },

src/core/qgsproperty.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ QgsPropertyDefinition::QgsPropertyDefinition( const QString& name, const QString
126126
mHelpText = trString() + QLatin1String( "[<b>no</b>|<b>solid</b>|<b>dash</b>|<b>dot</b>|<b>dash dot</b>|<b>dash dot dot</b>]" );
127127
break;
128128

129+
case StrokeWidth:
130+
mTypes = DataTypeNumeric;
131+
mHelpText = QObject::tr( "double [&gt;= 0.0]" );
132+
break;
133+
129134
case FillStyle:
130135
mTypes = DataTypeString;
131136
mHelpText = trString() + QLatin1String( "[<b>solid</b>|<b>horizontal</b>|<b>vertical</b>|<b>cross</b>|<b>b_diagonal</b>|<b>f_diagonal"

src/core/qgsproperty.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class CORE_EXPORT QgsPropertyDefinition
6767
Size, //!< 1D size (eg marker radius, or square marker height/width)
6868
Size2D, //!< 2D size (width/height different)
6969
LineStyle, //!< Line style (eg solid/dashed)
70+
StrokeWidth, //!< Line stroke width
7071
FillStyle, //!< Fill style (eg solid, lines)
7172
CapStyle, //!< Line cap style (eg round)
7273
HorizontalAnchor, //!< Horizontal anchor point

src/core/symbology-ng/qgssymbollayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void QgsSymbolLayer::initPropertyDefinitions()
4545
{ QgsSymbolLayer::PropertyName, QgsPropertyDefinition( "name", QObject::tr( "Symbol name" ), QgsPropertyDefinition::String ) },
4646
{ QgsSymbolLayer::PropertyFillColor, QgsPropertyDefinition( "fillColor", QObject::tr( "Symbol fill color" ), QgsPropertyDefinition::ColorWithAlpha ) },
4747
{ QgsSymbolLayer::PropertyOutlineColor, QgsPropertyDefinition( "outlineColor", QObject::tr( "Symbol outline color" ), QgsPropertyDefinition::ColorWithAlpha ) },
48-
{ QgsSymbolLayer::PropertyOutlineWidth, QgsPropertyDefinition( "outlineWidth", QObject::tr( "Symbol outline width" ), QgsPropertyDefinition::DoublePositive ) },
48+
{ QgsSymbolLayer::PropertyOutlineWidth, QgsPropertyDefinition( "outlineWidth", QObject::tr( "Symbol outline width" ), QgsPropertyDefinition::StrokeWidth ) },
4949
{ QgsSymbolLayer::PropertyOutlineStyle, QgsPropertyDefinition( "outlineStyle", QObject::tr( "Symbol outline style" ), QgsPropertyDefinition::LineStyle )},
5050
{ QgsSymbolLayer::PropertyOffset, QgsPropertyDefinition( "offset", QObject::tr( "Symbol offset" ), QgsPropertyDefinition::Offset )},
5151
{ QgsSymbolLayer::PropertyCharacter, QgsPropertyDefinition( "char", QObject::tr( "Marker character(s)" ), QgsPropertyDefinition::String )},

src/gui/qgspropertyassistantwidget.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ QgsPropertyAssistantWidget::QgsPropertyAssistantWidget( QWidget* parent ,
6868
switch ( definition.standardTemplate() )
6969
{
7070
case QgsPropertyDefinition::Size:
71+
case QgsPropertyDefinition::StrokeWidth:
7172
{
7273
mTransformerWidget = new QgsPropertySizeAssistantWidget( this, mDefinition, initialState );
7374
}
@@ -266,10 +267,18 @@ QgsPropertySizeAssistantWidget::QgsPropertySizeAssistantWidget( QWidget* parent,
266267
layout()->setContentsMargins( 0, 0, 0, 0 );
267268
layout()->setMargin( 0 );
268269

269-
scaleMethodComboBox->addItem( tr( "Flannery" ), QgsSizeScaleTransformer::Flannery );
270-
scaleMethodComboBox->addItem( tr( "Surface" ), QgsSizeScaleTransformer::Area );
271-
scaleMethodComboBox->addItem( tr( "Radius" ), QgsSizeScaleTransformer::Linear );
272-
scaleMethodComboBox->addItem( tr( "Exponential" ), QgsSizeScaleTransformer::Exponential );
270+
if ( definition.standardTemplate() == QgsPropertyDefinition::Size )
271+
{
272+
scaleMethodComboBox->addItem( tr( "Flannery" ), QgsSizeScaleTransformer::Flannery );
273+
scaleMethodComboBox->addItem( tr( "Surface" ), QgsSizeScaleTransformer::Area );
274+
scaleMethodComboBox->addItem( tr( "Radius" ), QgsSizeScaleTransformer::Linear );
275+
scaleMethodComboBox->addItem( tr( "Exponential" ), QgsSizeScaleTransformer::Exponential );
276+
}
277+
else if ( definition.standardTemplate() == QgsPropertyDefinition::StrokeWidth )
278+
{
279+
scaleMethodComboBox->addItem( tr( "Exponential" ), QgsSizeScaleTransformer::Exponential );
280+
scaleMethodComboBox->addItem( tr( "Linear" ), QgsSizeScaleTransformer::Linear );
281+
}
273282

274283
minSizeSpinBox->setShowClearButton( false );
275284
maxSizeSpinBox->setShowClearButton( false );

src/gui/symbology-ng/qgssymbollayerwidget.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,10 @@ QgsSimpleLineSymbolLayerWidget::QgsSimpleLineSymbolLayerWidget( const QgsVectorL
151151
}
152152

153153
//make a temporary symbol for the size assistant preview
154-
mAssistantPreviewSymbol = new QgsLineSymbol();
154+
mAssistantPreviewSymbol.reset( new QgsLineSymbol() );
155155

156-
#if 0
157156
if ( vectorLayer() )
158-
mPenWidthDDBtn->setAssistant( tr( "Width Assistant..." ), new QgsSizeScaleWidget( vectorLayer(), mAssistantPreviewSymbol ) );
159-
#endif
157+
mPenWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
160158

161159
connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( penWidthChanged() ) );
162160
connect( btnChangeColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( colorChanged( const QColor& ) ) );
@@ -170,11 +168,6 @@ QgsSimpleLineSymbolLayerWidget::QgsSimpleLineSymbolLayerWidget( const QgsVectorL
170168
connect( this, SIGNAL( changed() ), this, SLOT( updateAssistantSymbol() ) );
171169
}
172170

173-
QgsSimpleLineSymbolLayerWidget::~QgsSimpleLineSymbolLayerWidget()
174-
{
175-
delete mAssistantPreviewSymbol;
176-
}
177-
178171
void QgsSimpleLineSymbolLayerWidget::updateAssistantSymbol()
179172
{
180173
for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )

src/gui/symbology-ng/qgssymbollayerwidget.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ class GUI_EXPORT QgsSimpleLineSymbolLayerWidget : public QgsSymbolLayerWidget, p
117117
public:
118118
QgsSimpleLineSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
119119

120-
~QgsSimpleLineSymbolLayerWidget();
121-
122120
static QgsSymbolLayerWidget* create( const QgsVectorLayer* vl ) { return new QgsSimpleLineSymbolLayerWidget( vl ); }
123121

124122
// from base class
@@ -149,7 +147,7 @@ class GUI_EXPORT QgsSimpleLineSymbolLayerWidget : public QgsSymbolLayerWidget, p
149147

150148
private:
151149

152-
QgsLineSymbol* mAssistantPreviewSymbol;
150+
std::shared_ptr< QgsLineSymbol > mAssistantPreviewSymbol;
153151

154152
};
155153

src/gui/symbology-ng/qgssymbolslistwidget.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,8 @@ void QgsSymbolsListWidget::updateAssistantSymbol()
371371
mAssistantSymbol.reset( mSymbol->clone() );
372372
if ( mSymbol->type() == QgsSymbol::Marker )
373373
mSizeDDBtn->setSymbol( mAssistantSymbol );
374-
#if 0
375374
else if ( mSymbol->type() == QgsSymbol::Line && mLayer )
376-
mWidthDDBtn->setAssistant( tr( "Width Assistant..." ), new QgsSizeScaleWidget( mLayer, mSymbol ) );
377-
#endif
375+
mWidthDDBtn->setSymbol( mAssistantSymbol );
378376
}
379377

380378
void QgsSymbolsListWidget::symbolAddedToStyle( const QString& name, QgsSymbol* symbol )

0 commit comments

Comments
 (0)