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