Skip to content

Commit

Permalink
Defer mask source widget population (fixes #34942)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and nyalldawson committed Apr 9, 2020
1 parent 5531b2c commit acdf279
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 37 deletions.
19 changes: 18 additions & 1 deletion src/app/qgsmaskingwidget.cpp
Expand Up @@ -14,6 +14,7 @@
***************************************************************************/

#include <QSet>
#include <QCheckBox>

#include "qgsmaskingwidget.h"
#include "qgsmasksourceselectionwidget.h"
Expand Down Expand Up @@ -43,6 +44,14 @@ QgsMaskingWidget::QgsMaskingWidget( QWidget *parent ) :
{
emit widgetChanged();
} );

connect( mEditMaskSettingsGroup, &QGroupBox::toggled, this, [&]( bool on )
{
if ( on && mLayer )
{
populate();
}
} );
}

/**
Expand Down Expand Up @@ -128,8 +137,16 @@ QList<QPair<QgsSymbolLayerId, QList<QgsSymbolLayerReference>>> symbolLayerMasks(
void QgsMaskingWidget::setLayer( QgsVectorLayer *layer )
{
mLayer = layer;
if ( mEditMaskSettingsGroup->isChecked() )
{
populate();
}
}

void QgsMaskingWidget::populate()
{
mMaskSourcesWidget->update();
mMaskTargetsWidget->setLayer( layer );
mMaskTargetsWidget->setLayer( mLayer );

// collect masks and filter on those which have the current layer as destination
QSet<QgsSymbolLayerId> maskedSymbolLayers;
Expand Down
4 changes: 3 additions & 1 deletion src/app/qgsmaskingwidget.h
Expand Up @@ -35,7 +35,9 @@ class QgsMaskingWidget: public QgsPanelWidget, private Ui::QgsMaskingWidgetBase
signals:
void widgetChanged();
private:
QgsVectorLayer *mLayer;
QgsVectorLayer *mLayer = nullptr;
//! Populate the mask source and target widgets
void populate();
};

#endif
1 change: 1 addition & 0 deletions src/app/qgsmasksourceselectionwidget.cpp
Expand Up @@ -63,6 +63,7 @@ QgsMaskSourceSelectionWidget::QgsMaskSourceSelectionWidget( QWidget *parent )

// place the tree in a layout
QVBoxLayout *vbox = new QVBoxLayout();
vbox->setContentsMargins( 0, 0, 0, 0 );
vbox->addWidget( mTree );

setLayout( vbox );
Expand Down
1 change: 1 addition & 0 deletions src/app/qgssymbollayerselectionwidget.cpp
Expand Up @@ -37,6 +37,7 @@ QgsSymbolLayerSelectionWidget::QgsSymbolLayerSelectionWidget( QWidget *parent )

// place the tree in a layout
QVBoxLayout *vbox = new QVBoxLayout();
vbox->setContentsMargins( 0, 0, 0, 0 );
vbox->addWidget( mTree );

setLayout( vbox );
Expand Down
73 changes: 38 additions & 35 deletions src/ui/qgsmaskingwidgetbase.ui
Expand Up @@ -6,51 +6,54 @@
<rect>
<x>0</x>
<y>0</y>
<width>637</width>
<height>409</height>
<width>863</width>
<height>461</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Masked symbol layers</string>
<widget class="QGroupBox" name="mEditMaskSettingsGroup">
<property name="title">
<string>Edit mask settings</string>
</property>
</widget>
</item>
<item>
<widget class="QgsSymbolLayerSelectionWidget" name="mMaskTargetsWidget" native="true"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Mask sources</string>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QgsMaskSourceSelectionWidget" name="mMaskSourcesWidget" native="true">
<property name="enabled">
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>9</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Masked symbol layers</string>
</property>
</widget>
</item>
<item>
<widget class="QgsSymbolLayerSelectionWidget" name="mMaskTargetsWidget" native="true"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Mask sources</string>
</property>
</widget>
</item>
<item>
<widget class="QgsMaskSourceSelectionWidget" name="mMaskSourcesWidget" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
Expand Down

0 comments on commit acdf279

Please sign in to comment.