Skip to content

Commit 80d645d

Browse files
committed
fix #6446
1 parent 99876cc commit 80d645d

File tree

1 file changed

+51
-24
lines changed

1 file changed

+51
-24
lines changed

src/app/qgsvectorlayerproperties.cpp

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,30 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
105105

106106
connect( btnUseNewSymbology, SIGNAL( clicked() ), this, SLOT( useNewSymbology() ) );
107107

108-
QVBoxLayout *layout = new QVBoxLayout( labelingFrame );
109-
layout->setMargin( 0 );
110-
labelingDialog = new QgsLabelingGui( QgisApp::instance()->palLabeling(), layer, QgisApp::instance()->mapCanvas(), labelingFrame );
111-
layout->addWidget( labelingDialog );
112-
labelingFrame->setLayout( layout );
113-
114-
// Create the Label dialog tab
115-
layout = new QVBoxLayout( labelOptionsFrame );
116-
layout->setMargin( 0 );
117-
labelDialog = new QgsLabelDialog( layer->label(), labelOptionsFrame );
118-
layout->addWidget( labelDialog );
119-
labelOptionsFrame->setLayout( layout );
120-
connect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) );
108+
QVBoxLayout *layout;
109+
110+
if ( layer->hasGeometryType() )
111+
{
112+
// Create the Labeling dialog tab
113+
layout= new QVBoxLayout( labelingFrame );
114+
layout->setMargin( 0 );
115+
labelingDialog = new QgsLabelingGui( QgisApp::instance()->palLabeling(), layer, QgisApp::instance()->mapCanvas(), labelingFrame );
116+
layout->addWidget( labelingDialog );
117+
labelingFrame->setLayout( layout );
118+
119+
// Create the Labeling (deprecated) dialog tab
120+
layout = new QVBoxLayout( labelOptionsFrame );
121+
layout->setMargin( 0 );
122+
labelDialog = new QgsLabelDialog( layer->label(), labelOptionsFrame );
123+
layout->addWidget( labelDialog );
124+
labelOptionsFrame->setLayout( layout );
125+
connect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) );
126+
}
127+
else
128+
{
129+
tabWidget->setTabEnabled( 1, false ); // hide labeling item
130+
tabWidget->setTabEnabled( 2, false ); // hide labeling (deprecated) item
131+
}
121132

122133
// Create the Actions dialog tab
123134
QVBoxLayout *actionLayout = new QVBoxLayout( actionOptionsFrame );
@@ -202,19 +213,35 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
202213
mLayerAbstractTextEdit->setPlainText( layer->abstract() );
203214
}
204215

205-
tabWidget->setCurrentIndex( 0 );
206-
207216
QSettings settings;
208217
restoreGeometry( settings.value( "/Windows/VectorLayerProperties/geometry" ).toByteArray() );
209-
tabWidget->setCurrentIndex( settings.value( "/Windows/VectorLayerProperties/row" ).toInt() );
218+
int tabIndex = settings.value( "/Windows/VectorLayerProperties/row", 0 ).toInt();
219+
220+
// if the last used tab is not enabled display the first enabled one
221+
if ( !tabWidget->isTabEnabled( tabIndex ) )
222+
{
223+
tabIndex = 0;
224+
for ( int i = 0; i < tabWidget->count(); i++ )
225+
{
226+
if ( tabWidget->isTabEnabled( i ) )
227+
{
228+
tabIndex = i;
229+
break;
230+
}
231+
}
232+
}
233+
tabWidget->setCurrentIndex( tabIndex );
210234

211235
setWindowTitle( tr( "Layer Properties - %1" ).arg( layer->name() ) );
212236
} // QgsVectorLayerProperties ctor
213237

214238

215239
QgsVectorLayerProperties::~QgsVectorLayerProperties()
216240
{
217-
disconnect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) );
241+
if ( layer->hasGeometryType() )
242+
{
243+
disconnect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) );
244+
}
218245

219246
QSettings settings;
220247
settings.setValue( "/Windows/VectorLayerProperties/geometry", saveGeometry() );
@@ -615,9 +642,14 @@ void QgsVectorLayerProperties::reset( void )
615642
layer->label()->setFields( layer->pendingFields() );
616643

617644
actionDialog->init();
618-
labelDialog->init();
645+
646+
if ( layer->hasGeometryType() )
647+
{
648+
labelDialog->init();
649+
}
619650
labelCheckBox->setChecked( layer->hasLabelsEnabled() );
620651
labelOptionsFrame->setEnabled( layer->hasLabelsEnabled() );
652+
621653
//set the transparency slider
622654
sliderTransparency->setValue( 255 - layer->getTransparency() );
623655
//update the transparency percentage label
@@ -1293,12 +1325,7 @@ void QgsVectorLayerProperties::updateSymbologyPage()
12931325
}
12941326
else
12951327
{
1296-
if ( tabWidget->currentIndex() == 0 )
1297-
{
1298-
tabWidget->setCurrentIndex( 1 );
1299-
}
1300-
1301-
tabWidget->setTabEnabled( 0, true ); // hide symbology item
1328+
tabWidget->setTabEnabled( 0, false ); // hide symbology item
13021329
}
13031330

13041331
if ( mRendererDialog )

0 commit comments

Comments
 (0)