42 #include "qgsconfig.h"
44 #include <QButtonGroup>
45 #include <QMessageBox>
49 , mMapCanvas( mapCanvas )
53 setWidgetMode(
Text );
60 , mMapCanvas( mapCanvas )
67 setWidgetMode( mode );
70 void QgsTextFormatWidget::initWidget()
74 mGeometryGeneratorGroupBox->setCollapsed(
true );
76 connect( mShapeSVGPathLineEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged );
77 connect( mFontSizeSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontSizeSpinBox_valueChanged );
78 connect( mFontFamilyCmbBx, &QFontComboBox::currentFontChanged,
this, &QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged );
79 connect( mFontStyleComboBox, &QComboBox::currentTextChanged,
this, &QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged );
80 connect( mFontUnderlineBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontUnderlineBtn_toggled );
81 connect( mFontStrikethroughBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontStrikethroughBtn_toggled );
82 connect( mFontWordSpacingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged );
83 connect( mFontLetterSpacingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged );
85 connect( mFontMinPixelSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged );
86 connect( mFontMaxPixelSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged );
95 connect( mShapeTypeCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged );
96 connect( mShapeRotationCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged );
97 connect( mShapeSVGParamsBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGParamsBtn_clicked );
98 connect( mShapeSVGSelectorBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked );
99 connect( mPreviewTextEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mPreviewTextEdit_textChanged );
100 connect( mPreviewTextBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mPreviewTextBtn_clicked );
102 connect( mDirectSymbLeftToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked );
103 connect( mDirectSymbRightToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked );
104 connect( chkLineOrientationDependent, &QCheckBox::toggled,
this, &QgsTextFormatWidget::chkLineOrientationDependent_toggled );
105 connect( mToolButtonConfigureSubstitutes, &QToolButton::clicked,
this, &QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked );
106 connect( mKerningCheckBox, &QCheckBox::toggled,
this, &QgsTextFormatWidget::kerningToggled );
116 mPreviewTextBtn->setIconSize( QSize( iconSize16, iconSize16 ) );
117 mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
118 mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
119 mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );
120 mPointOffsetLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
121 mPointOffsetOver ->setIconSize( QSize( iconSize32, iconSize18 ) );
122 mPointOffsetRight->setIconSize( QSize( iconSize32, iconSize18 ) );
123 mPointOffsetBelowLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
124 mPointOffsetBelow->setIconSize( QSize( iconSize32, iconSize18 ) );
125 mPointOffsetBelowRight->setIconSize( QSize( iconSize32, iconSize18 ) );
126 mLabelMinScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomOut.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
127 mLabelMaxScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomIn.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
130 mFontUnderlineBtn->setMinimumSize( buttonSize, buttonSize );
131 mFontUnderlineBtn->setMaximumSize( buttonSize, buttonSize );
132 mFontStrikethroughBtn->setMinimumSize( buttonSize, buttonSize );
133 mFontStrikethroughBtn->setMaximumSize( buttonSize, buttonSize );
134 mFontBoldBtn->setMinimumSize( buttonSize, buttonSize );
135 mFontBoldBtn->setMaximumSize( buttonSize, buttonSize );
136 mFontItalicBtn->setMinimumSize( buttonSize, buttonSize );
137 mFontItalicBtn->setMaximumSize( buttonSize, buttonSize );
139 mPreviewScaleComboBox->setMapCanvas(
mMapCanvas );
140 mPreviewScaleComboBox->setShowCurrentScaleButton(
true );
143 const auto unitWidgets = findChildren<QgsUnitSelectionWidget *>();
175 mFontLineHeightSpinBox->setClearValue( 1.0 );
176 mShapeRotationDblSpnBx->setClearValue( 0.0 );
177 mShapeOffsetXSpnBx->setClearValue( 0.0 );
178 mShapeOffsetYSpnBx->setClearValue( 0.0 );
179 mPointOffsetXSpinBox->setClearValue( 0.0 );
180 mPointOffsetYSpinBox->setClearValue( 0.0 );
181 mPointAngleSpinBox->setClearValue( 0.0 );
182 mFontLetterSpacingSpinBox->setClearValue( 0.0 );
183 mFontWordSpacingSpinBox->setClearValue( 0.0 );
184 mZIndexSpinBox->setClearValue( 0.0 );
185 mLineDistanceSpnBx->setClearValue( 0.0 );
186 mSpinStretch->setClearValue( 100 );
198 updateAvailableShadowPositions();
201 mBackgroundMarkerSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
202 mBackgroundMarkerSymbolButton->registerExpressionContextGenerator(
this );
203 mBackgroundMarkerSymbolButton->setMapCanvas(
mMapCanvas );
205 mBackgroundFillSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
206 mBackgroundFillSymbolButton->registerExpressionContextGenerator(
this );
207 mBackgroundFillSymbolButton->setMapCanvas(
mMapCanvas );
211 mRefFont = lblFontPreview->font();
214 connect( mShadowOffsetAngleDial, &QAbstractSlider::valueChanged, mShadowOffsetAngleSpnBx, &QSpinBox::setValue );
215 connect( mShadowOffsetAngleSpnBx,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mShadowOffsetAngleDial, &QAbstractSlider::setValue );
216 connect( mLimitLabelChkBox, &QAbstractButton::toggled, mLimitLabelSpinBox, &QWidget::setEnabled );
217 connect( mCheckBoxSubstituteText, &QAbstractButton::toggled, mToolButtonConfigureSubstitutes, &QWidget::setEnabled );
227 populateFontCapitalsComboBox();
230 mPreviewBackgroundBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
231 mPreviewBackgroundBtn->setContext( QStringLiteral(
"labeling" ) );
232 mPreviewBackgroundBtn->setColor( QColor( 255, 255, 255 ) );
233 btnTextColor->setColorDialogTitle( tr(
"Select Text Color" ) );
234 btnTextColor->setContext( QStringLiteral(
"labeling" ) );
235 btnTextColor->setDefaultColor( Qt::black );
236 btnBufferColor->setColorDialogTitle( tr(
"Select Buffer Color" ) );
237 btnBufferColor->setContext( QStringLiteral(
"labeling" ) );
238 btnBufferColor->setDefaultColor( Qt::white );
239 mShapeStrokeColorBtn->setColorDialogTitle( tr(
"Select Stroke Color" ) );
240 mShapeStrokeColorBtn->setContext( QStringLiteral(
"labeling" ) );
241 mShapeFillColorBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
242 mShapeFillColorBtn->setContext( QStringLiteral(
"labeling" ) );
243 mShadowColorBtn->setColorDialogTitle( tr(
"Select Shadow Color" ) );
244 mShadowColorBtn->setContext( QStringLiteral(
"labeling" ) );
245 mShadowColorBtn->setDefaultColor( Qt::black );
247 mFontColorDDBtn->registerLinkedWidget( btnTextColor );
248 mBufferColorDDBtn->registerLinkedWidget( btnBufferColor );
249 mShapeStrokeColorDDBtn->registerLinkedWidget( mShapeStrokeColorBtn );
250 mShapeFillColorDDBtn->registerLinkedWidget( mShapeFillColorBtn );
251 mShadowColorDDBtn->registerLinkedWidget( mShadowColorBtn );
292 const auto groupBoxes = findChildren<QgsCollapsibleGroupBox *>();
295 grpbox->setSettingGroup( QStringLiteral(
"mAdvLabelingDlg" ) );
301 mLabelingOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect,
false );
306 QSizePolicy policy( mLabelingOptionsListFrame->sizePolicy() );
307 policy.setHorizontalStretch( 0 );
308 mLabelingOptionsListFrame->setSizePolicy( policy );
309 if ( !settings.
contains( QStringLiteral(
"/Windows/Labeling/OptionsSplitState" ) ) )
312 QList<int> splitsizes;
314 mLabelingOptionsSplitter->setSizes( splitsizes );
318 connect( mLabelStackedWidget, &QStackedWidget::currentChanged,
this, &QgsTextFormatWidget::optionsStackedWidget_CurrentChanged );
321 mFontPreviewSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ) ).toByteArray() );
322 mLabelingOptionsSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ) ).toByteArray() );
324 mLabelingOptionsListWidget->setCurrentRow( settings.
value( QStringLiteral(
"Windows/Labeling/Tab" ), 0 ).toInt() );
328 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
332 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
336 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
338 #ifndef HAS_KDE_QT5_FONT_STRETCH_FIX
339 mLabelStretch->hide();
340 mSpinStretch->hide();
341 mFontStretchDDBtn->hide();
346 QList<QWidget *> widgets;
347 widgets << btnBufferColor
349 << chkLabelPerFeaturePart
353 << chkLineOrientationDependent
355 << chkPreserveRotation
357 << comboBufferBlendMode
359 << mBufferJoinStyleComboBox
360 << mBufferTranspFillChbx
361 << mBufferOpacityWidget
362 << mCentroidInsideCheckBox
364 << mCoordRotationUnitComboBox
366 << mDirectSymbLeftLineEdit
367 << mDirectSymbRevChkBx
368 << mDirectSymbRightLineEdit
369 << mFitInsidePolygonCheckBox
370 << mFontCapitalsComboBox
371 << mFontLetterSpacingSpinBox
372 << mFontLimitPixelChkBox
373 << mFontLineHeightSpinBox
374 << mFontMaxPixelSpinBox
375 << mFontMinPixelSpinBox
376 << mFontMultiLineAlignComboBox
378 << mFontStyleComboBox
379 << mTextOrientationComboBox
380 << mTextOpacityWidget
382 << mFontWordSpacingSpinBox
384 << mFormatNumDecimalsSpnBx
385 << mFormatNumPlusSignChkBx
387 << mLimitLabelSpinBox
388 << mLineDistanceSpnBx
389 << mLineDistanceUnitWidget
390 << mMaxCharAngleInDSpinBox
391 << mMaxCharAngleOutDSpinBox
393 << mOffsetTypeComboBox
394 << mPalShowAllLabelsForLayerChkBx
395 << mPointAngleSpinBox
396 << mPointOffsetUnitWidget
397 << mPointOffsetXSpinBox
398 << mPointOffsetYSpinBox
399 << mPreviewBackgroundBtn
402 << mRepeatDistanceSpinBox
403 << mRepeatDistanceUnitWidget
404 << mOverrunDistanceSpinBox
405 << mOverrunDistanceUnitWidget
406 << mScaleBasedVisibilityChkBx
412 << mShadowOffsetAngleSpnBx
413 << mShadowOffsetGlobalChkBx
414 << mShadowOffsetSpnBx
415 << mShadowOffsetUnitWidget
416 << mShadowRadiusAlphaChkBx
417 << mShadowRadiusDblSpnBx
418 << mShadowRadiusUnitWidget
420 << mShadowOpacityWidget
423 << mShapeStrokeColorBtn
424 << mShapeStrokeWidthSpnBx
425 << mShapeStrokeWidthUnitWidget
427 << mShapeFillColorBtn
428 << mShapeOffsetXSpnBx
429 << mShapeOffsetYSpnBx
430 << mShapeOffsetUnitWidget
431 << mShapeRadiusXDbSpnBx
432 << mShapeRadiusYDbSpnBx
433 << mShapeRotationCmbBx
434 << mShapeRotationDblSpnBx
435 << mShapeRadiusUnitWidget
436 << mShapeSVGPathLineEdit
438 << mShapeSizeUnitWidget
441 << mBackgroundOpacityWidget
446 << mAutoWrapLengthSpinBox
447 << mAutoWrapTypeComboBox
448 << mCentroidRadioVisible
449 << mCentroidRadioWhole
450 << mDirectSymbRadioBtnAbove
451 << mDirectSymbRadioBtnBelow
452 << mDirectSymbRadioBtnLR
453 << mUpsidedownRadioAll
454 << mUpsidedownRadioDefined
455 << mUpsidedownRadioOff
456 << mPlacementModeComboBox
457 << mFieldExpressionWidget
458 << mCheckBoxSubstituteText
459 << mGeometryGeneratorGroupBox
460 << mGeometryGenerator
461 << mGeometryGeneratorType
462 << mBackgroundMarkerSymbolButton
463 << mBackgroundFillSymbolButton
464 << mCalloutsDrawCheckBox
465 << mCalloutStyleComboBox
468 << mMaskJoinStyleComboBox
469 << mMaskBufferSizeSpinBox
470 << mMaskOpacityWidget
471 << mCheckAllowLabelsOutsidePolygons
472 << mHtmlFormattingCheckBox;
479 connect( mBufferDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
481 updateBufferFrameStatus();
484 connect( mShapeDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
486 updateShapeFrameStatus();
489 connect( mShadowDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
491 updateShadowFrameStatus();
494 connect( mCalloutsDrawCheckBox, &QCheckBox::stateChanged,
this, [ = ](
int )
496 updateCalloutFrameStatus();
504 whileBlocking( mOptionsTab )->setCurrentIndex( mLabelStackedWidget->currentIndex() );
505 mOptionsTab->tabBar()->setUsesScrollButtons(
true );
526 toggleDDButtons(
true );
533 const int prevIndex = mOptionsTab->currentIndex();
534 toggleDDButtons(
true );
535 delete mLabelingOptionsListWidget->takeItem( 8 );
536 delete mLabelingOptionsListWidget->takeItem( 7 );
537 delete mLabelingOptionsListWidget->takeItem( 6 );
538 delete mLabelingOptionsListWidget->takeItem( 3 );
539 mOptionsTab->removeTab( 8 );
540 mOptionsTab->removeTab( 7 );
541 mOptionsTab->removeTab( 6 );
542 mOptionsTab->removeTab( 3 );
543 mLabelStackedWidget->removeWidget( mLabelPage_Rendering );
544 mLabelStackedWidget->removeWidget( mLabelPage_Callouts );
545 mLabelStackedWidget->removeWidget( mLabelPage_Mask );
546 mLabelStackedWidget->removeWidget( mLabelPage_Placement );
556 mLabelStackedWidget->setCurrentIndex( prevIndex - 1 );
557 mOptionsTab->setCurrentIndex( prevIndex - 1 );
564 mLabelStackedWidget->setCurrentIndex( 0 );
565 mOptionsTab->setCurrentIndex( 0 );
569 frameLabelWith->hide();
570 mDirectSymbolsFrame->hide();
571 mFormatNumFrame->hide();
572 mFormatNumChkBx->hide();
573 mFormatNumDDBtn->hide();
574 mCheckBoxSubstituteText->hide();
575 mToolButtonConfigureSubstitutes->hide();
576 mLabelWrapOnCharacter->hide();
577 wrapCharacterEdit->hide();
578 mWrapCharDDBtn->hide();
579 mLabelWrapLinesTo->hide();
580 mAutoWrapLengthSpinBox->hide();
581 mAutoWrapLengthDDBtn->hide();
582 mAutoWrapTypeComboBox->hide();
583 mFontMultiLineLabel->hide();
584 mFontMultiLineAlignComboBox->hide();
585 mFontMultiLineAlignDDBtn->hide();
593 void QgsTextFormatWidget::toggleDDButtons(
bool visible )
595 const auto buttons = findChildren< QgsPropertyOverrideButton * >();
598 #ifndef HAS_KDE_QT5_FONT_STRETCH_FIX
599 if ( button == mFontStretchDDBtn )
602 button->setVisible( visible );
608 mOptionsTab->setVisible( enabled );
609 mOptionsTab->setTabToolTip( 0, tr(
"Text" ) );
610 mOptionsTab->setTabToolTip( 1, tr(
"Formatting" ) );
611 mOptionsTab->setTabToolTip( 2, tr(
"Buffer" ) );
612 mOptionsTab->setTabToolTip( 3, tr(
"Mask" ) );
613 mOptionsTab->setTabToolTip( 4, tr(
"Background" ) );
614 mOptionsTab->setTabToolTip( 5, tr(
"Shadow" ) );
615 mOptionsTab->setTabToolTip( 6, tr(
"Callouts" ) );
616 mOptionsTab->setTabToolTip( 7, tr(
"Placement" ) );
617 mOptionsTab->setTabToolTip( 8, tr(
"Rendering" ) );
619 mLabelingOptionsListFrame->setVisible( !enabled );
620 groupBox_mPreview->setVisible( !enabled );
624 void QgsTextFormatWidget::connectValueChanged(
const QList<QWidget *> &widgets,
const char *slot )
626 const auto constWidgets = widgets;
627 for ( QWidget *widget : constWidgets )
631 connect( w, SIGNAL( changed() ),
this, slot );
635 connect( w, SIGNAL( fieldChanged( QString ) ),
this, slot );
637 else if (
QgsOpacityWidget *w = qobject_cast< QgsOpacityWidget *>( widget ) )
639 connect( w, SIGNAL( opacityChanged(
double ) ),
this, slot );
641 else if (
QgsScaleWidget *w = qobject_cast< QgsScaleWidget *>( widget ) )
643 connect( w, SIGNAL( scaleChanged(
double ) ),
this, slot );
647 connect( w, SIGNAL( changed() ),
this, slot );
649 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
651 connect( w, SIGNAL( currentIndexChanged(
int ) ),
this, slot );
653 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
655 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
657 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
659 connect( w, SIGNAL( valueChanged(
double ) ),
this, slot );
661 else if (
QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
663 connect( w, SIGNAL( colorChanged( QColor ) ),
this, slot );
665 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
667 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
669 else if ( QRadioButton *w = qobject_cast<QRadioButton *>( widget ) )
671 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
673 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
675 connect( w, SIGNAL( textEdited( QString ) ),
this, slot );
677 else if ( QSlider *w = qobject_cast<QSlider *>( widget ) )
679 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
681 else if ( QGroupBox *w = qobject_cast<QGroupBox *>( widget ) )
683 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
687 connect( w, SIGNAL( textChanged() ),
this, slot );
691 QgsLogger::warning( QStringLiteral(
"Could not create connection for widget %1" ).arg( widget->objectName() ) );
723 mDirectSymbDDBtn->registerCheckedWidget( mDirectSymbChkBx );
731 mFormatNumDDBtn->registerCheckedWidget( mFormatNumChkBx );
746 mEnableMaskDDBtn->registerCheckedWidget( mEnableMaskChkBx );
754 mShapeDrawDDBtn->registerCheckedWidget( mShapeDrawChkBx );
776 mShadowDrawDDBtn->registerCheckedWidget( mShadowDrawChkBx );
816 updateDataDefinedAlignment();
819 const QString ddScaleVisInfo = tr(
"Value < 0 represents a scale closer than 1:1, e.g. -10 = 10:1<br>"
820 "Value of 0 disables the specific limit." );
822 mScaleBasedVisibilityDDBtn->registerCheckedWidget( mScaleBasedVisibilityChkBx );
824 mScaleBasedVisibilityMinDDBtn->setUsageInfo( ddScaleVisInfo );
826 mScaleBasedVisibilityMaxDDBtn->setUsageInfo( ddScaleVisInfo );
829 mFontLimitPixelDDBtn->registerCheckedWidget( mFontLimitPixelChkBox );
848 if ( !mButtons.contains( key ) )
853 mButtons[key] = button;
870 mBufferDrawChkBx->setChecked( buffer.
enabled() );
871 mBufferFrame->setEnabled( buffer.
enabled() );
872 spinBufferSize->setValue( buffer.
size() );
873 mBufferUnitWidget->setUnit( buffer.
sizeUnit() );
875 btnBufferColor->setColor( buffer.
color() );
876 mBufferOpacityWidget->setOpacity( buffer.
opacity() );
877 mBufferJoinStyleComboBox->setPenJoinStyle( buffer.
joinStyle() );
879 comboBufferBlendMode->setBlendMode( buffer.
blendMode() );
881 mBufferEffect.reset( lPaintEffect->clone() );
885 mBufferEffect->setEnabled(
false );
887 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
891 mEnableMaskChkBx->setChecked( mask.
enabled() );
892 mMaskBufferSizeSpinBox->setValue( mask.
size() );
893 mMaskBufferUnitWidget->setUnit( mask.
sizeUnit() );
895 mMaskOpacityWidget->setOpacity( mask.
opacity() );
896 mMaskJoinStyleComboBox->setPenJoinStyle( mask.
joinStyle() );
898 mMaskEffect.reset( lPaintEffect->clone() );
902 mMaskEffect->setEnabled(
false );
904 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
914 mTextOrientationComboBox->setCurrentIndex( mTextOrientationComboBox->findData(
format.
orientation() ) );
917 mFontWordSpacingSpinBox->setValue(
format.
font().wordSpacing() );
918 mFontLetterSpacingSpinBox->setValue(
format.
font().letterSpacing() );
923 updateFont( mRefFont );
929 const QString missingTxt = tr(
"%1 not found. Default substituted." );
930 QString txtPrepend = tr(
"Chosen font" );
935 mFontMissingLabel->setText( missingTxt.arg( txtPrepend ) );
938 mLabelingOptionsListWidget->setCurrentRow( 0 );
944 mShapeDrawChkBx->setChecked( background.
enabled() );
945 mShapeFrame->setEnabled( background.
enabled() );
946 mShapeTypeCmbBx->blockSignals(
true );
947 mShapeTypeCmbBx->setCurrentIndex( mShapeTypeCmbBx->findData( background.
type() ) );
948 mShapeTypeCmbBx->blockSignals(
false );
949 updateAvailableShadowPositions();
950 mShapeSVGPathLineEdit->setText( background.
svgFile() );
952 mShapeSizeCmbBx->setCurrentIndex( background.
sizeType() );
953 mShapeSizeXSpnBx->setValue( background.
size().width() );
954 mShapeSizeYSpnBx->setValue( background.
size().height() );
955 mShapeSizeUnitWidget->setUnit( background.
sizeUnit() );
957 mShapeRotationCmbBx->setCurrentIndex( background.
rotationType() );
960 mShapeRotationDblSpnBx->setValue( background.
rotation() );
961 mShapeOffsetXSpnBx->setValue( background.
offset().x() );
962 mShapeOffsetYSpnBx->setValue( background.
offset().y() );
963 mShapeOffsetUnitWidget->setUnit( background.
offsetUnit() );
965 mShapeRadiusXDbSpnBx->setValue( background.
radii().width() );
966 mShapeRadiusYDbSpnBx->setValue( background.
radii().height() );
967 mShapeRadiusUnitWidget->setUnit( background.
radiiUnit() );
970 mShapeFillColorBtn->setColor( background.
fillColor() );
971 mShapeStrokeColorBtn->setColor( background.
strokeColor() );
972 mShapeStrokeWidthSpnBx->setValue( background.
strokeWidth() );
976 mBackgroundOpacityWidget->setOpacity( background.
opacity() );
977 mShapeBlendCmbBx->setBlendMode( background.
blendMode() );
979 mLoadSvgParams =
false;
980 mShapeTypeCmbBx_currentIndexChanged( background.
type() );
982 if (
auto *lPaintEffect = background.
paintEffect() )
983 mBackgroundEffect.reset( lPaintEffect->clone() );
987 mBackgroundEffect->setEnabled(
false );
989 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
995 mShadowDrawChkBx->setChecked( shadow.
enabled() );
996 mShadowFrame->setEnabled( shadow.
enabled() );
997 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( shadow.
shadowPlacement() ) );
998 mShadowOffsetAngleSpnBx->setValue( shadow.
offsetAngle() );
1000 mShadowOffsetUnitWidget->setUnit( shadow.
offsetUnit() );
1002 mShadowOffsetGlobalChkBx->setChecked( shadow.
offsetGlobal() );
1004 mShadowRadiusDblSpnBx->setValue( shadow.
blurRadius() );
1007 mShadowRadiusAlphaChkBx->setChecked( shadow.
blurAlphaOnly() );
1008 mShadowOpacityWidget->setOpacity( shadow.
opacity() );
1009 mShadowScaleSpnBx->setValue( shadow.
scale() );
1011 mShadowColorBtn->setColor( shadow.
color() );
1012 mShadowBlendCmbBx->setBlendMode( shadow.
blendMode() );
1024 settings.
setValue( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ), mFontPreviewSplitter->saveState() );
1025 settings.
setValue( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ), mLabelingOptionsSplitter->saveState() );
1027 int prevIndex = mLabelingOptionsListWidget->currentRow();
1028 if ( mWidgetMode ==
Text )
1030 switch ( prevIndex )
1039 settings.
setValue( QStringLiteral(
"Windows/Labeling/Tab" ), prevIndex );
1062 buffer.
setEnabled( mBufferDrawChkBx->isChecked() );
1063 buffer.
setSize( spinBufferSize->value() );
1064 buffer.
setColor( btnBufferColor->color() );
1065 buffer.
setOpacity( mBufferOpacityWidget->opacity() );
1068 buffer.
setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
1070 buffer.
setBlendMode( comboBufferBlendMode->blendMode() );
1079 mask.
setEnabled( mEnableMaskChkBx->isChecked() );
1080 mask.
setSize( mMaskBufferSizeSpinBox->value() );
1081 mask.
setOpacity( mMaskOpacityWidget->opacity() );
1082 mask.
setSizeUnit( mMaskBufferUnitWidget->unit() );
1084 mask.
setJoinStyle( mMaskJoinStyleComboBox->penJoinStyle() );
1094 background.
setEnabled( mShapeDrawChkBx->isChecked() );
1096 background.
setSvgFile( mShapeSVGPathLineEdit->text() );
1098 background.
setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
1099 background.
setSizeUnit( mShapeSizeUnitWidget->unit() );
1102 background.
setRotation( mShapeRotationDblSpnBx->value() );
1103 background.
setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
1106 background.
setRadii( QSizeF( mShapeRadiusXDbSpnBx->value(), mShapeRadiusYDbSpnBx->value() ) );
1107 background.
setRadiiUnit( mShapeRadiusUnitWidget->unit() );
1110 background.
setFillColor( mShapeFillColorBtn->color() );
1115 background.
setOpacity( mBackgroundOpacityWidget->opacity() );
1116 background.
setBlendMode( mShapeBlendCmbBx->blendMode() );
1127 shadow.
setEnabled( mShadowDrawChkBx->isChecked() );
1138 shadow.
setOpacity( mShadowOpacityWidget->opacity() );
1139 shadow.
setScale( mShadowScaleSpnBx->value() );
1140 shadow.
setColor( mShadowColorBtn->color() );
1144 if ( includeDataDefinedProperties )
1175 if ( mButtons.contains( key ) )
1184 void QgsTextFormatWidget::optionsStackedWidget_CurrentChanged(
int indx )
1186 mLabelingOptionsListWidget->blockSignals(
true );
1187 mLabelingOptionsListWidget->setCurrentRow( indx );
1188 mLabelingOptionsListWidget->blockSignals(
false );
1197 mPreviewExpressionContext = *lExpressionContext;
1202 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
1210 void QgsTextFormatWidget::collapseSample(
bool collapse )
1214 QList<int> splitSizes = mFontPreviewSplitter->sizes();
1215 if ( splitSizes[0] > groupBox_mPreview->height() )
1217 const int delta = splitSizes[0] - groupBox_mPreview->height();
1218 splitSizes[0] -= delta;
1219 splitSizes[1] += delta;
1220 mFontPreviewSplitter->setSizes( splitSizes );
1225 void QgsTextFormatWidget::changeTextColor(
const QColor &color )
1231 void QgsTextFormatWidget::updateFont(
const QFont &font )
1234 if ( font != mRefFont )
1243 mDirectSymbLeftLineEdit->setFont( mRefFont );
1244 mDirectSymbRightLineEdit->setFont( mRefFont );
1246 blockFontChangeSignals(
true );
1247 mFontFamilyCmbBx->setCurrentFont( mRefFont );
1248 populateFontStyleComboBox();
1249 mFontUnderlineBtn->setChecked( mRefFont.underline() );
1250 mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
1251 mKerningCheckBox->setChecked( mRefFont.kerning() );
1252 blockFontChangeSignals(
false );
1260 void QgsTextFormatWidget::blockFontChangeSignals(
bool blk )
1262 mFontFamilyCmbBx->blockSignals( blk );
1263 mFontStyleComboBox->blockSignals( blk );
1264 mFontCapitalsComboBox->blockSignals( blk );
1265 mFontUnderlineBtn->blockSignals( blk );
1266 mFontStrikethroughBtn->blockSignals( blk );
1267 mFontWordSpacingSpinBox->blockSignals( blk );
1268 mFontLetterSpacingSpinBox->blockSignals( blk );
1269 mKerningCheckBox->blockSignals( blk );
1284 lblFontPreview->setFormat(
format() );
1287 void QgsTextFormatWidget::scrollPreview()
1289 scrollArea_mPreview->ensureVisible( 0, 0, 0, 0 );
1294 mPreviewBackgroundColor = color;
1296 scrollArea_mPreview->widget()->setStyleSheet( QStringLiteral(
"background: rgb(%1, %2, %3);" ).arg( QString::number( color.red() ),
1297 QString::number( color.green() ),
1298 QString::number( color.blue() ) ) );
1301 void QgsTextFormatWidget::changeBufferColor(
const QColor &color )
1310 bool showLineFrame =
false;
1311 bool showCentroidFrame =
false;
1312 bool showQuadrantFrame =
false;
1313 bool showFixedQuadrantFrame =
false;
1314 bool showPlacementPriorityFrame =
false;
1315 bool showOffsetTypeFrame =
false;
1316 bool showOffsetFrame =
false;
1317 bool showDistanceFrame =
false;
1318 bool showRotationFrame =
false;
1319 bool showMaxCharAngleFrame =
false;
1324 bool enableMultiLinesFrame =
true;
1330 showDistanceFrame =
true;
1338 showQuadrantFrame =
true;
1339 showFixedQuadrantFrame =
true;
1340 showOffsetFrame =
true;
1341 showRotationFrame =
true;
1345 showDistanceFrame =
true;
1346 showPlacementPriorityFrame =
true;
1347 showOffsetTypeFrame =
true;
1354 showLineFrame =
true;
1355 showDistanceFrame =
true;
1358 const bool offline = chkLineAbove->isChecked() || chkLineBelow->isChecked();
1359 chkLineOrientationDependent->setEnabled( offline );
1360 mPlacementDistanceFrame->setEnabled( offline );
1364 showMaxCharAngleFrame = isCurved;
1366 enableMultiLinesFrame = !isCurved;
1371 showDistanceFrame =
true;
1374 mPlacementLineFrame->setVisible( showLineFrame );
1375 mPlacementPolygonFrame->setVisible( showPolygonPlacementOptions );
1376 mPlacementCentroidFrame->setVisible( showCentroidFrame );
1377 mPlacementQuadrantFrame->setVisible( showQuadrantFrame );
1378 mPlacementFixedQuadrantFrame->setVisible( showFixedQuadrantFrame );
1379 mPlacementCartographicFrame->setVisible( showPlacementPriorityFrame );
1380 mPlacementOffsetFrame->setVisible( showOffsetFrame );
1381 mPlacementDistanceFrame->setVisible( showDistanceFrame );
1382 mPlacementOffsetTypeFrame->setVisible( showOffsetTypeFrame );
1383 mPlacementRotationFrame->setVisible( showRotationFrame );
1388 mPlacementMaxCharAngleFrame->setVisible( showMaxCharAngleFrame );
1390 mMultiLinesFrame->setEnabled( enableMultiLinesFrame );
1394 switch ( currentPlacement )
1398 helperText = tr(
"Arranges label candidates in a clockwise circle around the feature, preferring placements to the top-right of the feature." );
1400 helperText = tr(
"Arranges label candidates in a cluster around the feature's centroid, preferring placements directly over the centroid." );
1404 helperText = tr(
"Arranges label candidates directly over the feature or at a preset offset from the feature." );
1406 helperText = tr(
"Arranges label candidates directly over the feature's centroid, or at a preset offset from the centroid." );
1410 helperText = tr(
"Arranges label candidates parallel to a generalised line representing the feature. Placements which fall over straighter portions of the line are preferred." );
1412 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." );
1416 helperText = tr(
"Arranges candidates following the curvature of a line feature. Placements which fall over straighter portions of the line are preferred." );
1420 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." );
1422 helperText = tr(
"Label candidates are arranged horizontally along the length of the feature." );
1426 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." );
1430 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." );
1434 helperText = tr(
"Arranges candidates following the curvature of the feature's perimeter. Placements which fall over straighter portions of the perimeter are preferred." );
1438 helperText = tr(
"Label candidates are placed outside of the features, preferring placements which give greatest visual association between the label and the feature." );
1441 mPlacementModeDescriptionLabel->setText( QStringLiteral(
"<i>%1</i>" ).arg( helperText ) );
1444 void QgsTextFormatWidget::populateFontCapitalsComboBox()
1449 #if defined(HAS_KDE_QT5_SMALL_CAPS_FIX) || QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
1459 void QgsTextFormatWidget::populateFontStyleComboBox()
1461 mFontStyleComboBox->clear();
1462 const QStringList styles = mFontDB.styles( mRefFont.family() );
1463 const auto constStyles = styles;
1464 for (
const QString &style : constStyles )
1466 mFontStyleComboBox->addItem( style );
1469 QString targetStyle = mFontDB.styleString( mRefFont );
1470 if ( !styles.contains( targetStyle ) )
1472 const QFont f = QFont( mRefFont.family() );
1473 targetStyle = QFontInfo( f ).styleName();
1474 mRefFont.setStyleName( targetStyle );
1477 const int stylIndx = mFontStyleComboBox->findText( targetStyle );
1478 if ( stylIndx > -1 )
1483 mFontStyleComboBox->setCurrentIndex( curIndx );
1486 void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged(
double d )
1488 mRefFont.setPointSizeF( d );
1489 updateFont( mRefFont );
1492 void QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged(
const QFont &f )
1494 mRefFont.setFamily( f.family() );
1495 updateFont( mRefFont );
1498 void QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged(
const QString &text )
1501 updateFont( mRefFont );
1504 void QgsTextFormatWidget::mFontUnderlineBtn_toggled(
bool ckd )
1506 mRefFont.setUnderline( ckd );
1507 updateFont( mRefFont );
1510 void QgsTextFormatWidget::mFontStrikethroughBtn_toggled(
bool ckd )
1512 mRefFont.setStrikeOut( ckd );
1513 updateFont( mRefFont );
1516 void QgsTextFormatWidget::kerningToggled(
bool checked )
1518 mRefFont.setKerning( checked );
1519 updateFont( mRefFont );
1522 void QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged(
double spacing )
1524 mRefFont.setWordSpacing( spacing );
1525 updateFont( mRefFont );
1528 void QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged(
double spacing )
1530 mRefFont.setLetterSpacing( QFont::AbsoluteSpacing, spacing );
1531 updateFont( mRefFont );
1534 void QgsTextFormatWidget::mFontSizeUnitWidget_changed()
1539 mFontLimitPixelChkBox->setChecked(
false );
1545 mFontLimitPixelChkBox->setChecked(
true );
1547 updateFont( mRefFont );
1550 void QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged(
int px )
1553 mFontMaxPixelSpinBox->setMinimum( px );
1554 mFontMaxPixelSpinBox->update();
1557 void QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged(
int px )
1560 if ( px < mFontMinPixelSpinBox->value() )
1562 mFontMaxPixelSpinBox->blockSignals(
true );
1563 mFontMaxPixelSpinBox->setValue( mFontMinPixelSpinBox->value() );
1564 mFontMaxPixelSpinBox->blockSignals(
false );
1566 mFontMaxPixelSpinBox->setMinimum( mFontMinPixelSpinBox->value() );
1569 void QgsTextFormatWidget::mBufferUnitWidget_changed()
1571 updateFont( mRefFont );
1574 void QgsTextFormatWidget::mMaskBufferUnitWidget_changed()
1576 updateFont( mRefFont );
1579 void QgsTextFormatWidget::mCoordXDDBtn_changed()
1581 updateDataDefinedAlignment();
1584 void QgsTextFormatWidget::mCoordXDDBtn_activated(
bool isActive )
1589 mCoordPointDDBtn->setActive(
false );
1592 void QgsTextFormatWidget::mCoordYDDBtn_changed()
1594 updateDataDefinedAlignment();
1597 void QgsTextFormatWidget::mCoordYDDBtn_activated(
bool isActive )
1602 mCoordPointDDBtn->setActive(
false );
1605 void QgsTextFormatWidget::mCoordPointDDBtn_changed()
1607 updateDataDefinedAlignment();
1610 void QgsTextFormatWidget::mCoordPointDDBtn_activated(
bool isActive )
1615 mCoordXDDBtn->setActive(
false );
1616 mCoordYDDBtn->setActive(
false );
1619 void QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged(
int )
1627 showBackgroundRadius( isRect );
1629 mShapeSVGPathFrame->setVisible( isSVG );
1630 mBackgroundMarkerSymbolButton->setVisible( isMarker );
1631 mBackgroundFillSymbolButton->setVisible( !isSVG && !isMarker );
1635 mShapeSizeYLabel->setVisible( !isSVG && !isMarker );
1636 mShapeSizeYSpnBx->setVisible( !isSVG && !isMarker );
1637 mShapeSizeYDDBtn->setVisible( !isSVG && !isMarker );
1638 mShapeSizeXLabel->setText( tr(
"Size%1" ).arg( !isSVG && !isMarker ? tr(
" X" ) : QString() ) );
1641 mShapeFillColorBtn->setAllowOpacity( !isSVG );
1642 mShapeFillColorBtn->setButtonBackground();
1643 mShapeStrokeColorBtn->setAllowOpacity( !isSVG );
1644 mShapeStrokeColorBtn->setButtonBackground();
1647 mShapeFillColorLabel->setVisible( isSVG );
1648 mShapeFillColorLabel->setEnabled( isSVG );
1649 mShapeFillColorBtn->setVisible( isSVG );
1650 mShapeFillColorBtn->setEnabled( isSVG );
1651 mShapeFillColorDDBtn->setVisible( isSVG );
1652 mShapeFillColorDDBtn->setEnabled( isSVG );
1653 mShapeStrokeColorLabel->setVisible( isSVG );
1654 mShapeStrokeColorLabel->setEnabled( isSVG );
1655 mShapeStrokeColorBtn->setVisible( isSVG );
1656 mShapeStrokeColorBtn->setEnabled( isSVG );
1657 mShapeStrokeColorDDBtn->setVisible( isSVG );
1658 mShapeStrokeColorDDBtn->setEnabled( isSVG );
1659 mShapeStrokeWidthLabel->setVisible( isSVG );
1660 mShapeStrokeWidthLabel->setEnabled( isSVG );
1661 mShapeStrokeWidthSpnBx->setVisible( isSVG );
1662 mShapeStrokeWidthSpnBx->setEnabled( isSVG );
1663 mShapeStrokeWidthDDBtn->setVisible( isSVG );
1664 mShapeStrokeWidthDDBtn->setEnabled( isSVG );
1667 mShapeSVGParamsBtn->setVisible( isSVG );
1670 updateSvgWidgets( mShapeSVGPathLineEdit->text() );
1674 mShapeSVGUnitsLabel->setVisible( isSVG );
1675 mShapeStrokeWidthUnitWidget->setVisible(
false );
1676 mShapeStrokeUnitsDDBtn->setVisible(
false );
1677 mShapeStrokeUnitsDDBtn->setEnabled(
false );
1679 updateAvailableShadowPositions();
1682 void QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged(
const QString &text )
1684 updateSvgWidgets( text );
1689 const int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) +
1690 ( chkLineBelow->isChecked() ? 1 : 0 ) +
1691 ( chkLineOn->isChecked() ? 1 : 0 );
1693 if ( numOptionsChecked == 1 )
1696 chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
1697 chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
1698 chkLineOn->setEnabled( !chkLineOn->isChecked() );
1702 chkLineAbove->setEnabled(
true );
1703 chkLineBelow->setEnabled(
true );
1704 chkLineOn->setEnabled(
true );
1714 void QgsTextFormatWidget::previewScaleChanged(
double scale )
1716 lblFontPreview->setScale( scale );
1719 void QgsTextFormatWidget::updateSvgWidgets(
const QString &svgPath )
1721 if ( mShapeSVGPathLineEdit->text() != svgPath )
1723 mShapeSVGPathLineEdit->setText( svgPath );
1726 QString resolvedPath;
1727 bool validSVG =
true;
1728 if ( ! svgPath.startsWith( QLatin1String(
"base64:" ), Qt::CaseInsensitive ) )
1731 validSVG = QFileInfo::exists( resolvedPath );
1735 resolvedPath = svgPath;
1740 mShapeSVGPathLineEdit->setStyleSheet( !validSVG ? QStringLiteral(
"QLineEdit{ color: rgb(225, 0, 0); }" ) : QString() );
1741 mShapeSVGPathLineEdit->setToolTip( !validSVG ? tr(
"File not found" ) : resolvedPath );
1743 QColor fill, stroke;
1744 double strokeWidth = 0.0;
1745 bool fillParam =
false, strokeParam =
false, strokeWidthParam =
false;
1751 mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || strokeParam || strokeWidthParam ) );
1753 mShapeFillColorLabel->setEnabled( validSVG && fillParam );
1754 mShapeFillColorBtn->setEnabled( validSVG && fillParam );
1755 mShapeFillColorDDBtn->setEnabled( validSVG && fillParam );
1756 if ( mLoadSvgParams && validSVG && fillParam )
1757 mShapeFillColorBtn->setColor( fill );
1759 mShapeStrokeColorLabel->setEnabled( validSVG && strokeParam );
1760 mShapeStrokeColorBtn->setEnabled( validSVG && strokeParam );
1761 mShapeStrokeColorDDBtn->setEnabled( validSVG && strokeParam );
1762 if ( mLoadSvgParams && validSVG && strokeParam )
1763 mShapeStrokeColorBtn->setColor( stroke );
1765 mShapeStrokeWidthLabel->setEnabled( validSVG && strokeWidthParam );
1766 mShapeStrokeWidthSpnBx->setEnabled( validSVG && strokeWidthParam );
1767 mShapeStrokeWidthDDBtn->setEnabled( validSVG && strokeWidthParam );
1768 if ( mLoadSvgParams && validSVG && strokeWidthParam )
1769 mShapeStrokeWidthSpnBx->setValue( strokeWidth );
1775 mShapeSVGUnitsLabel->setEnabled( validSVG && strokeWidthParam );
1778 void QgsTextFormatWidget::updateAvailableShadowPositions()
1780 if ( mShadowUnderCmbBx->count() == 0
1786 mShadowUnderCmbBx->clear();
1794 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( currentPlacement ) );
1795 if ( mShadowUnderCmbBx->currentIndex() == -1 )
1796 mShadowUnderCmbBx->setCurrentIndex( 0 );
1800 void QgsTextFormatWidget::updateProperty()
1808 void QgsTextFormatWidget::createAuxiliaryField()
1835 property.setActive(
true );
1844 void QgsTextFormatWidget::updateShapeFrameStatus()
1846 mShapeFrame->setEnabled( mShapeDrawDDBtn->isActive() || mShapeDrawChkBx->isChecked() );
1849 void QgsTextFormatWidget::updateBufferFrameStatus()
1851 mBufferFrame->setEnabled( mBufferDrawDDBtn->isActive() || mBufferDrawChkBx->isChecked() );
1854 void QgsTextFormatWidget::updateShadowFrameStatus()
1856 mShadowFrame->setEnabled( mShadowDrawDDBtn->isActive() || mShadowDrawChkBx->isChecked() );
1859 void QgsTextFormatWidget::updateCalloutFrameStatus()
1861 mCalloutFrame->setEnabled( mCalloutDrawDDBtn->isActive() || mCalloutsDrawCheckBox->isChecked() );
1864 void QgsTextFormatWidget::updateDataDefinedAlignment()
1867 mCoordAlignmentFrame->setEnabled( ( mCoordXDDBtn->isActive() && mCoordYDDBtn->isActive() )
1868 || mCoordPointDDBtn->isActive() );
1912 saveDlg.
setDefaultTags( mTextFormatsListWidget->currentTagFilter() );
1913 if ( !saveDlg.exec() )
1916 if ( saveDlg.
name().isEmpty() )
1922 const int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1923 tr(
"Format with name '%1' already exists. Overwrite?" )
1924 .arg( saveDlg.
name() ),
1925 QMessageBox::Yes | QMessageBox::No );
1926 if ( res != QMessageBox::Yes )
1933 const QStringList symbolTags = saveDlg.
tags().split(
',' );
1940 void QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked()
1943 svgDlg.setWindowTitle( tr(
"Select SVG file" ) );
1944 svgDlg.svgSelector()->setSvgPath( mShapeSVGPathLineEdit->text().trimmed() );
1946 if ( svgDlg.exec() == QDialog::Accepted )
1948 const QString svgPath = svgDlg.svgSelector()->currentSvgPath();
1949 if ( !svgPath.isEmpty() )
1951 mShapeSVGPathLineEdit->setText( svgPath );
1957 void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
1959 const QString svgPath = mShapeSVGPathLineEdit->text();
1960 mLoadSvgParams =
true;
1961 updateSvgWidgets( svgPath );
1962 mLoadSvgParams =
false;
1965 void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged(
int index )
1971 void QgsTextFormatWidget::mPreviewTextEdit_textChanged(
const QString &text )
1973 lblFontPreview->setText( text );
1977 void QgsTextFormatWidget::mPreviewTextBtn_clicked()
1979 mPreviewTextEdit->setText( QStringLiteral(
"Lorem Ipsum" ) );
1983 void QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged(
const QColor &color )
1988 void QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked()
1990 bool gotChar =
false;
1992 const QChar initial = !mDirectSymbLeftLineEdit->text().isEmpty() ? mDirectSymbLeftLineEdit->text().at( 0 ) : QChar();
1993 const QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
1998 if ( !dirSymb.isNull() )
1999 mDirectSymbLeftLineEdit->setText( QString( dirSymb ) );
2002 void QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked()
2004 bool gotChar =
false;
2005 const QChar initial = !mDirectSymbRightLineEdit->text().isEmpty() ? mDirectSymbRightLineEdit->text().at( 0 ) : QChar();
2006 const QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
2011 if ( !dirSymb.isNull() )
2012 mDirectSymbRightLineEdit->setText( QString( dirSymb ) );
2015 void QgsTextFormatWidget::chkLineOrientationDependent_toggled(
bool active )
2019 chkLineAbove->setText( tr(
"Left of line" ) );
2020 chkLineBelow->setText( tr(
"Right of line" ) );
2024 chkLineAbove->setText( tr(
"Above line" ) );
2025 chkLineBelow->setText( tr(
"Below line" ) );
2030 void QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked()
2045 if ( dlg.exec() == QDialog::Accepted )
2052 void QgsTextFormatWidget::showBackgroundRadius(
bool show )
2054 mShapeRadiusLabel->setVisible( show );
2055 mShapeRadiusXDbSpnBx->setVisible( show );
2057 mShapeRadiusYDbSpnBx->setVisible( show );
2059 mShapeRadiusUnitWidget->setVisible( show );
2061 mShapeRadiusDDBtn->setVisible( show );
2062 mShapeRadiusUnitsDDBtn->setVisible( show );
2068 return *lExpressionContext;
2089 if ( mGeometryGeneratorGroupBox->isChecked() )
2103 : QDialog( parent, fl )
2105 setWindowTitle( tr(
"Text Settings" ) );
2108 mFormatWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
2110 QVBoxLayout *layout =
new QVBoxLayout(
this );
2111 layout->addWidget( mFormatWidget );
2113 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, Qt::Horizontal,
this );
2114 layout->addWidget( mButtonBox );
2116 setLayout( layout );
2119 connect( mButtonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked,
this, &QDialog::accept );
2120 connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked,
this, &QDialog::reject );
2121 connect( mButtonBox->button( QDialogButtonBox::Help ), &QAbstractButton::clicked,
this, &QgsTextFormatDialog::showHelp );
2126 return mFormatWidget->
format();
2129 void QgsTextFormatDialog::showHelp()
2131 QgsHelp::openHelp( QStringLiteral(
"style_library/label_settings.html#formatting-the-label-text" ) );
2147 mFormatWidget = qobject_cast< QgsTextFormatWidget * >(
widget() );
2150 if ( !mBlockSignals )
2157 return mFormatWidget->
format();
2162 mBlockSignals =
true;
2164 mBlockSignals =
false;
Capitalization
String capitalization options.
@ AllSmallCaps
Force all characters to small caps (since QGIS 3.24)
@ MixedCase
Mixed case, ie no change.
@ AllLowercase
Convert all characters to lowercase.
@ TitleCase
Simple title case conversion - does not fully grammatically parse the text and uses simple rules only...
@ SmallCaps
Mixed case small caps (since QGIS 3.24)
@ ForceFirstLetterToCapital
Convert just the first letter of each word to uppercase, leave the rest untouched.
@ AllUppercase
Convert all characters to uppercase.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
A dialog for selecting a single character from a single font.
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.
A QGIS expression editor based on QScintilla2.
void collapsedStateChanged(bool collapsed)
Signal emitted when groupbox collapsed/expanded state is changed, and when first shown.
A groupbox that collapses/expands when toggled and can save its collapsed and checked states.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
QgsFillSymbol * clone() const override
Returns a deep copy of this symbol.
static bool fontFamilyMatchOnSystem(const QString &family, QString *chosen=nullptr, bool *match=nullptr)
Check whether font family is on system.
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
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...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
static QIcon iconForWkbType(QgsWkbTypes::Type type)
Returns the icon for a vector layer whose geometry type is provided.
@ SymbolLeftRight
Place direction symbols on left/right of label.
@ SymbolAbove
Place direction symbols on above label.
@ SymbolBelow
Place direction symbols on below label.
static void warning(const QString &msg)
Goes to qWarning.
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
double scale() const
Returns the calculated map scale.
QgsUnitTypes::DistanceUnit mapUnits() const
Returns the units of the map's geographical coordinates - used for scale calculation.
A marker symbol type, for rendering Point and MultiPoint geometries.
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
A dialog to create a new auxiliary layer.
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
@ ShowDefined
Show upside down when rotation is layer- or data-defined.
@ Upright
Upside-down labels (90 <= angle < 270) are shown upright.
@ ShowAll
Show upside down for all labels, including dynamic ones.
Placement
Placement modes which determine how label candidates are generated for a feature.
@ PerimeterCurved
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only.
@ Curved
Arranges candidates following the curvature of a line feature. Applies to line layers only.
@ Horizontal
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
@ Free
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
@ OrderedPositionsAroundPoint
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
@ OutsidePolygons
Candidates are placed outside of polygon boundaries. Applies to polygon layers only....
Property
Data definable properties.
@ MaskEnabled
Whether the mask is enabled.
@ LabelRotation
Label rotation.
@ PositionY
Y-coordinate data defined label position.
@ OverrunDistance
Distance which labels can extend past either end of linear features.
@ Strikeout
Use strikeout.
@ FontStyle
Font style name.
@ PositionX
X-coordinate data defined label position.
@ CalloutDraw
Show callout.
@ Underline
Use underline.
@ FontLetterSpacing
Letter spacing.
@ MaskJoinStyle
Mask join style.
@ PositionPoint
Point-coordinate data defined label position.
@ Hali
Horizontal alignment for data defined label position (Left, Center, Right)
@ FontStretchFactor
Font stretch factor, since QGIS 3.24.
@ MaskBufferUnit
Mask buffer size unit.
@ LabelAllParts
Whether all parts of multi-part features should be labeled.
@ ShadowOpacity
Shadow opacity.
@ BufferOpacity
Buffer opacity.
@ ShapeOpacity
Shape opacity.
@ FontSizeUnit
Font size units.
@ Italic
Use italic style.
@ PredefinedPositionOrder
@ FontWordSpacing
Word spacing.
@ MaskBufferSize
Mask buffer size.
@ MinimumScale
Minimum map scale (ie most "zoomed out")
@ FontBlendMode
Text blend mode.
@ MaximumScale
Maximum map scale (ie most "zoomed in")
@ MaskOpacity
Mask opacity.
@ PolygonLabelOutside
Whether labels outside a polygon feature are permitted, or should be forced (since QGIS 3....
@ FontCase
Label text case.
@ LinePlacementOptions
Line placement flags.
@ Vali
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
@ FontOpacity
Text opacity.
@ FromPoint
Offset distance applies from point geometry.
@ FromSymbolBounds
Offset distance applies from rendered symbol bounds.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the labeling property definitions.
static QgsProject * instance()
Returns the QgsProject singleton instance.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
QSet< int > propertyKeys() const override
Returns a list of property keys contained within the collection.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
Definition for a property.
A store for object properties.
void setField(const QString &field)
Sets the field name the property references.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
A collection of string replacements (specified using QgsStringReplacement objects).
a dialog for setting properties of a newly saved style.
bool isFavorite() const
Returns true if the favorite is checked for the symbol.
QString name() const
Returns the entered name for the new symbol.
void setDefaultTags(const QString &tags)
Sets the default tags for the newly created item.
QString tags() const
Returns any tags entered for the new symbol (as a comma separated value list).
QgsTextFormat textFormat(const QString &name) const
Returns the text format with the specified name.
QgsTextFormat defaultTextFormat(QgsStyle::TextFormatContext context=QgsStyle::TextFormatContext::Labeling) const
Returns the default text format to use for new text based objects in the specified context.
QStringList textFormatNames() const
Returns a list of names of text formats in the style.
bool removeTextFormat(const QString &name)
Removes a text format from the style.
StyleEntity
Enum for Entities involved in a style.
@ LabelSettingsEntity
Label settings.
@ TextFormatEntity
Text formats.
@ SmartgroupEntity
Smart groups.
@ Symbol3DEntity
3D symbol entity (since QGIS 3.14)
@ ColorrampEntity
Color ramps.
@ LegendPatchShapeEntity
Legend patch shape (since QGIS 3.14)
static QgsStyle * defaultStyle()
Returns default application-wide style.
bool addTextFormat(const QString &name, const QgsTextFormat &format, bool update=false)
Adds a text format with the specified name to the style.
QgsPalLayerSettings labelSettings(const QString &name) const
Returns the label settings with the specified name.
bool saveTextFormat(const QString &name, const QgsTextFormat &format, bool favorite, const QStringList &tags)
Adds a text format to the database.
A dialog which allows users to specify a list of substitutions to apply to a string,...
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.
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Container for settings relating to a text background object.
QgsMapUnitScale strokeWidthMapUnitScale() const
Returns the map unit scale object for the shape stroke width.
void setFillSymbol(QgsFillSymbol *symbol)
Sets the current fill symbol for the background shape.
RotationType rotationType() const
Returns the method used for rotating the background shape.
QString svgFile() const
Returns the absolute path to the background SVG file, if set.
QSizeF size() const
Returns the size of the background shape.
QSizeF radii() const
Returns the radii used for rounding the corners of shapes.
QgsMapUnitScale radiiMapUnitScale() const
Returns the map unit scale object for the shape radii.
void setOpacity(double opacity)
Sets the background shape's opacity.
void setStrokeColor(const QColor &color)
Sets the color used for outlining the background shape.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units used for the shape's stroke width.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape size.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the background shape.
SizeType
Methods for determining the background shape size.
bool enabled() const
Returns whether the background is enabled.
void setRadiiUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's radii.
double opacity() const
Returns the background shape's opacity.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape stroke width.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the shape's offset.
double rotation() const
Returns the rotation for the background shape, in degrees clockwise.
QColor fillColor() const
Returns the color used for filing the background shape.
void setMarkerSymbol(QgsMarkerSymbol *symbol)
Sets the current marker symbol for the background shape.
void setRadii(QSizeF radii)
Sets the radii used for rounding the corners of shapes.
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
ShapeType type() const
Returns the type of background shape (e.g., square, ellipse, SVG).
double strokeWidth() const
Returns the width of the shape's stroke (stroke).
void setSizeType(SizeType type)
Sets the method used to determine the size of the background shape (e.g., fixed size or buffer around...
ShapeType
Background shape types.
@ ShapeMarkerSymbol
Marker symbol.
@ ShapeSquare
Square - buffered sizes only.
@ ShapeRectangle
Rectangle.
void setFillColor(const QColor &color)
Sets the color used for filing the background shape.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the background shape.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's stroke width.
QColor strokeColor() const
Returns the color used for outlining the background shape.
void setRotationType(RotationType type)
Sets the method used for rotating the background shape.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape offset.
QgsFillSymbol * fillSymbol() const
Returns the fill symbol to be rendered in the background.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the background shape.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
void setType(ShapeType type)
Sets the type of background shape to draw (e.g., square, ellipse, SVG).
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units used for the shape's size.
RotationType
Methods for determining the rotation of the background shape.
@ RotationSync
Shape rotation is synced with text rotation.
QgsUnitTypes::RenderUnit radiiUnit() const
Returns the units used for the shape's radii.
void setEnabled(bool enabled)
Sets whether the text background will be drawn.
QgsMarkerSymbol * markerSymbol() const
Returns the marker symbol to be rendered in the background.
void setRadiiMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape radii.
void setRotation(double rotation)
Sets the rotation for the background shape, in degrees clockwise.
void setOffset(QPointF offset)
Sets the offset used for drawing the background shape.
void setSize(QSizeF size)
Sets the size of the background shape.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the shape's size.
const QgsPaintEffect * paintEffect() const
Returns the current paint effect for the background shape.
void setSvgFile(const QString &file)
Sets the path to the background SVG file.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shape offset.
void setStrokeWidth(double width)
Sets the width of the shape's stroke (stroke).
QPointF offset() const
Returns the offset used for drawing the background shape.
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's offset.
Container for settings relating to a text buffer.
void setFillBufferInterior(bool fill)
Sets whether the interior of the buffer will be filled in.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the buffer.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
double size() const
Returns the size of the buffer.
void setColor(const QColor &color)
Sets the color for the buffer.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
void setOpacity(double opacity)
Sets the buffer opacity.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
bool enabled() const
Returns whether the buffer is enabled.
double opacity() const
Returns the buffer opacity.
bool fillBufferInterior() const
Returns whether the interior of the buffer will be filled in.
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the buffer.
const QgsPaintEffect * paintEffect() const
Returns the current paint effect for the buffer.
QColor color() const
Returns the color of the buffer.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the buffer.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
void setSize(double size)
Sets the size of the buffer.
QgsTextFormatDialog(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QgsVectorLayer *layer=nullptr)
Constructor for QgsTextFormatDialog.
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
void setFormat(const QgsTextFormat &format)
Sets the format to show in the widget.
void setDockMode(bool dockMode) override
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
QgsTextFormatPanelWidget(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsVectorLayer *layer=nullptr)
Constructor for QgsTextFormatPanelWidget.
A widget for customizing text formatting settings.
void updatePlacementWidgets()
Updates label placement options to reflect current state of widget.
QButtonGroup * mUpsidedownBtnGrp
Upside down labels button group.
QgsTextFormatWidget(const QgsTextFormat &format=QgsTextFormat(), QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsVectorLayer *layer=nullptr)
Constructor for QgsTextFormatWidget.
int mMinPixelLimit
Pixel size font limit.
void setDockMode(bool enabled)
Sets whether the widget should be shown in a compact dock mode.
QgsMapCanvas * mMapCanvas
Associated map canvas.
QgsSymbolWidgetContext context() const
Returns the context in which the widget is shown, e.g., the associated map canvas and expression cont...
~QgsTextFormatWidget() override
void deactivateField(QgsPalLayerSettings::Property key)
Deactivate a field from data defined properties and update the corresponding button.
void setFormat(const QgsTextFormat &format)
Sets the current formatting settings.
virtual void setFormatFromStyle(const QString &name, QgsStyle::StyleEntity type)
Sets the current text settings from a style entry.
QButtonGroup * mDirectSymbBtnGrp
Symbol direction button group.
void updateWidgetForFormat(const QgsTextFormat &format)
Updates the widget's state to reflect the settings in a QgsTextFormat.
QList< QgsSymbolLayerReference > mMaskedSymbolLayers
void widgetChanged()
Emitted when the text format defined by the widget changes.
void setPreviewBackground(const QColor &color)
Sets the background color for the text preview widget.
QButtonGroup * mQuadrantBtnGrp
Quadrant button group.
QgsWkbTypes::GeometryType labelGeometryType() const
Returns the geometry type which will be used by the labeling engine when registering labels for the l...
QgsWkbTypes::GeometryType mGeomType
Geometry type for layer, if known.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsSymbolWidgetContext mContext
Context in which widget is shown.
void updateLinePlacementOptions()
Updates line placement options to reflect current state of widget.
void populateDataDefinedButtons()
Sets up connections required for data defined buttons, or updates the existing definition of these bu...
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
void updatePreview()
Updates the text preview.
void auxiliaryFieldCreated()
Emitted when an auxiliary field is created in the widget.
QgsStringReplacementCollection mSubstitutions
Text substitution list.
@ Text
Default mode, show text formatting settings only.
@ Labeling
Show labeling settings in addition to text formatting settings.
virtual void saveFormat()
Saves the current text settings to a style entry.
QgsPropertyCollection mDataDefinedProperties
Data defined properties as defined in the widget.
QgsVectorLayer * mLayer
Associated vector layer.
Container for all settings relating to text rendering.
void setColor(const QColor &color)
Sets the color that text will be rendered in.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the text.
void setSize(double size)
Sets the size for rendered text.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the size.
void setCapitalization(Qgis::Capitalization capitalization)
Sets the text capitalization style.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the format's property collection, used for data defined overrides.
void setFont(const QFont &font)
Sets the font used for rendering text.
double lineHeight() const
Returns the line height for text.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the size of rendered text.
int stretchFactor() const
Returns the text's stretch factor.
void setOrientation(TextOrientation orientation)
Sets the orientation for the text.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the format's property collection, used for data defined overrides.
void setStretchFactor(int factor)
Sets the text's stretch factor.
void setShadow(const QgsTextShadowSettings &shadowSettings)
Sets the text's drop shadow settings.
void setMask(const QgsTextMaskSettings &maskSettings)
Sets the text's masking settings.
bool fontFound() const
Returns true if the specified font was found on the system, or false if the font was not found and a ...
void setPreviewBackgroundColor(const QColor &color)
Sets the background color that text will be rendered on for previews.
void setOpacity(double opacity)
Sets the text's opacity.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the text.
TextOrientation orientation() const
Returns the orientation of the text.
void setAllowHtmlFormatting(bool allow)
Sets whether text should be treated as a HTML document and HTML tags should be used for formatting th...
Qgis::Capitalization capitalization() const
Returns the text capitalization style.
QString resolvedFontFamily() const
Returns the family for the resolved font, ie if the specified font was not found on the system this w...
QgsTextMaskSettings & mask()
Returns a reference to the masking settings.
bool isValid() const
Returns true if the format is valid.
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
TextOrientation
Text orientation.
@ HorizontalOrientation
Vertically oriented text.
@ RotationBasedOrientation
Horizontally or vertically oriented text based on rotation (only available for map labeling)
@ VerticalOrientation
Horizontally oriented text.
bool allowHtmlFormatting() const
Returns true if text should be treated as a HTML document and HTML tags should be used for formatting...
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the size of rendered text.
double opacity() const
Returns the text's opacity.
QString namedStyle() const
Returns the named style for the font used for rendering text (e.g., "bold").
double size() const
Returns the size for rendered text.
QgsTextShadowSettings & shadow()
Returns a reference to the text drop shadow settings.
void setBackground(const QgsTextBackgroundSettings &backgroundSettings)
Sets the text's background settings.q.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the size.
void setNamedStyle(const QString &style)
Sets the named style for the font used for rendering text.
QColor color() const
Returns the color that text will be rendered in.
QFont font() const
Returns the font used for rendering text.
QColor previewBackgroundColor() const
Returns the background color for text previews.
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
void setLineHeight(double height)
Sets the line height for text.
Container for settings relating to a selective masking around a text.
void setEnabled(bool)
Returns whether the mask is enabled.
void setMaskedSymbolLayers(const QList< QgsSymbolLayerReference > &maskedLayers)
Sets the symbol layers that will be masked by this buffer.
QList< QgsSymbolLayerReference > maskedSymbolLayers() const
Returns a list of references to symbol layers that are masked by this buffer.
void setSize(double size)
Sets the size of the buffer.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
double size() const
Returns the size of the buffer.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the mask.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
double opacity() const
Returns the mask's opacity.
bool enabled() const
Returns whether the mask is enabled.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the mask.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
void setOpacity(double opacity)
Sets the mask's opacity.
Container for settings relating to a text shadow.
int offsetAngle() const
Returns the angle for offsetting the position of the shadow from the text.
void setBlurRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow blur radius.
bool enabled() const
Returns whether the shadow is enabled.
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
void setShadowPlacement(QgsTextShadowSettings::ShadowPlacement placement)
Sets the placement for the drop shadow.
double opacity() const
Returns the shadow's opacity.
QgsMapUnitScale blurRadiusMapUnitScale() const
Returns the map unit scale object for the shadow blur radius.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow offset distance.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the drop shadow.
void setColor(const QColor &color)
Sets the color for the drop shadow.
QColor color() const
Returns the color of the drop shadow.
void setOffsetGlobal(bool global)
Sets whether the global shadow offset should be used.
ShadowPlacement
Placement positions for text shadow.
@ ShadowBuffer
Draw shadow under buffer.
@ ShadowShape
Draw shadow under background shape.
@ ShadowLowest
Draw shadow below all text components.
@ ShadowText
Draw shadow under text.
void setScale(int scale)
Sets the scaling used for the drop shadow (in percentage of original size).
void setBlurAlphaOnly(bool alphaOnly)
Sets whether only the alpha channel for the shadow should be blurred.
QgsTextShadowSettings::ShadowPlacement shadowPlacement() const
Returns the placement for the drop shadow.
double offsetDistance() const
Returns the distance for offsetting the position of the shadow from the text.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the drop shadow.
void setOffsetDistance(double distance)
Sets the distance for offsetting the position of the shadow from the text.
void setOpacity(double opacity)
Sets the shadow's opacity.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shadow offset distance.
QgsUnitTypes::RenderUnit blurRadiusUnit() const
Returns the units used for the shadow's blur radius.
bool blurAlphaOnly() const
Returns whether only the alpha channel for the shadow will be blurred.
bool offsetGlobal() const
Returns true if the global shadow offset will be used.
void setOffsetAngle(int angle)
Sets the angle for offsetting the position of the shadow from the text.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the shadow's offset.
void setBlurRadiusUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's blur radius.
double blurRadius() const
Returns the blur radius for the shadow.
void setBlurRadius(double blurRadius)
Sets the blur radius for the shadow.
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's offset.
void setEnabled(bool enabled)
Sets whether the text shadow will be drawn.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
@ RenderMetersInMapUnits
Meters value as Map units.
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
@ RenderPoints
Points (e.g., for font sizes)
@ RenderMillimeters
Millimeters.
@ RenderMapUnits
Map units.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.