Skip to content

Commit

Permalink
Add option to reset plot symbols back to their defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 17, 2023
1 parent d6b6147 commit cebf540
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions python/core/auto_generated/plot/qgsplot.sip.in
Expand Up @@ -427,7 +427,7 @@ Returns the default line symbol to use for axis minor grid lines.
.. seealso:: :py:func:`axisGridMajorSymbol`
%End

static QgsFillSymbol *chartFillSymbol() /Factory/;
static QgsFillSymbol *chartBackgroundSymbol() /Factory/;
%Docstring
Returns the default fill symbol to use for the chart area background fill.

Expand All @@ -438,7 +438,7 @@ Returns the default fill symbol to use for the chart area background fill.
%Docstring
Returns the default fill symbol to use for the chart area border.

.. seealso:: :py:func:`chartFillSymbol`
.. seealso:: :py:func:`chartBackgroundSymbol`
%End

};
Expand Down
4 changes: 2 additions & 2 deletions src/core/plot/qgsplot.cpp
Expand Up @@ -145,7 +145,7 @@ Qgs2DPlot::Qgs2DPlot()
: mMargins( 2, 2, 2, 2 )
{
// setup default style
mChartBackgroundSymbol.reset( QgsPlotDefaultSettings::chartFillSymbol() );
mChartBackgroundSymbol.reset( QgsPlotDefaultSettings::chartBackgroundSymbol() );
mChartBorderSymbol.reset( QgsPlotDefaultSettings::chartBorderSymbol() );
}

Expand Down Expand Up @@ -600,7 +600,7 @@ QgsLineSymbol *QgsPlotDefaultSettings::axisGridMinorSymbol()
return new QgsLineSymbol( QgsSymbolLayerList( { gridMinor.release() } ) );
}

QgsFillSymbol *QgsPlotDefaultSettings::chartFillSymbol()
QgsFillSymbol *QgsPlotDefaultSettings::chartBackgroundSymbol()
{
std::unique_ptr< QgsSimpleFillSymbolLayer > chartFill = std::make_unique< QgsSimpleFillSymbolLayer >( QColor( 255, 255, 255 ) );
return new QgsFillSymbol( QgsSymbolLayerList( { chartFill.release() } ) );
Expand Down
4 changes: 2 additions & 2 deletions src/core/plot/qgsplot.h
Expand Up @@ -485,12 +485,12 @@ class CORE_EXPORT QgsPlotDefaultSettings
*
* \see chartBorderSymbol()
*/
static QgsFillSymbol *chartFillSymbol() SIP_FACTORY;
static QgsFillSymbol *chartBackgroundSymbol() SIP_FACTORY;

/**
* Returns the default fill symbol to use for the chart area border.
*
* \see chartFillSymbol()
* \see chartBackgroundSymbol()
*/
static QgsFillSymbol *chartBorderSymbol() SIP_FACTORY;

Expand Down
6 changes: 6 additions & 0 deletions src/gui/layout/qgslayoutelevationprofilewidget.cpp
Expand Up @@ -96,6 +96,7 @@ QgsLayoutElevationProfileWidget::QgsLayoutElevationProfileWidget( QgsLayoutItemE
mProfile->update();
mProfile->endCommand();
} );
mDistanceAxisMajorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMajorSymbol() );

mDistanceAxisMinorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
connect( mDistanceAxisMinorLinesSymbolButton, &QgsSymbolButton::changed, this, [ = ]
Expand All @@ -108,6 +109,7 @@ QgsLayoutElevationProfileWidget::QgsLayoutElevationProfileWidget( QgsLayoutItemE
mProfile->update();
mProfile->endCommand();
} );
mDistanceAxisMinorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMinorSymbol() );

connect( mDistanceAxisMajorIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
{
Expand Down Expand Up @@ -153,6 +155,7 @@ QgsLayoutElevationProfileWidget::QgsLayoutElevationProfileWidget( QgsLayoutItemE
mProfile->update();
mProfile->endCommand();
} );
mElevationAxisMajorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMajorSymbol() );

mElevationAxisMinorLinesSymbolButton->setSymbolType( Qgis::SymbolType::Line );
connect( mElevationAxisMinorLinesSymbolButton, &QgsSymbolButton::changed, this, [ = ]
Expand All @@ -165,6 +168,7 @@ QgsLayoutElevationProfileWidget::QgsLayoutElevationProfileWidget( QgsLayoutItemE
mProfile->update();
mProfile->endCommand();
} );
mElevationAxisMinorLinesSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::axisGridMinorSymbol() );

connect( mElevationAxisLabelIntervalSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
{
Expand Down Expand Up @@ -210,6 +214,7 @@ QgsLayoutElevationProfileWidget::QgsLayoutElevationProfileWidget( QgsLayoutItemE
mProfile->update();
mProfile->endCommand();
} );
mChartBackgroundSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::chartBackgroundSymbol() );

mChartBorderSymbolButton->setSymbolType( Qgis::SymbolType::Fill );
connect( mChartBorderSymbolButton, &QgsSymbolButton::changed, this, [ = ]
Expand All @@ -222,6 +227,7 @@ QgsLayoutElevationProfileWidget::QgsLayoutElevationProfileWidget( QgsLayoutItemE
mProfile->update();
mProfile->endCommand();
} );
mChartBorderSymbolButton->setDefaultSymbol( QgsPlotDefaultSettings::chartBorderSymbol() );

connect( mDistanceAxisLabelFormatButton, &QPushButton::clicked, this, [ = ]
{
Expand Down

0 comments on commit cebf540

Please sign in to comment.