@@ -432,58 +432,91 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
432
432
433
433
menu->addSeparator ();
434
434
435
- if ( vlayer )
435
+ // export menu
436
+ if ( layer )
436
437
{
437
- if ( vlayer->isTemporary () )
438
- {
439
- QAction *actionMakePermanent = new QAction ( QgsApplication::getThemeIcon ( QStringLiteral ( " mActionFileSave.svg" ) ), tr ( " Make Permanent…" ), menu );
440
- connect ( actionMakePermanent, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->makeMemoryLayerPermanent ( vlayer ); } );
441
- menu->addAction ( actionMakePermanent );
442
- }
443
- // save as vector file
444
- QMenu *menuExportVector = new QMenu ( tr ( " E&xport" ), menu );
445
- QAction *actionSaveAs = new QAction ( tr ( " Save Features &As…" ), menuExportVector );
446
- connect ( actionSaveAs, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->saveAsFile (); } );
447
- actionSaveAs->setEnabled ( vlayer->isValid () );
448
- menuExportVector->addAction ( actionSaveAs );
449
- QAction *actionSaveSelectedFeaturesAs = new QAction ( tr ( " Save &Selected Features As…" ), menuExportVector );
450
- connect ( actionSaveSelectedFeaturesAs, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->saveAsFile ( nullptr , true ); } );
451
- actionSaveSelectedFeaturesAs->setEnabled ( vlayer->isValid () && vlayer->selectedFeatureCount () > 0 );
452
- menuExportVector->addAction ( actionSaveSelectedFeaturesAs );
453
- QAction *actionSaveAsDefinitionLayer = new QAction ( tr ( " Save as Layer &Definition File…" ), menuExportVector );
454
- connect ( actionSaveAsDefinitionLayer, &QAction::triggered, QgisApp::instance (), &QgisApp::saveAsLayerDefinition );
455
- menuExportVector->addAction ( actionSaveAsDefinitionLayer );
456
- if ( vlayer->isSpatial () )
438
+ switch ( layer->type () )
457
439
{
458
- QAction *actionSaveStyle = new QAction ( tr ( " Save as &QGIS Layer Style File…" ), menuExportVector );
459
- connect ( actionSaveStyle, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->saveStyleFile (); } );
460
- menuExportVector->addAction ( actionSaveStyle );
440
+ case QgsMapLayerType::VectorLayer:
441
+ if ( vlayer )
442
+ {
443
+ if ( vlayer->isTemporary () )
444
+ {
445
+ QAction *actionMakePermanent = new QAction ( QgsApplication::getThemeIcon ( QStringLiteral ( " mActionFileSave.svg" ) ), tr ( " Make Permanent…" ), menu );
446
+ connect ( actionMakePermanent, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->makeMemoryLayerPermanent ( vlayer ); } );
447
+ menu->addAction ( actionMakePermanent );
448
+ }
449
+ // save as vector file
450
+ QMenu *menuExportVector = new QMenu ( tr ( " E&xport" ), menu );
451
+ QAction *actionSaveAs = new QAction ( tr ( " Save Features &As…" ), menuExportVector );
452
+ connect ( actionSaveAs, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->saveAsFile (); } );
453
+ actionSaveAs->setEnabled ( vlayer->isValid () );
454
+ menuExportVector->addAction ( actionSaveAs );
455
+ QAction *actionSaveSelectedFeaturesAs = new QAction ( tr ( " Save &Selected Features As…" ), menuExportVector );
456
+ connect ( actionSaveSelectedFeaturesAs, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->saveAsFile ( nullptr , true ); } );
457
+ actionSaveSelectedFeaturesAs->setEnabled ( vlayer->isValid () && vlayer->selectedFeatureCount () > 0 );
458
+ menuExportVector->addAction ( actionSaveSelectedFeaturesAs );
459
+ QAction *actionSaveAsDefinitionLayer = new QAction ( tr ( " Save as Layer &Definition File…" ), menuExportVector );
460
+ connect ( actionSaveAsDefinitionLayer, &QAction::triggered, QgisApp::instance (), &QgisApp::saveAsLayerDefinition );
461
+ menuExportVector->addAction ( actionSaveAsDefinitionLayer );
462
+ if ( vlayer->isSpatial () )
463
+ {
464
+ QAction *actionSaveStyle = new QAction ( tr ( " Save as &QGIS Layer Style File…" ), menuExportVector );
465
+ connect ( actionSaveStyle, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->saveStyleFile (); } );
466
+ menuExportVector->addAction ( actionSaveStyle );
467
+ }
468
+ menu->addMenu ( menuExportVector );
469
+ }
470
+ break ;
471
+
472
+ case QgsMapLayerType::RasterLayer:
473
+ if ( rlayer )
474
+ {
475
+ QMenu *menuExportRaster = new QMenu ( tr ( " E&xport" ), menu );
476
+ QAction *actionSaveAs = new QAction ( tr ( " Save &As…" ), menuExportRaster );
477
+ QAction *actionSaveAsDefinitionLayer = new QAction ( tr ( " Save as Layer &Definition File…" ), menuExportRaster );
478
+ QAction *actionSaveStyle = new QAction ( tr ( " Save as &QGIS Layer Style File…" ), menuExportRaster );
479
+ connect ( actionSaveAs, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->saveAsFile (); } );
480
+ menuExportRaster->addAction ( actionSaveAs );
481
+ actionSaveAs->setEnabled ( rlayer->isValid () );
482
+ connect ( actionSaveAsDefinitionLayer, &QAction::triggered, QgisApp::instance (), &QgisApp::saveAsLayerDefinition );
483
+ menuExportRaster->addAction ( actionSaveAsDefinitionLayer );
484
+ connect ( actionSaveStyle, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->saveStyleFile (); } );
485
+ menuExportRaster->addAction ( actionSaveStyle );
486
+ menu->addMenu ( menuExportRaster );
487
+ }
488
+ break ;
489
+
490
+ case QgsMapLayerType::MeshLayer:
491
+ case QgsMapLayerType::VectorTileLayer:
492
+ case QgsMapLayerType::PointCloudLayer:
493
+ {
494
+ QMenu *menuExportRaster = new QMenu ( tr ( " E&xport" ), menu );
495
+ QAction *actionSaveAsDefinitionLayer = new QAction ( tr ( " Save as Layer &Definition File…" ), menuExportRaster );
496
+ QAction *actionSaveStyle = new QAction ( tr ( " Save as &QGIS Layer Style File…" ), menuExportRaster );
497
+ connect ( actionSaveAsDefinitionLayer, &QAction::triggered, QgisApp::instance (), &QgisApp::saveAsLayerDefinition );
498
+ menuExportRaster->addAction ( actionSaveAsDefinitionLayer );
499
+ connect ( actionSaveStyle, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->saveStyleFile (); } );
500
+ menuExportRaster->addAction ( actionSaveStyle );
501
+ menu->addMenu ( menuExportRaster );
502
+ }
503
+ break ;
504
+
505
+ case QgsMapLayerType::AnnotationLayer:
506
+ break ;
507
+
508
+ case QgsMapLayerType::PluginLayer:
509
+ if ( mView ->selectedLayerNodes ().count () == 1 )
510
+ {
511
+ // disable duplication of plugin layers
512
+ duplicateLayersAction->setEnabled ( false );
513
+ }
514
+ break ;
515
+
461
516
}
462
- menu->addMenu ( menuExportVector );
463
- }
464
- else if ( rlayer )
465
- {
466
- QMenu *menuExportRaster = new QMenu ( tr ( " E&xport" ), menu );
467
- QAction *actionSaveAs = new QAction ( tr ( " Save &As…" ), menuExportRaster );
468
- QAction *actionSaveAsDefinitionLayer = new QAction ( tr ( " Save as Layer &Definition File…" ), menuExportRaster );
469
- QAction *actionSaveStyle = new QAction ( tr ( " Save as &QGIS Layer Style File…" ), menuExportRaster );
470
- connect ( actionSaveAs, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->saveAsFile (); } );
471
- menuExportRaster->addAction ( actionSaveAs );
472
- actionSaveAs->setEnabled ( rlayer->isValid () );
473
- connect ( actionSaveAsDefinitionLayer, &QAction::triggered, QgisApp::instance (), &QgisApp::saveAsLayerDefinition );
474
- menuExportRaster->addAction ( actionSaveAsDefinitionLayer );
475
- connect ( actionSaveStyle, &QAction::triggered, QgisApp::instance (), [ = ] { QgisApp::instance ()->saveStyleFile (); } );
476
- menuExportRaster->addAction ( actionSaveStyle );
477
- menu->addMenu ( menuExportRaster );
478
- }
479
- else if ( layer && layer->type () == QgsMapLayerType::PluginLayer && mView ->selectedLayerNodes ().count () == 1 )
480
- {
481
- // disable duplication of plugin layers
482
- duplicateLayersAction->setEnabled ( false );
517
+ menu->addSeparator ();
483
518
}
484
519
485
- menu->addSeparator ();
486
-
487
520
// style-related actions
488
521
if ( layer && mView ->selectedLayerNodes ().count () == 1 )
489
522
{
0 commit comments