Skip to content

Commit

Permalink
Fix style dock forgets expanded state of rendering group (fix #14864)
Browse files Browse the repository at this point in the history
Also fix a memory leak
  • Loading branch information
nyalldawson committed Jun 9, 2016
1 parent cb4dacf commit 31c572f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 12 deletions.
11 changes: 10 additions & 1 deletion python/gui/symbology-ng/qgsrendererv2propertiesdialog.sip
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ class QgsRendererV2PropertiesDialog : QDialog
%End

public:
QgsRendererV2PropertiesDialog( QgsVectorLayer* layer, QgsStyleV2* style, bool embedded = false );

/** Constructor for QgsRendererV2PropertiesDialog.
* @param layer associated layer
* @param style style collection
* @param embedded set to true to indicate that the dialog will be embedded in another widget, rather
* than shown as a dialog by itself
* @param parent parent widget
*/
QgsRendererV2PropertiesDialog( QgsVectorLayer* layer, QgsStyleV2* style, bool embedded = false, QWidget* parent /TransferThis/ = nullptr );

~QgsRendererV2PropertiesDialog();

/** Sets the map canvas associated with the dialog. This allows the widget to retrieve the current
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsmapstylingwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ void QgsMapStylingWidget::updateCurrentWidgetLayer()
{
case 0: // Style
{
mVectorStyleWidget = new QgsRendererV2PropertiesDialog( vlayer, QgsStyleV2::defaultStyle(), true );
mVectorStyleWidget->deleteLater();
mVectorStyleWidget = new QgsRendererV2PropertiesDialog( vlayer, QgsStyleV2::defaultStyle(), true, mWidgetArea );
connect( mVectorStyleWidget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) );
mWidgetArea->setWidget( mVectorStyleWidget );
break;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ void QgsVectorLayerProperties::updateSymbologyPage()

if ( mLayer->rendererV2() )
{
mRendererDialog = new QgsRendererV2PropertiesDialog( mLayer, QgsStyleV2::defaultStyle(), true );
mRendererDialog = new QgsRendererV2PropertiesDialog( mLayer, QgsStyleV2::defaultStyle(), true, this );
mRendererDialog->setMapCanvas( QgisApp::instance()->mapCanvas() );

connect( mRendererDialog, SIGNAL( layerVariablesChanged() ), this, SLOT( updateVariableEditor() ) );
Expand Down
8 changes: 5 additions & 3 deletions src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,16 @@ static void _initRendererWidgetFunctions()
initialized = true;
}

QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog( QgsVectorLayer* layer, QgsStyleV2* style, bool embedded )
: mLayer( layer )
QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog( QgsVectorLayer* layer, QgsStyleV2* style, bool embedded, QWidget* parent )
: QDialog( parent )
, mLayer( layer )
, mStyle( style )
, mActiveWidget( nullptr )
, mPaintEffect( nullptr )
, mMapCanvas( nullptr )
{
setupUi( this );
mLayerRenderingGroupBox->setSettingGroup( "layerRenderingGroupBox" );

// can be embedded in vector layer properties
if ( embedded )
Expand Down Expand Up @@ -378,7 +380,7 @@ void QgsRendererV2PropertiesDialog::changeOrderBy( const QgsFeatureRequest::Orde

void QgsRendererV2PropertiesDialog::updateUIState( bool hidden )
{
groupBox->setHidden( hidden );
mLayerRenderingGroupBox->setHidden( hidden );
cboRenderers->setHidden( hidden );
}

Expand Down
10 changes: 9 additions & 1 deletion src/gui/symbology-ng/qgsrendererv2propertiesdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ class GUI_EXPORT QgsRendererV2PropertiesDialog : public QDialog, private Ui::Qgs
Q_OBJECT

public:
QgsRendererV2PropertiesDialog( QgsVectorLayer* layer, QgsStyleV2* style, bool embedded = false );

/** Constructor for QgsRendererV2PropertiesDialog.
* @param layer associated layer
* @param style style collection
* @param embedded set to true to indicate that the dialog will be embedded in another widget, rather
* than shown as a dialog by itself
* @param parent parent widget
*/
QgsRendererV2PropertiesDialog( QgsVectorLayer* layer, QgsStyleV2* style, bool embedded = false, QWidget* parent = nullptr );
~QgsRendererV2PropertiesDialog();

/** Sets the map canvas associated with the dialog. This allows the widget to retrieve the current
Expand Down
37 changes: 32 additions & 5 deletions src/ui/qgsrendererv2propsdialogbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,40 @@
<rect>
<x>0</x>
<y>0</y>
<width>354</width>
<width>370</width>
<height>501</height>
</rect>
</property>
<property name="windowTitle">
<string>Renderer settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="margin">
<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>
<item>
<widget class="QStackedWidget" name="mainStack">
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<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>
<item>
Expand Down Expand Up @@ -49,7 +67,16 @@
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<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>
<item>
Expand All @@ -64,7 +91,7 @@
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="groupBox">
<widget class="QgsCollapsibleGroupBox" name="mLayerRenderingGroupBox">
<property name="title">
<string>Layer rendering</string>
</property>
Expand Down

0 comments on commit 31c572f

Please sign in to comment.