19#include "moc_qgslayoutmarkerwidget.cpp"
41 mainLayout->addWidget( mItemPropertiesWidget );
43 blockAllSignals(
true );
47 blockAllSignals(
false );
50 mShapeStyleButton->registerExpressionContextGenerator( mMarker );
54 connect( mRotationFromMapCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMarkerWidget::rotationFromMapCheckBoxChanged );
55 connect( mNorthOffsetSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMarkerWidget::northOffsetSpinBoxChanged );
56 connect( mNorthTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMarkerWidget::northTypeComboBoxChanged );
58 mNorthTypeComboBox->blockSignals(
true );
61 mNorthTypeComboBox->blockSignals(
false );
62 mNorthOffsetSpinBox->setClearValue( 0.0 );
65 if ( mMarker->layout() )
68 mMapComboBox->setCurrentLayout( mMarker->layout() );
73 setGuiElementValues();
78 if ( mItemPropertiesWidget )
92 mMarker = qobject_cast<QgsLayoutItemMarker *>( item );
93 mItemPropertiesWidget->
setItem( mMarker );
98 mShapeStyleButton->registerExpressionContextGenerator( mMarker );
101 setGuiElementValues();
106void QgsLayoutMarkerWidget::blockAllSignals(
bool block )
108 mShapeStyleButton->blockSignals( block );
109 mMapComboBox->blockSignals( block );
110 mRotationFromMapCheckBox->blockSignals( block );
111 mNorthTypeComboBox->blockSignals( block );
112 mNorthOffsetSpinBox->blockSignals( block );
115void QgsLayoutMarkerWidget::setGuiElementValues()
122 blockAllSignals(
true );
124 mShapeStyleButton->setSymbol( mMarker->symbol()->clone() );
126 mMapComboBox->setItem( mMarker->linkedMap() );
127 if ( mMarker->linkedMap() )
129 mRotationFromMapCheckBox->setCheckState( Qt::Checked );
130 mMapComboBox->setEnabled(
true );
131 mNorthTypeComboBox->setEnabled(
true );
132 mNorthOffsetSpinBox->setEnabled(
true );
136 mRotationFromMapCheckBox->setCheckState( Qt::Unchecked );
137 mMapComboBox->setEnabled(
false );
138 mNorthTypeComboBox->setEnabled(
false );
139 mNorthOffsetSpinBox->setEnabled(
false );
141 mNorthTypeComboBox->setCurrentIndex( mNorthTypeComboBox->findData( mMarker->northMode() ) );
142 mNorthOffsetSpinBox->setValue( mMarker->northOffset() );
144 blockAllSignals(
false );
147void QgsLayoutMarkerWidget::symbolChanged()
153 mMarker->setSymbol( mShapeStyleButton->clonedSymbol<
QgsMarkerSymbol>() );
154 mMarker->layout()->undoStack()->endCommand();
157void QgsLayoutMarkerWidget::rotationFromMapCheckBoxChanged(
int state )
164 mMarker->beginCommand( tr(
"Toggle Rotation Sync" ) );
165 if ( state == Qt::Unchecked )
167 mMarker->setLinkedMap(
nullptr );
168 mMapComboBox->setEnabled(
false );
169 mNorthTypeComboBox->setEnabled(
false );
170 mNorthOffsetSpinBox->setEnabled(
false );
174 QgsLayoutItemMap *map = qobject_cast<QgsLayoutItemMap *>( mMapComboBox->currentItem() );
175 mMarker->setLinkedMap( map );
176 mNorthTypeComboBox->setEnabled(
true );
177 mNorthOffsetSpinBox->setEnabled(
true );
178 mMapComboBox->setEnabled(
true );
180 mMarker->endCommand();
190 const QgsLayout *layout = mMarker->layout();
202 mMarker->beginCommand( tr(
"Change Rotation Map" ) );
203 mMarker->setLinkedMap( map );
205 mMarker->endCommand();
208void QgsLayoutMarkerWidget::northOffsetSpinBoxChanged(
double d )
211 mMarker->setNorthOffset( d );
212 mMarker->endCommand();
216void QgsLayoutMarkerWidget::northTypeComboBoxChanged(
int index )
218 mMarker->beginCommand( tr(
"Change Marker North Mode" ) );
220 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.