38 mainLayout->addWidget( mItemPropertiesWidget );
40 blockAllSignals(
true );
44 blockAllSignals(
false );
47 mShapeStyleButton->registerExpressionContextGenerator( mMarker );
51 connect( mRotationFromMapCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMarkerWidget::rotationFromMapCheckBoxChanged );
52 connect( mNorthOffsetSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMarkerWidget::northOffsetSpinBoxChanged );
53 connect( mNorthTypeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMarkerWidget::northTypeComboBoxChanged );
55 mNorthTypeComboBox->blockSignals(
true );
58 mNorthTypeComboBox->blockSignals(
false );
59 mNorthOffsetSpinBox->setClearValue( 0.0 );
62 if ( mMarker->layout() )
65 mMapComboBox->setCurrentLayout( mMarker->layout() );
70 setGuiElementValues();
75 if ( mItemPropertiesWidget )
89 mMarker = qobject_cast< QgsLayoutItemMarker * >( item );
90 mItemPropertiesWidget->
setItem( mMarker );
95 mShapeStyleButton->registerExpressionContextGenerator( mMarker );
98 setGuiElementValues();
103 void QgsLayoutMarkerWidget::blockAllSignals(
bool block )
105 mShapeStyleButton->blockSignals( block );
106 mMapComboBox->blockSignals( block );
107 mRotationFromMapCheckBox->blockSignals( block );
108 mNorthTypeComboBox->blockSignals( block );
109 mNorthOffsetSpinBox->blockSignals( block );
112 void QgsLayoutMarkerWidget::setGuiElementValues()
119 blockAllSignals(
true );
121 mShapeStyleButton->setSymbol( mMarker->symbol()->clone() );
123 mMapComboBox->setItem( mMarker->linkedMap() );
124 if ( mMarker->linkedMap() )
126 mRotationFromMapCheckBox->setCheckState( Qt::Checked );
127 mMapComboBox->setEnabled(
true );
128 mNorthTypeComboBox->setEnabled(
true );
129 mNorthOffsetSpinBox->setEnabled(
true );
133 mRotationFromMapCheckBox->setCheckState( Qt::Unchecked );
134 mMapComboBox->setEnabled(
false );
135 mNorthTypeComboBox->setEnabled(
false );
136 mNorthOffsetSpinBox->setEnabled(
false );
138 mNorthTypeComboBox->setCurrentIndex( mNorthTypeComboBox->findData( mMarker->northMode() ) );
139 mNorthOffsetSpinBox->setValue( mMarker->northOffset() );
141 blockAllSignals(
false );
144 void QgsLayoutMarkerWidget::symbolChanged()
150 mMarker->setSymbol( mShapeStyleButton->clonedSymbol<
QgsMarkerSymbol>() );
151 mMarker->layout()->undoStack()->endCommand();
154 void QgsLayoutMarkerWidget::rotationFromMapCheckBoxChanged(
int state )
161 mMarker->beginCommand( tr(
"Toggle Rotation Sync" ) );
162 if ( state == Qt::Unchecked )
164 mMarker->setLinkedMap(
nullptr );
165 mMapComboBox->setEnabled(
false );
166 mNorthTypeComboBox->setEnabled(
false );
167 mNorthOffsetSpinBox->setEnabled(
false );
171 QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( mMapComboBox->currentItem() );
172 mMarker->setLinkedMap( map );
173 mNorthTypeComboBox->setEnabled(
true );
174 mNorthOffsetSpinBox->setEnabled(
true );
175 mMapComboBox->setEnabled(
true );
177 mMarker->endCommand();
180 void QgsLayoutMarkerWidget::mapChanged(
QgsLayoutItem *item )
187 const QgsLayout *layout = mMarker->layout();
199 mMarker->beginCommand( tr(
"Change Rotation Map" ) );
200 mMarker->setLinkedMap( map );
202 mMarker->endCommand();
205 void QgsLayoutMarkerWidget::northOffsetSpinBoxChanged(
double d )
208 mMarker->setNorthOffset( d );
209 mMarker->endCommand();
213 void QgsLayoutMarkerWidget::northTypeComboBoxChanged(
int index )
215 mMarker->beginCommand( tr(
"Change Marker North Mode" ) );
217 mMarker->endCommand();