diff --git a/python/gui/auto_generated/symbology/qgsrendererwidget.sip.in b/python/gui/auto_generated/symbology/qgsrendererwidget.sip.in index a3358def554..b160a21d754 100644 --- a/python/gui/auto_generated/symbology/qgsrendererwidget.sip.in +++ b/python/gui/auto_generated/symbology/qgsrendererwidget.sip.in @@ -76,6 +76,11 @@ This method should be called whenever the renderer is actually set on the layer. Emitted when expression context variables on the associated vector layers have been changed. Will request the parent dialog to re-synchronize with the variables. +%End + + void symbolLevelsChanged(); +%Docstring +Emitted when the symbol levels settings have been changed. %End protected: diff --git a/python/gui/auto_generated/symbology/qgssymbolselectordialog.sip.in b/python/gui/auto_generated/symbology/qgssymbolselectordialog.sip.in index e3b28f8b623..cf7245ec7cf 100644 --- a/python/gui/auto_generated/symbology/qgssymbolselectordialog.sip.in +++ b/python/gui/auto_generated/symbology/qgssymbolselectordialog.sip.in @@ -71,6 +71,7 @@ Returns the symbol that is currently active in the widget. Can be ``None``. :return: The active symbol. %End + protected: void loadSymbol(); @@ -78,7 +79,6 @@ Returns the symbol that is currently active in the widget. Can be ``None``. Reload the current symbol in the view. %End - void updateUi(); %Docstring Update the state of the UI based on the currently set symbol layer. diff --git a/src/gui/symbology/qgsrendererwidget.cpp b/src/gui/symbology/qgsrendererwidget.cpp index c2a1ed99e2a..640837a4346 100644 --- a/src/gui/symbology/qgsrendererwidget.cpp +++ b/src/gui/symbology/qgsrendererwidget.cpp @@ -320,7 +320,7 @@ void QgsRendererWidget::showSymbolLevelsDialog( QgsFeatureRenderer *r ) QgsSymbolLevelsWidget *widget = new QgsSymbolLevelsWidget( r, r->usingSymbolLevels(), panel ); widget->setPanelTitle( tr( "Symbol Levels" ) ); connect( widget, &QgsPanelWidget::widgetChanged, widget, &QgsSymbolLevelsWidget::apply ); - connect( widget, &QgsPanelWidget::widgetChanged, this, &QgsPanelWidget::widgetChanged ); + connect( widget, &QgsPanelWidget::widgetChanged, [ = ]() { emit widgetChanged(); emit symbolLevelsChanged(); } ); panel->openPanel( widget ); return; } @@ -329,6 +329,7 @@ void QgsRendererWidget::showSymbolLevelsDialog( QgsFeatureRenderer *r ) if ( dlg.exec() ) { emit widgetChanged(); + emit symbolLevelsChanged(); } } diff --git a/src/gui/symbology/qgsrendererwidget.h b/src/gui/symbology/qgsrendererwidget.h index 1d815f19c15..9db86ea9fa8 100644 --- a/src/gui/symbology/qgsrendererwidget.h +++ b/src/gui/symbology/qgsrendererwidget.h @@ -88,6 +88,11 @@ class GUI_EXPORT QgsRendererWidget : public QgsPanelWidget */ void layerVariablesChanged(); + /** + * Emitted when the symbol levels settings have been changed. + */ + void symbolLevelsChanged(); + protected: QgsVectorLayer *mLayer = nullptr; QgsStyle *mStyle = nullptr; diff --git a/src/gui/symbology/qgssinglesymbolrendererwidget.cpp b/src/gui/symbology/qgssinglesymbolrendererwidget.cpp index 14f736fcaa8..45d448f85e6 100644 --- a/src/gui/symbology/qgssinglesymbolrendererwidget.cpp +++ b/src/gui/symbology/qgssinglesymbolrendererwidget.cpp @@ -57,6 +57,12 @@ QgsSingleSymbolRendererWidget::QgsSingleSymbolRendererWidget( QgsVectorLayer *la mSelector = new QgsSymbolSelectorWidget( mSingleSymbol, mStyle, mLayer, nullptr ); connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, &QgsSingleSymbolRendererWidget::changeSingleSymbol ); connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel ); + connect( this, &QgsRendererWidget::symbolLevelsChanged, [ = ]() + { + delete mSingleSymbol; + mSingleSymbol = mRenderer->symbol()->clone(); + mSelector->loadSymbol( mSingleSymbol ); + } ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setContentsMargins( 0, 0, 0, 0 ); diff --git a/src/gui/symbology/qgssymbolselectordialog.cpp b/src/gui/symbology/qgssymbolselectordialog.cpp index e661229e25a..99a80df14b6 100644 --- a/src/gui/symbology/qgssymbolselectordialog.cpp +++ b/src/gui/symbology/qgssymbolselectordialog.cpp @@ -385,6 +385,13 @@ QgsSymbolWidgetContext QgsSymbolSelectorWidget::context() const void QgsSymbolSelectorWidget::loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent ) { + if ( !parent ) + { + mSymbol = symbol; + model->clear(); + parent = static_cast( model->invisibleRootItem() ); + } + SymbolLayerItem *symbolItem = new SymbolLayerItem( symbol ); QFont boldFont = symbolItem->font(); boldFont.setBold( true ); diff --git a/src/gui/symbology/qgssymbolselectordialog.h b/src/gui/symbology/qgssymbolselectordialog.h index 96bb740f58a..dd55c1f4053 100644 --- a/src/gui/symbology/qgssymbolselectordialog.h +++ b/src/gui/symbology/qgssymbolselectordialog.h @@ -127,6 +127,14 @@ class GUI_EXPORT QgsSymbolSelectorWidget: public QgsPanelWidget, private Ui::Qgs */ QgsSymbol *symbol() { return mSymbol; } + /** + * Load the given symbol into the widget. + * \param symbol The symbol to load. + * \param parent The parent symbol layer item. If the parent parameter is null, the whole symbol and model will be reset. + * \note not available in Python bindings + */ + void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP; + protected: /** @@ -134,14 +142,6 @@ class GUI_EXPORT QgsSymbolSelectorWidget: public QgsPanelWidget, private Ui::Qgs */ void loadSymbol(); - /** - * Load the given symbol into the widget. - * \param symbol The symbol to load. - * \param parent The parent symbol layer item. - * \note not available in Python bindings - */ - void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent ) SIP_SKIP; - /** * Update the state of the UI based on the currently set symbol layer. */