Skip to content

Commit a85d4d1

Browse files
committedJul 22, 2019
[FEATURE] Allow data defined settings in text formats
This allows text formats to store data defined settings, allowing them to be used wherever the text renderer is (e.g. in layout scalebar text).
1 parent 19a2b0e commit a85d4d1

File tree

5 files changed

+312
-336
lines changed

5 files changed

+312
-336
lines changed
 

‎python/gui/auto_generated/qgstextformatwidget.sip.in

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ Constructor for QgsTextFormatWidget.
4747

4848
~QgsTextFormatWidget();
4949

50-
QgsTextFormat format() const;
50+
QgsTextFormat format( bool includeDataDefinedProperties = true ) const;
5151
%Docstring
5252
Returns the current formatting settings defined by the widget.
53+
54+
If ``includateDataDefinedProperties`` is ``True``, then data defined properties
55+
specified in the widget will be included in the format definition.
5356
%End
5457

5558
void setFormat( const QgsTextFormat &format );
@@ -75,6 +78,16 @@ Returns the context in which the widget is shown, e.g., the associated map canva
7578
.. seealso:: :py:func:`setContext`
7679

7780
.. versionadded:: 3.10
81+
%End
82+
83+
void deactivateField( QgsPalLayerSettings::Property key );
84+
%Docstring
85+
Deactivate a field from data defined properties and update the
86+
corresponding button.
87+
88+
:param key: The property key to deactivate
89+
90+
.. versionadded:: 3.0
7891
%End
7992

8093
public slots:
@@ -91,6 +104,13 @@ Sets whether the widget should be shown in a compact dock mode.
91104
void widgetChanged();
92105
%Docstring
93106
Emitted when the text format defined by the widget changes
107+
%End
108+
109+
void auxiliaryFieldCreated();
110+
%Docstring
111+
Emitted when an auxiliary field is creatd in the widget.
112+
113+
.. versionadded:: 3.10
94114
%End
95115

96116
protected:
@@ -138,6 +158,7 @@ Controls whether data defined alignment buttons are enabled.
138158

139159

140160

161+
141162
protected slots:
142163

143164
void updateLinePlacementOptions();
@@ -169,6 +190,7 @@ Updates the text preview.
169190
.. versionadded:: 3.10
170191
%End
171192

193+
172194
};
173195

174196

‎src/gui/qgslabelinggui.cpp

Lines changed: 1 addition & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,6 @@ QgsExpressionContext QgsLabelingGui::createExpressionContext() const
5757
return expContext;
5858
}
5959

60-
void QgsLabelingGui::registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsPalLayerSettings::Property key )
61-
{
62-
button->init( key, mDataDefinedProperties, QgsPalLayerSettings::propertyDefinitions(), mLayer, true );
63-
connect( button, &QgsPropertyOverrideButton::changed, this, &QgsLabelingGui::updateProperty );
64-
connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsLabelingGui::createAuxiliaryField );
65-
button->registerExpressionContextGenerator( this );
66-
67-
mButtons[key] = button;
68-
}
69-
70-
void QgsLabelingGui::updateProperty()
71-
{
72-
QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
73-
QgsPalLayerSettings::Property key = static_cast< QgsPalLayerSettings::Property >( button->propertyKey() );
74-
mDataDefinedProperties.setProperty( key, button->toProperty() );
75-
}
76-
7760
static bool _initCalloutWidgetFunction( const QString &name, QgsCalloutWidgetFunc f )
7861
{
7962
QgsCalloutRegistry *registry = QgsApplication::calloutRegistry();
@@ -500,7 +483,7 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
500483
lyr.useSubstitutions = mCheckBoxSubstituteText->isChecked();
501484
lyr.substitutions = mSubstitutions;
502485

503-
lyr.setFormat( format() );
486+
lyr.setFormat( format( false ) );
504487

505488
// format numbers
506489
lyr.formatNumbers = mFormatNumChkBx->isChecked();
@@ -563,148 +546,6 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
563546
return lyr;
564547
}
565548

