40 mainLayout->addWidget( mItemPropertiesWidget );
42 blockAllSignals(
true );
46 blockAllSignals(
false );
49 mShapeStyleButton->registerExpressionContextGenerator( mMarker );
53 connect( mRotationFromMapCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMarkerWidget::rotationFromMapCheckBoxChanged );
54 connect( mNorthOffsetSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMarkerWidget::northOffsetSpinBoxChanged );
55 connect( mNorthTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMarkerWidget::northTypeComboBoxChanged );
57 mNorthTypeComboBox->blockSignals(
true );
60 mNorthTypeComboBox->blockSignals(
false );
61 mNorthOffsetSpinBox->setClearValue( 0.0 );
64 if ( mMarker->layout() )
67 mMapComboBox->setCurrentLayout( mMarker->layout() );
72 setGuiElementValues();
77 if ( mItemPropertiesWidget )
91 mMarker = qobject_cast< QgsLayoutItemMarker * >( item );
92 mItemPropertiesWidget->
setItem( mMarker );
97 mShapeStyleButton->registerExpressionContextGenerator( mMarker );
100 setGuiElementValues();
105void QgsLayoutMarkerWidget::blockAllSignals(
bool block )
107 mShapeStyleButton->blockSignals( block );
108 mMapComboBox->blockSignals( block );
109 mRotationFromMapCheckBox->blockSignals( block );
110 mNorthTypeComboBox->blockSignals( block );
111 mNorthOffsetSpinBox->blockSignals( block );
114void QgsLayoutMarkerWidget::setGuiElementValues()
121 blockAllSignals(
true );
123 mShapeStyleButton->setSymbol( mMarker->symbol()->clone() );
125 mMapComboBox->setItem( mMarker->linkedMap() );
126 if ( mMarker->linkedMap() )
128 mRotationFromMapCheckBox->setCheckState( Qt::Checked );
129 mMapComboBox->setEnabled(
true );
130 mNorthTypeComboBox->setEnabled(
true );
131 mNorthOffsetSpinBox->setEnabled(
true );
135 mRotationFromMapCheckBox->setCheckState( Qt::Unchecked );
136 mMapComboBox->setEnabled(
false );
137 mNorthTypeComboBox->setEnabled(
false );
138 mNorthOffsetSpinBox->setEnabled(
false );
140 mNorthTypeComboBox->setCurrentIndex( mNorthTypeComboBox->findData( mMarker->northMode() ) );
141 mNorthOffsetSpinBox->setValue( mMarker->northOffset() );
143 blockAllSignals(
false );
146void QgsLayoutMarkerWidget::symbolChanged()
152 mMarker->setSymbol( mShapeStyleButton->clonedSymbol<
QgsMarkerSymbol>() );
153 mMarker->layout()->undoStack()->endCommand();
156void QgsLayoutMarkerWidget::rotationFromMapCheckBoxChanged(
int state )
163 mMarker->beginCommand( tr(
"Toggle Rotation Sync" ) );
164 if ( state == Qt::Unchecked )
166 mMarker->setLinkedMap(
nullptr );
167 mMapComboBox->setEnabled(
false );
168 mNorthTypeComboBox->setEnabled(
false );
169 mNorthOffsetSpinBox->setEnabled(
false );
173 QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( mMapComboBox->currentItem() );
174 mMarker->setLinkedMap( map );
175 mNorthTypeComboBox->setEnabled(
true );
176 mNorthOffsetSpinBox->setEnabled(
true );
177 mMapComboBox->setEnabled(
true );
179 mMarker->endCommand();
189 const QgsLayout *layout = mMarker->layout();
201 mMarker->beginCommand( tr(
"Change Rotation Map" ) );
202 mMarker->setLinkedMap( map );
204 mMarker->endCommand();
207void QgsLayoutMarkerWidget::northOffsetSpinBoxChanged(
double d )
210 mMarker->setNorthOffset( d );
211 mMarker->endCommand();
215void QgsLayoutMarkerWidget::northTypeComboBoxChanged(
int index )
217 mMarker->beginCommand( tr(
"Change Marker North Mode" ) );
219 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.