33QgsAnnotationPolygonItemWidget::QgsAnnotationPolygonItemWidget( QWidget *parent )
39 mSelector->setDockMode( dockMode() );
42 if ( !mBlockChangedSignal )
50 QVBoxLayout *layout =
new QVBoxLayout();
51 layout->setContentsMargins( 0, 0, 0, 0 );
52 layout->addWidget( mSelector );
53 mSymbolSelectorFrame->setLayout( layout );
57 if ( !mBlockChangedSignal )
66 mPropertiesWidget->updateItem( newItem );
74 polygonItem->
setSymbol( mSymbol->clone() );
75 mPropertiesWidget->updateItem( polygonItem );
79void QgsAnnotationPolygonItemWidget::setDockMode(
bool dockMode )
83 mSelector->setDockMode( dockMode );
90 mSelector->setContext( context );
91 mPropertiesWidget->setContext( context );
94QgsAnnotationPolygonItemWidget::~QgsAnnotationPolygonItemWidget() =
default;
102 mItem.reset( polygonItem->
clone() );
103 if ( mItem->symbol() )
105 mSymbol.reset( mItem->symbol()->clone() );
111 mBlockChangedSignal =
true;
112 mSelector->loadSymbol( mSymbol.get() );
113 mSelector->updatePreview();
114 mPropertiesWidget->setItem( mItem.get() );
115 mBlockChangedSignal =
false;
125QgsAnnotationLineItemWidget::QgsAnnotationLineItemWidget( QWidget *parent )
131 mSelector->setDockMode( dockMode() );
134 if ( !mBlockChangedSignal )
142 QVBoxLayout *layout =
new QVBoxLayout();
143 layout->setContentsMargins( 0, 0, 0, 0 );
144 layout->addWidget( mSelector );
145 mSymbolSelectorFrame->setLayout( layout );
149 if ( !mBlockChangedSignal )
158 mPropertiesWidget->updateItem( newItem );
167 mPropertiesWidget->updateItem( lineItem );
171void QgsAnnotationLineItemWidget::setDockMode(
bool dockMode )
175 mSelector->setDockMode( dockMode );
182 mSelector->setContext( context );
183 mPropertiesWidget->setContext( context );
186QgsAnnotationLineItemWidget::~QgsAnnotationLineItemWidget() =
default;
194 mItem.reset( lineItem->
clone() );
195 if ( mItem->symbol() )
197 mSymbol.reset( mItem->symbol()->clone() );
203 mBlockChangedSignal =
true;
204 mSelector->loadSymbol( mSymbol.get() );
205 mSelector->updatePreview();
206 mPropertiesWidget->setItem( mItem.get() );
207 mBlockChangedSignal =
false;
217QgsAnnotationMarkerItemWidget::QgsAnnotationMarkerItemWidget( QWidget *parent )
223 mSelector->setDockMode( dockMode() );
226 if ( !mBlockChangedSignal )
234 QVBoxLayout *layout =
new QVBoxLayout();
235 layout->setContentsMargins( 0, 0, 0, 0 );
236 layout->addWidget( mSelector );
237 mSymbolSelectorFrame->setLayout( layout );
241 if ( !mBlockChangedSignal )
250 mPropertiesWidget->updateItem( newItem );
258 markerItem->
setSymbol( mSymbol->clone() );
259 mPropertiesWidget->updateItem( markerItem );
263void QgsAnnotationMarkerItemWidget::setDockMode(
bool dockMode )
267 mSelector->setDockMode( dockMode );
274 mSelector->setContext( context );
275 mPropertiesWidget->setContext( context );
278QgsAnnotationMarkerItemWidget::~QgsAnnotationMarkerItemWidget() =
default;
286 mItem.reset( markerItem->
clone() );
287 if ( mItem->symbol() )
289 mSymbol.reset( mItem->symbol()->clone() );
295 mBlockChangedSignal =
true;
296 mSelector->loadSymbol( mSymbol.get() );
297 mSelector->updatePreview();
298 mPropertiesWidget->setItem( mItem.get() );
299 mBlockChangedSignal =
false;
310QgsAnnotationPointTextItemWidget::QgsAnnotationPointTextItemWidget( QWidget *parent )
316 QVBoxLayout *vLayout =
new QVBoxLayout();
317 vLayout->setContentsMargins( 0, 0, 0, 0 );
318 vLayout->addWidget( mTextFormatWidget );
319 mTextFormatWidgetContainer->setLayout( vLayout );
321 mTextEdit->setMaximumHeight( mTextEdit->fontMetrics().height() * 10 );
323 mTextFormatWidget->setDockMode( dockMode() );
326 if ( !mBlockChangedSignal )
329 connect( mTextEdit, &QPlainTextEdit::textChanged,
this, [ = ]
331 if ( !mBlockChangedSignal )
334 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked );
337 if ( !mBlockChangedSignal )
345 newItem->
setFormat( mTextFormatWidget->format() );
346 newItem->
setText( mTextEdit->toPlainText() );
347 mPropertiesWidget->updateItem( newItem );
355 pointTextItem->
setFormat( mTextFormatWidget->format() );
356 pointTextItem->setText( mTextEdit->toPlainText() );
357 mPropertiesWidget->updateItem( pointTextItem );
361void QgsAnnotationPointTextItemWidget::setDockMode(
bool dockMode )
364 if ( mTextFormatWidget )
365 mTextFormatWidget->setDockMode( dockMode );
371 if ( mTextFormatWidget )
372 mTextFormatWidget->setContext( context );
373 mPropertiesWidget->setContext( context );
376void QgsAnnotationPointTextItemWidget::focusDefaultWidget()
378 mTextEdit->selectAll();
379 mTextEdit->setFocus();
382QgsAnnotationPointTextItemWidget::~QgsAnnotationPointTextItemWidget() =
default;
390 mItem.reset( textItem->
clone() );
392 mBlockChangedSignal =
true;
393 mTextFormatWidget->
setFormat( mItem->format() );
394 mTextEdit->setPlainText( mItem->text() );
395 mPropertiesWidget->setItem( mItem.get() );
396 mBlockChangedSignal =
false;
401void QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked()
403 QString selText = mTextEdit->textCursor().selectedText();
406 selText = selText.replace( QChar( 0x2029 ), QChar(
'\n' ) );
409 if ( selText.startsWith( QLatin1String(
"[%" ) ) && selText.endsWith( QLatin1String(
"%]" ) ) )
410 selText = selText.mid( 2, selText.size() - 4 );
413 if ( context().expressionContext() )
420 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
421 if ( exprDlg.exec() == QDialog::Accepted )
423 QString expression = exprDlg.expressionText();
424 if ( !expression.isEmpty() )
426 mTextEdit->insertPlainText(
"[%" + expression +
"%]" );
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
An annotation item which renders a line symbol along a line geometry.
void setSymbol(QgsLineSymbol *symbol)
Sets the symbol used to render the marker item.
QgsAnnotationLineItem * clone() override
Returns a clone of the item.
An annotation item which renders a marker symbol at a point location.
QgsAnnotationMarkerItem * clone() override
Returns a clone of the item.
void setSymbol(QgsMarkerSymbol *symbol)
Sets the symbol used to render the marker item.
An annotation item which renders a text string at a point location.
void setText(const QString &text)
Sets the text rendered by the item.
void setFormat(const QgsTextFormat &format)
Sets the text format used to render the text.
QgsAnnotationPointTextItem * clone() override
Returns a clone of the item.
An annotation item which renders a fill symbol for a polygon geometry.
void setSymbol(QgsFillSymbol *symbol)
Sets the symbol used to render the polygon item.
QgsAnnotationPolygonItem * clone() override
Returns a clone of the item.
static QgsRecentStyleHandler * recentStyleHandler()
Returns the handler for recently used style items.
A generic dialog for building expression strings.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static QgsFillSymbol * createSimple(const QVariantMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties.
static QgsLineSymbol * createSimple(const QVariantMap &properties)
Create a line symbol with one symbol layer: SimpleLine with specified properties.
static QgsMarkerSymbol * createSimple(const QVariantMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void pushRecentSymbol(const QString &identifier, QgsSymbol *symbol)
Pushes a recently used symbol with the specified identifier.
static QgsStyle * defaultStyle()
Returns default application-wide style.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
A widget for customizing text formatting settings.
void widgetChanged()
Emitted when the text format defined by the widget changes.