@@ -3956,14 +3956,14 @@ void QgisApp::labeling()
3956
3956
// alter labeling - save the changes
3957
3957
labelGui.layerSettings ().writeToLayer ( vlayer );
3958
3958
3959
- activateDeactivateLayerRelatedActions ( layer );
3960
-
3961
3959
// trigger refresh
3962
3960
if ( mMapCanvas )
3963
3961
{
3964
3962
mMapCanvas ->refresh ();
3965
3963
}
3966
3964
}
3965
+
3966
+ activateDeactivateLayerRelatedActions ( layer );
3967
3967
}
3968
3968
3969
3969
void QgisApp::attributeTable ()
@@ -6129,6 +6129,36 @@ void QgisApp::legendLayerSelectionChanged( void )
6129
6129
6130
6130
void QgisApp::activateDeactivateLayerRelatedActions ( QgsMapLayer* layer )
6131
6131
{
6132
+ bool enableMove = false , enableRotate = false , enableChange = false ;
6133
+
6134
+ QMap<QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance ()->mapLayers ();
6135
+ for ( QMap<QString, QgsMapLayer*>::iterator it = layers.begin (); it != layers.end (); it++ )
6136
+ {
6137
+ QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( it.value () );
6138
+ if ( !vlayer || !vlayer->isEditable () || vlayer->customProperty ( " labeling" ).toString () != QString ( " pal" ) )
6139
+ continue ;
6140
+
6141
+ int colX, colY, colAng;
6142
+ enableMove =
6143
+ enableMove ||
6144
+ ( qobject_cast<QgsMapToolMoveLabel*>( mMapTools .mMoveLabel ) &&
6145
+ qobject_cast<QgsMapToolMoveLabel*>( mMapTools .mMoveLabel )->layerIsMoveable ( vlayer, colX, colY ) );
6146
+
6147
+ enableRotate =
6148
+ enableRotate ||
6149
+ ( qobject_cast<QgsMapToolRotateLabel*>( mMapTools .mRotateLabel ) &&
6150
+ qobject_cast<QgsMapToolRotateLabel*>( mMapTools .mRotateLabel )->layerIsRotatable ( vlayer, colAng ) );
6151
+
6152
+ enableChange = true ;
6153
+
6154
+ if ( enableMove && enableRotate && enableChange )
6155
+ break ;
6156
+ }
6157
+
6158
+ mActionMoveLabel ->setEnabled ( enableMove );
6159
+ mActionRotateLabel ->setEnabled ( enableRotate );
6160
+ mActionChangeLabelProperties ->setEnabled ( enableChange );
6161
+
6132
6162
if ( !layer )
6133
6163
{
6134
6164
mActionSelect ->setEnabled ( false );
@@ -6254,29 +6284,11 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
6254
6284
dprovider->capabilities () & QgsVectorDataProvider::AddFeatures );
6255
6285
6256
6286
mActionMergeFeatureAttributes ->setEnabled ( layerHasSelection );
6257
-
6258
- if ( layer->customProperty ( " labeling" ).toString () == QString ( " pal" ) )
6259
- {
6260
- int colX, colY, colAng;
6261
- mActionMoveLabel ->setEnabled ( qobject_cast<QgsMapToolMoveLabel*>( mMapTools .mMoveLabel ) && qobject_cast<QgsMapToolMoveLabel*>( mMapTools .mMoveLabel )->layerIsMoveable ( layer, colX, colY ) );
6262
- mActionRotateLabel ->setEnabled ( qobject_cast<QgsMapToolRotateLabel*>( mMapTools .mRotateLabel ) && qobject_cast<QgsMapToolRotateLabel*>( mMapTools .mMoveLabel )->layerIsRotatable ( layer, colAng ) );
6263
- mActionChangeLabelProperties ->setEnabled ( true );
6264
- }
6265
- else
6266
- {
6267
- mActionMoveLabel ->setEnabled ( false );
6268
- mActionRotateLabel ->setEnabled ( false );
6269
- mActionChangeLabelProperties ->setEnabled ( false );
6270
- }
6271
6287
}
6272
6288
else
6273
6289
{
6274
6290
mActionMergeFeatures ->setEnabled ( false );
6275
6291
mActionMergeFeatureAttributes ->setEnabled ( false );
6276
-
6277
- mActionMoveLabel ->setEnabled ( false );
6278
- mActionRotateLabel ->setEnabled ( false );
6279
- mActionChangeLabelProperties ->setEnabled ( false );
6280
6292
}
6281
6293
6282
6294
// moving enabled if geometry changes are supported
0 commit comments