28#include "moc_qgslayoutshapewidget.cpp"
37 connect( mShapeComboBox, &QComboBox::currentTextChanged,
this, &QgsLayoutShapeWidget::mShapeComboBox_currentIndexChanged );
38 connect( mCornerRadiusSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutShapeWidget::mCornerRadiusSpinBox_valueChanged );
44 mItemPropertiesWidget->showBackgroundGroup(
false );
45 mItemPropertiesWidget->showFrameGroup(
false );
46 mainLayout->addWidget( mItemPropertiesWidget );
48 blockAllSignals(
true );
56 mRadiusUnitsComboBox->linkToWidget( mCornerRadiusSpinBox );
57 mRadiusUnitsComboBox->setConverter( &mShape->layout()->renderContext().measurementConverter() );
59 setGuiElementValues();
61 blockAllSignals(
false );
64 mShapeStyleButton->registerExpressionContextGenerator( mShape );
70 if ( mShape->layout() )
78 if ( mItemPropertiesWidget )
79 mItemPropertiesWidget->setMasterLayout( masterLayout );
92 mShape = qobject_cast<QgsLayoutItemShape *>( item );
93 mItemPropertiesWidget->setItem( mShape );
98 mShapeStyleButton->registerExpressionContextGenerator( mShape );
101 setGuiElementValues();
106void QgsLayoutShapeWidget::blockAllSignals(
bool block )
108 mShapeComboBox->blockSignals( block );
109 mCornerRadiusSpinBox->blockSignals( block );
110 mRadiusUnitsComboBox->blockSignals( block );
111 mShapeStyleButton->blockSignals( block );
114void QgsLayoutShapeWidget::setGuiElementValues()
121 blockAllSignals(
true );
123 mShapeStyleButton->setSymbol( mShape->symbol()->clone() );
125 mCornerRadiusSpinBox->setValue( mShape->cornerRadius().length() );
126 mRadiusUnitsComboBox->setUnit( mShape->cornerRadius().units() );
128 mShapeComboBox->setCurrentIndex( mShapeComboBox->findData( mShape->shapeType() ) );
129 toggleRadiusSpin( mShape->shapeType() );
131 blockAllSignals(
false );
134void QgsLayoutShapeWidget::symbolChanged()
140 mShape->setSymbol( mShapeStyleButton->clonedSymbol<QgsFillSymbol>() );
141 mShape->layout()->undoStack()->endCommand();
144void QgsLayoutShapeWidget::mCornerRadiusSpinBox_valueChanged(
double val )
150 mShape->setCornerRadius( QgsLayoutMeasurement( val, mRadiusUnitsComboBox->unit() ) );
151 mShape->layout()->undoStack()->endCommand();
155void QgsLayoutShapeWidget::radiusUnitsChanged()
161 mShape->setCornerRadius( QgsLayoutMeasurement( mCornerRadiusSpinBox->value(), mRadiusUnitsComboBox->unit() ) );
162 mShape->layout()->undoStack()->endCommand();
166void QgsLayoutShapeWidget::mShapeComboBox_currentIndexChanged(
const QString & )
173 mShape->layout()->undoStack()->beginCommand( mShape, tr(
"Change Shape Type" ) );
175 mShape->setShapeType( shape );
176 toggleRadiusSpin( shape );
178 mShape->layout()->undoStack()->endCommand();
188 mCornerRadiusSpinBox->setEnabled(
false );
193 mCornerRadiusSpinBox->setEnabled(
true );
Layout item for basic filled shapes (e.g.
@ Rectangle
Rectangle shape.
@ Triangle
Triangle shape.
Base class for graphical items within a QgsLayout.
@ UndoShapeCornerRadius
Shape corner radius.
@ UndoShapeStyle
Shape symbol style.
int type() const override
Returns a unique graphics item type identifier.
void changed()
Emitted when the object's properties change.
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
void unitChanged(Qgis::LayoutUnit unit)
Emitted when the unit is changed.
Interface for master layout type objects, such as print layouts and reports.