566-
void QgsLabelingGui::populateDataDefinedButtons()
567-
{
568-
// text style
569-
registerDataDefinedButton( mFontDDBtn, QgsPalLayerSettings::Family );
570-
registerDataDefinedButton( mFontStyleDDBtn, QgsPalLayerSettings::FontStyle );
571-
registerDataDefinedButton( mFontUnderlineDDBtn, QgsPalLayerSettings::Underline );
572-
registerDataDefinedButton( mFontStrikeoutDDBtn, QgsPalLayerSettings::Strikeout );
573-
registerDataDefinedButton( mFontBoldDDBtn, QgsPalLayerSettings::Bold );
574-
registerDataDefinedButton( mFontItalicDDBtn, QgsPalLayerSettings::Italic );
575-
registerDataDefinedButton( mFontSizeDDBtn, QgsPalLayerSettings::Size );
576-
registerDataDefinedButton( mFontUnitsDDBtn, QgsPalLayerSettings::FontSizeUnit );
577-
registerDataDefinedButton( mFontColorDDBtn, QgsPalLayerSettings::Color );
578-
registerDataDefinedButton( mFontOpacityDDBtn, QgsPalLayerSettings::FontOpacity );
579-
registerDataDefinedButton( mFontCaseDDBtn, QgsPalLayerSettings::FontCase );
580-
registerDataDefinedButton( mFontLetterSpacingDDBtn, QgsPalLayerSettings::FontLetterSpacing );
581-
registerDataDefinedButton( mFontWordSpacingDDBtn, QgsPalLayerSettings::FontWordSpacing );
582-
registerDataDefinedButton( mFontBlendModeDDBtn, QgsPalLayerSettings::FontBlendMode );
583-
584-
// text formatting
585-
registerDataDefinedButton( mWrapCharDDBtn, QgsPalLayerSettings::MultiLineWrapChar );
586-
registerDataDefinedButton( mAutoWrapLengthDDBtn, QgsPalLayerSettings::AutoWrapLength );
587-
registerDataDefinedButton( mFontLineHeightDDBtn, QgsPalLayerSettings::MultiLineHeight );
588-
registerDataDefinedButton( mFontMultiLineAlignDDBtn, QgsPalLayerSettings::MultiLineAlignment );
589-
590-
registerDataDefinedButton( mDirectSymbDDBtn, QgsPalLayerSettings::DirSymbDraw );
591-
mDirectSymbDDBtn->registerCheckedWidget( mDirectSymbChkBx );
592-
registerDataDefinedButton( mDirectSymbLeftDDBtn, QgsPalLayerSettings::DirSymbLeft );
593-
registerDataDefinedButton( mDirectSymbRightDDBtn, QgsPalLayerSettings::DirSymbRight );
594-
595-
registerDataDefinedButton( mDirectSymbPlacementDDBtn, QgsPalLayerSettings::DirSymbPlacement );
596-
registerDataDefinedButton( mDirectSymbRevDDBtn, QgsPalLayerSettings::DirSymbReverse );
597-
598-
registerDataDefinedButton( mFormatNumDDBtn, QgsPalLayerSettings::NumFormat );
599-
mFormatNumDDBtn->registerCheckedWidget( mFormatNumChkBx );
600-
registerDataDefinedButton( mFormatNumDecimalsDDBtn, QgsPalLayerSettings::NumDecimals );
601-
registerDataDefinedButton( mFormatNumPlusSignDDBtn, QgsPalLayerSettings::NumPlusSign );
602-
603-
// text buffer
604-
registerDataDefinedButton( mBufferDrawDDBtn, QgsPalLayerSettings::BufferDraw );
605-
mBufferDrawDDBtn->registerCheckedWidget( mBufferDrawChkBx );
606-
registerDataDefinedButton( mBufferSizeDDBtn, QgsPalLayerSettings::BufferSize );
607-
registerDataDefinedButton( mBufferUnitsDDBtn, QgsPalLayerSettings::BufferUnit );
608-
registerDataDefinedButton( mBufferColorDDBtn, QgsPalLayerSettings::BufferColor );
609-
registerDataDefinedButton( mBufferOpacityDDBtn, QgsPalLayerSettings::BufferOpacity );
610-
registerDataDefinedButton( mBufferJoinStyleDDBtn, QgsPalLayerSettings::BufferJoinStyle );
611-
registerDataDefinedButton( mBufferBlendModeDDBtn, QgsPalLayerSettings::BufferBlendMode );
612-
613-
// background
614-
registerDataDefinedButton( mShapeDrawDDBtn, QgsPalLayerSettings::ShapeDraw );
615-
mShapeDrawDDBtn->registerCheckedWidget( mShapeDrawChkBx );
616-
registerDataDefinedButton( mShapeTypeDDBtn, QgsPalLayerSettings::ShapeKind );
617-
registerDataDefinedButton( mShapeSVGPathDDBtn, QgsPalLayerSettings::ShapeSVGFile );
618-
registerDataDefinedButton( mShapeSizeTypeDDBtn, QgsPalLayerSettings::ShapeSizeType );
619-
registerDataDefinedButton( mShapeSizeXDDBtn, QgsPalLayerSettings::ShapeSizeX );
620-
registerDataDefinedButton( mShapeSizeYDDBtn, QgsPalLayerSettings::ShapeSizeY );
621-
registerDataDefinedButton( mShapeSizeUnitsDDBtn, QgsPalLayerSettings::ShapeSizeUnits );
622-
registerDataDefinedButton( mShapeRotationTypeDDBtn, QgsPalLayerSettings::ShapeRotationType );
623-
registerDataDefinedButton( mShapeRotationDDBtn, QgsPalLayerSettings::ShapeRotation );
624-
registerDataDefinedButton( mShapeOffsetDDBtn, QgsPalLayerSettings::ShapeOffset );
625-
registerDataDefinedButton( mShapeOffsetUnitsDDBtn, QgsPalLayerSettings::ShapeOffsetUnits );
626-
registerDataDefinedButton( mShapeRadiusDDBtn, QgsPalLayerSettings::ShapeRadii );
627-
registerDataDefinedButton( mShapeRadiusUnitsDDBtn, QgsPalLayerSettings::ShapeRadiiUnits );
628-
registerDataDefinedButton( mShapeOpacityDDBtn, QgsPalLayerSettings::ShapeOpacity );
629-
registerDataDefinedButton( mShapeBlendModeDDBtn, QgsPalLayerSettings::ShapeBlendMode );
630-
registerDataDefinedButton( mShapeFillColorDDBtn, QgsPalLayerSettings::ShapeFillColor );
631-
registerDataDefinedButton( mShapeStrokeColorDDBtn, QgsPalLayerSettings::ShapeStrokeColor );
632-
registerDataDefinedButton( mShapeStrokeWidthDDBtn, QgsPalLayerSettings::ShapeStrokeWidth );
633-
registerDataDefinedButton( mShapeStrokeUnitsDDBtn, QgsPalLayerSettings::ShapeStrokeWidthUnits );
634-
registerDataDefinedButton( mShapePenStyleDDBtn, QgsPalLayerSettings::ShapeJoinStyle );
635-
636-
// drop shadows
637-
registerDataDefinedButton( mShadowDrawDDBtn, QgsPalLayerSettings::ShadowDraw );
638-
mShadowDrawDDBtn->registerCheckedWidget( mShadowDrawChkBx );
639-
registerDataDefinedButton( mShadowUnderDDBtn, QgsPalLayerSettings::ShadowUnder );
640-
registerDataDefinedButton( mShadowOffsetAngleDDBtn, QgsPalLayerSettings::ShadowOffsetAngle );
641-
registerDataDefinedButton( mShadowOffsetDDBtn, QgsPalLayerSettings::ShadowOffsetDist );
642-
registerDataDefinedButton( mShadowOffsetUnitsDDBtn, QgsPalLayerSettings::ShadowOffsetUnits );
643-
registerDataDefinedButton( mShadowRadiusDDBtn, QgsPalLayerSettings::ShadowRadius );
644-
registerDataDefinedButton( mShadowRadiusUnitsDDBtn, QgsPalLayerSettings::ShadowRadiusUnits );
645-
registerDataDefinedButton( mShadowOpacityDDBtn, QgsPalLayerSettings::ShadowOpacity );
646-
registerDataDefinedButton( mShadowScaleDDBtn, QgsPalLayerSettings::ShadowScale );
647-
registerDataDefinedButton( mShadowColorDDBtn, QgsPalLayerSettings::ShadowColor );
648-
registerDataDefinedButton( mShadowBlendDDBtn, QgsPalLayerSettings::ShadowBlendMode );
649-
650-
// placement
651-
registerDataDefinedButton( mCentroidDDBtn, QgsPalLayerSettings::CentroidWhole );
652-
registerDataDefinedButton( mPointQuadOffsetDDBtn, QgsPalLayerSettings::OffsetQuad );
653-
registerDataDefinedButton( mPointPositionOrderDDBtn, QgsPalLayerSettings::PredefinedPositionOrder );
654-
registerDataDefinedButton( mLinePlacementFlagsDDBtn, QgsPalLayerSettings::LinePlacementOptions );
655-
registerDataDefinedButton( mPointOffsetDDBtn, QgsPalLayerSettings::OffsetXY );
656-
registerDataDefinedButton( mPointOffsetUnitsDDBtn, QgsPalLayerSettings::OffsetUnits );
657-
registerDataDefinedButton( mLineDistanceDDBtn, QgsPalLayerSettings::LabelDistance );
658-
registerDataDefinedButton( mLineDistanceUnitDDBtn, QgsPalLayerSettings::DistanceUnits );
659-
registerDataDefinedButton( mPriorityDDBtn, QgsPalLayerSettings::Priority );
660-
661-
// TODO: is this necessary? maybe just use the data defined-only rotation?
662-
//mPointAngleDDBtn, QgsPalLayerSettings::OffsetRotation,
663-
// QgsPropertyOverrideButton::AnyType, QgsPropertyOverrideButton::double180RotDesc() );
664-
registerDataDefinedButton( mMaxCharAngleDDBtn, QgsPalLayerSettings::CurvedCharAngleInOut );
665-
registerDataDefinedButton( mRepeatDistanceDDBtn, QgsPalLayerSettings::RepeatDistance );
666-
registerDataDefinedButton( mRepeatDistanceUnitDDBtn, QgsPalLayerSettings::RepeatDistanceUnit );
667-
668-
// data defined-only
669-
QString ddPlaceInfo = tr( "In edit mode, layer's relevant labeling map tool is:<br>"
670-
"&nbsp;&nbsp;Defined attribute field -&gt; <i>enabled</i><br>"
671-
"&nbsp;&nbsp;Defined expression -&gt; <i>disabled</i>" );
672-
registerDataDefinedButton( mCoordXDDBtn, QgsPalLayerSettings::PositionX );
673-
mCoordXDDBtn->setUsageInfo( ddPlaceInfo );
674-
registerDataDefinedButton( mCoordYDDBtn, QgsPalLayerSettings::PositionY );
675-
mCoordYDDBtn->setUsageInfo( ddPlaceInfo );
676-
registerDataDefinedButton( mCoordAlignmentHDDBtn, QgsPalLayerSettings::Hali );
677-
mCoordAlignmentHDDBtn->setUsageInfo( ddPlaceInfo );
678-
registerDataDefinedButton( mCoordAlignmentVDDBtn, QgsPalLayerSettings::Vali );
679-
mCoordAlignmentVDDBtn->setUsageInfo( ddPlaceInfo );
680-
registerDataDefinedButton( mCoordRotationDDBtn, QgsPalLayerSettings::LabelRotation );
681-
mCoordRotationDDBtn->setUsageInfo( ddPlaceInfo );
682-
683-
// rendering
684-
QString ddScaleVisInfo = tr( "Value &lt; 0 represents a scale closer than 1:1, e.g. -10 = 10:1<br>"
685-
"Value of 0 disables the specific limit." );
686-
registerDataDefinedButton( mScaleBasedVisibilityDDBtn, QgsPalLayerSettings::ScaleVisibility );
687-
mScaleBasedVisibilityDDBtn->registerCheckedWidget( mScaleBasedVisibilityChkBx );
688-
registerDataDefinedButton( mScaleBasedVisibilityMinDDBtn, QgsPalLayerSettings::MinimumScale );
689-
mScaleBasedVisibilityMinDDBtn->setUsageInfo( ddScaleVisInfo );
690-
registerDataDefinedButton( mScaleBasedVisibilityMaxDDBtn, QgsPalLayerSettings::MaximumScale );
691-
mScaleBasedVisibilityMaxDDBtn->setUsageInfo( ddScaleVisInfo );
692-
693-
registerDataDefinedButton( mFontLimitPixelDDBtn, QgsPalLayerSettings::FontLimitPixel );
694-
mFontLimitPixelDDBtn->registerCheckedWidget( mFontLimitPixelChkBox );
695-
registerDataDefinedButton( mFontMinPixelDDBtn, QgsPalLayerSettings::FontMinPixel );
696-
registerDataDefinedButton( mFontMaxPixelDDBtn, QgsPalLayerSettings::FontMaxPixel );
697-
698-
registerDataDefinedButton( mShowLabelDDBtn, QgsPalLayerSettings::Show );
699-
700-
registerDataDefinedButton( mAlwaysShowDDBtn, QgsPalLayerSettings::AlwaysShow );
701-
702-
registerDataDefinedButton( mIsObstacleDDBtn, QgsPalLayerSettings::IsObstacle );
703-
registerDataDefinedButton( mObstacleFactorDDBtn, QgsPalLayerSettings::ObstacleFactor );
704-
registerDataDefinedButton( mZIndexDDBtn, QgsPalLayerSettings::ZIndex );
705-
706-
registerDataDefinedButton( mCalloutDrawDDBtn, QgsPalLayerSettings::CalloutDraw );
707-
}
708549

