QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgstextformatwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgstextformatwidget.h
3  ---------------------
4  begin : June 2009
5  copyright : (C) Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgstextformatwidget.h"
17 #include "qgsmapcanvas.h"
19 #include "qgslogger.h"
20 #include "qgsfontutils.h"
21 #include "qgssymbollayerutils.h"
22 #include "qgssvgcache.h"
23 #include "qgssvgselectorwidget.h"
25 #include "qgspallabeling.h" // for enum values
26 #include "qgspathresolver.h"
27 #include "qgsproject.h"
28 #include "qgssettings.h"
29 #include "qgseffectstack.h"
30 #include "qgspainteffectregistry.h"
31 #include "qgsstylesavedialog.h"
33 #include "qgsgui.h"
34 #include "qgsvectorlayer.h"
35 #include "qgsauxiliarystorage.h"
37 #include "qgshelp.h"
38 
39 #include <QButtonGroup>
40 #include <QMessageBox>
41 
42 QgsTextFormatWidget::QgsTextFormatWidget( const QgsTextFormat &format, QgsMapCanvas *mapCanvas, QWidget *parent, QgsVectorLayer *layer )
43  : QWidget( parent )
44  , mMapCanvas( mapCanvas )
45  , mLayer( layer )
46 {
47  initWidget();
48  setWidgetMode( Text );
51 }
52 
53 QgsTextFormatWidget::QgsTextFormatWidget( QgsMapCanvas *mapCanvas, QWidget *parent, Mode mode, QgsVectorLayer *layer )
54  : QWidget( parent )
55  , mMapCanvas( mapCanvas )
56  , mLayer( layer )
57  , mWidgetMode( mode )
58 {
59  initWidget();
60  if ( mode == Text )
62  setWidgetMode( mode );
63 }
64 
65 void QgsTextFormatWidget::initWidget()
66 {
67  setupUi( this );
68  connect( mShapeSVGPathLineEdit, &QLineEdit::textChanged, this, &QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged );
69  connect( mFontSizeSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsTextFormatWidget::mFontSizeSpinBox_valueChanged );
70  connect( mFontCapitalsComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsTextFormatWidget::mFontCapitalsComboBox_currentIndexChanged );
71  connect( mFontFamilyCmbBx, &QFontComboBox::currentFontChanged, this, &QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged );
72  connect( mFontStyleComboBox, &QComboBox::currentTextChanged, this, &QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged );
73  connect( mFontUnderlineBtn, &QToolButton::toggled, this, &QgsTextFormatWidget::mFontUnderlineBtn_toggled );
74  connect( mFontStrikethroughBtn, &QToolButton::toggled, this, &QgsTextFormatWidget::mFontStrikethroughBtn_toggled );
75  connect( mFontWordSpacingSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged );
76  connect( mFontLetterSpacingSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged );
77  connect( mFontSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsTextFormatWidget::mFontSizeUnitWidget_changed );
78  connect( mFontMinPixelSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged );
79  connect( mFontMaxPixelSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged );
80  connect( mBufferUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsTextFormatWidget::mBufferUnitWidget_changed );
81  connect( mMaskBufferUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsTextFormatWidget::mMaskBufferUnitWidget_changed );
82  connect( mCoordXDDBtn, &QgsPropertyOverrideButton::changed, this, &QgsTextFormatWidget::mCoordXDDBtn_changed );
83  connect( mCoordYDDBtn, &QgsPropertyOverrideButton::changed, this, &QgsTextFormatWidget::mCoordYDDBtn_changed );
84  connect( mShapeTypeCmbBx, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged );
85  connect( mShapeRotationCmbBx, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged );
86  connect( mShapeSVGParamsBtn, &QPushButton::clicked, this, &QgsTextFormatWidget::mShapeSVGParamsBtn_clicked );
87  connect( mShapeSVGSelectorBtn, &QPushButton::clicked, this, &QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked );
88  connect( mPreviewTextEdit, &QLineEdit::textChanged, this, &QgsTextFormatWidget::mPreviewTextEdit_textChanged );
89  connect( mPreviewTextBtn, &QToolButton::clicked, this, &QgsTextFormatWidget::mPreviewTextBtn_clicked );
90  connect( mPreviewBackgroundBtn, &QgsColorButton::colorChanged, this, &QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged );
91  connect( mDirectSymbLeftToolBtn, &QToolButton::clicked, this, &QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked );
92  connect( mDirectSymbRightToolBtn, &QToolButton::clicked, this, &QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked );
93  connect( chkLineOrientationDependent, &QCheckBox::toggled, this, &QgsTextFormatWidget::chkLineOrientationDependent_toggled );
94  connect( mToolButtonConfigureSubstitutes, &QToolButton::clicked, this, &QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked );
95  connect( mKerningCheckBox, &QCheckBox::toggled, this, &QgsTextFormatWidget::kerningToggled );
96 
97  const int iconSize = QgsGuiUtils::scaleIconSize( 20 );
98  mOptionsTab->setIconSize( QSize( iconSize, iconSize ) );
99  mLabelingOptionsListWidget->setIconSize( QSize( iconSize, iconSize ) ) ;
100  const int iconSize32 = QgsGuiUtils::scaleIconSize( 32 );
101  const int iconSize24 = QgsGuiUtils::scaleIconSize( 24 );
102  const int iconSize18 = QgsGuiUtils::scaleIconSize( 18 );
103  const int iconSize16 = QgsGuiUtils::scaleIconSize( 16 );
104 
105  mPreviewTextBtn->setIconSize( QSize( iconSize16, iconSize16 ) );
106  mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
107  mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
108  mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );
109  mPointOffsetLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
110  mPointOffsetOver ->setIconSize( QSize( iconSize32, iconSize18 ) );
111  mPointOffsetRight->setIconSize( QSize( iconSize32, iconSize18 ) );
112  mPointOffsetBelowLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
113  mPointOffsetBelow->setIconSize( QSize( iconSize32, iconSize18 ) );
114  mPointOffsetBelowRight->setIconSize( QSize( iconSize32, iconSize18 ) );
115  mLabelMinScale->setPixmap( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomOut.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
116  mLabelMaxScale->setPixmap( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomIn.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
117 
118  const int buttonSize = QgsGuiUtils::scaleIconSize( 24 );
119  mFontUnderlineBtn->setMinimumSize( buttonSize, buttonSize );
120  mFontUnderlineBtn->setMaximumSize( buttonSize, buttonSize );
121  mFontStrikethroughBtn->setMinimumSize( buttonSize, buttonSize );
122  mFontStrikethroughBtn->setMaximumSize( buttonSize, buttonSize );
123  mFontBoldBtn->setMinimumSize( buttonSize, buttonSize );
124  mFontBoldBtn->setMaximumSize( buttonSize, buttonSize );
125  mFontItalicBtn->setMinimumSize( buttonSize, buttonSize );
126  mFontItalicBtn->setMaximumSize( buttonSize, buttonSize );
127 
128  mPreviewScaleComboBox->setMapCanvas( mMapCanvas );
129  mPreviewScaleComboBox->setShowCurrentScaleButton( true );
130  connect( mPreviewScaleComboBox, &QgsScaleWidget::scaleChanged, this, &QgsTextFormatWidget::previewScaleChanged );
131 
132  const auto unitWidgets = findChildren<QgsUnitSelectionWidget *>();
133  for ( QgsUnitSelectionWidget *unitWidget : unitWidgets )
134  {
135  unitWidget->setMapCanvas( mMapCanvas );
136  }
163  mFontLineHeightSpinBox->setClearValue( 1.0 );
164  mShapeRotationDblSpnBx->setClearValue( 0.0 );
165  mShapeOffsetXSpnBx->setClearValue( 0.0 );
166  mShapeOffsetYSpnBx->setClearValue( 0.0 );
167  mPointOffsetXSpinBox->setClearValue( 0.0 );
168  mPointOffsetYSpinBox->setClearValue( 0.0 );
169  mPointAngleSpinBox->setClearValue( 0.0 );
170  mFontLetterSpacingSpinBox->setClearValue( 0.0 );
171  mFontWordSpacingSpinBox->setClearValue( 0.0 );
172  mZIndexSpinBox->setClearValue( 0.0 );
173  mLineDistanceSpnBx->setClearValue( 0.0 );
174 
175  mOffsetTypeComboBox->addItem( tr( "From Point" ), QgsPalLayerSettings::FromPoint );
176  mOffsetTypeComboBox->addItem( tr( "From Symbol Bounds" ), QgsPalLayerSettings::FromSymbolBounds );
177 
178  mShapeTypeCmbBx->addItem( tr( "Rectangle" ), QgsTextBackgroundSettings::ShapeRectangle );
179  mShapeTypeCmbBx->addItem( tr( "Square" ), QgsTextBackgroundSettings::ShapeSquare );
180  mShapeTypeCmbBx->addItem( tr( "Ellipse" ), QgsTextBackgroundSettings::ShapeEllipse );
181  mShapeTypeCmbBx->addItem( tr( "Circle" ), QgsTextBackgroundSettings::ShapeCircle );
182  mShapeTypeCmbBx->addItem( tr( "SVG" ), QgsTextBackgroundSettings::ShapeSVG );
183  mShapeTypeCmbBx->addItem( tr( "Marker Symbol" ), QgsTextBackgroundSettings::ShapeMarkerSymbol );
184 
185  updateAvailableShadowPositions();
186 
187  mBackgroundSymbolButton->setSymbolType( QgsSymbol::Marker );
188  mBackgroundSymbolButton->setDialogTitle( tr( "Background Symbol" ) );
189  mBackgroundSymbolButton->registerExpressionContextGenerator( this );
190  mBackgroundSymbolButton->setMapCanvas( mMapCanvas );
191 
192  mCharDlg = new QgsCharacterSelectorDialog( this );
193 
194  mRefFont = lblFontPreview->font();
195 
196  // internal connections
197  connect( mShadowOffsetAngleDial, &QAbstractSlider::valueChanged, mShadowOffsetAngleSpnBx, &QSpinBox::setValue );
198  connect( mShadowOffsetAngleSpnBx, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), mShadowOffsetAngleDial, &QAbstractSlider::setValue );
199  connect( mLimitLabelChkBox, &QAbstractButton::toggled, mLimitLabelSpinBox, &QWidget::setEnabled );
200  connect( mCheckBoxSubstituteText, &QAbstractButton::toggled, mToolButtonConfigureSubstitutes, &QWidget::setEnabled );
201 
202  //connections to prevent users removing all line placement positions
203  connect( chkLineAbove, &QAbstractButton::toggled, this, &QgsTextFormatWidget::updateLinePlacementOptions );
204  connect( chkLineBelow, &QAbstractButton::toggled, this, &QgsTextFormatWidget::updateLinePlacementOptions );
205  connect( chkLineOn, &QAbstractButton::toggled, this, &QgsTextFormatWidget::updateLinePlacementOptions );
206 
207  mTextOrientationComboBox->addItem( tr( "Horizontal" ), QgsTextFormat::HorizontalOrientation );
208  mTextOrientationComboBox->addItem( tr( "Vertical" ), QgsTextFormat::VerticalOrientation );
209 
210  populateFontCapitalsComboBox();
211 
212  // color buttons
213  mPreviewBackgroundBtn->setColorDialogTitle( tr( "Select Fill Color" ) );
214  mPreviewBackgroundBtn->setContext( QStringLiteral( "labeling" ) );
215  mPreviewBackgroundBtn->setColor( QColor( 255, 255, 255 ) );
216  btnTextColor->setColorDialogTitle( tr( "Select Text Color" ) );
217  btnTextColor->setContext( QStringLiteral( "labeling" ) );
218  btnTextColor->setDefaultColor( Qt::black );
219  btnBufferColor->setColorDialogTitle( tr( "Select Buffer Color" ) );
220  btnBufferColor->setContext( QStringLiteral( "labeling" ) );
221  btnBufferColor->setDefaultColor( Qt::white );
222  mShapeStrokeColorBtn->setColorDialogTitle( tr( "Select Stroke Color" ) );
223  mShapeStrokeColorBtn->setContext( QStringLiteral( "labeling" ) );
224  mShapeFillColorBtn->setColorDialogTitle( tr( "Select Fill Color" ) );
225  mShapeFillColorBtn->setContext( QStringLiteral( "labeling" ) );
226  mShadowColorBtn->setColorDialogTitle( tr( "Select Shadow Color" ) );
227  mShadowColorBtn->setContext( QStringLiteral( "labeling" ) );
228  mShadowColorBtn->setDefaultColor( Qt::black );
229 
230  mFontColorDDBtn->registerLinkedWidget( btnTextColor );
231  mBufferColorDDBtn->registerLinkedWidget( btnBufferColor );
232  mShapeStrokeColorDDBtn->registerLinkedWidget( mShapeStrokeColorBtn );
233  mShapeFillColorDDBtn->registerLinkedWidget( mShapeFillColorBtn );
234  mShadowColorDDBtn->registerLinkedWidget( mShadowColorBtn );
235 
236  // set up quadrant offset button group
237  mQuadrantBtnGrp = new QButtonGroup( this );
238  mQuadrantBtnGrp->addButton( mPointOffsetAboveLeft, static_cast<int>( QgsPalLayerSettings::QuadrantAboveLeft ) );
239  mQuadrantBtnGrp->addButton( mPointOffsetAbove, static_cast<int>( QgsPalLayerSettings::QuadrantAbove ) );
240  mQuadrantBtnGrp->addButton( mPointOffsetAboveRight, static_cast<int>( QgsPalLayerSettings::QuadrantAboveRight ) );
241  mQuadrantBtnGrp->addButton( mPointOffsetLeft, static_cast<int>( QgsPalLayerSettings::QuadrantLeft ) );
242  mQuadrantBtnGrp->addButton( mPointOffsetOver, static_cast<int>( QgsPalLayerSettings::QuadrantOver ) );
243  mQuadrantBtnGrp->addButton( mPointOffsetRight, static_cast<int>( QgsPalLayerSettings::QuadrantRight ) );
244  mQuadrantBtnGrp->addButton( mPointOffsetBelowLeft, static_cast<int>( QgsPalLayerSettings::QuadrantBelowLeft ) );
245  mQuadrantBtnGrp->addButton( mPointOffsetBelow, static_cast<int>( QgsPalLayerSettings::QuadrantBelow ) );
246  mQuadrantBtnGrp->addButton( mPointOffsetBelowRight, static_cast<int>( QgsPalLayerSettings::QuadrantBelowRight ) );
247  mQuadrantBtnGrp->setExclusive( true );
248 
249  // setup direction symbol(s) button group
250  mDirectSymbBtnGrp = new QButtonGroup( this );
251  mDirectSymbBtnGrp->addButton( mDirectSymbRadioBtnLR, static_cast<int>( QgsPalLayerSettings::SymbolLeftRight ) );
252  mDirectSymbBtnGrp->addButton( mDirectSymbRadioBtnAbove, static_cast<int>( QgsPalLayerSettings::SymbolAbove ) );
253  mDirectSymbBtnGrp->addButton( mDirectSymbRadioBtnBelow, static_cast<int>( QgsPalLayerSettings::SymbolBelow ) );
254  mDirectSymbBtnGrp->setExclusive( true );
255 
256  // upside-down labels button group
257  mUpsidedownBtnGrp = new QButtonGroup( this );
258  mUpsidedownBtnGrp->addButton( mUpsidedownRadioOff, static_cast<int>( QgsPalLayerSettings::Upright ) );
259  mUpsidedownBtnGrp->addButton( mUpsidedownRadioDefined, static_cast<int>( QgsPalLayerSettings::ShowDefined ) );
260  mUpsidedownBtnGrp->addButton( mUpsidedownRadioAll, static_cast<int>( QgsPalLayerSettings::ShowAll ) );
261  mUpsidedownBtnGrp->setExclusive( true );
262 
263  //mShapeCollisionsChkBx->setVisible( false ); // until implemented
264 
265  // post updatePlacementWidgets() connections
266  connect( chkLineAbove, &QAbstractButton::toggled, this, &QgsTextFormatWidget::updatePlacementWidgets );
267  connect( chkLineBelow, &QAbstractButton::toggled, this, &QgsTextFormatWidget::updatePlacementWidgets );
268  connect( mCheckAllowLabelsOutsidePolygons, &QAbstractButton::toggled, this, &QgsTextFormatWidget::updatePlacementWidgets );
269  connect( mAllowOutsidePolygonsDDBtn, &QgsPropertyOverrideButton::changed, this, &QgsTextFormatWidget::updatePlacementWidgets );
270 
271  // setup point placement button group
272  mPlacePointBtnGrp = new QButtonGroup( this );
273  mPlacePointBtnGrp->addButton( radPredefinedOrder, static_cast<int>( QgsPalLayerSettings::OrderedPositionsAroundPoint ) );
274  mPlacePointBtnGrp->addButton( radAroundPoint, static_cast<int>( QgsPalLayerSettings::AroundPoint ) );
275  mPlacePointBtnGrp->addButton( radOverPoint, static_cast<int>( QgsPalLayerSettings::OverPoint ) );
276  mPlacePointBtnGrp->setExclusive( true );
277  connect( mPlacePointBtnGrp, static_cast<void ( QButtonGroup::* )( int )>( &QButtonGroup::buttonClicked ), this, &QgsTextFormatWidget::updatePlacementWidgets );
278 
279  // setup line placement button group (assigned enum id currently unused)
280  mPlaceLineBtnGrp = new QButtonGroup( this );
281  mPlaceLineBtnGrp->addButton( radLineParallel, static_cast<int>( QgsPalLayerSettings::Line ) );
282  mPlaceLineBtnGrp->addButton( radLineCurved, static_cast<int>( QgsPalLayerSettings::Curved ) );
283  mPlaceLineBtnGrp->addButton( radLineHorizontal, static_cast<int>( QgsPalLayerSettings::Horizontal ) );
284  mPlaceLineBtnGrp->setExclusive( true );
285  connect( mPlaceLineBtnGrp, static_cast<void ( QButtonGroup::* )( int )>( &QButtonGroup::buttonClicked ), this, &QgsTextFormatWidget::updatePlacementWidgets );
286 
287  // setup polygon placement button group (assigned enum id currently unused)
288  mPlacePolygonBtnGrp = new QButtonGroup( this );
289  mPlacePolygonBtnGrp->addButton( radOverCentroid, static_cast<int>( QgsPalLayerSettings::OverPoint ) );
290  mPlacePolygonBtnGrp->addButton( radAroundCentroid, static_cast<int>( QgsPalLayerSettings::AroundPoint ) );
291  mPlacePolygonBtnGrp->addButton( radPolygonHorizontal, static_cast<int>( QgsPalLayerSettings::Horizontal ) );
292  mPlacePolygonBtnGrp->addButton( radPolygonFree, static_cast<int>( QgsPalLayerSettings::Free ) );
293  mPlacePolygonBtnGrp->addButton( radPolygonPerimeter, static_cast<int>( QgsPalLayerSettings::Line ) );
294  mPlacePolygonBtnGrp->addButton( radPolygonPerimeterCurved, static_cast<int>( QgsPalLayerSettings::PerimeterCurved ) );
295  mPlacePolygonBtnGrp->addButton( radPolygonOutside, static_cast<int>( QgsPalLayerSettings::OutsidePolygons ) );
296  mPlacePolygonBtnGrp->setExclusive( true );
297  connect( mPlacePolygonBtnGrp, static_cast<void ( QButtonGroup::* )( int )>( &QButtonGroup::buttonClicked ), this, &QgsTextFormatWidget::updatePlacementWidgets );
298 
299  // Global settings group for groupboxes' saved/restored collapsed state
300  // maintains state across different dialogs
301  const auto groupBoxes = findChildren<QgsCollapsibleGroupBox *>();
302  for ( QgsCollapsibleGroupBox *grpbox : groupBoxes )
303  {
304  grpbox->setSettingGroup( QStringLiteral( "mAdvLabelingDlg" ) );
305  }
306 
307  connect( groupBox_mPreview, &QgsCollapsibleGroupBoxBasic::collapsedStateChanged, this, &QgsTextFormatWidget::collapseSample );
308 
309  // get rid of annoying outer focus rect on Mac
310  mLabelingOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect, false );
311 
312  QgsSettings settings;
313 
314  // reset horiz stretch of left side of options splitter (set to 1 for previewing in Qt Designer)
315  QSizePolicy policy( mLabelingOptionsListFrame->sizePolicy() );
316  policy.setHorizontalStretch( 0 );
317  mLabelingOptionsListFrame->setSizePolicy( policy );
318  if ( !settings.contains( QStringLiteral( "/Windows/Labeling/OptionsSplitState" ) ) )
319  {
320  // set left list widget width on initial showing
321  QList<int> splitsizes;
322  splitsizes << 115;
323  mLabelingOptionsSplitter->setSizes( splitsizes );
324  }
325 
326  // set up reverse connection from stack to list
327  connect( mLabelStackedWidget, &QStackedWidget::currentChanged, this, &QgsTextFormatWidget::optionsStackedWidget_CurrentChanged );
328 
329  // restore dialog, splitters and current tab
330  mFontPreviewSplitter->restoreState( settings.value( QStringLiteral( "Windows/Labeling/FontPreviewSplitState" ) ).toByteArray() );
331  mLabelingOptionsSplitter->restoreState( settings.value( QStringLiteral( "Windows/Labeling/OptionsSplitState" ) ).toByteArray() );
332 
333  mLabelingOptionsListWidget->setCurrentRow( settings.value( QStringLiteral( "Windows/Labeling/Tab" ), 0 ).toInt() );
334 
335  mBufferEffect.reset( QgsPaintEffectRegistry::defaultStack() );
336  connect( mBufferEffectWidget, &QgsEffectStackCompactWidget::changed, this, &QgsTextFormatWidget::updatePreview );
337  mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
338 
339  mMaskEffect.reset( QgsPaintEffectRegistry::defaultStack() );
340  connect( mMaskEffectWidget, &QgsEffectStackCompactWidget::changed, this, &QgsTextFormatWidget::updatePreview );
341  mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
342 
343  mBackgroundEffect.reset( QgsPaintEffectRegistry::defaultStack() );
344  connect( mBackgroundEffectWidget, &QgsEffectStackCompactWidget::changed, this, &QgsTextFormatWidget::updatePreview );
345  mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
346 
347  setDockMode( false );
348 
349  QList<QWidget *> widgets;
350  widgets << btnBufferColor
351  << btnTextColor
352  << chkLabelPerFeaturePart
353  << chkLineAbove
354  << chkLineBelow
355  << chkLineOn
356  << chkLineOrientationDependent
357  << chkMergeLines
358  << chkPreserveRotation
359  << comboBlendMode
360  << comboBufferBlendMode
361  << mBufferDrawChkBx
362  << mBufferJoinStyleComboBox
363  << mBufferTranspFillChbx
364  << mBufferOpacityWidget
365  << mCentroidInsideCheckBox
366  << mChkNoObstacle
367  << mDirectSymbChkBx
368  << mDirectSymbLeftLineEdit
369  << mDirectSymbRevChkBx
370  << mDirectSymbRightLineEdit
371  << mFitInsidePolygonCheckBox
372  << mFontCapitalsComboBox
373  << mFontLetterSpacingSpinBox
374  << mFontLimitPixelChkBox
375  << mFontLineHeightSpinBox
376  << mFontMaxPixelSpinBox
377  << mFontMinPixelSpinBox
378  << mFontMultiLineAlignComboBox
379  << mFontSizeSpinBox
380  << mFontStyleComboBox
381  << mTextOrientationComboBox
382  << mTextOpacityWidget
383  << mFontWordSpacingSpinBox
384  << mFormatNumChkBx
385  << mFormatNumDecimalsSpnBx
386  << mFormatNumPlusSignChkBx
387  << mLimitLabelChkBox
388  << mLimitLabelSpinBox
389  << mLineDistanceSpnBx
390  << mLineDistanceUnitWidget
391  << mMaxCharAngleInDSpinBox
392  << mMaxCharAngleOutDSpinBox
393  << mMinSizeSpinBox
394  << mOffsetTypeComboBox
395  << mPalShowAllLabelsForLayerChkBx
396  << mPointAngleSpinBox
397  << mPointOffsetUnitWidget
398  << mPointOffsetXSpinBox
399  << mPointOffsetYSpinBox
400  << mPreviewBackgroundBtn
401  << mPreviewTextEdit
402  << mPrioritySlider
403  << mRepeatDistanceSpinBox
404  << mRepeatDistanceUnitWidget
405  << mOverrunDistanceSpinBox
406  << mOverrunDistanceUnitWidget
407  << mScaleBasedVisibilityChkBx
408  << mMaxScaleWidget
409  << mMinScaleWidget
410  << mShadowBlendCmbBx
411  << mShadowColorBtn
412  << mShadowDrawChkBx
413  << mShadowOffsetAngleSpnBx
414  << mShadowOffsetGlobalChkBx
415  << mShadowOffsetSpnBx
416  << mShadowOffsetUnitWidget
417  << mShadowRadiusAlphaChkBx
418  << mShadowRadiusDblSpnBx
419  << mShadowRadiusUnitWidget
420  << mShadowScaleSpnBx
421  << mShadowOpacityWidget
422  << mShadowUnderCmbBx
423  << mShapeBlendCmbBx
424  << mShapeStrokeColorBtn
425  << mShapeStrokeWidthSpnBx
426  << mShapeStrokeWidthUnitWidget
427  << mShapeDrawChkBx
428  << mShapeFillColorBtn
429  << mShapeOffsetXSpnBx
430  << mShapeOffsetYSpnBx
431  << mShapeOffsetUnitWidget
432  << mShapePenStyleCmbBx
433  << mShapeRadiusXDbSpnBx
434  << mShapeRadiusYDbSpnBx
435  << mShapeRotationCmbBx
436  << mShapeRotationDblSpnBx
437  << mShapeRadiusUnitWidget
438  << mShapeSVGPathLineEdit
439  << mShapeSizeCmbBx
440  << mShapeSizeUnitWidget
441  << mShapeSizeXSpnBx
442  << mShapeSizeYSpnBx
443  << mBackgroundOpacityWidget
444  << mShapeTypeCmbBx
445  << mZIndexSpinBox
446  << spinBufferSize
447  << wrapCharacterEdit
448  << mAutoWrapLengthSpinBox
449  << mAutoWrapTypeComboBox
450  << mCentroidRadioVisible
451  << mCentroidRadioWhole
452  << mDirectSymbRadioBtnAbove
453  << mDirectSymbRadioBtnBelow
454  << mDirectSymbRadioBtnLR
455  << mUpsidedownRadioAll
456  << mUpsidedownRadioDefined
457  << mUpsidedownRadioOff
458  << radAroundCentroid
459  << radAroundPoint
460  << radLineCurved
461  << radLineHorizontal
462  << radLineParallel
463  << radOverCentroid
464  << radOverPoint
465  << radPolygonFree
466  << radPolygonHorizontal
467  << radPolygonPerimeter
468  << radPolygonPerimeterCurved
469  << radPolygonOutside
470  << radPredefinedOrder
471  << mFieldExpressionWidget
472  << mCheckBoxSubstituteText
473  << mGeometryGeneratorGroupBox
474  << mGeometryGenerator
475  << mGeometryGeneratorType
476  << mBackgroundSymbolButton
477  << mCalloutsDrawCheckBox
478  << mCalloutStyleComboBox
479  << mKerningCheckBox
480  << mEnableMaskChkBx
481  << mMaskJoinStyleComboBox
482  << mMaskBufferSizeSpinBox
483  << mMaskOpacityWidget
484  << mCheckAllowLabelsOutsidePolygons
485  << mHtmlFormattingCheckBox;
486 
487  connectValueChanged( widgets, SLOT( updatePreview() ) );
488 
489  connect( mQuadrantBtnGrp, static_cast<void ( QButtonGroup::* )( int )>( &QButtonGroup::buttonClicked ), this, &QgsTextFormatWidget::updatePreview );
490 
491  connect( mBufferDrawDDBtn, &QgsPropertyOverrideButton::activated, this, &QgsTextFormatWidget::updateBufferFrameStatus );
492  connect( mBufferDrawChkBx, &QCheckBox::stateChanged, this, [ = ]( int )
493  {
494  updateBufferFrameStatus();
495  } );
496  connect( mShapeDrawDDBtn, &QgsPropertyOverrideButton::activated, this, &QgsTextFormatWidget::updateShapeFrameStatus );
497  connect( mShapeDrawChkBx, &QCheckBox::stateChanged, this, [ = ]( int )
498  {
499  updateShapeFrameStatus();
500  } );
501  connect( mShadowDrawDDBtn, &QgsPropertyOverrideButton::activated, this, &QgsTextFormatWidget::updateShadowFrameStatus );
502  connect( mShadowDrawChkBx, &QCheckBox::stateChanged, this, [ = ]( int )
503  {
504  updateShadowFrameStatus();
505  } );
506  connect( mCalloutDrawDDBtn, &QgsPropertyOverrideButton::activated, this, &QgsTextFormatWidget::updateCalloutFrameStatus );
507  connect( mCalloutsDrawCheckBox, &QCheckBox::stateChanged, this, [ = ]( int )
508  {
509  updateCalloutFrameStatus();
510  } );
511 
512  mGeometryGeneratorType->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "Polygon / MultiPolygon" ), QgsWkbTypes::GeometryType::PolygonGeometry );
513  mGeometryGeneratorType->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "LineString / MultiLineString" ), QgsWkbTypes::GeometryType::LineGeometry );
514  mGeometryGeneratorType->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "Point / MultiPoint" ), QgsWkbTypes::GeometryType::PointGeometry );
515 
516  // set correct initial tab to match displayed setting page
517  whileBlocking( mOptionsTab )->setCurrentIndex( mLabelStackedWidget->currentIndex() );
518  mOptionsTab->tabBar()->setUsesScrollButtons( true );
519 
520 
521  if ( mMapCanvas )
522  {
523  lblFontPreview->setMapUnits( mMapCanvas->mapSettings().mapUnits() );
524  mPreviewScaleComboBox->setScale( mMapCanvas->mapSettings().scale() );
525  }
526 
527  mTextFormatsListWidget->setStyle( QgsStyle::defaultStyle() );
528  mTextFormatsListWidget->setEntityType( QgsStyle::TextFormatEntity );
530  connect( mTextFormatsListWidget, &QgsStyleItemsListWidget::saveEntity, this, &QgsTextFormatWidget::saveFormat );
531 }
532 
533 void QgsTextFormatWidget::setWidgetMode( QgsTextFormatWidget::Mode mode )
534 {
535  mWidgetMode = mode;
536  switch ( mode )
537  {
538  case Labeling:
539  toggleDDButtons( true );
540  mTextFormatsListWidget->setEntityTypes( QList< QgsStyle::StyleEntity >() << QgsStyle::TextFormatEntity << QgsStyle::LabelSettingsEntity );
541  mTextOrientationComboBox->addItem( tr( "Rotation-based" ), QgsTextFormat::RotationBasedOrientation );
542  break;
543 
544  case Text:
545  toggleDDButtons( true );
546  delete mLabelingOptionsListWidget->takeItem( 8 ); // rendering
547  delete mLabelingOptionsListWidget->takeItem( 7 ); // placement
548  delete mLabelingOptionsListWidget->takeItem( 6 ); // callouts
549  delete mLabelingOptionsListWidget->takeItem( 3 ); // mask
550  mOptionsTab->removeTab( 8 );
551  mOptionsTab->removeTab( 7 );
552  mOptionsTab->removeTab( 6 );
553  mOptionsTab->removeTab( 3 );
554  mLabelStackedWidget->removeWidget( mLabelPage_Rendering );
555  mLabelStackedWidget->removeWidget( mLabelPage_Callouts );
556  mLabelStackedWidget->removeWidget( mLabelPage_Mask );
557  mLabelStackedWidget->removeWidget( mLabelPage_Placement );
558  mLabelStackedWidget->setCurrentIndex( 0 );
559 
560  frameLabelWith->hide();
561  mDirectSymbolsFrame->hide();
562  mFormatNumFrame->hide();
563  mFormatNumChkBx->hide();
564  mFormatNumDDBtn->hide();
565  mSubstitutionsFrame->hide();
566  mTextOrientationComboBox->removeItem( mTextOrientationComboBox->findData( QgsTextFormat::RotationBasedOrientation ) );
567  break;
568  }
569 }
570 
571 void QgsTextFormatWidget::toggleDDButtons( bool visible )
572 {
573  const auto buttons = findChildren< QgsPropertyOverrideButton * >();
574  for ( QgsPropertyOverrideButton *button : buttons )
575  {
576  button->setVisible( visible );
577  }
578 }
579 
581 {
582  mOptionsTab->setVisible( enabled );
583  mOptionsTab->setTabToolTip( 0, tr( "Text" ) );
584  mOptionsTab->setTabToolTip( 1, tr( "Formatting" ) );
585  mOptionsTab->setTabToolTip( 2, tr( "Buffer" ) );
586  mOptionsTab->setTabToolTip( 3, tr( "Mask" ) );
587  mOptionsTab->setTabToolTip( 4, tr( "Background" ) );
588  mOptionsTab->setTabToolTip( 5, tr( "Shadow" ) );
589  mOptionsTab->setTabToolTip( 6, tr( "Callouts" ) );
590  mOptionsTab->setTabToolTip( 7, tr( "Placement" ) );
591  mOptionsTab->setTabToolTip( 8, tr( "Rendering" ) );
592 
593  mLabelingOptionsListFrame->setVisible( !enabled );
594  groupBox_mPreview->setVisible( !enabled );
595  mDockMode = enabled;
596 }
597 
598 void QgsTextFormatWidget::connectValueChanged( const QList<QWidget *> &widgets, const char *slot )
599 {
600  const auto constWidgets = widgets;
601  for ( QWidget *widget : constWidgets )
602  {
603  if ( QgsSymbolButton *w = qobject_cast<QgsSymbolButton *>( widget ) )
604  {
605  connect( w, SIGNAL( changed() ), this, slot );
606  }
607  else if ( QgsFieldExpressionWidget *w = qobject_cast< QgsFieldExpressionWidget *>( widget ) )
608  {
609  connect( w, SIGNAL( fieldChanged( QString ) ), this, slot );
610  }
611  else if ( QgsOpacityWidget *w = qobject_cast< QgsOpacityWidget *>( widget ) )
612  {
613  connect( w, SIGNAL( opacityChanged( double ) ), this, slot );
614  }
615  else if ( QgsScaleWidget *w = qobject_cast< QgsScaleWidget *>( widget ) )
616  {
617  connect( w, SIGNAL( scaleChanged( double ) ), this, slot );
618  }
619  else if ( QgsUnitSelectionWidget *w = qobject_cast<QgsUnitSelectionWidget *>( widget ) )
620  {
621  connect( w, SIGNAL( changed() ), this, slot );
622  }
623  else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
624  {
625  connect( w, SIGNAL( currentIndexChanged( int ) ), this, slot );
626  }
627  else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
628  {
629  connect( w, SIGNAL( valueChanged( int ) ), this, slot );
630  }
631  else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
632  {
633  connect( w, SIGNAL( valueChanged( double ) ), this, slot );
634  }
635  else if ( QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
636  {
637  connect( w, SIGNAL( colorChanged( QColor ) ), this, slot );
638  }
639  else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
640  {
641  connect( w, SIGNAL( toggled( bool ) ), this, slot );
642  }
643  else if ( QRadioButton *w = qobject_cast<QRadioButton *>( widget ) )
644  {
645  connect( w, SIGNAL( toggled( bool ) ), this, slot );
646  }
647  else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
648  {
649  connect( w, SIGNAL( textEdited( QString ) ), this, slot );
650  }
651  else if ( QSlider *w = qobject_cast<QSlider *>( widget ) )
652  {
653  connect( w, SIGNAL( valueChanged( int ) ), this, slot );
654  }
655  else if ( QGroupBox *w = qobject_cast<QGroupBox *>( widget ) )
656  {
657  connect( w, SIGNAL( toggled( bool ) ), this, slot );
658  }
659  else if ( QgsCodeEditorExpression *w = qobject_cast<QgsCodeEditorExpression *>( widget ) )
660  {
661  connect( w, SIGNAL( textChanged() ), this, slot );
662  }
663  else
664  {
665  QgsLogger::warning( QStringLiteral( "Could not create connection for widget %1" ).arg( widget->objectName() ) );
666  }
667  }
668 }
669 
671 {
672  // text style
673  registerDataDefinedButton( mFontDDBtn, QgsPalLayerSettings::Family );
674  registerDataDefinedButton( mFontStyleDDBtn, QgsPalLayerSettings::FontStyle );
675  registerDataDefinedButton( mFontUnderlineDDBtn, QgsPalLayerSettings::Underline );
676  registerDataDefinedButton( mFontStrikeoutDDBtn, QgsPalLayerSettings::Strikeout );
677  registerDataDefinedButton( mFontBoldDDBtn, QgsPalLayerSettings::Bold );
678  registerDataDefinedButton( mFontItalicDDBtn, QgsPalLayerSettings::Italic );
679  registerDataDefinedButton( mFontSizeDDBtn, QgsPalLayerSettings::Size );
680  registerDataDefinedButton( mFontUnitsDDBtn, QgsPalLayerSettings::FontSizeUnit );
681  registerDataDefinedButton( mFontColorDDBtn, QgsPalLayerSettings::Color );
682  registerDataDefinedButton( mFontOpacityDDBtn, QgsPalLayerSettings::FontOpacity );
683  registerDataDefinedButton( mFontCaseDDBtn, QgsPalLayerSettings::FontCase );
684  registerDataDefinedButton( mFontLetterSpacingDDBtn, QgsPalLayerSettings::FontLetterSpacing );
685  registerDataDefinedButton( mFontWordSpacingDDBtn, QgsPalLayerSettings::FontWordSpacing );
686  registerDataDefinedButton( mFontBlendModeDDBtn, QgsPalLayerSettings::FontBlendMode );
687 
688  // text formatting
689  registerDataDefinedButton( mWrapCharDDBtn, QgsPalLayerSettings::MultiLineWrapChar );
690  registerDataDefinedButton( mAutoWrapLengthDDBtn, QgsPalLayerSettings::AutoWrapLength );
691  registerDataDefinedButton( mFontLineHeightDDBtn, QgsPalLayerSettings::MultiLineHeight );
692  registerDataDefinedButton( mFontMultiLineAlignDDBtn, QgsPalLayerSettings::MultiLineAlignment );
693  registerDataDefinedButton( mTextOrientationDDBtn, QgsPalLayerSettings::TextOrientation );
694 
695  registerDataDefinedButton( mDirectSymbDDBtn, QgsPalLayerSettings::DirSymbDraw );
696  mDirectSymbDDBtn->registerCheckedWidget( mDirectSymbChkBx );
697  registerDataDefinedButton( mDirectSymbLeftDDBtn, QgsPalLayerSettings::DirSymbLeft );
698  registerDataDefinedButton( mDirectSymbRightDDBtn, QgsPalLayerSettings::DirSymbRight );
699 
700  registerDataDefinedButton( mDirectSymbPlacementDDBtn, QgsPalLayerSettings::DirSymbPlacement );
701  registerDataDefinedButton( mDirectSymbRevDDBtn, QgsPalLayerSettings::DirSymbReverse );
702 
703  registerDataDefinedButton( mFormatNumDDBtn, QgsPalLayerSettings::NumFormat );
704  mFormatNumDDBtn->registerCheckedWidget( mFormatNumChkBx );
705  registerDataDefinedButton( mFormatNumDecimalsDDBtn, QgsPalLayerSettings::NumDecimals );
706  registerDataDefinedButton( mFormatNumPlusSignDDBtn, QgsPalLayerSettings::NumPlusSign );
707 
708  // text buffer
709  registerDataDefinedButton( mBufferDrawDDBtn, QgsPalLayerSettings::BufferDraw );
710  mBufferDrawDDBtn->registerCheckedWidget( mBufferDrawChkBx );
711  registerDataDefinedButton( mBufferSizeDDBtn, QgsPalLayerSettings::BufferSize );
712  registerDataDefinedButton( mBufferUnitsDDBtn, QgsPalLayerSettings::BufferUnit );
713  registerDataDefinedButton( mBufferColorDDBtn, QgsPalLayerSettings::BufferColor );
714  registerDataDefinedButton( mBufferOpacityDDBtn, QgsPalLayerSettings::BufferOpacity );
715  registerDataDefinedButton( mBufferJoinStyleDDBtn, QgsPalLayerSettings::BufferJoinStyle );
716  registerDataDefinedButton( mBufferBlendModeDDBtn, QgsPalLayerSettings::BufferBlendMode );
717 
718  // mask
719  registerDataDefinedButton( mEnableMaskDDBtn, QgsPalLayerSettings::MaskEnabled );
720  mEnableMaskDDBtn->registerCheckedWidget( mEnableMaskChkBx );
721  registerDataDefinedButton( mMaskBufferSizeDDBtn, QgsPalLayerSettings::MaskBufferSize );
722  registerDataDefinedButton( mMaskBufferUnitsDDBtn, QgsPalLayerSettings::MaskBufferUnit );
723  registerDataDefinedButton( mMaskOpacityDDBtn, QgsPalLayerSettings::MaskOpacity );
724  registerDataDefinedButton( mMaskJoinStyleDDBtn, QgsPalLayerSettings::MaskJoinStyle );
725 
726  // background
727  registerDataDefinedButton( mShapeDrawDDBtn, QgsPalLayerSettings::ShapeDraw );
728  mShapeDrawDDBtn->registerCheckedWidget( mShapeDrawChkBx );
729  registerDataDefinedButton( mShapeTypeDDBtn, QgsPalLayerSettings::ShapeKind );
730  registerDataDefinedButton( mShapeSVGPathDDBtn, QgsPalLayerSettings::ShapeSVGFile );
731  registerDataDefinedButton( mShapeSizeTypeDDBtn, QgsPalLayerSettings::ShapeSizeType );
732  registerDataDefinedButton( mShapeSizeXDDBtn, QgsPalLayerSettings::ShapeSizeX );
733  registerDataDefinedButton( mShapeSizeYDDBtn, QgsPalLayerSettings::ShapeSizeY );
734  registerDataDefinedButton( mShapeSizeUnitsDDBtn, QgsPalLayerSettings::ShapeSizeUnits );
735  registerDataDefinedButton( mShapeRotationTypeDDBtn, QgsPalLayerSettings::ShapeRotationType );
736  registerDataDefinedButton( mShapeRotationDDBtn, QgsPalLayerSettings::ShapeRotation );
737  registerDataDefinedButton( mShapeOffsetDDBtn, QgsPalLayerSettings::ShapeOffset );
738  registerDataDefinedButton( mShapeOffsetUnitsDDBtn, QgsPalLayerSettings::ShapeOffsetUnits );
739  registerDataDefinedButton( mShapeRadiusDDBtn, QgsPalLayerSettings::ShapeRadii );
740  registerDataDefinedButton( mShapeRadiusUnitsDDBtn, QgsPalLayerSettings::ShapeRadiiUnits );
741  registerDataDefinedButton( mShapeOpacityDDBtn, QgsPalLayerSettings::ShapeOpacity );
742  registerDataDefinedButton( mShapeBlendModeDDBtn, QgsPalLayerSettings::ShapeBlendMode );
743  registerDataDefinedButton( mShapeFillColorDDBtn, QgsPalLayerSettings::ShapeFillColor );
744  registerDataDefinedButton( mShapeStrokeColorDDBtn, QgsPalLayerSettings::ShapeStrokeColor );
745  registerDataDefinedButton( mShapeStrokeWidthDDBtn, QgsPalLayerSettings::ShapeStrokeWidth );
746  registerDataDefinedButton( mShapeStrokeUnitsDDBtn, QgsPalLayerSettings::ShapeStrokeWidthUnits );
747  registerDataDefinedButton( mShapePenStyleDDBtn, QgsPalLayerSettings::ShapeJoinStyle );
748 
749  // drop shadows
750  registerDataDefinedButton( mShadowDrawDDBtn, QgsPalLayerSettings::ShadowDraw );
751  mShadowDrawDDBtn->registerCheckedWidget( mShadowDrawChkBx );
752  registerDataDefinedButton( mShadowUnderDDBtn, QgsPalLayerSettings::ShadowUnder );
753  registerDataDefinedButton( mShadowOffsetAngleDDBtn, QgsPalLayerSettings::ShadowOffsetAngle );
754  registerDataDefinedButton( mShadowOffsetDDBtn, QgsPalLayerSettings::ShadowOffsetDist );
755  registerDataDefinedButton( mShadowOffsetUnitsDDBtn, QgsPalLayerSettings::ShadowOffsetUnits );
756  registerDataDefinedButton( mShadowRadiusDDBtn, QgsPalLayerSettings::ShadowRadius );
757  registerDataDefinedButton( mShadowRadiusUnitsDDBtn, QgsPalLayerSettings::ShadowRadiusUnits );
758  registerDataDefinedButton( mShadowOpacityDDBtn, QgsPalLayerSettings::ShadowOpacity );
759  registerDataDefinedButton( mShadowScaleDDBtn, QgsPalLayerSettings::ShadowScale );
760  registerDataDefinedButton( mShadowColorDDBtn, QgsPalLayerSettings::ShadowColor );
761  registerDataDefinedButton( mShadowBlendDDBtn, QgsPalLayerSettings::ShadowBlendMode );
762 
763  // placement
764  registerDataDefinedButton( mCentroidDDBtn, QgsPalLayerSettings::CentroidWhole );
765  registerDataDefinedButton( mPointQuadOffsetDDBtn, QgsPalLayerSettings::OffsetQuad );
766  registerDataDefinedButton( mPointPositionOrderDDBtn, QgsPalLayerSettings::PredefinedPositionOrder );
767  registerDataDefinedButton( mLinePlacementFlagsDDBtn, QgsPalLayerSettings::LinePlacementOptions );
768  registerDataDefinedButton( mPointOffsetDDBtn, QgsPalLayerSettings::OffsetXY );
769  registerDataDefinedButton( mPointOffsetUnitsDDBtn, QgsPalLayerSettings::OffsetUnits );
770  registerDataDefinedButton( mLineDistanceDDBtn, QgsPalLayerSettings::LabelDistance );
771  registerDataDefinedButton( mLineDistanceUnitDDBtn, QgsPalLayerSettings::DistanceUnits );
772  registerDataDefinedButton( mPriorityDDBtn, QgsPalLayerSettings::Priority );
773  registerDataDefinedButton( mAllowOutsidePolygonsDDBtn, QgsPalLayerSettings::PolygonLabelOutside );
774 
775  // TODO: is this necessary? maybe just use the data defined-only rotation?
776  //mPointAngleDDBtn, QgsPalLayerSettings::OffsetRotation,
777  // QgsPropertyOverrideButton::AnyType, QgsPropertyOverrideButton::double180RotDesc() );
778  registerDataDefinedButton( mMaxCharAngleDDBtn, QgsPalLayerSettings::CurvedCharAngleInOut );
779  registerDataDefinedButton( mRepeatDistanceDDBtn, QgsPalLayerSettings::RepeatDistance );
780  registerDataDefinedButton( mRepeatDistanceUnitDDBtn, QgsPalLayerSettings::RepeatDistanceUnit );
781  registerDataDefinedButton( mOverrunDistanceDDBtn, QgsPalLayerSettings::OverrunDistance );
782 
783  // data defined-only
784  QString ddPlaceInfo = tr( "In edit mode, layer's relevant labeling map tool is:<br>"
785  "&nbsp;&nbsp;Defined attribute field -&gt; <i>enabled</i><br>"
786  "&nbsp;&nbsp;Defined expression -&gt; <i>disabled</i>" );
787  registerDataDefinedButton( mCoordXDDBtn, QgsPalLayerSettings::PositionX );
788  mCoordXDDBtn->setUsageInfo( ddPlaceInfo );
789  registerDataDefinedButton( mCoordYDDBtn, QgsPalLayerSettings::PositionY );
790  mCoordYDDBtn->setUsageInfo( ddPlaceInfo );
791  registerDataDefinedButton( mCoordAlignmentHDDBtn, QgsPalLayerSettings::Hali );
792  mCoordAlignmentHDDBtn->setUsageInfo( ddPlaceInfo );
793  registerDataDefinedButton( mCoordAlignmentVDDBtn, QgsPalLayerSettings::Vali );
794  mCoordAlignmentVDDBtn->setUsageInfo( ddPlaceInfo );
795  registerDataDefinedButton( mCoordRotationDDBtn, QgsPalLayerSettings::LabelRotation );
796  mCoordRotationDDBtn->setUsageInfo( ddPlaceInfo );
797 
798  // rendering
799  QString ddScaleVisInfo = tr( "Value &lt; 0 represents a scale closer than 1:1, e.g. -10 = 10:1<br>"
800  "Value of 0 disables the specific limit." );
801  registerDataDefinedButton( mScaleBasedVisibilityDDBtn, QgsPalLayerSettings::ScaleVisibility );
802  mScaleBasedVisibilityDDBtn->registerCheckedWidget( mScaleBasedVisibilityChkBx );
803  registerDataDefinedButton( mScaleBasedVisibilityMinDDBtn, QgsPalLayerSettings::MinimumScale );
804  mScaleBasedVisibilityMinDDBtn->setUsageInfo( ddScaleVisInfo );
805  registerDataDefinedButton( mScaleBasedVisibilityMaxDDBtn, QgsPalLayerSettings::MaximumScale );
806  mScaleBasedVisibilityMaxDDBtn->setUsageInfo( ddScaleVisInfo );
807 
808  registerDataDefinedButton( mFontLimitPixelDDBtn, QgsPalLayerSettings::FontLimitPixel );
809  mFontLimitPixelDDBtn->registerCheckedWidget( mFontLimitPixelChkBox );
810  registerDataDefinedButton( mFontMinPixelDDBtn, QgsPalLayerSettings::FontMinPixel );
811  registerDataDefinedButton( mFontMaxPixelDDBtn, QgsPalLayerSettings::FontMaxPixel );
812 
813  registerDataDefinedButton( mShowLabelDDBtn, QgsPalLayerSettings::Show );
814 
815  registerDataDefinedButton( mAlwaysShowDDBtn, QgsPalLayerSettings::AlwaysShow );
816 
817  registerDataDefinedButton( mIsObstacleDDBtn, QgsPalLayerSettings::IsObstacle );
818  registerDataDefinedButton( mZIndexDDBtn, QgsPalLayerSettings::ZIndex );
819 
820  registerDataDefinedButton( mCalloutDrawDDBtn, QgsPalLayerSettings::CalloutDraw );
821  mCalloutDrawDDBtn->registerCheckedWidget( mCalloutsDrawCheckBox );
822 
823  registerDataDefinedButton( mLabelAllPartsDDBtn, QgsPalLayerSettings::LabelAllParts );
824 }
825 
826 void QgsTextFormatWidget::registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsPalLayerSettings::Property key )
827 {
829  if ( !mButtons.contains( key ) )
830  {
831  connect( button, &QgsPropertyOverrideButton::changed, this, &QgsTextFormatWidget::updateProperty );
832  connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsTextFormatWidget::createAuxiliaryField );
833  button->registerExpressionContextGenerator( this );
834  mButtons[key] = button;
835  }
836 }
837 
839 {
844 
845  if ( mWidgetMode != Labeling )
846  {
848  }
849 
850  // buffer
851  mBufferDrawChkBx->setChecked( buffer.enabled() );
852  mBufferFrame->setEnabled( buffer.enabled() );
853  spinBufferSize->setValue( buffer.size() );
854  mBufferUnitWidget->setUnit( buffer.sizeUnit() );
855  mBufferUnitWidget->setMapUnitScale( buffer.sizeMapUnitScale() );
856  btnBufferColor->setColor( buffer.color() );
857  mBufferOpacityWidget->setOpacity( buffer.opacity() );
858  mBufferJoinStyleComboBox->setPenJoinStyle( buffer.joinStyle() );
859  mBufferTranspFillChbx->setChecked( buffer.fillBufferInterior() );
860  comboBufferBlendMode->setBlendMode( buffer.blendMode() );
861  if ( buffer.paintEffect() )
862  mBufferEffect.reset( buffer.paintEffect()->clone() );
863  else
864  {
865  mBufferEffect.reset( QgsPaintEffectRegistry::defaultStack() );
866  mBufferEffect->setEnabled( false );
867  }
868  mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
869 
870  // mask
872  mEnableMaskChkBx->setChecked( mask.enabled() );
873  mMaskBufferSizeSpinBox->setValue( mask.size() );
874  mMaskBufferUnitWidget->setUnit( mask.sizeUnit() );
875  mMaskBufferUnitWidget->setMapUnitScale( mask.sizeMapUnitScale() );
876  mMaskOpacityWidget->setOpacity( mask.opacity() );
877  mMaskJoinStyleComboBox->setPenJoinStyle( mask.joinStyle() );
878  if ( mask.paintEffect() )
879  mMaskEffect.reset( mask.paintEffect()->clone() );
880  else
881  {
882  mMaskEffect.reset( QgsPaintEffectRegistry::defaultStack() );
883  mMaskEffect->setEnabled( false );
884  }
885  mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
886 
887  mFontSizeUnitWidget->setUnit( format.sizeUnit() );
888  mFontSizeUnitWidget->setMapUnitScale( format.sizeMapUnitScale() );
889  mRefFont = format.font();
890  mFontSizeSpinBox->setValue( format.size() );
891  btnTextColor->setColor( format.color() );
892  mTextOpacityWidget->setOpacity( format.opacity() );
893  comboBlendMode->setBlendMode( format.blendMode() );
894  mTextOrientationComboBox->setCurrentIndex( mTextOrientationComboBox->findData( format.orientation() ) );
895  mHtmlFormattingCheckBox->setChecked( format.allowHtmlFormatting() );
896 
897  mFontWordSpacingSpinBox->setValue( format.font().wordSpacing() );
898  mFontLetterSpacingSpinBox->setValue( format.font().letterSpacing() );
899  whileBlocking( mKerningCheckBox )->setChecked( format.font().kerning() );
900 
902  updateFont( mRefFont );
903 
904  // show 'font not found' if substitution has occurred (should come after updateFont())
905  mFontMissingLabel->setVisible( !format.fontFound() );
906  if ( !format.fontFound() )
907  {
908  QString missingTxt = tr( "%1 not found. Default substituted." );
909  QString txtPrepend = tr( "Chosen font" );
910  if ( !format.resolvedFontFamily().isEmpty() )
911  {
912  txtPrepend = QStringLiteral( "'%1'" ).arg( format.resolvedFontFamily() );
913  }
914  mFontMissingLabel->setText( missingTxt.arg( txtPrepend ) );
915 
916  // ensure user is sent to 'Text style' section to see notice
917  mLabelingOptionsListWidget->setCurrentRow( 0 );
918  }
919  mFontLineHeightSpinBox->setValue( format.lineHeight() );
920 
921  // shape background
922  mShapeDrawChkBx->setChecked( background.enabled() );
923  mShapeFrame->setEnabled( background.enabled() );
924  mShapeTypeCmbBx->blockSignals( true );
925  mShapeTypeCmbBx->setCurrentIndex( mShapeTypeCmbBx->findData( background.type() ) );
926  mShapeTypeCmbBx->blockSignals( false );
927  updateAvailableShadowPositions();
928  mShapeSVGPathLineEdit->setText( background.svgFile() );
929 
930  mShapeSizeCmbBx->setCurrentIndex( background.sizeType() );
931  mShapeSizeXSpnBx->setValue( background.size().width() );
932  mShapeSizeYSpnBx->setValue( background.size().height() );
933  mShapeSizeUnitWidget->setUnit( background.sizeUnit() );
934  mShapeSizeUnitWidget->setMapUnitScale( background.sizeMapUnitScale() );
935  mShapeRotationCmbBx->setCurrentIndex( background.rotationType() );
936  mShapeRotationDblSpnBx->setEnabled( background.rotationType() != QgsTextBackgroundSettings::RotationSync );
937  mShapeRotationDDBtn->setEnabled( background.rotationType() != QgsTextBackgroundSettings::RotationSync );
938  mShapeRotationDblSpnBx->setValue( background.rotation() );
939  mShapeOffsetXSpnBx->setValue( background.offset().x() );
940  mShapeOffsetYSpnBx->setValue( background.offset().y() );
941  mShapeOffsetUnitWidget->setUnit( background.offsetUnit() );
942  mShapeOffsetUnitWidget->setMapUnitScale( background.offsetMapUnitScale() );
943  mShapeRadiusXDbSpnBx->setValue( background.radii().width() );
944  mShapeRadiusYDbSpnBx->setValue( background.radii().height() );
945  mShapeRadiusUnitWidget->setUnit( background.radiiUnit() );
946  mShapeRadiusUnitWidget->setMapUnitScale( background.radiiMapUnitScale() );
947 
948  mShapeFillColorBtn->setColor( background.fillColor() );
949  mShapeStrokeColorBtn->setColor( background.strokeColor() );
950  mShapeStrokeWidthSpnBx->setValue( background.strokeWidth() );
951  mShapeStrokeWidthUnitWidget->setUnit( background.strokeWidthUnit() );
952  mShapeStrokeWidthUnitWidget->setMapUnitScale( background.strokeWidthMapUnitScale() );
953  mShapePenStyleCmbBx->setPenJoinStyle( background.joinStyle() );
954 
955  mBackgroundOpacityWidget->setOpacity( background.opacity() );
956  mShapeBlendCmbBx->setBlendMode( background.blendMode() );
957 
958  mLoadSvgParams = false;
959  mShapeTypeCmbBx_currentIndexChanged( background.type() ); // force update of shape background gui
960 
961  if ( background.paintEffect() )
962  mBackgroundEffect.reset( background.paintEffect()->clone() );
963  else
964  {
965  mBackgroundEffect.reset( QgsPaintEffectRegistry::defaultStack() );
966  mBackgroundEffect->setEnabled( false );
967  }
968  mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
969 
970  mBackgroundSymbolButton->setSymbol( background.markerSymbol() ? background.markerSymbol()->clone() : QgsSymbol::defaultSymbol( QgsWkbTypes::PointGeometry ) );
971 
972  // drop shadow
973  mShadowDrawChkBx->setChecked( shadow.enabled() );
974  mShadowFrame->setEnabled( shadow.enabled() );
975  mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( shadow.shadowPlacement() ) );
976  mShadowOffsetAngleSpnBx->setValue( shadow.offsetAngle() );
977  mShadowOffsetSpnBx->setValue( shadow.offsetDistance() );
978  mShadowOffsetUnitWidget->setUnit( shadow.offsetUnit() );
979  mShadowOffsetUnitWidget->setMapUnitScale( shadow.offsetMapUnitScale() );
980  mShadowOffsetGlobalChkBx->setChecked( shadow.offsetGlobal() );
981 
982  mShadowRadiusDblSpnBx->setValue( shadow.blurRadius() );
983  mShadowRadiusUnitWidget->setUnit( shadow.blurRadiusUnit() );
984  mShadowRadiusUnitWidget->setMapUnitScale( shadow.blurRadiusMapUnitScale() );
985  mShadowRadiusAlphaChkBx->setChecked( shadow.blurAlphaOnly() );
986  mShadowOpacityWidget->setOpacity( shadow.opacity() );
987  mShadowScaleSpnBx->setValue( shadow.scale() );
988 
989  mShadowColorBtn->setColor( shadow.color() );
990  mShadowBlendCmbBx->setBlendMode( shadow.blendMode() );
991 
992  mPreviewBackgroundBtn->setColor( format.previewBackgroundColor() );
993  mPreviewBackgroundBtn->setDefaultColor( format.previewBackgroundColor() );
995 
997 }
998 
1000 {
1001  QgsSettings settings;
1002  settings.setValue( QStringLiteral( "Windows/Labeling/FontPreviewSplitState" ), mFontPreviewSplitter->saveState() );
1003  settings.setValue( QStringLiteral( "Windows/Labeling/OptionsSplitState" ), mLabelingOptionsSplitter->saveState() );
1004  settings.setValue( QStringLiteral( "Windows/Labeling/Tab" ), mLabelingOptionsListWidget->currentRow() );
1005 }
1006 
1007 QgsTextFormat QgsTextFormatWidget::format( bool includeDataDefinedProperties ) const
1008 {
1010  format.setColor( btnTextColor->color() );
1011  format.setFont( mRefFont );
1012  format.setSize( mFontSizeSpinBox->value() );
1013  format.setNamedStyle( mFontStyleComboBox->currentText() );
1014  format.setOpacity( mTextOpacityWidget->opacity() );
1015  format.setBlendMode( comboBlendMode->blendMode() );
1016  format.setSizeUnit( mFontSizeUnitWidget->unit() );
1017  format.setSizeMapUnitScale( mFontSizeUnitWidget->getMapUnitScale() );
1018  format.setLineHeight( mFontLineHeightSpinBox->value() );
1019  format.setPreviewBackgroundColor( mPreviewBackgroundColor );
1020  format.setOrientation( static_cast< QgsTextFormat::TextOrientation >( mTextOrientationComboBox->currentData().toInt() ) );
1021  format.setAllowHtmlFormatting( mHtmlFormattingCheckBox->isChecked( ) );
1022 
1023  // buffer
1024  QgsTextBufferSettings buffer;
1025  buffer.setEnabled( mBufferDrawChkBx->isChecked() );
1026  buffer.setSize( spinBufferSize->value() );
1027  buffer.setColor( btnBufferColor->color() );
1028  buffer.setOpacity( mBufferOpacityWidget->opacity() );
1029  buffer.setSizeUnit( mBufferUnitWidget->unit() );
1030  buffer.setSizeMapUnitScale( mBufferUnitWidget->getMapUnitScale() );
1031  buffer.setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
1032  buffer.setFillBufferInterior( mBufferTranspFillChbx->isChecked() );
1033  buffer.setBlendMode( comboBufferBlendMode->blendMode() );
1034  if ( mBufferEffect && !QgsPaintEffectRegistry::isDefaultStack( mBufferEffect.get() ) )
1035  buffer.setPaintEffect( mBufferEffect->clone() );
1036  else
1037  buffer.setPaintEffect( nullptr );
1038  format.setBuffer( buffer );
1039 
1040  // mask
1041  QgsTextMaskSettings mask;
1042  mask.setEnabled( mEnableMaskChkBx->isChecked() );
1043  mask.setSize( mMaskBufferSizeSpinBox->value() );
1044  mask.setOpacity( mMaskOpacityWidget->opacity() );
1045  mask.setSizeUnit( mMaskBufferUnitWidget->unit() );
1046  mask.setSizeMapUnitScale( mMaskBufferUnitWidget->getMapUnitScale() );
1047  mask.setJoinStyle( mMaskJoinStyleComboBox->penJoinStyle() );
1048  if ( mMaskEffect && !QgsPaintEffectRegistry::isDefaultStack( mMaskEffect.get() ) )
1049  mask.setPaintEffect( mMaskEffect->clone() );
1050  else
1051  mask.setPaintEffect( nullptr );
1053  format.setMask( mask );
1054 
1055  // shape background
1056  QgsTextBackgroundSettings background;
1057  background.setEnabled( mShapeDrawChkBx->isChecked() );
1058  background.setType( static_cast< QgsTextBackgroundSettings::ShapeType >( mShapeTypeCmbBx->currentData().toInt() ) );
1059  background.setSvgFile( mShapeSVGPathLineEdit->text() );
1060  background.setSizeType( static_cast< QgsTextBackgroundSettings::SizeType >( mShapeSizeCmbBx->currentIndex() ) );
1061  background.setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
1062  background.setSizeUnit( mShapeSizeUnitWidget->unit() );
1063  background.setSizeMapUnitScale( mShapeSizeUnitWidget->getMapUnitScale() );
1064  background.setRotationType( static_cast< QgsTextBackgroundSettings::RotationType >( mShapeRotationCmbBx->currentIndex() ) );
1065  background.setRotation( mShapeRotationDblSpnBx->value() );
1066  background.setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
1067  background.setOffsetUnit( mShapeOffsetUnitWidget->unit() );
1068  background.setOffsetMapUnitScale( mShapeOffsetUnitWidget->getMapUnitScale() );
1069  background.setRadii( QSizeF( mShapeRadiusXDbSpnBx->value(), mShapeRadiusYDbSpnBx->value() ) );
1070  background.setRadiiUnit( mShapeRadiusUnitWidget->unit() );
1071  background.setRadiiMapUnitScale( mShapeRadiusUnitWidget->getMapUnitScale() );
1072 
1073  background.setFillColor( mShapeFillColorBtn->color() );
1074  background.setStrokeColor( mShapeStrokeColorBtn->color() );
1075  background.setStrokeWidth( mShapeStrokeWidthSpnBx->value() );
1076  background.setStrokeWidthUnit( mShapeStrokeWidthUnitWidget->unit() );
1077  background.setStrokeWidthMapUnitScale( mShapeStrokeWidthUnitWidget->getMapUnitScale() );
1078  background.setJoinStyle( mShapePenStyleCmbBx->penJoinStyle() );
1079  background.setOpacity( mBackgroundOpacityWidget->opacity() );
1080  background.setBlendMode( mShapeBlendCmbBx->blendMode() );
1081  if ( mBackgroundEffect && !QgsPaintEffectRegistry::isDefaultStack( mBackgroundEffect.get() ) )
1082  background.setPaintEffect( mBackgroundEffect->clone() );
1083  else
1084  background.setPaintEffect( nullptr );
1085  background.setMarkerSymbol( mBackgroundSymbolButton->clonedSymbol< QgsMarkerSymbol >() );
1086  format.setBackground( background );
1087 
1088  // drop shadow
1089  QgsTextShadowSettings shadow;
1090  shadow.setEnabled( mShadowDrawChkBx->isChecked() );
1091  shadow.setShadowPlacement( static_cast< QgsTextShadowSettings::ShadowPlacement >( mShadowUnderCmbBx->currentData().toInt() ) );
1092  shadow.setOffsetAngle( mShadowOffsetAngleSpnBx->value() );
1093  shadow.setOffsetDistance( mShadowOffsetSpnBx->value() );
1094  shadow.setOffsetUnit( mShadowOffsetUnitWidget->unit() );
1095  shadow.setOffsetMapUnitScale( mShadowOffsetUnitWidget->getMapUnitScale() );
1096  shadow.setOffsetGlobal( mShadowOffsetGlobalChkBx->isChecked() );
1097  shadow.setBlurRadius( mShadowRadiusDblSpnBx->value() );
1098  shadow.setBlurRadiusUnit( mShadowRadiusUnitWidget->unit() );
1099  shadow.setBlurRadiusMapUnitScale( mShadowRadiusUnitWidget->getMapUnitScale() );
1100  shadow.setBlurAlphaOnly( mShadowRadiusAlphaChkBx->isChecked() );
1101  shadow.setOpacity( mShadowOpacityWidget->opacity() );
1102  shadow.setScale( mShadowScaleSpnBx->value() );
1103  shadow.setColor( mShadowColorBtn->color() );
1104  shadow.setBlendMode( mShadowBlendCmbBx->blendMode() );
1105  format.setShadow( shadow );
1106 
1107  if ( includeDataDefinedProperties )
1109 
1110  return format;
1111 }
1112 
1114 {
1115  if ( mWidgetMode != Labeling )
1116  {
1117  // we need to combine any data defined properties from the text format with existing ones from the label settings
1118  const QgsPropertyCollection formatProps = format.dataDefinedProperties();
1119  for ( int key : formatProps.propertyKeys() )
1120  {
1121  if ( formatProps.isActive( key ) )
1122  {
1123  mDataDefinedProperties.setProperty( key, formatProps.property( key ) );
1124  }
1125  }
1126  }
1127 
1129 }
1130 
1132 {
1133  return mContext;
1134 }
1135 
1137 {
1138  if ( mButtons.contains( key ) )
1139  {
1140  QgsPropertyOverrideButton *button = mButtons[ key ];
1141  QgsProperty p = button->toProperty();
1142  p.setField( QString() );
1143  p.setActive( false );
1144  button->updateFieldLists();
1145  button->setToProperty( p );
1147  }
1148 }
1149 
1150 void QgsTextFormatWidget::optionsStackedWidget_CurrentChanged( int indx )
1151 {
1152  mLabelingOptionsListWidget->blockSignals( true );
1153  mLabelingOptionsListWidget->setCurrentRow( indx );
1154  mLabelingOptionsListWidget->blockSignals( false );
1155 }
1156 
1158 {
1159  mContext = context;
1160 
1161  if ( mContext.expressionContext() )
1162  {
1163  mPreviewExpressionContext = *mContext.expressionContext();
1164  if ( mLayer )
1165  mPreviewExpressionContext.appendScope( QgsExpressionContextUtils::layerScope( mLayer ) );
1166  }
1167 
1168  const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
1169  for ( QgsSymbolButton *symbolWidget : symbolButtonWidgets )
1170  {
1171  symbolWidget->setMapCanvas( mContext.mapCanvas() );
1172  symbolWidget->setMessageBar( mContext.messageBar() );
1173  }
1174 }
1175 
1176 void QgsTextFormatWidget::collapseSample( bool collapse )
1177 {
1178  if ( collapse )
1179  {
1180  QList<int> splitSizes = mFontPreviewSplitter->sizes();
1181  if ( splitSizes[0] > groupBox_mPreview->height() )
1182  {
1183  int delta = splitSizes[0] - groupBox_mPreview->height();
1184  splitSizes[0] -= delta;
1185  splitSizes[1] += delta;
1186  mFontPreviewSplitter->setSizes( splitSizes );
1187  }
1188  }
1189 }
1190 
1191 void QgsTextFormatWidget::changeTextColor( const QColor &color )
1192 {
1193  Q_UNUSED( color )
1194  updatePreview();
1195 }
1196 
1197 void QgsTextFormatWidget::updateFont( const QFont &font )
1198 {
1199  // update background reference font
1200  if ( font != mRefFont )
1201  {
1202  mRefFont = font;
1203  }
1204 
1205  // test if font is actually available
1206  // NOTE: QgsFontUtils::fontMatchOnSystem may fail here, just crosscheck family
1207  mFontMissingLabel->setVisible( !QgsFontUtils::fontFamilyMatchOnSystem( mRefFont.family() ) );
1208 
1209  mDirectSymbLeftLineEdit->setFont( mRefFont );
1210  mDirectSymbRightLineEdit->setFont( mRefFont );
1211 
1212  blockFontChangeSignals( true );
1213  mFontFamilyCmbBx->setCurrentFont( mRefFont );
1214  populateFontStyleComboBox();
1215  int idx = mFontCapitalsComboBox->findData( QVariant( static_cast< unsigned int >( mRefFont.capitalization() ) ) );
1216  mFontCapitalsComboBox->setCurrentIndex( idx == -1 ? 0 : idx );
1217  mFontUnderlineBtn->setChecked( mRefFont.underline() );
1218  mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
1219  mKerningCheckBox->setChecked( mRefFont.kerning() );
1220  blockFontChangeSignals( false );
1221 
1222  // update font name with font face
1223 // font.setPixelSize( 24 );
1224 
1225  updatePreview();
1226 }
1227 
1228 void QgsTextFormatWidget::blockFontChangeSignals( bool blk )
1229 {
1230  mFontFamilyCmbBx->blockSignals( blk );
1231  mFontStyleComboBox->blockSignals( blk );
1232  mFontCapitalsComboBox->blockSignals( blk );
1233  mFontUnderlineBtn->blockSignals( blk );
1234  mFontStrikethroughBtn->blockSignals( blk );
1235  mFontWordSpacingSpinBox->blockSignals( blk );
1236  mFontLetterSpacingSpinBox->blockSignals( blk );
1237  mKerningCheckBox->blockSignals( blk );
1238 }
1239 
1241 {
1242  // In dock mode we don't have a preview we
1243  // just let stuff know we have changed because
1244  // there might be live updates connected.
1245  if ( mDockMode )
1246  {
1247  emit widgetChanged();
1248  return;
1249  }
1250 
1251  scrollPreview();
1252  lblFontPreview->setFormat( format() );
1253 }
1254 
1255 void QgsTextFormatWidget::scrollPreview()
1256 {
1257  scrollArea_mPreview->ensureVisible( 0, 0, 0, 0 );
1258 }
1259 
1261 {
1262  mPreviewBackgroundColor = color;
1263 
1264  scrollArea_mPreview->widget()->setStyleSheet( QStringLiteral( "background: rgb(%1, %2, %3);" ).arg( QString::number( color.red() ),
1265  QString::number( color.green() ),
1266  QString::number( color.blue() ) ) );
1267 }
1268 
1269 void QgsTextFormatWidget::changeBufferColor( const QColor &color )
1270 {
1271  Q_UNUSED( color )
1272  updatePreview();
1273 }
1274 
1276 {
1277  QWidget *curWdgt = stackedPlacement->currentWidget();
1278 
1279  bool showLineFrame = false;
1280  bool showCentroidFrame = false;
1281  bool showQuadrantFrame = false;
1282  bool showFixedQuadrantFrame = false;
1283  bool showPlacementPriorityFrame = false;
1284  bool showOffsetTypeFrame = false;
1285  bool showOffsetFrame = false;
1286  bool showDistanceFrame = false;
1287  bool showRotationFrame = false;
1288  bool showMaxCharAngleFrame = false;
1289  bool showPolygonPlacementOptions = ( curWdgt == pagePolygon && !radPolygonPerimeter->isChecked() && !radPolygonPerimeterCurved->isChecked() && !radPolygonOutside->isChecked() );
1290 
1291  bool enableMultiLinesFrame = true;
1292 
1293  if ( ( curWdgt == pagePoint && radAroundPoint->isChecked() )
1294  || ( curWdgt == pagePolygon && radAroundCentroid->isChecked() ) )
1295  {
1296  showCentroidFrame = ( curWdgt == pagePolygon && radAroundCentroid->isChecked() );
1297  showDistanceFrame = true;
1298  //showRotationFrame = true; // TODO: uncomment when supported
1299  if ( curWdgt == pagePoint )
1300  {
1301  showQuadrantFrame = true;
1302  }
1303  }
1304  else if ( ( curWdgt == pagePoint && radOverPoint->isChecked() )
1305  || ( curWdgt == pagePolygon && radOverCentroid->isChecked() ) )
1306  {
1307  showCentroidFrame = ( curWdgt == pagePolygon && radOverCentroid->isChecked() );
1308  showQuadrantFrame = true;
1309  showFixedQuadrantFrame = true;
1310  showOffsetFrame = true;
1311  showRotationFrame = true;
1312  }
1313  else if ( curWdgt == pagePoint && radPredefinedOrder->isChecked() )
1314  {
1315  showDistanceFrame = true;
1316  showPlacementPriorityFrame = true;
1317  showOffsetTypeFrame = true;
1318  }
1319  else if ( ( curWdgt == pageLine && radLineParallel->isChecked() )
1320  || ( curWdgt == pagePolygon && radPolygonPerimeter->isChecked() )
1321  || ( curWdgt == pageLine && radLineCurved->isChecked() )
1322  || ( curWdgt == pagePolygon && radPolygonPerimeterCurved->isChecked() ) )
1323  {
1324  showLineFrame = true;
1325  showDistanceFrame = true;
1326  //showRotationFrame = true; // TODO: uncomment when supported
1327 
1328  bool offline = chkLineAbove->isChecked() || chkLineBelow->isChecked();
1329  chkLineOrientationDependent->setEnabled( offline );
1330  mPlacementDistanceFrame->setEnabled( offline );
1331 
1332  bool isCurved = ( curWdgt == pageLine && radLineCurved->isChecked() )
1333  || ( curWdgt == pagePolygon && radPolygonPerimeterCurved->isChecked() );
1334  showMaxCharAngleFrame = isCurved;
1335  // TODO: enable mMultiLinesFrame when supported for curved labels
1336  enableMultiLinesFrame = !isCurved;
1337  }
1338  else if ( curWdgt == pagePolygon && ( radPolygonOutside->isChecked() || mCheckAllowLabelsOutsidePolygons->isChecked() || mAllowOutsidePolygonsDDBtn->isActive() ) )
1339  {
1340  showDistanceFrame = true;
1341  }
1342 
1343  mPlacementLineFrame->setVisible( showLineFrame );
1344  mPlacementPolygonFrame->setVisible( showPolygonPlacementOptions );
1345  mPlacementCentroidFrame->setVisible( showCentroidFrame );
1346  mPlacementQuadrantFrame->setVisible( showQuadrantFrame );
1347  mPlacementFixedQuadrantFrame->setVisible( showFixedQuadrantFrame );
1348  mPlacementCartographicFrame->setVisible( showPlacementPriorityFrame );
1349  mPlacementOffsetFrame->setVisible( showOffsetFrame );
1350  mPlacementDistanceFrame->setVisible( showDistanceFrame );
1351  mPlacementOffsetTypeFrame->setVisible( showOffsetTypeFrame );
1352  mPlacementRotationFrame->setVisible( showRotationFrame );
1353  mPlacementRepeatDistanceFrame->setVisible( curWdgt == pageLine || ( curWdgt == pagePolygon &&
1354  ( radPolygonPerimeter->isChecked() || radPolygonPerimeterCurved->isChecked() ) ) );
1355  mPlacementOverrunDistanceFrame->setVisible( curWdgt == pageLine );
1356  mPlacementMaxCharAngleFrame->setVisible( showMaxCharAngleFrame );
1357 
1358  mMultiLinesFrame->setEnabled( enableMultiLinesFrame );
1359 }
1360 
1361 void QgsTextFormatWidget::populateFontCapitalsComboBox()
1362 {
1363  mFontCapitalsComboBox->addItem( tr( "No Change" ), QVariant( 0 ) );
1364  mFontCapitalsComboBox->addItem( tr( "All Uppercase" ), QVariant( 1 ) );
1365  mFontCapitalsComboBox->addItem( tr( "All Lowercase" ), QVariant( 2 ) );
1366  // Small caps doesn't work right with QPainterPath::addText()
1367  // https://bugreports.qt.io/browse/QTBUG-13965
1368 // mFontCapitalsComboBox->addItem( tr( "Small Caps" ), QVariant( 3 ) );
1369  mFontCapitalsComboBox->addItem( tr( "Capitalize First Letter" ), QVariant( 4 ) );
1370 }
1371 
1372 void QgsTextFormatWidget::populateFontStyleComboBox()
1373 {
1374  mFontStyleComboBox->clear();
1375  QStringList styles = mFontDB.styles( mRefFont.family() );
1376  const auto constStyles = styles;
1377  for ( const QString &style : constStyles )
1378  {
1379  mFontStyleComboBox->addItem( style );
1380  }
1381 
1382  QString targetStyle = mFontDB.styleString( mRefFont );
1383  if ( !styles.contains( targetStyle ) )
1384  {
1385  QFont f = QFont( mRefFont.family() );
1386  targetStyle = QFontInfo( f ).styleName();
1387  mRefFont.setStyleName( targetStyle );
1388  }
1389  int curIndx = 0;
1390  int stylIndx = mFontStyleComboBox->findText( targetStyle );
1391  if ( stylIndx > -1 )
1392  {
1393  curIndx = stylIndx;
1394  }
1395 
1396  mFontStyleComboBox->setCurrentIndex( curIndx );
1397 }
1398 
1399 void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged( double d )
1400 {
1401  mRefFont.setPointSizeF( d );
1402  updateFont( mRefFont );
1403 }
1404 
1405 void QgsTextFormatWidget::mFontCapitalsComboBox_currentIndexChanged( int index )
1406 {
1407  int capitalsindex = mFontCapitalsComboBox->itemData( index ).toInt();
1408  mRefFont.setCapitalization( static_cast< QFont::Capitalization >( capitalsindex ) );
1409  updateFont( mRefFont );
1410 }
1411 
1412 void QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged( const QFont &f )
1413 {
1414  mRefFont.setFamily( f.family() );
1415  updateFont( mRefFont );
1416 }
1417 
1418 void QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged( const QString &text )
1419 {
1420  QgsFontUtils::updateFontViaStyle( mRefFont, text );
1421  updateFont( mRefFont );
1422 }
1423 
1424 void QgsTextFormatWidget::mFontUnderlineBtn_toggled( bool ckd )
1425 {
1426  mRefFont.setUnderline( ckd );
1427  updateFont( mRefFont );
1428 }
1429 
1430 void QgsTextFormatWidget::mFontStrikethroughBtn_toggled( bool ckd )
1431 {
1432  mRefFont.setStrikeOut( ckd );
1433  updateFont( mRefFont );
1434 }
1435 
1436 void QgsTextFormatWidget::kerningToggled( bool checked )
1437 {
1438  mRefFont.setKerning( checked );
1439  updateFont( mRefFont );
1440 }
1441 
1442 void QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged( double spacing )
1443 {
1444  mRefFont.setWordSpacing( spacing );
1445  updateFont( mRefFont );
1446 }
1447 
1448 void QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged( double spacing )
1449 {
1450  mRefFont.setLetterSpacing( QFont::AbsoluteSpacing, spacing );
1451  updateFont( mRefFont );
1452 }
1453 
1454 void QgsTextFormatWidget::mFontSizeUnitWidget_changed()
1455 {
1456  // disable pixel size limiting for labels defined in points
1457  if ( mFontSizeUnitWidget->unit() != QgsUnitTypes::RenderMapUnits )
1458  {
1459  mFontLimitPixelChkBox->setChecked( false );
1460  }
1461  else if ( mMinPixelLimit == 0 )
1462  {
1463  // initial minimum trigger value set, turn on pixel size limiting by default
1464  // for labels defined in map units (ignored after first settings save)
1465  mFontLimitPixelChkBox->setChecked( true );
1466  }
1467  updateFont( mRefFont );
1468 }
1469 
1470 void QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged( int px )
1471 {
1472  // ensure max font pixel size for map unit labels can't be lower than min
1473  mFontMaxPixelSpinBox->setMinimum( px );
1474  mFontMaxPixelSpinBox->update();
1475 }
1476 
1477 void QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged( int px )
1478 {
1479  // ensure max font pixel size for map unit labels can't be lower than min
1480  if ( px < mFontMinPixelSpinBox->value() )
1481  {
1482  mFontMaxPixelSpinBox->blockSignals( true );
1483  mFontMaxPixelSpinBox->setValue( mFontMinPixelSpinBox->value() );
1484  mFontMaxPixelSpinBox->blockSignals( false );
1485  }
1486  mFontMaxPixelSpinBox->setMinimum( mFontMinPixelSpinBox->value() );
1487 }
1488 
1489 void QgsTextFormatWidget::mBufferUnitWidget_changed()
1490 {
1491  updateFont( mRefFont );
1492 }
1493 
1494 void QgsTextFormatWidget::mMaskBufferUnitWidget_changed()
1495 {
1496  updateFont( mRefFont );
1497 }
1498 
1499 void QgsTextFormatWidget::mCoordXDDBtn_changed( )
1500 {
1501  if ( !mCoordXDDBtn->isActive() ) //no data defined alignment without data defined position
1502  {
1503  enableDataDefinedAlignment( false );
1504  }
1505  else if ( mCoordYDDBtn->isActive() )
1506  {
1508  }
1509 }
1510 
1511 void QgsTextFormatWidget::mCoordYDDBtn_changed( )
1512 {
1513  if ( !mCoordYDDBtn->isActive() ) //no data defined alignment without data defined position
1514  {
1515  enableDataDefinedAlignment( false );
1516  }
1517  else if ( mCoordXDDBtn->isActive() )
1518  {
1520  }
1521 }
1522 
1523 void QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged( int )
1524 {
1525  // shape background
1526  QgsTextBackgroundSettings::ShapeType type = static_cast< QgsTextBackgroundSettings::ShapeType >( mShapeTypeCmbBx->currentData().toInt() );
1528  const bool isSVG = type == QgsTextBackgroundSettings::ShapeSVG;
1529  const bool isMarker = type == QgsTextBackgroundSettings::ShapeMarkerSymbol;
1530 
1531  showBackgroundPenStyle( isRect );
1532  showBackgroundRadius( isRect );
1533 
1534  mShapeSVGPathFrame->setVisible( isSVG );
1535  mBackgroundSymbolButton->setVisible( isMarker );
1536 
1537  // symbology SVG and marker renderers only support size^2 scaling,
1538  // so we only use the x size spinbox
1539  mShapeSizeYLabel->setVisible( !isSVG && !isMarker );
1540  mShapeSizeYSpnBx->setVisible( !isSVG && !isMarker );
1541  mShapeSizeYDDBtn->setVisible( !isSVG && !isMarker );
1542  mShapeSizeXLabel->setText( tr( "Size%1" ).arg( !isSVG && !isMarker ? tr( " X" ) : QString() ) );
1543 
1544  // SVG parameter setting doesn't support color's alpha component yet
1545  mShapeFillColorBtn->setAllowOpacity( !isSVG );
1546  mShapeFillColorBtn->setButtonBackground();
1547  mShapeStrokeColorBtn->setAllowOpacity( !isSVG );
1548  mShapeStrokeColorBtn->setButtonBackground();
1549 
1550  // Hide parameter widgets not used by marker symbol
1551  mShapeFillColorLabel->setVisible( !isMarker );
1552  mShapeFillColorLabel->setEnabled( !isMarker );
1553  mShapeFillColorBtn->setVisible( !isMarker );
1554  mShapeFillColorBtn->setEnabled( !isMarker );
1555  mShapeFillColorDDBtn->setVisible( !isMarker );
1556  mShapeFillColorDDBtn->setEnabled( !isMarker );
1557  mShapeStrokeColorLabel->setVisible( !isMarker );
1558  mShapeStrokeColorLabel->setEnabled( !isMarker );
1559  mShapeStrokeColorBtn->setVisible( !isMarker );
1560  mShapeStrokeColorBtn->setEnabled( !isMarker );
1561  mShapeStrokeColorDDBtn->setVisible( !isMarker );
1562  mShapeStrokeColorDDBtn->setEnabled( !isMarker );
1563  mShapeStrokeWidthLabel->setVisible( !isMarker );
1564  mShapeStrokeWidthLabel->setEnabled( !isMarker );
1565  mShapeStrokeWidthSpnBx->setVisible( !isMarker );
1566  mShapeStrokeWidthSpnBx->setEnabled( !isMarker );
1567  mShapeStrokeWidthDDBtn->setVisible( !isMarker );
1568  mShapeStrokeWidthDDBtn->setEnabled( !isMarker );
1569 
1570  // configure SVG parameter widgets
1571  mShapeSVGParamsBtn->setVisible( isSVG );
1572  if ( isSVG )
1573  {
1574  updateSvgWidgets( mShapeSVGPathLineEdit->text() );
1575  }
1576  // TODO: fix overriding SVG symbol's stroke width units in QgsSvgCache
1577  // currently broken, fall back to symbol units only
1578  mShapeStrokeWidthUnitWidget->setVisible( !isSVG && !isMarker );
1579  mShapeSVGUnitsLabel->setVisible( isSVG );
1580  mShapeStrokeUnitsDDBtn->setVisible( !isSVG && !isMarker );
1581  mShapeStrokeUnitsDDBtn->setEnabled( !isSVG && !isMarker );
1582 
1583  updateAvailableShadowPositions();
1584 }
1585 
1586 void QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged( const QString &text )
1587 {
1588  updateSvgWidgets( text );
1589 }
1590 
1592 {
1593  int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) +
1594  ( chkLineBelow->isChecked() ? 1 : 0 ) +
1595  ( chkLineOn->isChecked() ? 1 : 0 );
1596 
1597  if ( numOptionsChecked == 1 )
1598  {
1599  //prevent unchecking last option
1600  chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
1601  chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
1602  chkLineOn->setEnabled( !chkLineOn->isChecked() );
1603  }
1604  else
1605  {
1606  chkLineAbove->setEnabled( true );
1607  chkLineBelow->setEnabled( true );
1608  chkLineOn->setEnabled( true );
1609  }
1610 }
1611 
1612 void QgsTextFormatWidget::onSubstitutionsChanged( const QgsStringReplacementCollection &substitutions )
1613 {
1614  mSubstitutions = substitutions;
1615  emit widgetChanged();
1616 }
1617 
1618 void QgsTextFormatWidget::previewScaleChanged( double scale )
1619 {
1620  lblFontPreview->setScale( scale );
1621 }
1622 
1623 void QgsTextFormatWidget::updateSvgWidgets( const QString &svgPath )
1624 {
1625  if ( mShapeSVGPathLineEdit->text() != svgPath )
1626  {
1627  mShapeSVGPathLineEdit->setText( svgPath );
1628  }
1629 
1630  QString resolvedPath;
1631  bool validSVG = true;
1632  if ( ! svgPath.startsWith( QLatin1String( "base64:" ), Qt::CaseInsensitive ) )
1633  {
1634  resolvedPath = QgsSymbolLayerUtils::svgSymbolNameToPath( svgPath, QgsProject::instance()->pathResolver() );
1635  validSVG = QFileInfo::exists( resolvedPath );
1636  }
1637  else
1638  {
1639  resolvedPath = svgPath;
1640  validSVG = true;
1641  }
1642 
1643  // draw red text for path field if invalid (path can't be resolved)
1644  mShapeSVGPathLineEdit->setStyleSheet( !validSVG ? QStringLiteral( "QLineEdit{ color: rgb(225, 0, 0); }" ) : QString() );
1645  mShapeSVGPathLineEdit->setToolTip( !validSVG ? tr( "File not found" ) : resolvedPath );
1646 
1647  QColor fill, stroke;
1648  double strokeWidth = 0.0;
1649  bool fillParam = false, strokeParam = false, strokeWidthParam = false;
1650  if ( validSVG )
1651  {
1652  QgsApplication::svgCache()->containsParams( resolvedPath, fillParam, fill, strokeParam, stroke, strokeWidthParam, strokeWidth );
1653  }
1654 
1655  mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || strokeParam || strokeWidthParam ) );
1656 
1657  mShapeFillColorLabel->setEnabled( validSVG && fillParam );
1658  mShapeFillColorBtn->setEnabled( validSVG && fillParam );
1659  mShapeFillColorDDBtn->setEnabled( validSVG && fillParam );
1660  if ( mLoadSvgParams && validSVG && fillParam )
1661  mShapeFillColorBtn->setColor( fill );
1662 
1663  mShapeStrokeColorLabel->setEnabled( validSVG && strokeParam );
1664  mShapeStrokeColorBtn->setEnabled( validSVG && strokeParam );
1665  mShapeStrokeColorDDBtn->setEnabled( validSVG && strokeParam );
1666  if ( mLoadSvgParams && validSVG && strokeParam )
1667  mShapeStrokeColorBtn->setColor( stroke );
1668 
1669  mShapeStrokeWidthLabel->setEnabled( validSVG && strokeWidthParam );
1670  mShapeStrokeWidthSpnBx->setEnabled( validSVG && strokeWidthParam );
1671  mShapeStrokeWidthDDBtn->setEnabled( validSVG && strokeWidthParam );
1672  if ( mLoadSvgParams && validSVG && strokeWidthParam )
1673  mShapeStrokeWidthSpnBx->setValue( strokeWidth );
1674 
1675  // TODO: fix overriding SVG symbol's stroke width units in QgsSvgCache
1676  // currently broken, fall back to symbol's
1677  //mShapeStrokeWidthUnitWidget->setEnabled( validSVG && strokeWidthParam );
1678  //mShapeStrokeUnitsDDBtn->setEnabled( validSVG && strokeWidthParam );
1679  mShapeSVGUnitsLabel->setEnabled( validSVG && strokeWidthParam );
1680 }
1681 
1682 void QgsTextFormatWidget::updateAvailableShadowPositions()
1683 {
1684  if ( mShadowUnderCmbBx->count() == 0
1685  || ( mShadowUnderCmbBx->findData( QgsTextShadowSettings::ShadowShape ) > -1 && mShapeTypeCmbBx->currentData().toInt() == QgsTextBackgroundSettings::ShapeMarkerSymbol )
1686  || ( mShadowUnderCmbBx->findData( QgsTextShadowSettings::ShadowShape ) == -1 && mShapeTypeCmbBx->currentData().toInt() != QgsTextBackgroundSettings::ShapeMarkerSymbol ) )
1687  {
1688  // showing invalid choices, have to rebuild the list
1689  QgsTextShadowSettings::ShadowPlacement currentPlacement = static_cast< QgsTextShadowSettings::ShadowPlacement >( mShadowUnderCmbBx->currentData().toInt() );
1690  mShadowUnderCmbBx->clear();
1691 
1692  mShadowUnderCmbBx->addItem( tr( "Lowest Label Component" ), QgsTextShadowSettings::ShadowLowest );
1693  mShadowUnderCmbBx->addItem( tr( "Text" ), QgsTextShadowSettings::ShadowText );
1694  mShadowUnderCmbBx->addItem( tr( "Buffer" ), QgsTextShadowSettings::ShadowBuffer );
1695  if ( mShapeTypeCmbBx->currentData().toInt() != QgsTextBackgroundSettings::ShapeMarkerSymbol )
1696  mShadowUnderCmbBx->addItem( tr( "Background" ), QgsTextShadowSettings::ShadowShape ); // not supported for marker symbol background shapes
1697 
1698  mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( currentPlacement ) );
1699  if ( mShadowUnderCmbBx->currentIndex() == -1 )
1700  mShadowUnderCmbBx->setCurrentIndex( 0 );
1701  }
1702 }
1703 
1704 void QgsTextFormatWidget::updateProperty()
1705 {
1706  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
1708  mDataDefinedProperties.setProperty( key, button->toProperty() );
1709  updatePreview();
1710 }
1711 
1712 void QgsTextFormatWidget::createAuxiliaryField()
1713 {
1714  if ( !mLayer )
1715  return;
1716 
1717  // try to create an auxiliary layer if not yet created
1718  if ( !mLayer->auxiliaryLayer() )
1719  {
1720  QgsNewAuxiliaryLayerDialog dlg( mLayer, this );
1721  dlg.exec();
1722  }
1723 
1724  // return if still not exists
1725  if ( !mLayer->auxiliaryLayer() )
1726  return;
1727 
1728  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
1729  const QgsPalLayerSettings::Property key = static_cast< QgsPalLayerSettings::Property >( button->propertyKey() );
1731 
1732  // create property in auxiliary storage if necessary
1733  if ( !mLayer->auxiliaryLayer()->exists( def ) )
1735 
1736  // update property with join field name from auxiliary storage
1737  QgsProperty property = button->toProperty();
1738  property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
1739  property.setActive( true );
1740  button->updateFieldLists();
1741  button->setToProperty( property );
1742  mDataDefinedProperties.setProperty( key, button->toProperty() );
1743  updatePreview();
1744  emit auxiliaryFieldCreated();
1745 }
1746 
1747 
1748 void QgsTextFormatWidget::updateShapeFrameStatus()
1749 {
1750  mShapeFrame->setEnabled( mShapeDrawDDBtn->isActive() || mShapeDrawChkBx->isChecked() );
1751 }
1752 
1753 void QgsTextFormatWidget::updateBufferFrameStatus()
1754 {
1755  mBufferFrame->setEnabled( mBufferDrawDDBtn->isActive() || mBufferDrawChkBx->isChecked() );
1756 }
1757 
1758 void QgsTextFormatWidget::updateShadowFrameStatus()
1759 {
1760  mShadowFrame->setEnabled( mShadowDrawDDBtn->isActive() || mShadowDrawChkBx->isChecked() );
1761 }
1762 
1763 void QgsTextFormatWidget::updateCalloutFrameStatus()
1764 {
1765  mCalloutFrame->setEnabled( mCalloutDrawDDBtn->isActive() || mCalloutsDrawCheckBox->isChecked() );
1766 }
1767 
1769 {
1770  switch ( type )
1771  {
1774  case QgsStyle::TagEntity:
1777  return;
1778 
1780  {
1781  if ( !QgsStyle::defaultStyle()->textFormatNames().contains( name ) )
1782  return;
1783 
1784  QgsTextFormat newFormat = QgsStyle::defaultStyle()->textFormat( name );
1785  setFormat( newFormat );
1786  break;
1787  }
1788 
1790  {
1791  if ( !QgsStyle::defaultStyle()->labelSettingsNames().contains( name ) )
1792  return;
1793 
1794  QgsTextFormat newFormat = QgsStyle::defaultStyle()->labelSettings( name ).format();
1795  setFormat( newFormat );
1796  break;
1797  }
1798  }
1799 }
1800 
1802 {
1803  QgsStyle *style = QgsStyle::defaultStyle();
1804  if ( !style )
1805  return;
1806 
1807  QgsStyleSaveDialog saveDlg( this, QgsStyle::TextFormatEntity );
1808  saveDlg.setDefaultTags( mTextFormatsListWidget->currentTagFilter() );
1809  if ( !saveDlg.exec() )
1810  return;
1811 
1812  if ( saveDlg.name().isEmpty() )
1813  return;
1814 
1815  // check if there is no format with same name
1816  if ( style->textFormatNames().contains( saveDlg.name() ) )
1817  {
1818  int res = QMessageBox::warning( this, tr( "Save Text Format" ),
1819  tr( "Format with name '%1' already exists. Overwrite?" )
1820  .arg( saveDlg.name() ),
1821  QMessageBox::Yes | QMessageBox::No );
1822  if ( res != QMessageBox::Yes )
1823  {
1824  return;
1825  }
1826  style->removeTextFormat( saveDlg.name() );
1827  }
1828 
1829  QStringList symbolTags = saveDlg.tags().split( ',' );
1830 
1831  QgsTextFormat newFormat = format();
1832  style->addTextFormat( saveDlg.name(), newFormat );
1833  style->saveTextFormat( saveDlg.name(), newFormat, saveDlg.isFavorite(), symbolTags );
1834 }
1835 
1836 void QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked()
1837 {
1838  QgsSvgSelectorDialog svgDlg( this );
1839  svgDlg.setWindowTitle( tr( "Select SVG file" ) );
1840  svgDlg.svgSelector()->setSvgPath( mShapeSVGPathLineEdit->text().trimmed() );
1841 
1842  if ( svgDlg.exec() == QDialog::Accepted )
1843  {
1844  QString svgPath = svgDlg.svgSelector()->currentSvgPath();
1845  if ( !svgPath.isEmpty() )
1846  {
1847  mShapeSVGPathLineEdit->setText( svgPath );
1848  updatePreview();
1849  }
1850  }
1851 }
1852 
1853 void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
1854 {
1855  QString svgPath = mShapeSVGPathLineEdit->text();
1856  mLoadSvgParams = true;
1857  updateSvgWidgets( svgPath );
1858  mLoadSvgParams = false;
1859 }
1860 
1861 void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged( int index )
1862 {
1863  mShapeRotationDblSpnBx->setEnabled( static_cast< QgsTextBackgroundSettings::RotationType >( index ) != QgsTextBackgroundSettings::RotationSync );
1864  mShapeRotationDDBtn->setEnabled( static_cast< QgsTextBackgroundSettings::RotationType >( index ) != QgsTextBackgroundSettings::RotationSync );
1865 }
1866 
1867 void QgsTextFormatWidget::mPreviewTextEdit_textChanged( const QString &text )
1868 {
1869  lblFontPreview->setText( text );
1870  updatePreview();
1871 }
1872 
1873 void QgsTextFormatWidget::mPreviewTextBtn_clicked()
1874 {
1875  mPreviewTextEdit->setText( QStringLiteral( "Lorem Ipsum" ) );
1876  updatePreview();
1877 }
1878 
1879 void QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged( const QColor &color )
1880 {
1881  setPreviewBackground( color );
1882 }
1883 
1884 void QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked()
1885 {
1886  bool gotChar = false;
1887 
1888  const QChar initial = !mDirectSymbLeftLineEdit->text().isEmpty() ? mDirectSymbLeftLineEdit->text().at( 0 ) : QChar();
1889  QChar dirSymb = mCharDlg->selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
1890 
1891  if ( !gotChar )
1892  return;
1893 
1894  if ( !dirSymb.isNull() )
1895  mDirectSymbLeftLineEdit->setText( QString( dirSymb ) );
1896 }
1897 
1898 void QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked()
1899 {
1900  bool gotChar = false;
1901  const QChar initial = !mDirectSymbRightLineEdit->text().isEmpty() ? mDirectSymbRightLineEdit->text().at( 0 ) : QChar();
1902  QChar dirSymb = mCharDlg->selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
1903 
1904  if ( !gotChar )
1905  return;
1906 
1907  if ( !dirSymb.isNull() )
1908  mDirectSymbRightLineEdit->setText( QString( dirSymb ) );
1909 }
1910 
1911 void QgsTextFormatWidget::chkLineOrientationDependent_toggled( bool active )
1912 {
1913  if ( active )
1914  {
1915  chkLineAbove->setText( tr( "Left of line" ) );
1916  chkLineBelow->setText( tr( "Right of line" ) );
1917  }
1918  else
1919  {
1920  chkLineAbove->setText( tr( "Above line" ) );
1921  chkLineBelow->setText( tr( "Below line" ) );
1922  }
1923 }
1924 
1925 
1926 void QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked()
1927 {
1929  if ( panel && panel->dockMode() )
1930  {
1932  widget->setPanelTitle( tr( "Substitutions" ) );
1933  widget->setSubstitutions( mSubstitutions );
1934  connect( widget, &QgsSubstitutionListWidget::substitutionsChanged, this, &QgsTextFormatWidget::onSubstitutionsChanged );
1935  panel->openPanel( widget );
1936  return;
1937  }
1938 
1939  QgsSubstitutionListDialog dlg( this );
1940  dlg.setSubstitutions( mSubstitutions );
1941  if ( dlg.exec() == QDialog::Accepted )
1942  {
1943  mSubstitutions = dlg.substitutions();
1944  emit widgetChanged();
1945  }
1946 }
1947 
1948 void QgsTextFormatWidget::showBackgroundRadius( bool show )
1949 {
1950  mShapeRadiusLabel->setVisible( show );
1951  mShapeRadiusXDbSpnBx->setVisible( show );
1952 
1953  mShapeRadiusYDbSpnBx->setVisible( show );
1954 
1955  mShapeRadiusUnitWidget->setVisible( show );
1956 
1957  mShapeRadiusDDBtn->setVisible( show );
1958  mShapeRadiusUnitsDDBtn->setVisible( show );
1959 }
1960 
1961 void QgsTextFormatWidget::showBackgroundPenStyle( bool show )
1962 {
1963  mShapePenStyleLabel->setVisible( show );
1964  mShapePenStyleCmbBx->setVisible( show );
1965 
1966  mShapePenStyleDDBtn->setVisible( show );
1967 }
1968 
1970 {
1971  mCoordAlignmentFrame->setEnabled( enable );
1972 }
1973 
1975 {
1976  if ( mContext.expressionContext() )
1977  return *mContext.expressionContext();
1978 
1979  QgsExpressionContext expContext;
1983  if ( mMapCanvas )
1985 
1986  if ( mLayer )
1988 
1989  //TODO - show actual value
1990  expContext.setOriginalValueVariable( QVariant() );
1992 
1993  return expContext;
1994 }
1995 
1996 
1997 //
1998 // QgsTextFormatDialog
1999 //
2000 
2001 QgsTextFormatDialog::QgsTextFormatDialog( const QgsTextFormat &format, QgsMapCanvas *mapCanvas, QWidget *parent, Qt::WindowFlags fl, QgsVectorLayer *layer )
2002  : QDialog( parent, fl )
2003 {
2004  setWindowTitle( tr( "Text Settings" ) );
2005 
2006  mFormatWidget = new QgsTextFormatWidget( format, mapCanvas, this, layer );
2007  mFormatWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
2008 
2009  QVBoxLayout *layout = new QVBoxLayout( this );
2010  layout->addWidget( mFormatWidget );
2011 
2012  mButtonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, Qt::Horizontal, this );
2013  layout->addWidget( mButtonBox );
2014 
2015  setLayout( layout );
2017 
2018  connect( mButtonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked, this, &QDialog::accept );
2019  connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked, this, &QDialog::reject );
2020  connect( mButtonBox->button( QDialogButtonBox::Help ), &QAbstractButton::clicked, this, &QgsTextFormatDialog::showHelp );
2021 }
2022 
2024 {
2025  return mFormatWidget->format();
2026 }
2027 
2028 void QgsTextFormatDialog::showHelp()
2029 {
2030  QgsHelp::openHelp( QStringLiteral( "style_library/label_settings.html#formatting-the-label-text" ) );
2031 }
2032 
2034 {
2035  mFormatWidget->setContext( context );
2036 }
2037 
2038 QDialogButtonBox *QgsTextFormatDialog::buttonBox() const
2039 {
2040  return mButtonBox;
2041 }
2042 
2044  : QgsPanelWidgetWrapper( new QgsTextFormatWidget( format, mapCanvas, nullptr, layer ), parent )
2045 {
2046  mFormatWidget = qobject_cast< QgsTextFormatWidget * >( widget() );
2047  connect( mFormatWidget, &QgsTextFormatWidget::widgetChanged, this, &QgsPanelWidget::widgetChanged );
2048 }
2049 
2051 {
2052  return mFormatWidget->format();
2053 }
2054 
2056 {
2057  mFormatWidget->setContext( context );
2058 }
2059 
2061 {
2062  mFormatWidget->setDockMode( dockMode );
2064 }
QgsTextMaskSettings::setSize
void setSize(double size)
Sets the size of the buffer.
Definition: qgstextmasksettings.cpp:66
QgsTextFormatWidget::updatePreview
void updatePreview()
Updates the text preview.
Definition: qgstextformatwidget.cpp:1240
QgsPalLayerSettings::ShadowBlendMode
@ ShadowBlendMode
Definition: qgspallabeling.h:423
QgsPalLayerSettings::BufferBlendMode
@ BufferBlendMode
Definition: qgspallabeling.h:379
QgsTextBufferSettings::setSizeUnit
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
Definition: qgstextbuffersettings.cpp:72
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:369
QgsPalLayerSettings::ShadowRadius
@ ShadowRadius
Definition: qgspallabeling.h:417
QgsPalLayerSettings::OffsetUnits
@ OffsetUnits
Definition: qgspallabeling.h:429
QgsStyle::saveTextFormat
bool saveTextFormat(const QString &name, const QgsTextFormat &format, bool favorite, const QStringList &tags)
Adds a text format to the database.
Definition: qgsstyle.cpp:820
QgsTextMaskSettings::enabled
bool enabled() const
Returns whether the mask is enabled.
Definition: qgstextmasksettings.cpp:40
qgsexpressioncontextutils.h
QgsPalLayerSettings::DistanceUnits
@ DistanceUnits
Definition: qgspallabeling.h:431
QgsSymbolWidgetContext::mapCanvas
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
Definition: qgssymbolwidgetcontext.cpp:54
QgsTextBackgroundSettings::setStrokeColor
void setStrokeColor(const QColor &color)
Sets the color used for outlining the background shape.
Definition: qgstextbackgroundsettings.cpp:242
QgsTextFormatWidget::createExpressionContext
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Definition: qgstextformatwidget.cpp:1974
qgssvgcache.h
QgsPalLayerSettings::MaskEnabled
@ MaskEnabled
Whether the mask is enabled.
Definition: qgspallabeling.h:382
QgsUnitTypes::RenderInches
@ RenderInches
Inches.
Definition: qgsunittypes.h:173
QgsTextFormatWidget::mPlacePointBtnGrp
QButtonGroup * mPlacePointBtnGrp
Point placement button group.
Definition: qgstextformatwidget.h:173
QgsTextFormat::buffer
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
Definition: qgstextformat.h:66
QgsStyleItemsListWidget::saveEntity
void saveEntity()
Emitted when the user has opted to save a new entity to the style database, by clicking the "Save" bu...
QgsPalLayerSettings::MaskBufferSize
@ MaskBufferSize
Mask buffer size.
Definition: qgspallabeling.h:383
QgsPalLayerSettings::Hali
@ Hali
Horizontal alignment for data defined label position (Left, Center, Right)
Definition: qgspallabeling.h:437
QgsPalLayerSettings::NumFormat
@ NumFormat
Definition: qgspallabeling.h:367
QgsTextShadowSettings::setOpacity
void setOpacity(double opacity)
Sets the shadow's opacity.
Definition: qgstextshadowsettings.cpp:161
QgsEffectStackCompactWidget::changed
void changed()
Emitted when the paint effect properties change.
qgspallabeling.h
QgsTextBufferSettings::setOpacity
void setOpacity(double opacity)
Sets the buffer opacity.
Definition: qgstextbuffersettings.cpp:112
QgsTextFormat::namedStyle
QString namedStyle() const
Returns the named style for the font used for rendering text (e.g., "bold").
Definition: qgstextformat.cpp:81
QgsPalLayerSettings::PerimeterCurved
@ PerimeterCurved
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only.
Definition: qgspallabeling.h:229
QgsTextFormatWidget::updateLinePlacementOptions
void updateLinePlacementOptions()
Updates line placement options to reflect current state of widget.
Definition: qgstextformatwidget.cpp:1591
QgsTextBackgroundSettings::setRotationType
void setRotationType(RotationType type)
Sets the method used for rotating the background shape.
Definition: qgstextbackgroundsettings.cpp:132
QgsStyle::ColorrampEntity
@ ColorrampEntity
Color ramps.
Definition: qgsstyle.h:182
QgsTextShadowSettings::offsetDistance
double offsetDistance() const
Returns the distance for offsetting the position of the shadow from the text.
Definition: qgstextshadowsettings.cpp:76
QgsTextBackgroundSettings::radiiUnit
QgsUnitTypes::RenderUnit radiiUnit() const
Returns the units used for the shape's radii.
Definition: qgstextbackgroundsettings.cpp:187
QgsTextFormat::setFont
void setFont(const QFont &font)
Sets the font used for rendering text.
Definition: qgstextformat.cpp:76
QgsProperty
A store for object properties.
Definition: qgsproperty.h:231
QgsTextShadowSettings::setEnabled
void setEnabled(bool enabled)
Sets whether the text shadow will be drawn.
Definition: qgstextshadowsettings.cpp:51
QgsApplication::getThemeIcon
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Definition: qgsapplication.cpp:605
QgsTextBufferSettings::sizeMapUnitScale
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
Definition: qgstextbuffersettings.cpp:77
QgsPalLayerSettings::OffsetXY
@ OffsetXY
Definition: qgspallabeling.h:428
QgsPalLayerSettings::AroundPoint
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
Definition: qgspallabeling.h:222
QgsSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Definition: qgssettings.cpp:174
QgsExpressionContext::EXPR_ORIGINAL_VALUE
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
Definition: qgsexpressioncontext.h:721
QgsExpressionContextUtils::globalScope
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Definition: qgsexpressioncontextutils.cpp:33
QgsSymbol::defaultSymbol
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Definition: qgssymbol.cpp:301
QgsTextBackgroundSettings::enabled
bool enabled() const
Returns whether the background is enabled.
Definition: qgstextbackgroundsettings.cpp:47
QgsPalLayerSettings::FromSymbolBounds
@ FromSymbolBounds
Offset distance applies from rendered symbol bounds.
Definition: qgspallabeling.h:260
QgsTextFormatPanelWidget::setContext
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
Definition: qgstextformatwidget.cpp:2055
qgsmapcanvas.h
QgsPalLayerSettings::RepeatDistanceUnit
@ RepeatDistanceUnit
Definition: qgspallabeling.h:442
QgsTextFormat::previewBackgroundColor
QColor previewBackgroundColor() const
Returns the background color for text previews.
Definition: qgstextformat.cpp:186
QgsPalLayerSettings::MaximumScale
@ MaximumScale
Maximum map scale (ie most "zoomed in")
Definition: qgspallabeling.h:455
QgsTextShadowSettings::blurRadiusMapUnitScale
QgsMapUnitScale blurRadiusMapUnitScale() const
Returns the map unit scale object for the shadow blur radius.
Definition: qgstextshadowsettings.cpp:136
QgsPalLayerSettings::ShapeSizeType
@ ShapeSizeType
Definition: qgspallabeling.h:392
QgsPalLayerSettings::BufferSize
@ BufferSize
Definition: qgspallabeling.h:373
QgsTextBackgroundSettings::setSizeType
void setSizeType(SizeType type)
Sets the method used to determine the size of the background shape (e.g., fixed size or buffer around...
Definition: qgstextbackgroundsettings.cpp:92
QgsTextFormatWidget::updateWidgetForFormat
void updateWidgetForFormat(const QgsTextFormat &format)
Updates the widget's state to reflect the settings in a QgsTextFormat.
Definition: qgstextformatwidget.cpp:838
QgsPanelWidget::setDockMode
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
Definition: qgspanelwidget.cpp:44
QgsPalLayerSettings::Color
@ Color
Text color.
Definition: qgspallabeling.h:344
QgsTextBufferSettings::joinStyle
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
Definition: qgstextbuffersettings.cpp:117
QgsStyle::textFormat
QgsTextFormat textFormat(const QString &name) const
Returns the text format with the specified name.
Definition: qgsstyle.cpp:1895
QgsTextFormat::resolvedFontFamily
QString resolvedFontFamily() const
Returns the family for the resolved font, ie if the specified font was not found on the system this w...
Definition: qgstextformat.h:424
QgsTextBackgroundSettings::setStrokeWidth
void setStrokeWidth(double width)
Sets the width of the shape's stroke (stroke).
Definition: qgstextbackgroundsettings.cpp:252
QgsPropertyOverrideButton::changed
void changed()
Emitted when property definition changes.
QgsPanelWidget::findParentPanel
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
Definition: qgspanelwidget.cpp:49
QgsPropertyCollection::propertyKeys
QSet< int > propertyKeys() const override
Returns a list of property keys contained within the collection.
Definition: qgspropertycollection.cpp:156
QgsTextBackgroundSettings::setJoinStyle
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the background shape.
Definition: qgstextbackgroundsettings.cpp:282
QgsPalLayerSettings::PositionY
@ PositionY
Y-coordinate data defined label position.
Definition: qgspallabeling.h:436
QgsMapCanvas::mapSettings
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
Definition: qgsmapcanvas.cpp:390
QgsTextBufferSettings::setEnabled
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
Definition: qgstextbuffersettings.cpp:52
QgsTextFormat::orientation
TextOrientation orientation() const
Returns the orientation of the text.
Definition: qgstextformat.cpp:166
QgsTextShadowSettings::ShadowBuffer
@ ShadowBuffer
Draw shadow under buffer.
Definition: qgstextshadowsettings.h:48
QgsPalLayerSettings::FontOpacity
@ FontOpacity
Text opacity.
Definition: qgspallabeling.h:350
QgsPalLayerSettings::MultiLineHeight
@ MultiLineHeight
Definition: qgspallabeling.h:359
QgsTextBackgroundSettings::setStrokeWidthMapUnitScale
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape stroke width.
Definition: qgstextbackgroundsettings.cpp:272
QgsPalLayerSettings::ShapeOffsetUnits
@ ShapeOffsetUnits
Definition: qgspallabeling.h:399
qgsgui.h
QgsSubstitutionListWidget::substitutionsChanged
void substitutionsChanged(const QgsStringReplacementCollection &substitutions)
Emitted when the substitution definitions change.
QgsPalLayerSettings::BufferUnit
@ BufferUnit
Definition: qgspallabeling.h:374
QgsTextBackgroundSettings::offsetMapUnitScale
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shape offset.
Definition: qgstextbackgroundsettings.cpp:167
QgsAuxiliaryLayer::exists
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
Definition: qgsauxiliarystorage.cpp:135
QgsTextBackgroundSettings::setRadiiMapUnitScale
void setRadiiMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape radii.
Definition: qgstextbackgroundsettings.cpp:202
QgsPalLayerSettings::ShapeFillColor
@ ShapeFillColor
Definition: qgspallabeling.h:405
QgsUnitTypes::RenderPoints
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:172
QgsPalLayerSettings::FromPoint
@ FromPoint
Offset distance applies from point geometry.
Definition: qgspallabeling.h:259
QgsTextShadowSettings::offsetUnit
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the shadow's offset.
Definition: qgstextshadowsettings.cpp:86
QgsExpressionContext::setOriginalValueVariable
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
Definition: qgsexpressioncontext.cpp:566
qgssymbollayerutils.h
QgsPalLayerSettings::BufferOpacity
@ BufferOpacity
Buffer opacity.
Definition: qgspallabeling.h:377
QgsPalLayerSettings::FontMaxPixel
@ FontMaxPixel
Definition: qgspallabeling.h:458
QgsPalLayerSettings::CurvedCharAngleInOut
@ CurvedCharAngleInOut
Definition: qgspallabeling.h:433
QgsTextBackgroundSettings::setMarkerSymbol
void setMarkerSymbol(QgsMarkerSymbol *symbol)
Sets the current marker symbol for the background shape.
Definition: qgstextbackgroundsettings.cpp:82
QgsExpressionContextUtils::layerScope
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Definition: qgsexpressioncontextutils.cpp:264
QgsSymbolWidgetContext
Definition: qgssymbolwidgetcontext.h:35
QgsPalLayerSettings::Strikeout
@ Strikeout
Use strikeout.
Definition: qgspallabeling.h:345
QgsPalLayerSettings::BufferJoinStyle
@ BufferJoinStyle
Definition: qgspallabeling.h:378
QgsMapCanvas
Definition: qgsmapcanvas.h:83
QgsSubstitutionListWidget
Definition: qgssubstitutionlistwidget.h:36
QgsPanelWidget::openPanel
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
Definition: qgspanelwidget.cpp:79
QgsTextFormatWidget::updatePlacementWidgets
void updatePlacementWidgets()
Updates label placement options to reflect current state of widget.
Definition: qgstextformatwidget.cpp:1275
QgsPalLayerSettings::FontLimitPixel
@ FontLimitPixel
Definition: qgspallabeling.h:456
QgsTextFormat::sizeUnit
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the size of rendered text.
Definition: qgstextformat.cpp:96
QgsTextBackgroundSettings::fillColor
QColor fillColor() const
Returns the color used for filing the background shape.
Definition: qgstextbackgroundsettings.cpp:227
QgsTextBackgroundSettings
Definition: qgstextbackgroundsettings.h:45
qgspathresolver.h
QgsUnitTypes::RenderPercentage
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
Definition: qgsunittypes.h:171
QgsTextShadowSettings::scale
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
Definition: qgstextshadowsettings.cpp:166
QgsTextBufferSettings::opacity
double opacity() const
Returns the buffer opacity.
Definition: qgstextbuffersettings.cpp:107
QgsExpressionContextUtils::mapSettingsScope
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
Definition: qgsexpressioncontextutils.cpp:356
QgsTextFormatWidget::mMapCanvas
QgsMapCanvas * mMapCanvas
Associated map canvas.
Definition: qgstextformatwidget.h:182
QgsPalLayerSettings::PredefinedPositionOrder
@ PredefinedPositionOrder
Definition: qgspallabeling.h:444
QgsTextBackgroundSettings::SizeType
SizeType
Methods for determining the background shape size.
Definition: qgstextbackgroundsettings.h:65
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:458
QgsTextFormat::shadow
QgsTextShadowSettings & shadow()
Returns a reference to the text drop shadow settings.
Definition: qgstextformat.h:104
QgsTextMaskSettings::setSizeUnit
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
Definition: qgstextmasksettings.cpp:76
QgsVectorLayer::auxiliaryLayer
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
Definition: qgsvectorlayer.cpp:5269
QgsTextFormat::mask
QgsTextMaskSettings & mask()
Returns a reference to the masking settings.
Definition: qgstextformat.h:123
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
QgsPropertyOverrideButton::createAuxiliaryField
void createAuxiliaryField()
Emitted when creating a new auxiliary field.
QgsPropertyOverrideButton::propertyKey
int propertyKey() const
Returns the property key linked to the button.
Definition: qgspropertyoverridebutton.h:123
QgsTextBackgroundSettings::RotationSync
@ RotationSync
Shape rotation is synced with text rotation.
Definition: qgstextbackgroundsettings.h:77
QgsTextBackgroundSettings::offset
QPointF offset() const
Returns the offset used for drawing the background shape.
Definition: qgstextbackgroundsettings.cpp:147
QgsSettings
Definition: qgssettings.h:61
QgsTextShadowSettings::setOffsetMapUnitScale
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow offset distance.
Definition: qgstextshadowsettings.cpp:101
qgspainteffectregistry.h
QgsPalLayerSettings::Vali
@ Vali
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
Definition: qgspallabeling.h:438
QgsTextBackgroundSettings::strokeWidthMapUnitScale
QgsMapUnitScale strokeWidthMapUnitScale() const
Returns the map unit scale object for the shape stroke width.
Definition: qgstextbackgroundsettings.cpp:267
QgsTextBackgroundSettings::opacity
double opacity() const
Returns the background shape's opacity.
Definition: qgstextbackgroundsettings.cpp:207
QgsPalLayerSettings::ShadowOffsetUnits
@ ShadowOffsetUnits
Definition: qgspallabeling.h:416
QgsPalLayerSettings::ShapeOpacity
@ ShapeOpacity
Shape opacity.
Definition: qgspallabeling.h:403
QgsPalLayerSettings::ShapeBlendMode
@ ShapeBlendMode
Definition: qgspallabeling.h:404
QgsTextFormatWidget::mDirectSymbBtnGrp
QButtonGroup * mDirectSymbBtnGrp
Symbol direction button group.
Definition: qgstextformatwidget.h:169
QgsTextBackgroundSettings::strokeWidthUnit
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units used for the shape's stroke width.
Definition: qgstextbackgroundsettings.cpp:257
QgsStyle::LegendPatchShapeEntity
@ LegendPatchShapeEntity
Legend patch shape (since QGIS 3.14)
Definition: qgsstyle.h:186
QgsTextFormat::setPreviewBackgroundColor
void setPreviewBackgroundColor(const QColor &color)
Sets the background color that text will be rendered on for previews.
Definition: qgstextformat.cpp:191
qgsfontutils.h
QgsTextBackgroundSettings::setBlendMode
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the background shape.
Definition: qgstextbackgroundsettings.cpp:222
QgsTextFormatDialog::buttonBox
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
Definition: qgstextformatwidget.cpp:2038
QgsPalLayerSettings::DirSymbDraw
@ DirSymbDraw
Definition: qgspallabeling.h:362
QgsPalLayerSettings::DirSymbReverse
@ DirSymbReverse
Definition: qgspallabeling.h:366
QgsPalLayerSettings::Line
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
Definition: qgspallabeling.h:224
QgsTextShadowSettings::blurRadius
double blurRadius() const
Returns the blur radius for the shadow.
Definition: qgstextshadowsettings.cpp:116
QgsTextBufferSettings::setFillBufferInterior
void setFillBufferInterior(bool fill)
Sets whether the interior of the buffer will be filled in.
Definition: qgstextbuffersettings.cpp:102
QgsPaintEffectRegistry::defaultStack
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects.
Definition: qgspainteffectregistry.cpp:114
QgsPalLayerSettings::MultiLineWrapChar
@ MultiLineWrapChar
Definition: qgspallabeling.h:357
QgsPalLayerSettings::LabelDistance
@ LabelDistance
Definition: qgspallabeling.h:430
QgsCollapsibleGroupBox
Definition: qgscollapsiblegroupbox.h:178
QgsTextShadowSettings::setOffsetDistance
void setOffsetDistance(double distance)
Sets the distance for offsetting the position of the shadow from the text.
Definition: qgstextshadowsettings.cpp:81
QgsTextBackgroundSettings::setOpacity
void setOpacity(double opacity)
Sets the background shape's opacity.
Definition: qgstextbackgroundsettings.cpp:212
QgsTextBackgroundSettings::setStrokeWidthUnit
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's stroke width.
Definition: qgstextbackgroundsettings.cpp:262
QgsTextFormatWidget::mMinPixelLimit
int mMinPixelLimit
Pixel size font limit.
Definition: qgstextformatwidget.h:179
QgsTextBackgroundSettings::sizeType
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
Definition: qgstextbackgroundsettings.cpp:87
QgsPalLayerSettings::SymbolLeftRight
@ SymbolLeftRight
Place direction symbols on left/right of label.
Definition: qgspallabeling.h:304
QgsSvgSelectorDialog
Definition: qgssvgselectorwidget.h:293
QgsPanelWidget::dockMode
bool dockMode()
Returns the dock mode state.
Definition: qgspanelwidget.h:83
QgsTextFormatPanelWidget::setDockMode
void setDockMode(bool dockMode) override
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
Definition: qgstextformatwidget.cpp:2060
qgsstylesavedialog.h
QgsTextBackgroundSettings::blendMode
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the background shape.
Definition: qgstextbackgroundsettings.cpp:217
QgsTextFormatWidget::mUpsidedownBtnGrp
QButtonGroup * mUpsidedownBtnGrp
Upside down labels button group.
Definition: qgstextformatwidget.h:171
QgsPalLayerSettings::OverPoint
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
Definition: qgspallabeling.h:223
QgsTextFormatDialog::setContext
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
Definition: qgstextformatwidget.cpp:2033
QgsTextBufferSettings::setSizeMapUnitScale
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
Definition: qgstextbuffersettings.cpp:82
QgsSymbolButton
Definition: qgssymbolbutton.h:41
QgsTextShadowSettings::setOffsetAngle
void setOffsetAngle(int angle)
Sets the angle for offsetting the position of the shadow from the text.
Definition: qgstextshadowsettings.cpp:71
QgsPalLayerSettings::Show
@ Show
Definition: qgspallabeling.h:465
QgsSvgCache::containsParams
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth, bool blocking=false) const
Tests if an svg file contains parameters for fill, stroke color, stroke width.
Definition: qgssvgcache.cpp:225
QgsTextShadowSettings::enabled
bool enabled() const
Returns whether the shadow is enabled.
Definition: qgstextshadowsettings.cpp:46
QgsStyle::SymbolEntity
@ SymbolEntity
Symbols.
Definition: qgsstyle.h:180
QgsTextMaskSettings::size
double size() const
Returns the size of the buffer.
Definition: qgstextmasksettings.cpp:61
QgsPropertyOverrideButton::setToProperty
void setToProperty(const QgsProperty &property)
Sets the widget to reflect the current state of a QgsProperty.
Definition: qgspropertyoverridebutton.cpp:286
QgsProperty::setActive
void setActive(bool active)
Sets whether the property is currently active.
Definition: qgsproperty.cpp:271
QgsPalLayerSettings::ShapeKind
@ ShapeKind
Definition: qgspallabeling.h:390
QgsStyle::TagEntity
@ TagEntity
Tags.
Definition: qgsstyle.h:181
QgsTextMaskSettings::setPaintEffect
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the mask.
Definition: qgstextmasksettings.cpp:116
QgsGuiUtils::iconSize
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
Definition: qgsguiutils.cpp:264
QgsPropertyCollection::property
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
Definition: qgspropertycollection.cpp:204
QgsPalLayerSettings::QuadrantAboveRight
@ QuadrantAboveRight
Definition: qgspallabeling.h:286
QgsTextBackgroundSettings::setSizeMapUnitScale
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape size.
Definition: qgstextbackgroundsettings.cpp:122
QgsTextFormatWidget::mPlaceLineBtnGrp
QButtonGroup * mPlaceLineBtnGrp
Line placement button group.
Definition: qgstextformatwidget.h:175
QgsMarkerSymbol::clone
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
Definition: qgssymbol.cpp:1896
QgsPropertyOverrideButton
Definition: qgspropertyoverridebutton.h:50
QgsTextBackgroundSettings::ShapeSquare
@ ShapeSquare
Square - buffered sizes only.
Definition: qgstextbackgroundsettings.h:55
QgsColorButton::colorChanged
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
QgsStyle::LabelSettingsEntity
@ LabelSettingsEntity
Label settings.
Definition: qgsstyle.h:185
QgsTextFormat::VerticalOrientation
@ VerticalOrientation
Horizontally oriented text.
Definition: qgstextformat.h:46
QgsTextFormat::color
QColor color() const
Returns the color that text will be rendered in.
Definition: qgstextformat.cpp:126
QgsStyle::defaultStyle
static QgsStyle * defaultStyle()
Returns default application-wide style.
Definition: qgsstyle.cpp:111
QgsTextFormatWidget::mContext
QgsSymbolWidgetContext mContext
Context in which widget is shown.
Definition: qgstextformatwidget.h:185
QgsTextBackgroundSettings::paintEffect
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the background shape.
Definition: qgstextbackgroundsettings.cpp:287
qgsauxiliarystorage.h
QgsTextShadowSettings::blurAlphaOnly
bool blurAlphaOnly() const
Returns whether only the alpha channel for the shadow will be blurred.
Definition: qgstextshadowsettings.cpp:146
QgsPalLayerSettings::FontWordSpacing
@ FontWordSpacing
Word spacing.
Definition: qgspallabeling.h:353
QgsTextBackgroundSettings::setRadiiUnit
void setRadiiUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's radii.
Definition: qgstextbackgroundsettings.cpp:192
qgsnewauxiliarylayerdialog.h
QgsPalLayerSettings::PolygonLabelOutside
@ PolygonLabelOutside
Whether labels outside a polygon feature are permitted, or should be forced (since QGIS 3....
Definition: qgspallabeling.h:448
QgsPalLayerSettings::QuadrantBelowLeft
@ QuadrantBelowLeft
Definition: qgspallabeling.h:290
QgsGui::enableAutoGeometryRestore
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
Definition: qgsgui.cpp:133
QgsTextFormat::setBackground
void setBackground(const QgsTextBackgroundSettings &backgroundSettings)
Sets the text's background settings.q.
Definition: qgstextformat.h:98
QgsTextFormatWidget::deactivateField
void deactivateField(QgsPalLayerSettings::Property key)
Deactivate a field from data defined properties and update the corresponding button.
Definition: qgstextformatwidget.cpp:1136
QgsTextBackgroundSettings::sizeMapUnitScale
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
Definition: qgstextbackgroundsettings.cpp:117
QgsPalLayerSettings::OrderedPositionsAroundPoint
@ OrderedPositionsAroundPoint
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
Definition: qgspallabeling.h:228
QgsTextBackgroundSettings::rotationType
RotationType rotationType() const
Returns the method used for rotating the background shape.
Definition: qgstextbackgroundsettings.cpp:127
QgsTextFormat
Definition: qgstextformat.h:38
QgsTextBackgroundSettings::RotationType
RotationType
Methods for determining the rotation of the background shape.
Definition: qgstextbackgroundsettings.h:75
QgsTextFormat::setColor
void setColor(const QColor &color)
Sets the color that text will be rendered in.
Definition: qgstextformat.cpp:131
QgsPropertyOverrideButton::activated
void activated(bool isActive)
Emitted when the activated status of the widget changes.
QgsPalLayerSettings::MultiLineAlignment
@ MultiLineAlignment
Definition: qgspallabeling.h:360
QgsExpressionContextUtils::projectScope
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
Definition: qgsexpressioncontextutils.cpp:221
QgsTextBackgroundSettings::size
QSizeF size() const
Returns the size of the background shape.
Definition: qgstextbackgroundsettings.cpp:97
QgsTextFormat::sizeMapUnitScale
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the size.
Definition: qgstextformat.cpp:106
QgsPalLayerSettings::DirSymbRight
@ DirSymbRight
Definition: qgspallabeling.h:364
QgsPalLayerSettings::Curved
@ Curved
Arranges candidates following the curvature of a line feature. Applies to line layers only.
Definition: qgspallabeling.h:225
QgsPaintEffectRegistry::isDefaultStack
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
Definition: qgspainteffectregistry.cpp:134
QgsTextShadowSettings::blendMode
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the drop shadow.
Definition: qgstextshadowsettings.cpp:186
QgsTextShadowSettings::ShadowPlacement
ShadowPlacement
Placement positions for text shadow.
Definition: qgstextshadowsettings.h:44
QgsTextBackgroundSettings::setOffset
void setOffset(QPointF offset)
Sets the offset used for drawing the background shape.
Definition: qgstextbackgroundsettings.cpp:152
QgsTextFormatDialog::QgsTextFormatDialog
QgsTextFormatDialog(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QgsVectorLayer *layer=nullptr)
Constructor for QgsTextFormatDialog.
Definition: qgstextformatwidget.cpp:2001
qgstextformatwidget.h
QgsTextBackgroundSettings::ShapeRectangle
@ ShapeRectangle
Rectangle.
Definition: qgstextbackgroundsettings.h:54
QgsTextBackgroundSettings::joinStyle
Qt::PenJoinStyle joinStyle() const
Returns the join style used for drawing the background shape.
Definition: qgstextbackgroundsettings.cpp:277
QgsPalLayerSettings::FontLetterSpacing
@ FontLetterSpacing
Letter spacing.
Definition: qgspallabeling.h:352
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:29
QgsPalLayerSettings::Bold
@ Bold
Use bold style.
Definition: qgspallabeling.h:341
QgsProperty::setField
void setField(const QString &field)
Sets the field name the property references.
Definition: qgsproperty.cpp:292
QgsTextFormatWidget::mPlacePolygonBtnGrp
QButtonGroup * mPlacePolygonBtnGrp
Polygon placement button group.
Definition: qgstextformatwidget.h:177
QgsPanelWidgetWrapper::widget
QWidget * widget()
Returns the internal widget that is wrapped in this panel.
Definition: qgspanelwidget.h:217
QgsPalLayerSettings::QuadrantLeft
@ QuadrantLeft
Definition: qgspallabeling.h:287
whileBlocking
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:262
QgsPalLayerSettings::SymbolAbove
@ SymbolAbove
Place direction symbols on above label.
Definition: qgspallabeling.h:305
QgsTextFormatPanelWidget::QgsTextFormatPanelWidget
QgsTextFormatPanelWidget(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsVectorLayer *layer=nullptr)
Constructor for QgsTextFormatPanelWidget.
Definition: qgstextformatwidget.cpp:2043
QgsPalLayerSettings::ShadowUnder
@ ShadowUnder
Definition: qgspallabeling.h:413
QgsTextShadowSettings::setColor
void setColor(const QColor &color)
Sets the color for the drop shadow.
Definition: qgstextshadowsettings.cpp:181
QgsPropertyOverrideButton::updateFieldLists
void updateFieldLists()
Updates list of fields.
Definition: qgspropertyoverridebutton.cpp:152
QgsPalLayerSettings::DirSymbPlacement
@ DirSymbPlacement
Definition: qgspallabeling.h:365
QgsTextFormatWidget::setPreviewBackground
void setPreviewBackground(const QColor &color)
Sets the background color for the text preview widget.
Definition: qgstextformatwidget.cpp:1260
QgsTextMaskSettings
Definition: qgstextmasksettings.h:41
QgsMarkerSymbol
Definition: qgssymbol.h:917
QgsTextMaskSettings::setJoinStyle
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
Definition: qgstextmasksettings.cpp:96
QgsTextBackgroundSettings::ShapeCircle
@ ShapeCircle
Circle.
Definition: qgstextbackgroundsettings.h:57
QgsTextShadowSettings::ShadowLowest
@ ShadowLowest
Draw shadow below all text components.
Definition: qgstextshadowsettings.h:46
QgsPalLayerSettings::BufferColor
@ BufferColor
Definition: qgspallabeling.h:375
QgsStyleItemsListWidget::selectionChanged
void selectionChanged(const QString &name, QgsStyle::StyleEntity type)
Emitted when the selected item is changed in the widget.
QgsPalLayerSettings::Priority
@ Priority
Definition: qgspallabeling.h:443
QgsMapSettings::mapUnits
QgsUnitTypes::DistanceUnit mapUnits() const
Gets units of map's geographical coordinates - used for scale calculation.
Definition: qgsmapsettings.cpp:359
QgsPalLayerSettings::LabelAllParts
@ LabelAllParts
Whether all parts of multi-part features should be labeled.
Definition: qgspallabeling.h:447
QgsPalLayerSettings::MaskOpacity
@ MaskOpacity
Mask opacity.
Definition: qgspallabeling.h:385
QgsPalLayerSettings::format
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
Definition: qgspallabeling.h:1015
QgsTextBufferSettings::setPaintEffect
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the buffer.
Definition: qgstextbuffersettings.cpp:142
QgsPalLayerSettings::CalloutDraw
@ CalloutDraw
Show callout.
Definition: qgspallabeling.h:462
QgsTextBackgroundSettings::strokeWidth
double strokeWidth() const
Returns the width of the shape's stroke (stroke).
Definition: qgstextbackgroundsettings.cpp:247
QgsPalLayerSettings::TextOrientation
@ TextOrientation
Definition: qgspallabeling.h:361
qgscharacterselectordialog.h
QgsTextFormatWidget::format
QgsTextFormat format
Definition: qgstextformatwidget.h:53
QgsTextBackgroundSettings::setPaintEffect
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the background shape.
Definition: qgstextbackgroundsettings.cpp:292
QgsPaintEffect::clone
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
QgsTextShadowSettings::offsetMapUnitScale
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shadow offset distance.
Definition: qgstextshadowsettings.cpp:96
QgsTextFormatWidget::mQuadrantBtnGrp
QButtonGroup * mQuadrantBtnGrp
Quadrant button group.
Definition: qgstextformatwidget.h:167
QgsPalLayerSettings::FontBlendMode
@ FontBlendMode
Text blend mode.
Definition: qgspallabeling.h:354
QgsTextFormatWidget::mMaskedSymbolLayers
QgsSymbolLayerReferenceList mMaskedSymbolLayers
Definition: qgstextformatwidget.h:193
QgsTextMaskSettings::setSizeMapUnitScale
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
Definition: qgstextmasksettings.cpp:86
QgsTextFormat::allowHtmlFormatting
bool allowHtmlFormatting() const
Returns true if text should be treated as a HTML document and HTML tags should be used for formatting...
Definition: qgstextformat.cpp:176
QgsPalLayerSettings::LabelRotation
@ LabelRotation
Label rotation.
Definition: qgspallabeling.h:440
QgsTextShadowSettings::color
QColor color() const
Returns the color of the drop shadow.
Definition: qgstextshadowsettings.cpp:176
QgsPalLayerSettings::RepeatDistance
@ RepeatDistance
Definition: qgspallabeling.h:441
QgsPalLayerSettings::NumPlusSign
@ NumPlusSign
Definition: qgspallabeling.h:369
QgsTextFormat::setBlendMode
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the text.
Definition: qgstextformat.cpp:151
QgsTextBackgroundSettings::setOffsetMapUnitScale
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape offset.
Definition: qgstextbackgroundsettings.cpp:172
QgsPanelWidget::widgetChanged
void widgetChanged()
Emitted when the widget state changes.
QgsTextShadowSettings::setBlurRadius
void setBlurRadius(double blurRadius)
Sets the blur radius for the shadow.
Definition: qgstextshadowsettings.cpp:121
QgsPalLayerSettings::ZIndex
@ ZIndex
Definition: qgspallabeling.h:461
QgsPalLayerSettings::Upright
@ Upright
Upside-down labels (90 <= angle < 270) are shown upright.
Definition: qgspallabeling.h:297
QgsPalLayerSettings::ShapeSizeY
@ ShapeSizeY
Definition: qgspallabeling.h:394
QgsTextFormat::lineHeight
double lineHeight() const
Returns the line height for text.
Definition: qgstextformat.cpp:156
QgsPropertyOverrideButton::toProperty
QgsProperty toProperty() const
Returns a QgsProperty object encapsulating the current state of the widget.
Definition: qgspropertyoverridebutton.cpp:210
QgsSubstitutionListDialog
Definition: qgssubstitutionlistwidget.h:89
QgsCharacterSelectorDialog::selectCharacter
QChar selectCharacter(bool *gotChar, const QFont &font, const QString &style, QChar initialSelection=QChar())
Opens the dialog modally and returns when the user has selected a character.
Definition: qgscharacterselectordialog.cpp:32
QgsLogger::warning
static void warning(const QString &msg)
Goes to qWarning.
Definition: qgslogger.cpp:122
QgsPropertyDefinition
Definition for a property.
Definition: qgsproperty.h:47
QgsPalLayerSettings::ScaleVisibility
@ ScaleVisibility
Definition: qgspallabeling.h:451
QgsPalLayerSettings::MaskBufferUnit
@ MaskBufferUnit
Mask buffer size unit.
Definition: qgspallabeling.h:384
QgsFontUtils::fontFamilyMatchOnSystem
static bool fontFamilyMatchOnSystem(const QString &family, QString *chosen=nullptr, bool *match=nullptr)
Check whether font family is on system.
Definition: qgsfontutils.cpp:69
QgsTextBackgroundSettings::rotation
double rotation() const
Returns the rotation for the background shape, in degrees clockwise.
Definition: qgstextbackgroundsettings.cpp:137
QgsStyle::SmartgroupEntity
@ SmartgroupEntity
Smart groups.
Definition: qgsstyle.h:183
QgsTextMaskSettings::opacity
double opacity() const
Returns the mask's opacity.
Definition: qgstextmasksettings.cpp:101
QgsTextFormat::opacity
double opacity() const
Returns the text's opacity.
Definition: qgstextformat.cpp:136
QgsPalLayerSettings::OverrunDistance
@ OverrunDistance
Distance which labels can extend past either end of linear features.
Definition: qgspallabeling.h:446
QgsTextFormatWidget::setFormatFromStyle
virtual void setFormatFromStyle(const QString &name, QgsStyle::StyleEntity type)
Sets the current text settings from a style entry.
Definition: qgstextformatwidget.cpp:1768
QgsUnitSelectionWidget::changed
void changed()
QgsTextShadowSettings::setShadowPlacement
void setShadowPlacement(QgsTextShadowSettings::ShadowPlacement placement)
Sets the placement for the drop shadow.
Definition: qgstextshadowsettings.cpp:61
QgsTextShadowSettings::offsetGlobal
bool offsetGlobal() const
Returns true if the global shadow offset will be used.
Definition: qgstextshadowsettings.cpp:106
QgsScaleWidget
Definition: qgsscalewidget.h:34
QgsPalLayerSettings::DirSymbLeft
@ DirSymbLeft
Definition: qgspallabeling.h:363
QgsPalLayerSettings::ShapeDraw
@ ShapeDraw
Definition: qgspallabeling.h:389
QgsPalLayerSettings::ShowDefined
@ ShowDefined
Show upside down when rotation is layer- or data-defined.
Definition: qgspallabeling.h:298
QgsPalLayerSettings::AutoWrapLength
@ AutoWrapLength
Definition: qgspallabeling.h:358
QgsOpacityWidget
A widget for setting an opacity value.
Definition: qgsopacitywidget.h:32
QgsMapSettings::scale
double scale() const
Returns the calculated map scale.
Definition: qgsmapsettings.cpp:395
QgsTextMaskSettings::sizeMapUnitScale
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
Definition: qgstextmasksettings.cpp:81
QgsSymbolWidgetContext::expressionContext
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
Definition: qgssymbolwidgetcontext.cpp:77
QgsPalLayerSettings::propertyDefinitions
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the labeling property definitions.
Definition: qgspallabeling.cpp:579
QgsSettings::setValue
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Definition: qgssettings.cpp:289
QgsTextBackgroundSettings::radiiMapUnitScale
QgsMapUnitScale radiiMapUnitScale() const
Returns the map unit scale object for the shape radii.
Definition: qgstextbackgroundsettings.cpp:197
QgsTextShadowSettings::setScale
void setScale(int scale)
Sets the scaling used for the drop shadow (in percentage of original size).
Definition: qgstextshadowsettings.cpp:171
QgsTextFormatWidget
Definition: qgstextformatwidget.h:50
QgsPalLayerSettings::FontCase
@ FontCase
Label text case.
Definition: qgspallabeling.h:351
QgsPalLayerSettings::ShapeOffset
@ ShapeOffset
Definition: qgspallabeling.h:398
QgsTextShadowSettings::setOffsetGlobal
void setOffsetGlobal(bool global)
Sets whether the global shadow offset should be used.
Definition: qgstextshadowsettings.cpp:111
QgsTextFormat::setOrientation
void setOrientation(TextOrientation orientation)
Sets the orientation for the text.
Definition: qgstextformat.cpp:171
qgseffectstack.h
QgsTextBackgroundSettings::setSizeUnit
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the shape's size.
Definition: qgstextbackgroundsettings.cpp:112
QgsTextBufferSettings
Definition: qgstextbuffersettings.h:42
QgsPalLayerSettings::MaskJoinStyle
@ MaskJoinStyle
Mask join style.
Definition: qgspallabeling.h:386
QgsPalLayerSettings::BufferDraw
@ BufferDraw
Definition: qgspallabeling.h:372
QgsPalLayerSettings::ShadowColor
@ ShadowColor
Definition: qgspallabeling.h:422
QgsTextBufferSettings::sizeUnit
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
Definition: qgstextbuffersettings.cpp:67
QgsStringReplacementCollection
A collection of string replacements (specified using QgsStringReplacement objects).
Definition: qgsstringutils.h:115
QgsPalLayerSettings::ShapeRadiiUnits
@ ShapeRadiiUnits
Definition: qgspallabeling.h:401
QgsTextFormatWidget::populateDataDefinedButtons
void populateDataDefinedButtons()
Sets up connections required for data defined buttons, or updates the existing definition of these bu...
Definition: qgstextformatwidget.cpp:670
QgsPalLayerSettings::ShapeSizeUnits
@ ShapeSizeUnits
Definition: qgspallabeling.h:395
QgsPanelWidget::setPanelTitle
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
Definition: qgspanelwidget.h:44
QgsPropertyOverrideButton::init
void init(int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer=nullptr, bool auxiliaryStorageEnabled=false)
Initialize a newly constructed property button (useful if button was included in a UI layout).
Definition: qgspropertyoverridebutton.cpp:96
QgsPalLayerSettings::NumDecimals
@ NumDecimals
Definition: qgspallabeling.h:368
QgsTextBackgroundSettings::type
ShapeType type() const
Returns the type of background shape (e.g., square, ellipse, SVG).
Definition: qgstextbackgroundsettings.cpp:57
QgsTextShadowSettings::setOffsetUnit
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's offset.
Definition: qgstextshadowsettings.cpp:91
QgsTextBackgroundSettings::svgFile
QString svgFile() const
Returns the absolute path to the background SVG file, if set.
Definition: qgstextbackgroundsettings.cpp:67
QgsTextFormatPanelWidget::format
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
Definition: qgstextformatwidget.cpp:2050
QgsTextShadowSettings::ShadowShape
@ ShadowShape
Draw shadow under background shape.
Definition: qgstextshadowsettings.h:49
QgsTextBackgroundSettings::setFillColor
void setFillColor(const QColor &color)
Sets the color used for filing the background shape.
Definition: qgstextbackgroundsettings.cpp:232
QgsTextFormat::setNamedStyle
void setNamedStyle(const QString &style)
Sets the named style for the font used for rendering text.
Definition: qgstextformat.cpp:90
QgsApplication::svgCache
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
Definition: qgsapplication.cpp:2129
QgsPalLayerSettings::Horizontal
@ Horizontal
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
Definition: qgspallabeling.h:226
QgsTextBufferSettings::size
double size() const
Returns the size of the buffer.
Definition: qgstextbuffersettings.cpp:57
QgsUnitTypes::RenderPixels
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:170
QgsTextShadowSettings::offsetAngle
int offsetAngle() const
Returns the angle for offsetting the position of the shadow from the text.
Definition: qgstextshadowsettings.cpp:66
QgsTextMaskSettings::maskedSymbolLayers
QgsSymbolLayerReferenceList maskedSymbolLayers() const
Returns a list of references to symbol layers that are masked by this buffer.
Definition: qgstextmasksettings.cpp:207
QgsTextBackgroundSettings::ShapeEllipse
@ ShapeEllipse
Ellipse.
Definition: qgstextbackgroundsettings.h:56
QgsTextFormatWidget::setContext
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
Definition: qgstextformatwidget.cpp:1157
QgsExpressionContext::appendScope
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Definition: qgsexpressioncontext.cpp:490
QgsPalLayerSettings::ShapeStrokeWidth
@ ShapeStrokeWidth
Definition: qgspallabeling.h:407
qgsvectorlayer.h
QgsPalLayerSettings::QuadrantBelowRight
@ QuadrantBelowRight
Definition: qgspallabeling.h:292
QgsPalLayerSettings::QuadrantBelow
@ QuadrantBelow
Definition: qgspallabeling.h:291
QgsTextFormat::size
double size() const
Returns the size for rendered text.
Definition: qgstextformat.cpp:116
QgsPalLayerSettings::CentroidWhole
@ CentroidWhole
Definition: qgspallabeling.h:426
QgsTextFormat::setSizeMapUnitScale
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the size.
Definition: qgstextformat.cpp:111
QgsPalLayerSettings::ShadowScale
@ ShadowScale
Definition: qgspallabeling.h:421
QgsCodeEditorExpression
Definition: qgscodeeditorexpression.h:36
QgsTextFormat::setAllowHtmlFormatting
void setAllowHtmlFormatting(bool allow)
Sets whether text should be treated as a HTML document and HTML tags should be used for formatting th...
Definition: qgstextformat.cpp:181
QgsPalLayerSettings::PositionX
@ PositionX
X-coordinate data defined label position.
Definition: qgspallabeling.h:435
QgsTextFormatWidget::mLayer
QgsVectorLayer * mLayer
Associated vector layer.
Definition: qgstextformatwidget.h:191
QgsPropertyCollection
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition: qgspropertycollection.h:318
QgsTextBackgroundSettings::setRadii
void setRadii(QSizeF radii)
Sets the radii used for rounding the corners of shapes.
Definition: qgstextbackgroundsettings.cpp:182
QgsTextShadowSettings::setBlurRadiusUnit
void setBlurRadiusUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's blur radius.
Definition: qgstextshadowsettings.cpp:131
QgsPalLayerSettings::Size
@ Size
Label size.
Definition: qgspallabeling.h:340
QgsTextFormatWidget::mSubstitutions
QgsStringReplacementCollection mSubstitutions
Text substitution list.
Definition: qgstextformatwidget.h:165
QgsPalLayerSettings::ShadowOffsetAngle
@ ShadowOffsetAngle
Definition: qgspallabeling.h:414
QgsCharacterSelectorDialog
Definition: qgscharacterselectordialog.h:34
QgsTextShadowSettings
Definition: qgstextshadowsettings.h:37
QgsTextBufferSettings::enabled
bool enabled() const
Returns whether the buffer is enabled.
Definition: qgstextbuffersettings.cpp:47
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:141
QgsTextFormat::setBuffer
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
Definition: qgstextformat.h:79
QgsPalLayerSettings::ShadowOffsetDist
@ ShadowOffsetDist
Definition: qgspallabeling.h:415
QgsTextBackgroundSettings::setType
void setType(ShapeType type)
Sets the type of background shape to draw (e.g., square, ellipse, SVG).
Definition: qgstextbackgroundsettings.cpp:62
QgsStyle::textFormatNames
QStringList textFormatNames() const
Returns a list of names of text formats in the style.
Definition: qgsstyle.cpp:1905
QgsPalLayerSettings::ShapeSizeX
@ ShapeSizeX
Definition: qgspallabeling.h:393
QgsGui::instance
static QgsGui * instance()
Returns a pointer to the singleton instance.
Definition: qgsgui.cpp:62
QgsTextShadowSettings::setBlurAlphaOnly
void setBlurAlphaOnly(bool alphaOnly)
Sets whether only the alpha channel for the shadow should be blurred.
Definition: qgstextshadowsettings.cpp:151
QgsPalLayerSettings::Italic
@ Italic
Use italic style.
Definition: qgspallabeling.h:342
QgsTextFormat::dataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the format's property collection, used for data defined overrides.
Definition: qgstextformat.cpp:569
QgsTextFormat::setDataDefinedProperties
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the format's property collection, used for data defined overrides.
Definition: qgstextformat.cpp:589
QgsTextFormat::RotationBasedOrientation
@ RotationBasedOrientation
Horizontally or vertically oriented text based on rotation (only available for map labeling)
Definition: qgstextformat.h:47
QgsTextFormat::setShadow
void setShadow(const QgsTextShadowSettings &shadowSettings)
Sets the text's drop shadow settings.
Definition: qgstextformat.h:117
QgsTextBackgroundSettings::ShapeSVG
@ ShapeSVG
SVG file.
Definition: qgstextbackgroundsettings.h:58
QgsPalLayerSettings::ShapeRotation
@ ShapeRotation
Definition: qgspallabeling.h:397
QgsPalLayerSettings::ShapeRotationType
@ ShapeRotationType
Definition: qgspallabeling.h:396
QgsTextMaskSettings::setMaskedSymbolLayers
void setMaskedSymbolLayers(QgsSymbolLayerReferenceList maskedLayers)
Sets the symbol layers that will be masked by this buffer.
Definition: qgstextmasksettings.cpp:212
QgsStyle
Definition: qgsstyle.h:159
QgsTextFormatDialog::format
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
Definition: qgstextformatwidget.cpp:2023
QgsStyle::TextFormatEntity
@ TextFormatEntity
Text formats.
Definition: qgsstyle.h:184
QgsPalLayerSettings::ShapeStrokeWidthUnits
@ ShapeStrokeWidthUnits
Definition: qgspallabeling.h:408
QgsPalLayerSettings::AlwaysShow
@ AlwaysShow
Definition: qgspallabeling.h:466
QgsPalLayerSettings::ShapeStrokeColor
@ ShapeStrokeColor
Definition: qgspallabeling.h:406
QgsTextFormat::setLineHeight
void setLineHeight(double height)
Sets the line height for text.
Definition: qgstextformat.cpp:161
QgsHelp::openHelp
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Definition: qgshelp.cpp:36
QgsTextFormatWidget::widgetChanged
void widgetChanged()
Emitted when the text format defined by the widget changes.
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsPropertyOverrideButton::registerExpressionContextGenerator
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
Definition: qgspropertyoverridebutton.cpp:954
QgsPalLayerSettings::Family
@ Family
Font family.
Definition: qgspallabeling.h:346
QgsTextMaskSettings::setEnabled
void setEnabled(bool)
Returns whether the mask is enabled.
Definition: qgstextmasksettings.cpp:45
QgsTextFormatWidget::saveFormat
virtual void saveFormat()
Saves the current text settings to a style entry.
Definition: qgstextformatwidget.cpp:1801
QgsPalLayerSettings::OutsidePolygons
@ OutsidePolygons
Candidates are placed outside of polygon boundaries. Applies to polygon layers only....
Definition: qgspallabeling.h:230
QgsSymbolLayerUtils::svgSymbolNameToPath
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
Definition: qgssymbollayerutils.cpp:3879
QgsPalLayerSettings::QuadrantRight
@ QuadrantRight
Definition: qgspallabeling.h:289
QgsTextBufferSettings::paintEffect
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the buffer.
Definition: qgstextbuffersettings.cpp:137
QgsTextFormat::setOpacity
void setOpacity(double opacity)
Sets the text's opacity.
Definition: qgstextformat.cpp:141
QgsTextBufferSettings::setBlendMode
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the buffer.
Definition: qgstextbuffersettings.cpp:132
QgsTextFormat::setMask
void setMask(const QgsTextMaskSettings &maskSettings)
Sets the text's masking settings.
Definition: qgstextformat.h:140
QgsTextShadowSettings::ShadowText
@ ShadowText
Draw shadow under text.
Definition: qgstextshadowsettings.h:47
QgsSubstitutionListWidget::setSubstitutions
void setSubstitutions(const QgsStringReplacementCollection &substitutions)
Sets the list of substitutions to show in the widget.
Definition: qgssubstitutionlistwidget.cpp:42
qgssettings.h
QgsPalLayerSettings::FontStyle
@ FontStyle
Font style name.
Definition: qgspallabeling.h:347
QgsTextBufferSettings::setSize
void setSize(double size)
Sets the size of the buffer.
Definition: qgstextbuffersettings.cpp:62
QgsTextBackgroundSettings::ShapeType
ShapeType
Background shape types.
Definition: qgstextbackgroundsettings.h:52
QgsColorButton
Definition: qgscolorbutton.h:35
QgsUnitTypes::RenderMetersInMapUnits
@ RenderMetersInMapUnits
Meters value as Map units.
Definition: qgsunittypes.h:175
QgsCollapsibleGroupBoxBasic::collapsedStateChanged
void collapsedStateChanged(bool collapsed)
Signal emitted when groupbox collapsed/expanded state is changed, and when first shown.
QgsTextFormatWidget::enableDataDefinedAlignment
void enableDataDefinedAlignment(bool enable)
Controls whether data defined alignment buttons are enabled.
Definition: qgstextformatwidget.cpp:1969
QgsPalLayerSettings::ShadowOpacity
@ ShadowOpacity
Shadow opacity.
Definition: qgspallabeling.h:420
QgsTextBackgroundSettings::setSvgFile
void setSvgFile(const QString &file)
Sets the path to the background SVG file.
Definition: qgstextbackgroundsettings.cpp:72
QgsTextMaskSettings::paintEffect
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the mask.
Definition: qgstextmasksettings.cpp:111
QgsTextFormatWidget::setDockMode
void setDockMode(bool enabled)
Sets whether the widget should be shown in a compact dock mode.
Definition: qgstextformatwidget.cpp:580
QgsAuxiliaryLayer::nameFromProperty
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
Definition: qgsauxiliarystorage.cpp:366
QgsTextMaskSettings::sizeUnit
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
Definition: qgstextmasksettings.cpp:71
QgsTextFormatWidget::context
QgsSymbolWidgetContext context() const
Returns the context in which the widget is shown, e.g., the associated map canvas and expression cont...
Definition: qgstextformatwidget.cpp:1131
QgsPalLayerSettings::ShapeRadii
@ ShapeRadii
Definition: qgspallabeling.h:400
QgsScaleWidget::scaleChanged
void scaleChanged(double scale)
Emitted when user has finished editing/selecting a new scale.
QgsTextMaskSettings::setOpacity
void setOpacity(double opacity)
Sets the mask's opacity.
Definition: qgstextmasksettings.cpp:106
QgsSymbol::Marker
@ Marker
Marker symbol.
Definition: qgssymbol.h:87
QgsTextBufferSettings::setColor
void setColor(const QColor &color)
Sets the color for the buffer.
Definition: qgstextbuffersettings.cpp:92
QgsExpressionContextUtils::atlasScope
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
Definition: qgsexpressioncontextutils.cpp:570
QgsPalLayerSettings::OffsetQuad
@ OffsetQuad
Definition: qgspallabeling.h:427
QgsTextFormat::font
QFont font() const
Returns the font used for rendering text.
Definition: qgstextformat.cpp:62
QgsPalLayerSettings::QuadrantOver
@ QuadrantOver
Definition: qgspallabeling.h:288
QgsTextFormat::background
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
Definition: qgstextformat.h:85
QgsExpressionContext::setHighlightedVariables
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
Definition: qgsexpressioncontext.cpp:324
QgsPalLayerSettings::LinePlacementOptions
@ LinePlacementOptions
Line placement flags.
Definition: qgspallabeling.h:445
QgsTextFormat::setSizeUnit
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the size of rendered text.
Definition: qgstextformat.cpp:101
QgsTextFormatWidget::setFormat
void setFormat(const QgsTextFormat &format)
Sets the current formatting settings.
Definition: qgstextformatwidget.cpp:1113
QgsTextBufferSettings::setJoinStyle
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
Definition: qgstextbuffersettings.cpp:122
QgsSymbolWidgetContext::messageBar
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
Definition: qgssymbolwidgetcontext.cpp:64
qgssubstitutionlistwidget.h
QgsTextBackgroundSettings::sizeUnit
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units used for the shape's size.
Definition: qgstextbackgroundsettings.cpp:107
QgsPalLayerSettings::ShapeSVGFile
@ ShapeSVGFile
Definition: qgspallabeling.h:391
QgsSettings::contains
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
Definition: qgssettings.cpp:188
QgsTextShadowSettings::opacity
double opacity() const
Returns the shadow's opacity.
Definition: qgstextshadowsettings.cpp:156
QgsPropertyCollection::setProperty
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
Definition: qgspropertycollection.cpp:177
QgsTextBackgroundSettings::setSize
void setSize(QSizeF size)
Sets the size of the background shape.
Definition: qgstextbackgroundsettings.cpp:102
QgsTextShadowSettings::setBlurRadiusMapUnitScale
void setBlurRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow blur radius.
Definition: qgstextshadowsettings.cpp:141
QgsPalLayerSettings::ShadowRadiusUnits
@ ShadowRadiusUnits
Definition: qgspallabeling.h:418
QgsPalLayerSettings::Property
Property
Data definable properties.
Definition: qgspallabeling.h:337
QgsPalLayerSettings::MinimumScale
@ MinimumScale
Minimum map scale (ie most "zoomed out")
Definition: qgspallabeling.h:453
QgsTextBackgroundSettings::setRotation
void setRotation(double rotation)
Sets the rotation for the background shape, in degrees clockwise.
Definition: qgstextbackgroundsettings.cpp:142
QgsPalLayerSettings::Underline
@ Underline
Use underline.
Definition: qgspallabeling.h:343
QgsPanelWidgetWrapper
Wrapper widget for existing widgets which can't have the inheritance tree changed,...
Definition: qgspanelwidget.h:200
qgslogger.h
QgsTextFormatWidget::Text
@ Text
Default mode, show text formatting settings only.
Definition: qgstextformatwidget.h:131
QgsUnitTypes::RenderUnitList
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:239
QgsTextFormat::blendMode
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the text.
Definition: qgstextformat.cpp:146
QgsTextFormatWidget::auxiliaryFieldCreated
void auxiliaryFieldCreated()
Emitted when an auxiliary field is created in the widget.
QgsTextShadowSettings::setBlendMode
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the drop shadow.
Definition: qgstextshadowsettings.cpp:191
QgsTextFormat::setSize
void setSize(double size)
Sets the size for rendered text.
Definition: qgstextformat.cpp:121
QgsPalLayerSettings::QuadrantAboveLeft
@ QuadrantAboveLeft
Definition: qgspallabeling.h:284
QgsAuxiliaryLayer::addAuxiliaryField
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
Definition: qgsauxiliarystorage.cpp:140
QgsTextBackgroundSettings::ShapeMarkerSymbol
@ ShapeMarkerSymbol
Marker symbol.
Definition: qgstextbackgroundsettings.h:59
QgsTextBufferSettings::color
QColor color() const
Returns the color of the buffer.
Definition: qgstextbuffersettings.cpp:87
QgsTextBufferSettings::fillBufferInterior
bool fillBufferInterior() const
Returns whether the interior of the buffer will be filled in.
Definition: qgstextbuffersettings.cpp:97
QgsGuiUtils::scaleIconSize
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
Definition: qgsguiutils.cpp:257
qgssvgselectorwidget.h
QgsTextBackgroundSettings::markerSymbol
QgsMarkerSymbol * markerSymbol() const
Returns the marker symbol to be rendered in the background.
Definition: qgstextbackgroundsettings.cpp:77
QgsPalLayerSettings::SymbolBelow
@ SymbolBelow
Place direction symbols on below label.
Definition: qgspallabeling.h:306
QgsTextShadowSettings::shadowPlacement
QgsTextShadowSettings::ShadowPlacement shadowPlacement() const
Returns the placement for the drop shadow.
Definition: qgstextshadowsettings.cpp:56
QgsPropertyCollection::isActive
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
Definition: qgspropertycollection.cpp:258
QgsStyle::removeTextFormat
bool removeTextFormat(const QString &name)
Removes a text format from the style.
Definition: qgsstyle.cpp:854
QgsPalLayerSettings::FontMinPixel
@ FontMinPixel
Definition: qgspallabeling.h:457
QgsStyle::addTextFormat
bool addTextFormat(const QString &name, const QgsTextFormat &format, bool update=false)
Adds a text format with the specified name to the style.
Definition: qgsstyle.cpp:294
QgsPalLayerSettings::ShapeJoinStyle
@ ShapeJoinStyle
Definition: qgspallabeling.h:409
QgsPalLayerSettings::FontSizeUnit
@ FontSizeUnit
Font size units.
Definition: qgspallabeling.h:348
QgsFieldExpressionWidget
The QgsFieldExpressionWidget class reates a widget to choose fields and edit expressions It contains ...
Definition: qgsfieldexpressionwidget.h:46
QgsTextBackgroundSettings::setOffsetUnit
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's offset.
Definition: qgstextbackgroundsettings.cpp:162
QgsTextFormat::HorizontalOrientation
@ HorizontalOrientation
Vertically oriented text.
Definition: qgstextformat.h:45
QgsPalLayerSettings::ShadowDraw
@ ShadowDraw
Definition: qgspallabeling.h:412
QgsPalLayerSettings::Free
@ Free
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...
Definition: qgspallabeling.h:227
QgsTextBufferSettings::blendMode
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the buffer.
Definition: qgstextbuffersettings.cpp:127
QgsStyle::labelSettings
QgsPalLayerSettings labelSettings(const QString &name) const
Returns the label settings with the specified name.
Definition: qgsstyle.cpp:1915
QgsTextShadowSettings::blurRadiusUnit
QgsUnitTypes::RenderUnit blurRadiusUnit() const
Returns the units used for the shadow's blur radius.
Definition: qgstextshadowsettings.cpp:126
qgshelp.h
QgsTextFormatWidget::mDataDefinedProperties
QgsPropertyCollection mDataDefinedProperties
Data defined properties as defined in the widget.
Definition: qgstextformatwidget.h:188
QgsUnitTypes::RenderMapUnits
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:169
QgsNewAuxiliaryLayerDialog
A dialog to create a new auxiliary layer.
Definition: qgsnewauxiliarylayerdialog.h:34
QgsTextFormat::TextOrientation
TextOrientation
Text orientation.
Definition: qgstextformat.h:43
QgsTextBackgroundSettings::strokeColor
QColor strokeColor() const
Returns the color used for outlining the background shape.
Definition: qgstextbackgroundsettings.cpp:237
qgsproject.h
QgsTextBackgroundSettings::setEnabled
void setEnabled(bool enabled)
Sets whether the text background will be drawn.
Definition: qgstextbackgroundsettings.cpp:52
QgsTextFormat::fontFound
bool fontFound() const
Returns true if the specified font was found on the system, or false if the font was not found and a ...
Definition: qgstextformat.h:416
QgsPalLayerSettings::QuadrantAbove
@ QuadrantAbove
Definition: qgspallabeling.h:285
QgsTextBackgroundSettings::offsetUnit
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the shape's offset.
Definition: qgstextbackgroundsettings.cpp:157
QgsTextFormatWidget::Labeling
@ Labeling
Show labeling settings in addition to text formatting settings.
Definition: qgstextformatwidget.h:132
QgsFontUtils::updateFontViaStyle
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
Definition: qgsfontutils.cpp:122
QgsTextFormatWidget::Mode
Mode
Widget mode.
Definition: qgstextformatwidget.h:129
QgsTextMaskSettings::joinStyle
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
Definition: qgstextmasksettings.cpp:91
QgsTextBackgroundSettings::radii
QSizeF radii() const
Returns the radii used for rounding the corners of shapes.
Definition: qgstextbackgroundsettings.cpp:177
QgsPalLayerSettings::ShowAll
@ ShowAll
Show upside down for all labels, including dynamic ones.
Definition: qgspallabeling.h:299
QgsStyle::StyleEntity
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:178
QgsTextFormatWidget::~QgsTextFormatWidget
~QgsTextFormatWidget() override
Definition: qgstextformatwidget.cpp:999
QgsTextFormatWidget::QgsTextFormatWidget
QgsTextFormatWidget(const QgsTextFormat &format=QgsTextFormat(), QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsVectorLayer *layer=nullptr)
Constructor for QgsTextFormatWidget.
Definition: qgstextformatwidget.cpp:42
QgsPalLayerSettings::IsObstacle
@ IsObstacle
Definition: qgspallabeling.h:459