Skip to content

Commit be2cbe8

Browse files
committed
Fix the labeling dialog when opened from toolbar in main window
This code has been funded by Tuscany Region (Italy) - SITA (CIG: 63526840AE) and commissioned to Gis3W s.a.s.
1 parent b088220 commit be2cbe8

1 file changed

Lines changed: 15 additions & 19 deletions

File tree

‎src/app/qgisapp.cpp‎

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
#include "qgscustomprojectiondialog.h"
123123
#include "qgsdatasourceuri.h"
124124
#include "qgsdatumtransformdialog.h"
125+
#include "qgsdoublespinbox.h"
125126
#include "qgsdxfexport.h"
126127
#include "qgsdxfexportdialog.h"
127128
#include "qgsdecorationcopyright.h"
@@ -140,7 +141,7 @@
140141
#include "qgsgenericprojectionselector.h"
141142
#include "qgsgpsinformationwidget.h"
142143
#include "qgsguivectorlayertools.h"
143-
#include "qgslabelinggui.h"
144+
#include "qgslabelingwidget.h"
144145
#include "qgslayerdefinition.h"
145146
#include "qgslayertree.h"
146147
#include "qgslayertreemapcanvasbridge.h"
@@ -5176,34 +5177,31 @@ void QgisApp::labeling()
51765177
}
51775178

51785179

5179-
QDialog *dlg = new QDialog( this );
5180-
dlg->setWindowTitle( tr( "Layer labeling settings" ) );
5181-
QgsLabelingGui *labelingGui = new QgsLabelingGui( vlayer, mMapCanvas, 0, dlg );
5182-
labelingGui->init(); // load QgsPalLayerSettings for layer
5180+
QDialog dlg;
5181+
dlg.setWindowTitle( tr( "Layer labeling settings" ) );
5182+
QgsLabelingWidget *labelingGui = new QgsLabelingWidget( vlayer, mMapCanvas, &dlg );
51835183
labelingGui->layout()->setContentsMargins( 0, 0, 0, 0 );
5184-
QVBoxLayout *layout = new QVBoxLayout( dlg );
5184+
QVBoxLayout *layout = new QVBoxLayout( &dlg );
51855185
layout->addWidget( labelingGui );
51865186

5187-
QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply, Qt::Horizontal, dlg );
5187+
QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply, Qt::Horizontal, &dlg );
51885188
layout->addWidget( buttonBox );
5189+
layout->setContentsMargins( 0, 0, 0, 0 );
51895190

5190-
dlg->setLayout( layout );
5191+
dlg.setLayout( layout );
51915192

51925193
QSettings settings;
5193-
dlg->restoreGeometry( settings.value( "/Windows/Labeling/geometry" ).toByteArray() );
5194+
dlg.restoreGeometry( settings.value( "/Windows/Labeling/geometry" ).toByteArray() );
51945195

5195-
connect( buttonBox->button( QDialogButtonBox::Ok ), SIGNAL( clicked() ), dlg, SLOT( accept() ) );
5196-
connect( buttonBox->button( QDialogButtonBox::Cancel ), SIGNAL( clicked() ), dlg, SLOT( reject() ) );
5196+
connect( buttonBox->button( QDialogButtonBox::Ok ), SIGNAL( clicked() ), &dlg, SLOT( accept() ) );
5197+
connect( buttonBox->button( QDialogButtonBox::Cancel ), SIGNAL( clicked() ), &dlg, SLOT( reject() ) );
51975198
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), labelingGui, SLOT( apply() ) );
51985199

5199-
if ( dlg->exec() )
5200+
if ( dlg.exec() )
52005201
{
5201-
labelingGui->apply();
5202-
5203-
settings.setValue( "/Windows/Labeling/geometry", dlg->saveGeometry() );
5202+
labelingGui->writeSettingsToLayer();
52045203

5205-
// alter labeling - save the changes
5206-
labelingGui->layerSettings().writeToLayer( vlayer );
5204+
settings.setValue( "/Windows/Labeling/geometry", dlg.saveGeometry() );
52075205

52085206
// trigger refresh
52095207
if ( mMapCanvas )
@@ -5212,8 +5210,6 @@ void QgisApp::labeling()
52125210
}
52135211
}
52145212

5215-
delete dlg;
5216-
52175213
activateDeactivateLayerRelatedActions( vlayer );
52185214
}
52195215

0 commit comments

Comments
 (0)