709550
void QgsLabelingGui::syncDefinedCheckboxFrame( QgsPropertyOverrideButton *ddBtn, QCheckBox *chkBx, QFrame *f )
710551
{
@@ -739,41 +580,6 @@ void QgsLabelingGui::updateUi()
739580
}
740581
}
741582

742-
void QgsLabelingGui::createAuxiliaryField()
743-
{
744-
if ( !mLayer )
745-
return;
746-
747-
// try to create an auxiliary layer if not yet created
748-
if ( !mLayer->auxiliaryLayer() )
749-
{
750-
QgsNewAuxiliaryLayerDialog dlg( mLayer, this );
751-
dlg.exec();
752-
}
753-
754-
// return if still not exists
755-
if ( !mLayer->auxiliaryLayer() )
756-
return;
757-
758-
QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
759-
const QgsPalLayerSettings::Property key = static_cast< QgsPalLayerSettings::Property >( button->propertyKey() );
760-
const QgsPropertyDefinition def = QgsPalLayerSettings::propertyDefinitions()[key];
761-
762-
// create property in auxiliary storage if necessary
763-
if ( !mLayer->auxiliaryLayer()->exists( def ) )
764-
mLayer->auxiliaryLayer()->addAuxiliaryField( def );
765-
766-
// update property with join field name from auxiliary storage
767-
QgsProperty property = button->toProperty();
768-
property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
769-
property.setActive( true );
770-
button->updateFieldLists();
771-
button->setToProperty( property );
772-
mDataDefinedProperties.setProperty( key, button->toProperty() );
773-
774-
emit auxiliaryFieldCreated();
775-
}
776-
777583
void QgsLabelingGui::setFormatFromStyle( const QString &name, QgsStyle::StyleEntity type )
778584
{
779585
switch ( type )
@@ -886,20 +692,6 @@ void QgsLabelingGui::saveFormat()
886692
}
887693
}
888694

