|
15 | 15 |
|
16 | 16 | #include "qgslayoutapputils.h" |
17 | 17 | #include "qgsgui.h" |
| 18 | +#include "qgslayout.h" |
18 | 19 | #include "qgslayoutitemguiregistry.h" |
19 | 20 | #include "qgslayoutitemregistry.h" |
20 | 21 | #include "qgslayoutviewrubberband.h" |
@@ -59,35 +60,56 @@ void QgsLayoutAppUtils::registerGuiForKnownItemTypes() |
59 | 60 | return new QgsLayoutShapeWidget( qobject_cast< QgsLayoutItemShape * >( item ) ); |
60 | 61 | }; |
61 | 62 |
|
62 | | - registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutShape, QObject::tr( "Rectangle" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicRectangle.svg" ) ), createShapeWidget, createRubberBand, QStringLiteral( "shapes" ), 0, []( QgsLayout * layout )->QgsLayoutItem* |
| 63 | + registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutShape, QObject::tr( "Rectangle" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicRectangle.svg" ) ), createShapeWidget, createRubberBand, QStringLiteral( "shapes" ), false, 0, []( QgsLayout * layout )->QgsLayoutItem* |
63 | 64 | { |
64 | 65 | std::unique_ptr< QgsLayoutItemShape > shape = qgis::make_unique< QgsLayoutItemShape >( layout ); |
65 | 66 | shape->setShapeType( QgsLayoutItemShape::Rectangle ); |
66 | 67 | return shape.release(); |
67 | 68 | } ) ); |
68 | | - registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutShape, QObject::tr( "Ellipse" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicCircle.svg" ) ), createShapeWidget, createEllipseBand, QStringLiteral( "shapes" ), 0, []( QgsLayout * layout )->QgsLayoutItem* |
| 69 | + registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutShape, QObject::tr( "Ellipse" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicCircle.svg" ) ), createShapeWidget, createEllipseBand, QStringLiteral( "shapes" ), false, 0, []( QgsLayout * layout )->QgsLayoutItem* |
69 | 70 | { |
70 | 71 | std::unique_ptr< QgsLayoutItemShape > shape = qgis::make_unique< QgsLayoutItemShape >( layout ); |
71 | 72 | shape->setShapeType( QgsLayoutItemShape::Ellipse ); |
72 | 73 | return shape.release(); |
73 | 74 | } ) ); |
74 | | - registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutShape, QObject::tr( "Triangle" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicTriangle.svg" ) ), createShapeWidget, createTriangleBand, QStringLiteral( "shapes" ), 0, []( QgsLayout * layout )->QgsLayoutItem* |
| 75 | + registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutShape, QObject::tr( "Triangle" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicTriangle.svg" ) ), createShapeWidget, createTriangleBand, QStringLiteral( "shapes" ), false, 0, []( QgsLayout * layout )->QgsLayoutItem* |
75 | 76 | { |
76 | 77 | std::unique_ptr< QgsLayoutItemShape > shape = qgis::make_unique< QgsLayoutItemShape >( layout ); |
77 | 78 | shape->setShapeType( QgsLayoutItemShape::Triangle ); |
78 | 79 | return shape.release(); |
79 | 80 | } ) ); |
80 | 81 |
|
81 | | - registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutPolygon, QObject::tr( "Polygon" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddPolygon.svg" ) ), |
82 | | - [ = ]( QgsLayoutItem * item )->QgsLayoutItemBaseWidget * |
| 82 | + |
| 83 | + std::unique_ptr< QgsLayoutItemGuiMetadata > polygonMetadata = qgis::make_unique< QgsLayoutItemGuiMetadata >( |
| 84 | + QgsLayoutItemRegistry::LayoutPolygon, QObject::tr( "Polygon" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddPolygon.svg" ) ), |
| 85 | + [ = ]( QgsLayoutItem * item )->QgsLayoutItemBaseWidget * |
83 | 86 | { |
84 | 87 | return nullptr; |
85 | 88 | //return new QgsLayoutMapWidget( qobject_cast< QgsLayoutItemMap * >( item ) ); |
86 | | - }, createRubberBand, QStringLiteral( "nodes" ) ) ); |
87 | | - registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutPolyline, QObject::tr( "Polyline" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddPolyline.svg" ) ), |
88 | | - [ = ]( QgsLayoutItem * item )->QgsLayoutItemBaseWidget * |
| 89 | + }, createRubberBand, QStringLiteral( "nodes" ), true ); |
| 90 | + polygonMetadata->setNodeRubberBandCreationFunction( []( QgsLayoutView * )->QGraphicsPolygonItem* |
| 91 | + { |
| 92 | + std::unique_ptr< QGraphicsPolygonItem > band = qgis::make_unique< QGraphicsPolygonItem >(); |
| 93 | + band->setBrush( Qt::NoBrush ); |
| 94 | + band->setPen( QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 ) ); |
| 95 | + band->setZValue( QgsLayout::ZViewTool ); |
| 96 | + return band.release(); |
| 97 | + } ); |
| 98 | + registry->addLayoutItemGuiMetadata( polygonMetadata.release() ); |
| 99 | + |
| 100 | + std::unique_ptr< QgsLayoutItemGuiMetadata > polylineMetadata = qgis::make_unique< QgsLayoutItemGuiMetadata>( |
| 101 | + QgsLayoutItemRegistry::LayoutPolyline, QObject::tr( "Polyline" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddPolyline.svg" ) ), |
| 102 | + [ = ]( QgsLayoutItem * item )->QgsLayoutItemBaseWidget * |
89 | 103 | { |
90 | 104 | return nullptr; |
91 | 105 | //return new QgsLayoutMapWidget( qobject_cast< QgsLayoutItemMap * >( item ) ); |
92 | | - }, createRubberBand, QStringLiteral( "nodes" ) ) ); |
| 106 | + }, createRubberBand, QStringLiteral( "nodes" ), true ); |
| 107 | + polylineMetadata->setNodeRubberBandCreationFunction( []( QgsLayoutView * )->QGraphicsPathItem* |
| 108 | + { |
| 109 | + std::unique_ptr< QGraphicsPathItem > band = qgis::make_unique< QGraphicsPathItem >(); |
| 110 | + band->setPen( QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 ) ); |
| 111 | + band->setZValue( QgsLayout::ZViewTool ); |
| 112 | + return band.release(); |
| 113 | + } ); |
| 114 | + registry->addLayoutItemGuiMetadata( polylineMetadata.release() ); |
93 | 115 | } |
0 commit comments