39 mainLayout->addWidget( mItemPropertiesWidget );
41 blockAllSignals(
true );
45 blockAllSignals(
false );
48 mShapeStyleButton->registerExpressionContextGenerator( mMarker );
52 connect( mRotationFromMapCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMarkerWidget::rotationFromMapCheckBoxChanged );
53 connect( mNorthOffsetSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMarkerWidget::northOffsetSpinBoxChanged );
54 connect( mNorthTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMarkerWidget::northTypeComboBoxChanged );
56 mNorthTypeComboBox->blockSignals(
true );
59 mNorthTypeComboBox->blockSignals(
false );
60 mNorthOffsetSpinBox->setClearValue( 0.0 );
63 if ( mMarker->layout() )
66 mMapComboBox->setCurrentLayout( mMarker->layout() );
71 setGuiElementValues();
76 if ( mItemPropertiesWidget )
90 mMarker = qobject_cast< QgsLayoutItemMarker * >( item );
91 mItemPropertiesWidget->
setItem( mMarker );
96 mShapeStyleButton->registerExpressionContextGenerator( mMarker );
99 setGuiElementValues();
104 void QgsLayoutMarkerWidget::blockAllSignals(
bool block )
106 mShapeStyleButton->blockSignals( block );
107 mMapComboBox->blockSignals( block );
108 mRotationFromMapCheckBox->blockSignals( block );
109 mNorthTypeComboBox->blockSignals( block );
110 mNorthOffsetSpinBox->blockSignals( block );
113 void QgsLayoutMarkerWidget::setGuiElementValues()
120 blockAllSignals(
true );
122 mShapeStyleButton->setSymbol( mMarker->symbol()->clone() );
124 mMapComboBox->setItem( mMarker->linkedMap() );
125 if ( mMarker->linkedMap() )
127 mRotationFromMapCheckBox->setCheckState( Qt::Checked );
128 mMapComboBox->setEnabled(
true );
129 mNorthTypeComboBox->setEnabled(
true );
130 mNorthOffsetSpinBox->setEnabled(
true );
134 mRotationFromMapCheckBox->setCheckState( Qt::Unchecked );
135 mMapComboBox->setEnabled(
false );
136 mNorthTypeComboBox->setEnabled(
false );
137 mNorthOffsetSpinBox->setEnabled(
false );
139 mNorthTypeComboBox->setCurrentIndex( mNorthTypeComboBox->findData( mMarker->northMode() ) );
140 mNorthOffsetSpinBox->setValue( mMarker->northOffset() );
142 blockAllSignals(
false );
145 void QgsLayoutMarkerWidget::symbolChanged()
151 mMarker->setSymbol( mShapeStyleButton->clonedSymbol<
QgsMarkerSymbol>() );
152 mMarker->layout()->undoStack()->endCommand();
155 void QgsLayoutMarkerWidget::rotationFromMapCheckBoxChanged(
int state )
162 mMarker->beginCommand( tr(
"Toggle Rotation Sync" ) );
163 if ( state == Qt::Unchecked )
165 mMarker->setLinkedMap(
nullptr );
166 mMapComboBox->setEnabled(
false );
167 mNorthTypeComboBox->setEnabled(
false );
168 mNorthOffsetSpinBox->setEnabled(
false );
172 QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( mMapComboBox->currentItem() );
173 mMarker->setLinkedMap( map );
174 mNorthTypeComboBox->setEnabled(
true );
175 mNorthOffsetSpinBox->setEnabled(
true );
176 mMapComboBox->setEnabled(
true );
178 mMarker->endCommand();
181 void QgsLayoutMarkerWidget::mapChanged(
QgsLayoutItem *item )
188 const QgsLayout *layout = mMarker->layout();
200 mMarker->beginCommand( tr(
"Change Rotation Map" ) );
201 mMarker->setLinkedMap( map );
203 mMarker->endCommand();
206 void QgsLayoutMarkerWidget::northOffsetSpinBoxChanged(
double d )
209 mMarker->setNorthOffset( d );
210 mMarker->endCommand();
214 void QgsLayoutMarkerWidget::northTypeComboBoxChanged(
int index )
216 mMarker->beginCommand( tr(
"Change Marker North Mode" ) );
218 mMarker->endCommand();
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
Layout graphical items for displaying a map.
A layout item for showing marker symbols.
Base class for graphical items within a QgsLayout.
@ UndoPictureNorthOffset
Picture north offset.
@ UndoShapeStyle
Shape symbol style.
int type() const override
Returns a unique graphics item type identifier.
NorthMode
Method for syncing rotation to a map's North direction.
@ GridNorth
Align to grid north.
@ TrueNorth
Align to true north.
void changed()
Emitted when the object's properties change.
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
A marker symbol type, for rendering Point and MultiPoint geometries.
Interface for master layout type objects, such as print layouts and reports.