889-
void QgsLabelingGui::deactivateField( QgsPalLayerSettings::Property key )
890-
{
891-
if ( mButtons.contains( key ) )
892-
{
893-
QgsPropertyOverrideButton *button = mButtons[ key ];
894-
QgsProperty p = button->toProperty();
895-
p.setField( QString() );
896-
p.setActive( false );
897-
button->updateFieldLists();
898-
button->setToProperty( p );
899-
mDataDefinedProperties.setProperty( key, p );
900-
}
901-
}
902-
903695
void QgsLabelingGui::updateGeometryTypeBasedWidgets()
904696
{
905697
QgsWkbTypes::GeometryType geometryType = mGeomType;

‎src/gui/qgslabelinggui.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,12 @@ class GUI_EXPORT QgsLabelingGui : public QgsTextFormatWidget
5252

5353
void setSettings( const QgsPalLayerSettings &settings );
5454

55-
/**
56-
* Deactivate a field from data defined properties and update the
57-
* corresponding button.
58-
*
59-
* \param key The property key to deactivate
60-
*
61-
* \since QGIS 3.0
62-
*/
63-
void deactivateField( QgsPalLayerSettings::Property key );
64-
6555
void setContext( const QgsSymbolWidgetContext &context ) override;
6656

67-
signals:
68-
69-
void auxiliaryFieldCreated();
70-
7157
public slots:
7258

7359
void updateUi();
7460

75-
void createAuxiliaryField();
76-
7761
protected slots:
7862
void setFormatFromStyle( const QString &name, QgsStyle::StyleEntity type ) override;
7963
void saveFormat() override;
@@ -100,23 +84,17 @@ class GUI_EXPORT QgsLabelingGui : public QgsTextFormatWidget
10084
void calloutTypeChanged();
10185

10286
private:
87+
10388
QgsWkbTypes::GeometryType mGeomType = QgsWkbTypes::UnknownGeometry;
10489
QgsPalLayerSettings mSettings;
105-
QgsPropertyCollection mDataDefinedProperties;
10690
LabelMode mMode;
10791
QgsFeature mPreviewFeature;
10892
QgsMapCanvas *mCanvas = nullptr;
10993

11094
QgsExpressionContext createExpressionContext() const override;
11195

112-
void populateDataDefinedButtons();
113-
void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsPalLayerSettings::Property key );
114-
115-
QMap<QgsPalLayerSettings::Property, QgsPropertyOverrideButton *> mButtons;
116-
11796
private slots:
11897

