@@ -105,19 +105,30 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
105
105
106
106
connect ( btnUseNewSymbology, SIGNAL ( clicked () ), this , SLOT ( useNewSymbology () ) );
107
107
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
+ }
121
132
122
133
// Create the Actions dialog tab
123
134
QVBoxLayout *actionLayout = new QVBoxLayout ( actionOptionsFrame );
@@ -202,19 +213,35 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
202
213
mLayerAbstractTextEdit ->setPlainText ( layer->abstract () );
203
214
}
204
215
205
- tabWidget->setCurrentIndex ( 0 );
206
-
207
216
QSettings settings;
208
217
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 );
210
234
211
235
setWindowTitle ( tr ( " Layer Properties - %1" ).arg ( layer->name () ) );
212
236
} // QgsVectorLayerProperties ctor
213
237
214
238
215
239
QgsVectorLayerProperties::~QgsVectorLayerProperties ()
216
240
{
217
- disconnect ( labelDialog, SIGNAL ( labelSourceSet () ), this , SLOT ( setLabelCheckBox () ) );
241
+ if ( layer->hasGeometryType () )
242
+ {
243
+ disconnect ( labelDialog, SIGNAL ( labelSourceSet () ), this , SLOT ( setLabelCheckBox () ) );
244
+ }
218
245
219
246
QSettings settings;
220
247
settings.setValue ( " /Windows/VectorLayerProperties/geometry" , saveGeometry () );
@@ -615,9 +642,14 @@ void QgsVectorLayerProperties::reset( void )
615
642
layer->label ()->setFields ( layer->pendingFields () );
616
643
617
644
actionDialog->init ();
618
- labelDialog->init ();
645
+
646
+ if ( layer->hasGeometryType () )
647
+ {
648
+ labelDialog->init ();
649
+ }
619
650
labelCheckBox->setChecked ( layer->hasLabelsEnabled () );
620
651
labelOptionsFrame->setEnabled ( layer->hasLabelsEnabled () );
652
+
621
653
// set the transparency slider
622
654
sliderTransparency->setValue ( 255 - layer->getTransparency () );
623
655
// update the transparency percentage label
@@ -1293,12 +1325,7 @@ void QgsVectorLayerProperties::updateSymbologyPage()
1293
1325
}
1294
1326
else
1295
1327
{
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
1302
1329
}
1303
1330
1304
1331
if ( mRendererDialog )
0 commit comments