Skip to content
Permalink
Browse files
Add effect widget for group layers
  • Loading branch information
nyalldawson committed Nov 25, 2021
1 parent e04e20c commit f3a1eff52fd13f7f63e0df5710b64e9d1bc530f4
Showing with 39 additions and 15 deletions.
  1. +5 −4 src/app/qgslayertreegrouppropertieswidget.cpp
  2. +5 −1 src/core/qgsgrouplayer.cpp
  3. +1 −1 src/core/qgsgrouplayerrenderer.cpp
  4. +28 −9 src/ui/qgslayertreegrouppropertieswidgetbase.ui
@@ -20,6 +20,7 @@
#include "qgsgui.h"
#include "qgspainteffect.h"
#include "qgsmapcanvas.h"
#include "qgspainteffectregistry.h"

#include <QStackedWidget>
#include <QHBoxLayout>
@@ -32,7 +33,7 @@ QgsLayerTreeGroupPropertiesWidget::QgsLayerTreeGroupPropertiesWidget( QgsMapCanv

connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsLayerTreeGroupPropertiesWidget::onLayerPropertyChanged );
connect( mBlendModeComboBox, qOverload< int >( &QgsBlendModeComboBox::currentIndexChanged ), this, &QgsLayerTreeGroupPropertiesWidget::onLayerPropertyChanged );
// connect( mEffectWidget, &QgsEffectStackCompactWidget::changed, this, &QgsLayerTreeGroupPropertiesWidget::onLayerPropertyChanged );
connect( mEffectWidget, &QgsEffectStackCompactWidget::changed, this, &QgsLayerTreeGroupPropertiesWidget::onLayerPropertyChanged );
connect( mRenderAsGroupCheckBox, &QGroupBox::toggled, this, &QgsLayerTreeGroupPropertiesWidget::onLayerPropertyChanged );

setDockMode( true );
@@ -58,7 +59,7 @@ void QgsLayerTreeGroupPropertiesWidget::setMapLayerConfigWidgetContext( const Qg
if ( groupLayer->paintEffect() )
{
mPaintEffect.reset( groupLayer->paintEffect()->clone() );
//mEffectWidget->setPaintEffect( mPaintEffect.get() );
mEffectWidget->setPaintEffect( mPaintEffect.get() );
}
}
else
@@ -97,8 +98,8 @@ void QgsLayerTreeGroupPropertiesWidget::apply()
// set the blend mode and opacity for the layer
groupLayer->setBlendMode( mBlendModeComboBox->blendMode() );
groupLayer->setOpacity( mOpacityWidget->opacity() );
if ( mPaintEffect )
groupLayer->setPaintEffect( mPaintEffect->clone() );
groupLayer->setPaintEffect( mPaintEffect->clone() );

groupLayer->triggerRepaint();
}
else if ( mMapLayerConfigWidgetContext.mapCanvas() )
@@ -35,6 +35,9 @@ QgsGroupLayer::QgsGroupLayer( const QString &name, const LayerOptions &options )
mShouldValidateCrs = false;
mValid = true;

mPaintEffect.reset( QgsPaintEffectRegistry::defaultStack() );
mPaintEffect->setEnabled( false );

QgsDataProvider::ProviderOptions providerOptions;
providerOptions.transformContext = options.transformContext;
mDataProvider = new QgsGroupLayerDataProvider( providerOptions, QgsDataProvider::ReadFlags() );
@@ -224,7 +227,8 @@ bool QgsGroupLayer::readSymbology( const QDomNode &node, QString &, QgsReadWrite
}
else
{
mPaintEffect.reset();
mPaintEffect.reset( QgsPaintEffectRegistry::defaultStack() );
mPaintEffect->setEnabled( false );
}
}

@@ -54,7 +54,7 @@ QgsGroupLayerRenderer::QgsGroupLayerRenderer( QgsGroupLayer *layer, QgsRenderCon
mTransforms.emplace_back( layerToDestTransform );
}

mPaintEffect.reset( layer->paintEffect() ? layer->paintEffect()->clone() : nullptr );
mPaintEffect.reset( layer->paintEffect() && layer->paintEffect()->enabled() ? layer->paintEffect()->clone() : nullptr );

mForceRasterRender = layer->blendMode() != QPainter::CompositionMode_SourceOver;
}
@@ -35,6 +35,16 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="2">
<widget class="QgsBlendModeComboBox" name="mBlendModeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>4</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblTransparency">
<property name="text">
@@ -49,18 +59,21 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QgsBlendModeComboBox" name="mBlendModeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>4</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="0" column="2">
<widget class="QgsOpacityWidget" name="mOpacityWidget" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QgsOpacityWidget" name="mOpacityWidget" native="true">
<item row="2" column="0" colspan="3">
<widget class="QgsEffectStackCompactWidget" name="mEffectWidget" native="true">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
@@ -90,6 +103,12 @@
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsEffectStackCompactWidget</class>
<extends>QWidget</extends>
<header>qgseffectstackpropertieswidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsOpacityWidget</class>
<extends>QWidget</extends>

0 comments on commit f3a1eff

Please sign in to comment.