119-
void updateProperty();
12098
void initCalloutWidgets();
12199
void updateCalloutWidget( QgsCallout *callout );
122100

‎src/gui/qgstextformatwidget.cpp

Lines changed: 247 additions & 101 deletions
Large diffs are not rendered by default.

‎src/gui/qgstextformatwidget.h

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ class GUI_EXPORT QgsTextFormatWidget : public QWidget, public QgsExpressionConte
6868

6969
/**
7070
* Returns the current formatting settings defined by the widget.
71+
*
72+
* If \a includateDataDefinedProperties is TRUE, then data defined properties
73+
* specified in the widget will be included in the format definition.
7174
*/
72-
QgsTextFormat format() const;
75+
QgsTextFormat format( bool includeDataDefinedProperties = true ) const;
7376

7477
/**
7578
* Sets the current formatting settings
@@ -91,6 +94,16 @@ class GUI_EXPORT QgsTextFormatWidget : public QWidget, public QgsExpressionConte
9194
*/
9295
QgsSymbolWidgetContext context() const;
9396

97+
/**
98+
* Deactivate a field from data defined properties and update the
99+
* corresponding button.
100+
*
101+
* \param key The property key to deactivate
102+
*
103+
* \since QGIS 3.0
104+
*/
105+
void deactivateField( QgsPalLayerSettings::Property key );
106+
94107
public slots:
95108

