Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer mask source widget population (fixes #34942) #35557

Merged
merged 1 commit into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/gui/qgsmaskingwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
***************************************************************************/

#include <QSet>
#include <QCheckBox>

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

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

/**
Expand Down Expand Up @@ -133,8 +142,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/gui/qgsmaskingwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ class GUI_EXPORT QgsMaskingWidget: public QgsPanelWidget, private Ui::QgsMasking
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/gui/qgsmasksourceselectionwidget.cpp
Original file line number Diff line number Diff line change
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/gui/qgssymbollayerselectionwidget.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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