96109
/**
@@ -104,6 +117,12 @@ class GUI_EXPORT QgsTextFormatWidget : public QWidget, public QgsExpressionConte
104117
//! Emitted when the text format defined by the widget changes
105118
void widgetChanged();
106119

120+
/**
121+
* Emitted when an auxiliary field is creatd in the widget.
122+
* \since QGIS 3.10
123+
*/
124+
void auxiliaryFieldCreated();
125+
107126
protected:
108127

109128
//! Widget mode
@@ -165,6 +184,9 @@ class GUI_EXPORT QgsTextFormatWidget : public QWidget, public QgsExpressionConte
165184
//! Context in which widget is shown
166185
QgsSymbolWidgetContext mContext;
167186

187+
//! Data defined properties as defined in the widget
188+
QgsPropertyCollection mDataDefinedProperties;
189+
168190
//! Associated vector layer
169191
QgsVectorLayer *mLayer = nullptr;
170192
protected slots:
@@ -192,6 +214,17 @@ class GUI_EXPORT QgsTextFormatWidget : public QWidget, public QgsExpressionConte
192214
*/
193215
void updatePreview();
194216

217+
#ifndef SIP_RUN
218+
219+
/**
220+
* Sets up connections required for data defined buttons, or updates the existing
221+
* definition of these buttons.
222+
*
223+
* \since QGIS 3.10
224+
*/
225+
void populateDataDefinedButtons();
226+
#endif
227+
195228
private:
196229
Mode mWidgetMode = Text;
197230

@@ -209,6 +242,8 @@ class GUI_EXPORT QgsTextFormatWidget : public QWidget, public QgsExpressionConte
209242
bool mLoadSvgParams = false;
210243
QgsExpressionContext mPreviewExpressionContext;
211244

245+
QMap<QgsPalLayerSettings::Property, QgsPropertyOverrideButton *> mButtons;
246+
212247
void initWidget();
213248
void setWidgetMode( Mode mode );
214249
void toggleDDButtons( bool visible );
@@ -218,6 +253,8 @@ class GUI_EXPORT QgsTextFormatWidget : public QWidget, public QgsExpressionConte
218253
void updateFont( const QFont &font );
219254
void connectValueChanged( const QList<QWidget *> &widgets, const char *slot );
220255

256+
void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsPalLayerSettings::Property key );
257+
221258
private slots:
222259
void optionsStackedWidget_CurrentChanged( int indx );
223260
void showBackgroundRadius( bool show );
@@ -257,7 +294,8 @@ class GUI_EXPORT QgsTextFormatWidget : public QWidget, public QgsExpressionConte
257294
void scrollPreview();
258295
void updateSvgWidgets( const QString &svgPath );
259296
void updateAvailableShadowPositions();
260-
297+
void updateProperty();
298+
void createAuxiliaryField();
261299
};
262300

263301

0 commit comments

Comments
 (0)
Please sign in to comment.