17#include "moc_qgstextformatwidget.cpp"
50#include <QButtonGroup>
55 , mMapCanvas( mapCanvas )
59 setWidgetMode(
Text );
66 , mMapCanvas( mapCanvas )
73 setWidgetMode( mode );
76void QgsTextFormatWidget::initWidget()
80 mGeometryGeneratorGroupBox->setCollapsed(
true );
82 connect( mShapeSVGPathLineEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged );
83 connect( mFontSizeSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontSizeSpinBox_valueChanged );
84 connect( mFontFamilyCmbBx, &QFontComboBox::currentFontChanged,
this, &QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged );
85 connect( mFontStyleComboBox, &QComboBox::currentTextChanged,
this, &QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged );
86 connect( mFontUnderlineBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontUnderlineBtn_toggled );
87 connect( mFontStrikethroughBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontStrikethroughBtn_toggled );
88 connect( mFontWordSpacingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged );
89 connect( mFontLetterSpacingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged );
91 connect( mFontMinPixelSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged );
92 connect( mFontMaxPixelSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged );
101 connect( mShapeTypeCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged );
102 connect( mShapeRotationCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged );
103 connect( mShapeSVGParamsBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGParamsBtn_clicked );
104 connect( mShapeSVGSelectorBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked );
105 connect( mPreviewTextEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mPreviewTextEdit_textChanged );
106 connect( mPreviewTextBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mPreviewTextBtn_clicked );
108 connect( mDirectSymbLeftToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked );
109 connect( mDirectSymbRightToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked );
110 connect( chkLineOrientationDependent, &QCheckBox::toggled,
this, &QgsTextFormatWidget::chkLineOrientationDependent_toggled );
111 connect( mToolButtonConfigureSubstitutes, &QToolButton::clicked,
this, &QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked );
112 connect( mKerningCheckBox, &QCheckBox::toggled,
this, &QgsTextFormatWidget::kerningToggled );
113 connect( mComboOverlapHandling, qOverload< int >( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::overlapModeChanged );
114 connect( mTabStopsButton, &QToolButton::clicked,
this, &QgsTextFormatWidget::configureTabStops );
117 mOptionsTab->setIconSize( QSize( iconSize, iconSize ) );
118 mLabelingOptionsListWidget->setIconSize( QSize( iconSize, iconSize ) ) ;
124 mPreviewTextBtn->setIconSize( QSize( iconSize16, iconSize16 ) );
125 mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
126 mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
127 mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );
128 mPointOffsetLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
129 mPointOffsetOver ->setIconSize( QSize( iconSize32, iconSize18 ) );
130 mPointOffsetRight->setIconSize( QSize( iconSize32, iconSize18 ) );
131 mPointOffsetBelowLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
132 mPointOffsetBelow->setIconSize( QSize( iconSize32, iconSize18 ) );
133 mPointOffsetBelowRight->setIconSize( QSize( iconSize32, iconSize18 ) );
134 mLabelMinScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomOut.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
135 mLabelMaxScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomIn.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
138 mFontUnderlineBtn->setMinimumSize( buttonSize, buttonSize );
139 mFontUnderlineBtn->setMaximumSize( buttonSize, buttonSize );
140 mFontStrikethroughBtn->setMinimumSize( buttonSize, buttonSize );
141 mFontStrikethroughBtn->setMaximumSize( buttonSize, buttonSize );
142 mFontBoldBtn->setMinimumSize( buttonSize, buttonSize );
143 mFontBoldBtn->setMaximumSize( buttonSize, buttonSize );
144 mFontItalicBtn->setMinimumSize( buttonSize, buttonSize );
145 mFontItalicBtn->setMaximumSize( buttonSize, buttonSize );
147 mPreviewScaleComboBox->setMapCanvas(
mMapCanvas );
148 mPreviewScaleComboBox->setShowCurrentScaleButton(
true );
151 const auto unitWidgets = findChildren<QgsUnitSelectionWidget *>();
189 mFontLineHeightSpinBox->setClearValue( 100.0 );
190 mShapeRotationDblSpnBx->setClearValue( 0.0 );
191 mShapeOffsetXSpnBx->setClearValue( 0.0 );
192 mShapeOffsetYSpnBx->setClearValue( 0.0 );
193 mPointOffsetXSpinBox->setClearValue( 0.0 );
194 mPointOffsetYSpinBox->setClearValue( 0.0 );
195 mPointAngleSpinBox->setClearValue( 0.0 );
196 mFontLetterSpacingSpinBox->setClearValue( 0.0 );
197 mFontWordSpacingSpinBox->setClearValue( 0.0 );
198 mZIndexSpinBox->setClearValue( 0.0 );
199 mLineDistanceSpnBx->setClearValue( 0.0 );
200 mMaximumDistanceSpnBx->setMinimum( 0 );
201 mMaximumDistanceSpnBx->setClearValue( 0.0, tr(
"Not set" ) );
202 mSpinStretch->setClearValue( 100 );
203 mTabStopDistanceSpin->setMinimum( 0 );
208 mFontLineHeightSpinBox->setClearValue( 100.0 );
210 mFontLineHeightSpinBox->setClearValue( 10.0 );
230 updateAvailableShadowPositions();
233 mBackgroundMarkerSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
234 mBackgroundMarkerSymbolButton->registerExpressionContextGenerator(
this );
235 mBackgroundMarkerSymbolButton->setMapCanvas(
mMapCanvas );
237 mBackgroundFillSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
238 mBackgroundFillSymbolButton->registerExpressionContextGenerator(
this );
239 mBackgroundFillSymbolButton->setMapCanvas(
mMapCanvas );
243 mRefFont = lblFontPreview->font();
246 connect( mShadowOffsetAngleDial, &QAbstractSlider::valueChanged, mShadowOffsetAngleSpnBx, &QSpinBox::setValue );
247 connect( mShadowOffsetAngleSpnBx,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mShadowOffsetAngleDial, &QAbstractSlider::setValue );
248 connect( mLimitLabelChkBox, &QAbstractButton::toggled, mLimitLabelSpinBox, &QWidget::setEnabled );
249 connect( mCheckBoxSubstituteText, &QAbstractButton::toggled, mToolButtonConfigureSubstitutes, &QWidget::setEnabled );
259 populateFontCapitalsComboBox();
262 mPreviewBackgroundBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
263 mPreviewBackgroundBtn->setContext( QStringLiteral(
"labeling" ) );
264 mPreviewBackgroundBtn->setColor( QColor( 255, 255, 255 ) );
265 btnTextColor->setColorDialogTitle( tr(
"Select Text Color" ) );
266 btnTextColor->setContext( QStringLiteral(
"labeling" ) );
267 btnTextColor->setDefaultColor( Qt::black );
268 btnBufferColor->setColorDialogTitle( tr(
"Select Buffer Color" ) );
269 btnBufferColor->setContext( QStringLiteral(
"labeling" ) );
270 btnBufferColor->setDefaultColor( Qt::white );
271 mShapeStrokeColorBtn->setColorDialogTitle( tr(
"Select Stroke Color" ) );
272 mShapeStrokeColorBtn->setContext( QStringLiteral(
"labeling" ) );
273 mShapeFillColorBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
274 mShapeFillColorBtn->setContext( QStringLiteral(
"labeling" ) );
275 mShadowColorBtn->setColorDialogTitle( tr(
"Select Shadow Color" ) );
276 mShadowColorBtn->setContext( QStringLiteral(
"labeling" ) );
277 mShadowColorBtn->setDefaultColor( Qt::black );
279 mFontColorDDBtn->registerLinkedWidget( btnTextColor );
280 mBufferColorDDBtn->registerLinkedWidget( btnBufferColor );
281 mShapeStrokeColorDDBtn->registerLinkedWidget( mShapeStrokeColorBtn );
282 mShapeFillColorDDBtn->registerLinkedWidget( mShapeFillColorBtn );
283 mShadowColorDDBtn->registerLinkedWidget( mShadowColorBtn );
324 const auto groupBoxes = findChildren<QgsCollapsibleGroupBox *>();
327 grpbox->setSettingGroup( QStringLiteral(
"mAdvLabelingDlg" ) );
333 mLabelingOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect,
false );
338 QSizePolicy policy( mLabelingOptionsListFrame->sizePolicy() );
339 policy.setHorizontalStretch( 0 );
340 mLabelingOptionsListFrame->setSizePolicy( policy );
341 if ( !settings.
contains( QStringLiteral(
"/Windows/Labeling/OptionsSplitState" ) ) )
344 QList<int> splitsizes;
346 mLabelingOptionsSplitter->setSizes( splitsizes );
350 connect( mLabelStackedWidget, &QStackedWidget::currentChanged,
this, &QgsTextFormatWidget::optionsStackedWidget_CurrentChanged );
353 mFontPreviewSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ) ).toByteArray() );
354 mLabelingOptionsSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ) ).toByteArray() );
356 mLabelingOptionsListWidget->setCurrentRow( settings.
value( QStringLiteral(
"Windows/Labeling/Tab" ), 0 ).toInt() );
360 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
364 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
368 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
370 overlapModeChanged();
372#if defined(HAS_KDE_QT5_FONT_STRETCH_FIX) || (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0))
375 mLabelStretch->hide();
376 mSpinStretch->hide();
377 mFontStretchDDBtn->hide();
382 QList<QWidget *> widgets;
383 widgets << btnBufferColor
385 << chkLabelPerFeaturePart
389 << chkLineOrientationDependent
391 << chkPreserveRotation
393 << comboBufferBlendMode
395 << mBufferJoinStyleComboBox
396 << mBufferTranspFillChbx
397 << mBufferOpacityWidget
398 << mCentroidInsideCheckBox
400 << mCoordRotationUnitComboBox
402 << mDirectSymbLeftLineEdit
403 << mDirectSymbRevChkBx
404 << mDirectSymbRightLineEdit
405 << mFitInsidePolygonCheckBox
406 << mFontCapitalsComboBox
407 << mFontLetterSpacingSpinBox
408 << mFontLimitPixelChkBox
409 << mFontLineHeightSpinBox
410 << mLineHeightUnitWidget
411 << mFontMaxPixelSpinBox
412 << mFontMinPixelSpinBox
413 << mFontMultiLineAlignComboBox
415 << mFontStyleComboBox
416 << mTextOrientationComboBox
417 << mTextOpacityWidget
419 << mFontWordSpacingSpinBox
421 << mFormatNumDecimalsSpnBx
422 << mFormatNumPlusSignChkBx
424 << mLimitLabelSpinBox
425 << mLineDistanceSpnBx
426 << mLineDistanceUnitWidget
427 << mMaximumDistanceSpnBx
428 << mMaximumDistanceUnitWidget
429 << mMaxCharAngleInDSpinBox
430 << mMaxCharAngleOutDSpinBox
432 << mOffsetTypeComboBox
433 << mCheckAllowDegradedPlacement
434 << mComboOverlapHandling
435 << mPointAngleSpinBox
436 << mPointOffsetUnitWidget
437 << mPointOffsetXSpinBox
438 << mPointOffsetYSpinBox
439 << mPreviewBackgroundBtn
442 << mRepeatDistanceSpinBox
443 << mRepeatDistanceUnitWidget
444 << mOverrunDistanceSpinBox
445 << mOverrunDistanceUnitWidget
446 << mScaleBasedVisibilityChkBx
452 << mShadowOffsetAngleSpnBx
453 << mShadowOffsetGlobalChkBx
454 << mShadowOffsetSpnBx
455 << mShadowOffsetUnitWidget
456 << mShadowRadiusAlphaChkBx
457 << mShadowRadiusDblSpnBx
458 << mShadowRadiusUnitWidget
460 << mShadowOpacityWidget
463 << mShapeStrokeColorBtn
464 << mShapeStrokeWidthSpnBx
465 << mShapeStrokeWidthUnitWidget
467 << mShapeFillColorBtn
468 << mShapeOffsetXSpnBx
469 << mShapeOffsetYSpnBx
470 << mShapeOffsetUnitWidget
471 << mShapeRadiusXDbSpnBx
472 << mShapeRadiusYDbSpnBx
473 << mShapeRotationCmbBx
474 << mShapeRotationDblSpnBx
475 << mShapeRadiusUnitWidget
476 << mShapeSVGPathLineEdit
478 << mShapeSizeUnitWidget
481 << mBackgroundOpacityWidget
486 << mAutoWrapLengthSpinBox
487 << mAutoWrapTypeComboBox
488 << mCentroidRadioVisible
489 << mCentroidRadioWhole
490 << mDirectSymbRadioBtnAbove
491 << mDirectSymbRadioBtnBelow
492 << mDirectSymbRadioBtnLR
493 << mUpsidedownRadioAll
494 << mUpsidedownRadioDefined
495 << mUpsidedownRadioOff
496 << mPlacementModeComboBox
497 << mFieldExpressionWidget
498 << mCheckBoxSubstituteText
499 << mGeometryGeneratorGroupBox
500 << mGeometryGenerator
501 << mGeometryGeneratorType
502 << mBackgroundMarkerSymbolButton
503 << mBackgroundFillSymbolButton
504 << mCalloutsDrawCheckBox
505 << mCalloutStyleComboBox
508 << mMaskJoinStyleComboBox
509 << mMaskBufferSizeSpinBox
510 << mMaskOpacityWidget
511 << mCheckAllowLabelsOutsidePolygons
512 << mHtmlFormattingCheckBox
513 << mPrioritizationComboBox
514 << mTabDistanceUnitWidget
515 << mTabStopDistanceSpin;
517 connectValueChanged( widgets );
522 connect( mBufferDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
524 updateBufferFrameStatus();
527 connect( mShapeDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
529 updateShapeFrameStatus();
532 connect( mShadowDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
534 updateShadowFrameStatus();
537 connect( mCalloutsDrawCheckBox, &QCheckBox::stateChanged,
this, [ = ](
int )
539 updateCalloutFrameStatus();
547 whileBlocking( mOptionsTab )->setCurrentIndex( mLabelStackedWidget->currentIndex() );
548 mOptionsTab->tabBar()->setUsesScrollButtons(
true );
569 toggleDDButtons(
true );
576 const int prevIndex = mOptionsTab->currentIndex();
577 toggleDDButtons(
true );
578 delete mLabelingOptionsListWidget->takeItem( 8 );
579 delete mLabelingOptionsListWidget->takeItem( 7 );
580 delete mLabelingOptionsListWidget->takeItem( 6 );
581 delete mLabelingOptionsListWidget->takeItem( 3 );
582 mOptionsTab->removeTab( 8 );
583 mOptionsTab->removeTab( 7 );
584 mOptionsTab->removeTab( 6 );
585 mOptionsTab->removeTab( 3 );
586 mLabelStackedWidget->removeWidget( mLabelPage_Rendering );
587 mLabelStackedWidget->removeWidget( mLabelPage_Callouts );
588 mLabelStackedWidget->removeWidget( mLabelPage_Mask );
589 mLabelStackedWidget->removeWidget( mLabelPage_Placement );
599 mLabelStackedWidget->setCurrentIndex( prevIndex - 1 );
600 mOptionsTab->setCurrentIndex( prevIndex - 1 );
607 mLabelStackedWidget->setCurrentIndex( 0 );
608 mOptionsTab->setCurrentIndex( 0 );
612 frameLabelWith->hide();
613 mDirectSymbolsFrame->hide();
614 mFormatNumFrame->hide();
615 mFormatNumChkBx->hide();
616 mFormatNumDDBtn->hide();
617 mCheckBoxSubstituteText->hide();
618 mToolButtonConfigureSubstitutes->hide();
619 mLabelWrapOnCharacter->hide();
620 wrapCharacterEdit->hide();
621 mWrapCharDDBtn->hide();
622 mLabelWrapLinesTo->hide();
623 mAutoWrapLengthSpinBox->hide();
624 mAutoWrapLengthDDBtn->hide();
625 mAutoWrapTypeComboBox->hide();
626 mFontMultiLineLabel->hide();
627 mFontMultiLineAlignComboBox->hide();
628 mFontMultiLineAlignDDBtn->hide();
636void QgsTextFormatWidget::toggleDDButtons(
bool visible )
638 const auto buttons = findChildren< QgsPropertyOverrideButton * >();
641#if defined(HAS_KDE_QT5_FONT_STRETCH_FIX) || (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0))
644 if ( button == mFontStretchDDBtn )
647 button->setVisible( visible );
653 mOptionsTab->setVisible( enabled );
654 mOptionsTab->setTabToolTip( 0, tr(
"Text" ) );
655 mOptionsTab->setTabToolTip( 1, tr(
"Formatting" ) );
656 mOptionsTab->setTabToolTip( 2, tr(
"Buffer" ) );
657 mOptionsTab->setTabToolTip( 3, tr(
"Mask" ) );
658 mOptionsTab->setTabToolTip( 4, tr(
"Background" ) );
659 mOptionsTab->setTabToolTip( 5, tr(
"Shadow" ) );
660 mOptionsTab->setTabToolTip( 6, tr(
"Callouts" ) );
661 mOptionsTab->setTabToolTip( 7, tr(
"Placement" ) );
662 mOptionsTab->setTabToolTip( 8, tr(
"Rendering" ) );
664 mLabelingOptionsListFrame->setVisible( !enabled );
665 groupBox_mPreview->setVisible( !enabled );
669void QgsTextFormatWidget::connectValueChanged(
const QList<QWidget *> &widgets )
671 const auto constWidgets = widgets;
672 for ( QWidget *widget : constWidgets )
682 else if (
QgsOpacityWidget *w = qobject_cast< QgsOpacityWidget *>( widget ) )
686 else if (
QgsScaleWidget *w = qobject_cast< QgsScaleWidget *>( widget ) )
694 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
698 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
702 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
706 else if (
QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
710 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
714 else if ( QRadioButton *w = qobject_cast<QRadioButton *>( widget ) )
718 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
722 else if ( QSlider *w = qobject_cast<QSlider *>( widget ) )
726 else if ( QGroupBox *w = qobject_cast<QGroupBox *>( widget ) )
736 QgsLogger::warning( QStringLiteral(
"Could not create connection for widget %1" ).arg( widget->objectName() ) );
769 mDirectSymbDDBtn->registerCheckedWidget( mDirectSymbChkBx );
777 mFormatNumDDBtn->registerCheckedWidget( mFormatNumChkBx );
792 mEnableMaskDDBtn->registerCheckedWidget( mEnableMaskChkBx );
800 mShapeDrawDDBtn->registerCheckedWidget( mShapeDrawChkBx );
822 mShadowDrawDDBtn->registerCheckedWidget( mShadowDrawChkBx );
865 updateDataDefinedAlignment();
868 const QString ddScaleVisInfo = tr(
"Value < 0 represents a scale closer than 1:1, e.g. -10 = 10:1<br>"
869 "Value of 0 disables the specific limit." );
871 mScaleBasedVisibilityDDBtn->registerCheckedWidget( mScaleBasedVisibilityChkBx );
873 mScaleBasedVisibilityMinDDBtn->setUsageInfo( ddScaleVisInfo );
875 mScaleBasedVisibilityMaxDDBtn->setUsageInfo( ddScaleVisInfo );
881 mMinScaleWidget->setPredefinedScales( scales );
882 mMaxScaleWidget->setPredefinedScales( scales );
887 mMinScaleWidget->updateScales();
888 mMaxScaleWidget->updateScales();
892 mFontLimitPixelDDBtn->registerCheckedWidget( mFontLimitPixelChkBox );
913 if ( !mButtons.contains( key ) )
918 mButtons[key] = button;
938 mBufferDrawChkBx->setChecked( buffer.
enabled() );
939 mBufferFrame->setEnabled( buffer.
enabled() );
940 spinBufferSize->setValue( buffer.
size() );
941 mBufferUnitWidget->setUnit( buffer.
sizeUnit() );
943 btnBufferColor->setColor( buffer.
color() );
944 mBufferOpacityWidget->setOpacity( buffer.
opacity() );
945 mBufferJoinStyleComboBox->setPenJoinStyle( buffer.
joinStyle() );
947 comboBufferBlendMode->setBlendMode( buffer.
blendMode() );
949 mBufferEffect.reset( lPaintEffect->clone() );
953 mBufferEffect->setEnabled(
false );
955 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
959 mEnableMaskChkBx->setChecked( mask.
enabled() );
960 mMaskBufferSizeSpinBox->setValue( mask.
size() );
961 mMaskBufferUnitWidget->setUnit( mask.
sizeUnit() );
963 mMaskOpacityWidget->setOpacity( mask.
opacity() );
964 mMaskJoinStyleComboBox->setPenJoinStyle( mask.
joinStyle() );
966 mMaskEffect.reset( lPaintEffect->clone() );
970 mMaskEffect->setEnabled(
false );
972 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
982 mTextOrientationComboBox->setCurrentIndex( mTextOrientationComboBox->findData(
static_cast< int >(
format.
orientation() ) ) );
985 mFontWordSpacingSpinBox->setValue(
format.
font().wordSpacing() );
986 mFontLetterSpacingSpinBox->setValue(
format.
font().letterSpacing() );
995 updateFont( mRefFont );
1001 const QString missingTxt = tr(
"%1 not found. Default substituted." );
1002 QString txtPrepend = tr(
"Chosen font" );
1007 mFontMissingLabel->setText( missingTxt.arg( txtPrepend ) );
1010 mLabelingOptionsListWidget->setCurrentRow( 0 );
1017 mShapeDrawChkBx->setChecked( background.
enabled() );
1018 mShapeFrame->setEnabled( background.
enabled() );
1019 mShapeTypeCmbBx->blockSignals(
true );
1020 mShapeTypeCmbBx->setCurrentIndex( mShapeTypeCmbBx->findData( background.
type() ) );
1021 mShapeTypeCmbBx->blockSignals(
false );
1022 updateAvailableShadowPositions();
1023 mShapeSVGPathLineEdit->setText( background.
svgFile() );
1025 mShapeSizeCmbBx->setCurrentIndex( background.
sizeType() );
1026 mShapeSizeXSpnBx->setValue( background.
size().width() );
1027 mShapeSizeYSpnBx->setValue( background.
size().height() );
1028 mShapeSizeUnitWidget->setUnit( background.
sizeUnit() );
1030 mShapeRotationCmbBx->setCurrentIndex( background.
rotationType() );
1033 mShapeRotationDblSpnBx->setValue( background.
rotation() );
1034 mShapeOffsetXSpnBx->setValue( background.
offset().x() );
1035 mShapeOffsetYSpnBx->setValue( background.
offset().y() );
1036 mShapeOffsetUnitWidget->setUnit( background.
offsetUnit() );
1038 mShapeRadiusXDbSpnBx->setValue( background.
radii().width() );
1039 mShapeRadiusYDbSpnBx->setValue( background.
radii().height() );
1040 mShapeRadiusUnitWidget->setUnit( background.
radiiUnit() );
1043 mShapeFillColorBtn->setColor( background.
fillColor() );
1044 mShapeStrokeColorBtn->setColor( background.
strokeColor() );
1045 mShapeStrokeWidthSpnBx->setValue( background.
strokeWidth() );
1049 mBackgroundOpacityWidget->setOpacity( background.
opacity() );
1050 mShapeBlendCmbBx->setBlendMode( background.
blendMode() );
1052 mLoadSvgParams =
false;
1053 mShapeTypeCmbBx_currentIndexChanged( background.
type() );
1055 if (
auto *lPaintEffect = background.
paintEffect() )
1056 mBackgroundEffect.reset( lPaintEffect->clone() );
1060 mBackgroundEffect->setEnabled(
false );
1062 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
1068 mShadowDrawChkBx->setChecked( shadow.
enabled() );
1069 mShadowFrame->setEnabled( shadow.
enabled() );
1070 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( shadow.
shadowPlacement() ) );
1071 mShadowOffsetAngleSpnBx->setValue( shadow.
offsetAngle() );
1073 mShadowOffsetUnitWidget->setUnit( shadow.
offsetUnit() );
1075 mShadowOffsetGlobalChkBx->setChecked( shadow.
offsetGlobal() );
1077 mShadowRadiusDblSpnBx->setValue( shadow.
blurRadius() );
1080 mShadowRadiusAlphaChkBx->setChecked( shadow.
blurAlphaOnly() );
1081 mShadowOpacityWidget->setOpacity( shadow.
opacity() );
1082 mShadowScaleSpnBx->setValue( shadow.
scale() );
1084 mShadowColorBtn->setColor( shadow.
color() );
1085 mShadowBlendCmbBx->setBlendMode( shadow.
blendMode() );
1097 settings.
setValue( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ), mFontPreviewSplitter->saveState() );
1098 settings.
setValue( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ), mLabelingOptionsSplitter->saveState() );
1100 int prevIndex = mLabelingOptionsListWidget->currentRow();
1101 if ( mWidgetMode ==
Text )
1103 switch ( prevIndex )
1112 settings.
setValue( QStringLiteral(
"Windows/Labeling/Tab" ), prevIndex );
1140 buffer.
setEnabled( mBufferDrawChkBx->isChecked() );
1141 buffer.
setSize( spinBufferSize->value() );
1142 buffer.
setColor( btnBufferColor->color() );
1143 buffer.
setOpacity( mBufferOpacityWidget->opacity() );
1146 buffer.
setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
1148 buffer.
setBlendMode( comboBufferBlendMode->blendMode() );
1157 mask.
setEnabled( mEnableMaskChkBx->isChecked() );
1158 mask.
setSize( mMaskBufferSizeSpinBox->value() );
1159 mask.
setOpacity( mMaskOpacityWidget->opacity() );
1160 mask.
setSizeUnit( mMaskBufferUnitWidget->unit() );
1162 mask.
setJoinStyle( mMaskJoinStyleComboBox->penJoinStyle() );
1172 background.
setEnabled( mShapeDrawChkBx->isChecked() );
1174 background.
setSvgFile( mShapeSVGPathLineEdit->text() );
1176 background.
setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
1177 background.
setSizeUnit( mShapeSizeUnitWidget->unit() );
1180 background.
setRotation( mShapeRotationDblSpnBx->value() );
1181 background.
setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
1184 background.
setRadii( QSizeF( mShapeRadiusXDbSpnBx->value(), mShapeRadiusYDbSpnBx->value() ) );
1185 background.
setRadiiUnit( mShapeRadiusUnitWidget->unit() );
1188 background.
setFillColor( mShapeFillColorBtn->color() );
1193 background.
setOpacity( mBackgroundOpacityWidget->opacity() );
1194 background.
setBlendMode( mShapeBlendCmbBx->blendMode() );
1205 shadow.
setEnabled( mShadowDrawChkBx->isChecked() );
1216 shadow.
setOpacity( mShadowOpacityWidget->opacity() );
1217 shadow.
setScale( mShadowScaleSpnBx->value() );
1218 shadow.
setColor( mShadowColorBtn->color() );
1222 if ( includeDataDefinedProperties )
1253 if ( mButtons.contains( key ) )
1262void QgsTextFormatWidget::optionsStackedWidget_CurrentChanged(
int indx )
1264 mLabelingOptionsListWidget->blockSignals(
true );
1265 mLabelingOptionsListWidget->setCurrentRow( indx );
1266 mLabelingOptionsListWidget->blockSignals(
false );
1275 mPreviewExpressionContext = *lExpressionContext;
1280 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
1288void QgsTextFormatWidget::collapseSample(
bool collapse )
1292 QList<int> splitSizes = mFontPreviewSplitter->sizes();
1293 if ( splitSizes[0] > groupBox_mPreview->height() )
1295 const int delta = splitSizes[0] - groupBox_mPreview->height();
1296 splitSizes[0] -= delta;
1297 splitSizes[1] += delta;
1298 mFontPreviewSplitter->setSizes( splitSizes );
1303void QgsTextFormatWidget::changeTextColor(
const QColor &color )
1309void QgsTextFormatWidget::updateFont(
const QFont &newFont )
1312 if ( newFont != mRefFont )
1321 QFont symbolFont = mRefFont;
1322 symbolFont.setPointSize( font().pointSize() );
1323 mDirectSymbLeftLineEdit->setFont( symbolFont );
1324 mDirectSymbRightLineEdit->setFont( symbolFont );
1326 blockFontChangeSignals(
true );
1327 mFontFamilyCmbBx->setCurrentFont( symbolFont );
1328 populateFontStyleComboBox();
1329 mFontUnderlineBtn->setChecked( mRefFont.underline() );
1330 mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
1331 mKerningCheckBox->setChecked( mRefFont.kerning() );
1332 blockFontChangeSignals(
false );
1340void QgsTextFormatWidget::blockFontChangeSignals(
bool blk )
1342 mFontFamilyCmbBx->blockSignals( blk );
1343 mFontStyleComboBox->blockSignals( blk );
1344 mFontCapitalsComboBox->blockSignals( blk );
1345 mFontUnderlineBtn->blockSignals( blk );
1346 mFontStrikethroughBtn->blockSignals( blk );
1347 mFontWordSpacingSpinBox->blockSignals( blk );
1348 mFontLetterSpacingSpinBox->blockSignals( blk );
1349 mKerningCheckBox->blockSignals( blk );
1364 lblFontPreview->setFormat(
format() );
1367void QgsTextFormatWidget::scrollPreview()
1369 scrollArea_mPreview->ensureVisible( 0, 0, 0, 0 );
1374 mPreviewBackgroundColor = color;
1376 scrollArea_mPreview->widget()->setStyleSheet( QStringLiteral(
"background: rgb(%1, %2, %3);" ).arg( QString::number( color.red() ),
1377 QString::number( color.green() ),
1378 QString::number( color.blue() ) ) );
1381void QgsTextFormatWidget::changeBufferColor(
const QColor &color )
1390 bool showLineFrame =
false;
1391 bool showCentroidFrame =
false;
1392 bool showQuadrantFrame =
false;
1393 bool showFixedQuadrantFrame =
false;
1394 bool showPlacementPriorityFrame =
false;
1395 bool showOffsetTypeFrame =
false;
1396 bool showOffsetFrame =
false;
1397 bool showDistanceFrame =
false;
1398 bool showMaximumDistanceFrame =
false;
1399 bool showPrioritizationFrame =
false;
1400 bool showRotationFrame =
false;
1401 bool showMaxCharAngleFrame =
false;
1406 bool enableMultiLinesFrame =
true;
1412 showDistanceFrame =
true;
1413 showMaximumDistanceFrame =
true;
1421 showQuadrantFrame =
true;
1422 showFixedQuadrantFrame =
true;
1423 showOffsetFrame =
true;
1424 showRotationFrame =
true;
1428 showDistanceFrame =
true;
1429 showMaximumDistanceFrame =
true;
1430 showPlacementPriorityFrame =
true;
1431 showPrioritizationFrame =
true;
1432 showOffsetTypeFrame =
true;
1439 showLineFrame =
true;
1440 showDistanceFrame =
true;
1443 const bool offline = chkLineAbove->isChecked() || chkLineBelow->isChecked();
1444 chkLineOrientationDependent->setEnabled( offline );
1445 mPlacementDistanceFrame->setEnabled( offline );
1449 showMaxCharAngleFrame = isCurved;
1451 enableMultiLinesFrame = !isCurved;
1456 showDistanceFrame =
true;
1459 mPlacementLineFrame->setVisible( showLineFrame );
1460 mPlacementPolygonFrame->setVisible( showPolygonPlacementOptions );
1461 mPlacementCentroidFrame->setVisible( showCentroidFrame );
1462 mPlacementQuadrantFrame->setVisible( showQuadrantFrame );
1463 mPlacementFixedQuadrantFrame->setVisible( showFixedQuadrantFrame );
1464 mPlacementCartographicFrame->setVisible( showPlacementPriorityFrame );
1465 mPlacementOffsetFrame->setVisible( showOffsetFrame );
1466 mPlacementDistanceFrame->setVisible( showDistanceFrame );
1467 mPlacementMaximumDistanceFrame->setVisible( showMaximumDistanceFrame );
1468 mPlacementPrioritizationFrame->setVisible( showPrioritizationFrame );
1469 mPlacementOffsetTypeFrame->setVisible( showOffsetTypeFrame );
1470 mPlacementRotationFrame->setVisible( showRotationFrame );
1475 mPlacementMaxCharAngleFrame->setVisible( showMaxCharAngleFrame );
1477 mMultiLinesFrame->setEnabled( enableMultiLinesFrame );
1481 switch ( currentPlacement )
1485 helperText = tr(
"Arranges label candidates in a clockwise circle around the feature, preferring placements to the top-right of the feature." );
1487 helperText = tr(
"Arranges label candidates in a cluster around the feature's centroid, preferring placements directly over the centroid." );
1491 helperText = tr(
"Arranges label candidates directly over the feature or at a preset offset from the feature." );
1493 helperText = tr(
"Arranges label candidates directly over the feature's centroid, or at a preset offset from the centroid." );
1497 helperText = tr(
"Arranges label candidates parallel to a generalised line representing the feature. Placements which fall over straighter portions of the line are preferred." );
1499 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." );
1503 helperText = tr(
"Arranges candidates following the curvature of a line feature. Placements which fall over straighter portions of the line are preferred." );
1507 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." );
1509 helperText = tr(
"Label candidates are arranged horizontally along the length of the feature." );
1513 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." );
1517 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." );
1521 helperText = tr(
"Arranges candidates following the curvature of the feature's perimeter. Placements which fall over straighter portions of the perimeter are preferred." );
1525 helperText = tr(
"Label candidates are placed outside of the features, preferring placements which give greatest visual association between the label and the feature." );
1528 mPlacementModeDescriptionLabel->setText( QStringLiteral(
"<i>%1</i>" ).arg( helperText ) );
1531void QgsTextFormatWidget::populateFontCapitalsComboBox()
1536#if defined(HAS_KDE_QT5_SMALL_CAPS_FIX) || QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
1546void QgsTextFormatWidget::populateFontStyleComboBox()
1548 mFontStyleComboBox->clear();
1549 const QStringList styles = mFontDB.styles( mRefFont.family() );
1550 const auto constStyles = styles;
1551 for (
const QString &style : constStyles )
1553 mFontStyleComboBox->addItem( style );
1556 QString targetStyle = mFontDB.styleString( mRefFont );
1557 if ( !styles.contains( targetStyle ) )
1560 targetStyle = QFontInfo( f ).styleName();
1561 mRefFont.setStyleName( targetStyle );
1564 const int stylIndx = mFontStyleComboBox->findText( targetStyle );
1565 if ( stylIndx > -1 )
1570 mFontStyleComboBox->setCurrentIndex( curIndx );
1573void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged(
double d )
1575 mRefFont.setPointSizeF( d );
1576 updateFont( mRefFont );
1579void QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged(
const QFont &f )
1582 updateFont( mRefFont );
1585void QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged(
const QString &text )
1588 updateFont( mRefFont );
1591void QgsTextFormatWidget::mFontUnderlineBtn_toggled(
bool ckd )
1593 mRefFont.setUnderline( ckd );
1594 updateFont( mRefFont );
1597void QgsTextFormatWidget::mFontStrikethroughBtn_toggled(
bool ckd )
1599 mRefFont.setStrikeOut( ckd );
1600 updateFont( mRefFont );
1603void QgsTextFormatWidget::kerningToggled(
bool checked )
1605 mRefFont.setKerning( checked );
1606 updateFont( mRefFont );
1609void QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged(
double spacing )
1611 mRefFont.setWordSpacing( spacing );
1612 updateFont( mRefFont );
1615void QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged(
double spacing )
1617 mRefFont.setLetterSpacing( QFont::AbsoluteSpacing, spacing );
1618 updateFont( mRefFont );
1621void QgsTextFormatWidget::mFontSizeUnitWidget_changed()
1626 mFontLimitPixelChkBox->setChecked(
false );
1632 mFontLimitPixelChkBox->setChecked(
true );
1634 updateFont( mRefFont );
1637void QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged(
int px )
1640 mFontMaxPixelSpinBox->setMinimum( px );
1641 mFontMaxPixelSpinBox->update();
1644void QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged(
int px )
1647 if ( px < mFontMinPixelSpinBox->value() )
1649 mFontMaxPixelSpinBox->blockSignals(
true );
1650 mFontMaxPixelSpinBox->setValue( mFontMinPixelSpinBox->value() );
1651 mFontMaxPixelSpinBox->blockSignals(
false );
1653 mFontMaxPixelSpinBox->setMinimum( mFontMinPixelSpinBox->value() );
1656void QgsTextFormatWidget::mBufferUnitWidget_changed()
1658 updateFont( mRefFont );
1661void QgsTextFormatWidget::mMaskBufferUnitWidget_changed()
1663 updateFont( mRefFont );
1666void QgsTextFormatWidget::mCoordXDDBtn_changed()
1668 updateDataDefinedAlignment();
1671void QgsTextFormatWidget::mCoordXDDBtn_activated(
bool isActive )
1676 mCoordPointDDBtn->setActive(
false );
1679void QgsTextFormatWidget::mCoordYDDBtn_changed()
1681 updateDataDefinedAlignment();
1684void QgsTextFormatWidget::mCoordYDDBtn_activated(
bool isActive )
1689 mCoordPointDDBtn->setActive(
false );
1692void QgsTextFormatWidget::mCoordPointDDBtn_changed()
1694 updateDataDefinedAlignment();
1697void QgsTextFormatWidget::mCoordPointDDBtn_activated(
bool isActive )
1702 mCoordXDDBtn->setActive(
false );
1703 mCoordYDDBtn->setActive(
false );
1706void QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged(
int )
1714 showBackgroundRadius( isRect );
1716 mShapeSVGPathFrame->setVisible( isSVG );
1717 mBackgroundMarkerSymbolButton->setVisible( isMarker );
1718 mBackgroundFillSymbolButton->setVisible( !isSVG && !isMarker );
1722 mShapeSizeYLabel->setVisible( !isSVG && !isMarker );
1723 mShapeSizeYSpnBx->setVisible( !isSVG && !isMarker );
1724 mShapeSizeYDDBtn->setVisible( !isSVG && !isMarker );
1725 mShapeSizeXLabel->setText( tr(
"Size%1" ).arg( !isSVG && !isMarker ? tr(
" X" ) : QString() ) );
1728 mShapeFillColorBtn->setAllowOpacity( !isSVG );
1729 mShapeFillColorBtn->setButtonBackground();
1730 mShapeStrokeColorBtn->setAllowOpacity( !isSVG );
1731 mShapeStrokeColorBtn->setButtonBackground();
1734 mShapeFillColorLabel->setVisible( isSVG );
1735 mShapeFillColorLabel->setEnabled( isSVG );
1736 mShapeFillColorBtn->setVisible( isSVG );
1737 mShapeFillColorBtn->setEnabled( isSVG );
1738 mShapeFillColorDDBtn->setVisible( isSVG );
1739 mShapeFillColorDDBtn->setEnabled( isSVG );
1740 mShapeStrokeColorLabel->setVisible( isSVG );
1741 mShapeStrokeColorLabel->setEnabled( isSVG );
1742 mShapeStrokeColorBtn->setVisible( isSVG );
1743 mShapeStrokeColorBtn->setEnabled( isSVG );
1744 mShapeStrokeColorDDBtn->setVisible( isSVG );
1745 mShapeStrokeColorDDBtn->setEnabled( isSVG );
1746 mShapeStrokeWidthLabel->setVisible( isSVG );
1747 mShapeStrokeWidthLabel->setEnabled( isSVG );
1748 mShapeStrokeWidthSpnBx->setVisible( isSVG );
1749 mShapeStrokeWidthSpnBx->setEnabled( isSVG );
1750 mShapeStrokeWidthDDBtn->setVisible( isSVG );
1751 mShapeStrokeWidthDDBtn->setEnabled( isSVG );
1754 mShapeSVGParamsBtn->setVisible( isSVG );
1757 updateSvgWidgets( mShapeSVGPathLineEdit->text() );
1761 mShapeSVGUnitsLabel->setVisible( isSVG );
1762 mShapeStrokeWidthUnitWidget->setVisible(
false );
1763 mShapeStrokeUnitsDDBtn->setVisible(
false );
1764 mShapeStrokeUnitsDDBtn->setEnabled(
false );
1766 updateAvailableShadowPositions();
1769void QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged(
const QString &text )
1771 updateSvgWidgets( text );
1776 const int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) +
1777 ( chkLineBelow->isChecked() ? 1 : 0 ) +
1778 ( chkLineOn->isChecked() ? 1 : 0 );
1780 if ( numOptionsChecked == 1 )
1783 chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
1784 chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
1785 chkLineOn->setEnabled( !chkLineOn->isChecked() );
1789 chkLineAbove->setEnabled(
true );
1790 chkLineBelow->setEnabled(
true );
1791 chkLineOn->setEnabled(
true );
1801void QgsTextFormatWidget::previewScaleChanged(
double scale )
1803 lblFontPreview->setScale( scale );
1806void QgsTextFormatWidget::updateSvgWidgets(
const QString &svgPath )
1808 if ( mShapeSVGPathLineEdit->text() != svgPath )
1810 mShapeSVGPathLineEdit->setText( svgPath );
1813 QString resolvedPath;
1814 bool validSVG =
true;
1815 if ( ! svgPath.startsWith( QLatin1String(
"base64:" ), Qt::CaseInsensitive ) )
1818 validSVG = QFileInfo::exists( resolvedPath );
1822 resolvedPath = svgPath;
1827 mShapeSVGPathLineEdit->setStyleSheet( !validSVG ? QStringLiteral(
"QLineEdit{ color: rgb(225, 0, 0); }" ) : QString() );
1828 mShapeSVGPathLineEdit->setToolTip( !validSVG ? tr(
"File not found" ) : resolvedPath );
1830 QColor fill, stroke;
1831 double strokeWidth = 0.0;
1832 bool fillParam =
false, strokeParam =
false, strokeWidthParam =
false;
1838 mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || strokeParam || strokeWidthParam ) );
1840 mShapeFillColorLabel->setEnabled( validSVG && fillParam );
1841 mShapeFillColorBtn->setEnabled( validSVG && fillParam );
1842 mShapeFillColorDDBtn->setEnabled( validSVG && fillParam );
1843 if ( mLoadSvgParams && validSVG && fillParam )
1844 mShapeFillColorBtn->setColor( fill );
1846 mShapeStrokeColorLabel->setEnabled( validSVG && strokeParam );
1847 mShapeStrokeColorBtn->setEnabled( validSVG && strokeParam );
1848 mShapeStrokeColorDDBtn->setEnabled( validSVG && strokeParam );
1849 if ( mLoadSvgParams && validSVG && strokeParam )
1850 mShapeStrokeColorBtn->setColor( stroke );
1852 mShapeStrokeWidthLabel->setEnabled( validSVG && strokeWidthParam );
1853 mShapeStrokeWidthSpnBx->setEnabled( validSVG && strokeWidthParam );
1854 mShapeStrokeWidthDDBtn->setEnabled( validSVG && strokeWidthParam );
1855 if ( mLoadSvgParams && validSVG && strokeWidthParam )
1856 mShapeStrokeWidthSpnBx->setValue( strokeWidth );
1862 mShapeSVGUnitsLabel->setEnabled( validSVG && strokeWidthParam );
1865void QgsTextFormatWidget::updateAvailableShadowPositions()
1867 if ( mShadowUnderCmbBx->count() == 0
1873 mShadowUnderCmbBx->clear();
1881 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( currentPlacement ) );
1882 if ( mShadowUnderCmbBx->currentIndex() == -1 )
1883 mShadowUnderCmbBx->setCurrentIndex( 0 );
1887void QgsTextFormatWidget::updateProperty()
1895void QgsTextFormatWidget::createAuxiliaryField()
1927 property.setActive(
true );
1936void QgsTextFormatWidget::updateShapeFrameStatus()
1938 mShapeFrame->setEnabled( mShapeDrawDDBtn->isActive() || mShapeDrawChkBx->isChecked() );
1941void QgsTextFormatWidget::updateBufferFrameStatus()
1943 mBufferFrame->setEnabled( mBufferDrawDDBtn->isActive() || mBufferDrawChkBx->isChecked() );
1946void QgsTextFormatWidget::updateShadowFrameStatus()
1948 mShadowFrame->setEnabled( mShadowDrawDDBtn->isActive() || mShadowDrawChkBx->isChecked() );
1951void QgsTextFormatWidget::updateCalloutFrameStatus()
1953 mCalloutFrame->setEnabled( mCalloutDrawDDBtn->isActive() || mCalloutsDrawCheckBox->isChecked() );
1956void QgsTextFormatWidget::updateDataDefinedAlignment()
1959 mCoordAlignmentFrame->setEnabled( ( mCoordXDDBtn->isActive() && mCoordYDDBtn->isActive() )
1960 || mCoordPointDDBtn->isActive() );
1963void QgsTextFormatWidget::overlapModeChanged()
1965 QString description;
1969 description = tr(
"Overlapping labels will never be placed for the layer, even if it means some labels will be missing. (To see unplaced labels use the \"Show Unplaced Labels\" toolbar action.)" );
1972 description = tr(
"If a label cannot otherwise be placed for a feature then an overlapping label is permitted." );
1975 description = tr(
"Labels from this layer may freely overlap other labels or label obstacles without penalty." );
1979 mOverlapModeDescriptionLabel->setText( QStringLiteral(
"<i>%1</i>" ).arg( description ) );
1984 if ( name.isEmpty() )
2027 saveDlg.
setDefaultTags( mTextFormatsListWidget->currentTagFilter() );
2028 if ( !saveDlg.exec() )
2031 if ( saveDlg.
name().isEmpty() )
2041 const int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
2042 tr(
"Format with name '%1' already exists. Overwrite?" )
2043 .arg( saveDlg.
name() ),
2044 QMessageBox::Yes | QMessageBox::No );
2045 if ( res != QMessageBox::Yes )
2052 const QStringList symbolTags = saveDlg.
tags().split(
',' );
2059void QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked()
2062 svgDlg.setWindowTitle( tr(
"Select SVG file" ) );
2063 svgDlg.svgSelector()->setSvgPath( mShapeSVGPathLineEdit->text().trimmed() );
2065 if ( svgDlg.exec() == QDialog::Accepted )
2067 const QString svgPath = svgDlg.svgSelector()->currentSvgPath();
2068 if ( !svgPath.isEmpty() )
2070 mShapeSVGPathLineEdit->setText( svgPath );
2076void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
2078 const QString svgPath = mShapeSVGPathLineEdit->text();
2079 mLoadSvgParams =
true;
2080 updateSvgWidgets( svgPath );
2081 mLoadSvgParams =
false;
2084void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged(
int index )
2090void QgsTextFormatWidget::mPreviewTextEdit_textChanged(
const QString &text )
2092 lblFontPreview->setText( text );
2096void QgsTextFormatWidget::mPreviewTextBtn_clicked()
2098 mPreviewTextEdit->setText( QStringLiteral(
"Lorem Ipsum" ) );
2102void QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged(
const QColor &color )
2107void QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked()
2109 bool gotChar =
false;
2111 const QChar initial = !mDirectSymbLeftLineEdit->text().isEmpty() ? mDirectSymbLeftLineEdit->text().at( 0 ) : QChar();
2112 const QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
2117 if ( !dirSymb.isNull() )
2118 mDirectSymbLeftLineEdit->setText( QString( dirSymb ) );
2121void QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked()
2123 bool gotChar =
false;
2124 const QChar initial = !mDirectSymbRightLineEdit->text().isEmpty() ? mDirectSymbRightLineEdit->text().at( 0 ) : QChar();
2125 const QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
2130 if ( !dirSymb.isNull() )
2131 mDirectSymbRightLineEdit->setText( QString( dirSymb ) );
2134void QgsTextFormatWidget::chkLineOrientationDependent_toggled(
bool active )
2138 chkLineAbove->setText( tr(
"Left of line" ) );
2139 chkLineBelow->setText( tr(
"Right of line" ) );
2143 chkLineAbove->setText( tr(
"Above line" ) );
2144 chkLineBelow->setText( tr(
"Below line" ) );
2149void QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked()
2164 if ( dlg.exec() == QDialog::Accepted )
2171void QgsTextFormatWidget::configureTabStops()
2179 widget->
setUnit( mTabDistanceUnitWidget->unit() );
2192 dlg.setUnit( mTabDistanceUnitWidget->unit() );
2193 if ( dlg.exec() == QDialog::Accepted )
2202void QgsTextFormatWidget::showBackgroundRadius(
bool show )
2204 mShapeRadiusLabel->setVisible( show );
2205 mShapeRadiusXDbSpnBx->setVisible( show );
2207 mShapeRadiusYDbSpnBx->setVisible( show );
2209 mShapeRadiusUnitWidget->setVisible( show );
2211 mShapeRadiusDDBtn->setVisible( show );
2212 mShapeRadiusUnitsDDBtn->setVisible( show );
2218 return *lExpressionContext;
2245 if ( mGeometryGeneratorGroupBox->isChecked() )
2259 : QDialog( parent, fl )
2261 setWindowTitle( tr(
"Text Settings" ) );
2264 mFormatWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
2266 QVBoxLayout *layout =
new QVBoxLayout(
this );
2267 layout->addWidget( mFormatWidget );
2269 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, Qt::Horizontal,
this );
2270 layout->addWidget( mButtonBox );
2272 setLayout( layout );
2275 connect( mButtonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked,
this, &QDialog::accept );
2276 connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked,
this, &QDialog::reject );
2277 connect( mButtonBox->button( QDialogButtonBox::Help ), &QAbstractButton::clicked,
this, &QgsTextFormatDialog::showHelp );
2282 return mFormatWidget->
format();
2285void QgsTextFormatDialog::showHelp()
2287 QgsHelp::openHelp( QStringLiteral(
"style_library/label_settings.html#formatting-the-label-text" ) );
2303 mFormatWidget = qobject_cast< QgsTextFormatWidget * >(
widget() );
2306 if ( !mBlockSignals )
2313 return mFormatWidget->
format();
2318 mBlockSignals =
true;
2320 mBlockSignals =
false;
@ FromPoint
Offset distance applies from point geometry.
@ FromSymbolBounds
Offset distance applies from rendered symbol bounds.
@ PreferCloser
Prefer closer labels, falling back to alternate positions before larger distances.
@ PreferPositionOrdering
Prefer labels follow position ordering, falling back to more distance labels before alternate positio...
LabelPlacement
Placement modes which determine how label candidates are generated for a feature.
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
@ Curved
Arranges candidates following the curvature of a line feature. Applies to line layers only.
@ 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'...
@ Free
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...
@ OrderedPositionsAroundPoint
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
@ Horizontal
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
@ PerimeterCurved
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only.
@ OutsidePolygons
Candidates are placed outside of polygon boundaries. Applies to polygon layers only.
Capitalization
String capitalization options.
@ AllSmallCaps
Force all characters to small caps.
@ 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.
@ ForceFirstLetterToCapital
Convert just the first letter of each word to uppercase, leave the rest untouched.
@ AllUppercase
Convert all characters to uppercase.
TextOrientation
Text orientations.
@ Vertical
Vertically oriented text.
@ RotationBased
Horizontally or vertically oriented text based on rotation (only available for map labeling)
@ Horizontal
Horizontally oriented text.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
@ Percentage
Percentage of another measurement (e.g., canvas size, feature size)
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MetersInMapUnits
Meters value as Map units.
LabelOverlapHandling
Label overlap handling.
@ AllowOverlapAtNoCost
Labels may freely overlap other labels, at no cost.
@ AllowOverlapIfRequired
Avoids overlapping labels when possible, but permit overlaps if labels for features cannot otherwise ...
@ PreventOverlap
Do not allow labels to overlap other labels.
@ FlipUpsideDownLabels
Upside-down labels (90 <= angle < 270) are shown upright.
@ AlwaysAllowUpsideDown
Show upside down for all labels, including dynamic ones.
@ AllowUpsideDownWhenRotationIsDefined
Show upside down when rotation is layer- or data-defined.
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...
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
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 QFont createFont(const QString &family, int pointSize=-1, int weight=-1, bool italic=false)
Creates a font with the specified family.
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 setFontFamily(QFont &font, const QString &family)
Sets the family for a font object.
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(Qgis::WkbType 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.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
Base class for all map layer types.
The QgsMapSettings class contains configuration for rendering of the map.
Qgis::DistanceUnit mapUnits() const
Returns the units of the map's geographical coordinates - used for scale calculation.
double scale() const
Returns the calculated map scale.
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.
Property
Data definable properties.
@ PositionX
X-coordinate data defined label position.
@ LinePlacementOptions
Line placement flags.
@ FontSizeUnit
Font size units.
@ LabelRotation
Label rotation.
@ FontStyle
Font style name.
@ Italic
Use italic style.
@ ShapeOpacity
Shape opacity.
@ AllowDegradedPlacement
Allow degraded label placements.
@ MaskEnabled
Whether the mask is enabled.
@ PredefinedPositionOrder
@ OverlapHandling
Overlap handling technique.
@ PositionY
Y-coordinate data defined label position.
@ MaximumScale
Maximum map scale (ie most "zoomed in")
@ Vali
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
@ MinimumScale
Minimum map scale (ie most "zoomed out")
@ FontStretchFactor
Font stretch factor, since QGIS 3.24.
@ PolygonLabelOutside
Whether labels outside a polygon feature are permitted, or should be forced.
@ BufferOpacity
Buffer opacity.
@ MaskJoinStyle
Mask join style.
@ Strikeout
Use strikeout.
@ LabelAllParts
Whether all parts of multi-part features should be labeled.
@ Underline
Use underline.
@ FontBlendMode
Text blend mode.
@ FontCase
Label text case.
@ Hali
Horizontal alignment for data defined label position (Left, Center, Right)
@ MaskOpacity
Mask opacity.
@ OverrunDistance
Distance which labels can extend past either end of linear features.
@ MaskBufferUnit
Mask buffer size unit.
@ FontOpacity
Text opacity.
@ FontWordSpacing
Word spacing.
@ CalloutDraw
Show callout.
@ MaskBufferSize
Mask buffer size.
@ FontLetterSpacing
Letter spacing.
@ TabStopDistance
Tab stop distance, since QGIS 3.38.
@ ShadowOpacity
Shadow opacity.
@ PositionPoint
Point-coordinate data defined label position.
@ MaximumDistance
Maximum distance of label from feature.
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.
QgsStyle * styleAtPath(const QString &path)
Returns a reference to the style database associated with the project with matching file path.
QVector< double > mapScales() const
Returns the list of custom project map scales.
static QgsProject * instance()
Returns the QgsProject singleton instance.
const QgsProjectStyleSettings * styleSettings() const
Returns the project's style settings, which contains settings and properties relating to how a QgsPro...
const QgsProjectViewSettings * viewSettings() const
Returns the project's view settings, which contains settings and properties relating to how a QgsProj...
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
QSet< int > propertyKeys() const final
Returns a list of property keys contained within the collection.
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
bool isActive(int key) const final
Returns true if the collection contains an active property with the specified key.
QgsProperty property(int key) const final
Returns a matching property from the collection, if one exists.
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).
QgsStyle * destinationStyle()
Returns the destination style database.
QgsTextFormat textFormat(const QString &name) const
Returns the text format with the specified name.
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
@ ColorrampEntity
Color ramps.
@ LegendPatchShapeEntity
Legend patch shape.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
QStringList labelSettingsNames() const
Returns a list of names of label settings in the style.
static QgsTextFormat defaultTextFormatForProject(QgsProject *project, QgsStyle::TextFormatContext context=QgsStyle::TextFormatContext::Labeling)
Returns the default text format to use for new text based objects for the specified project,...
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(Qgis::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
A dialog to enter a custom dash space pattern for lines.
Container for settings relating to a text background object.
QgsMapUnitScale strokeWidthMapUnitScale() const
Returns the map unit scale object for the shape stroke width.
void setRadiiUnit(Qgis::RenderUnit units)
Sets the units used for the shape's radii.
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.
Qgis::RenderUnit radiiUnit() const
Returns the units used for the shape's radii.
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.
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.
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...
Qgis::RenderUnit strokeWidthUnit() const
Returns the units used for the shape's stroke width.
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 setSizeUnit(Qgis::RenderUnit unit)
Sets the units used for the shape's size.
Qgis::RenderUnit offsetUnit() const
Returns the units used for the shape's offset.
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).
Qgis::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.
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 setStrokeWidthUnit(Qgis::RenderUnit units)
Sets the units used for the shape's stroke width.
void setOffsetUnit(Qgis::RenderUnit units)
Sets the units used for the shape's offset.
void setOffset(QPointF offset)
Sets the offset used for drawing the background shape.
void setSize(QSizeF size)
Sets the size of the background shape.
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.
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.
Qgis::RenderUnit sizeUnit() const
Returns the units for the buffer size.
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.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units used for the buffer size.
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.
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 setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
void setSize(double size)
Sets the size of the buffer.
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...
QgsTextFormatDialog(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QgsMapLayer *layer=nullptr)
Constructor for QgsTextFormatDialog.
void setFormat(const QgsTextFormat &format)
Sets the format to show in the widget.
QgsTextFormatPanelWidget(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsMapLayer *layer=nullptr)
Constructor for QgsTextFormatPanelWidget.
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...
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.
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(const QgsTextFormat &format=QgsTextFormat(), QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsMapLayer *layer=nullptr)
Constructor for QgsTextFormatWidget.
~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.
Qgis::GeometryType mGeomType
Geometry type for layer, if known.
QButtonGroup * mDirectSymbBtnGrp
Symbol direction button group.
void updateWidgetForFormat(const QgsTextFormat &format)
Updates the widget's state to reflect the settings in a QgsTextFormat.
QList< QgsTextFormat::Tab > mTabPositions
Tab positions.
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.
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.
virtual void setFormatFromStyle(const QString &name, QgsStyle::StyleEntity type, const QString &stylePath)
Sets the current text settings from a style entry.
Qgis::GeometryType labelGeometryType() const
Returns the geometry type which will be used by the labeling engine when registering labels for the l...
QgsMapLayer * mLayer
Associated vector layer.
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.
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 setOrientation(Qgis::TextOrientation orientation)
Sets the orientation for the text.
void setFont(const QFont &font)
Sets the font used for rendering text.
QList< QgsTextFormat::Tab > tabPositions() const
Returns the list of tab positions for tab stops.
double lineHeight() const
Returns the line height for text.
double tabStopDistance() const
Returns the distance for tab stops.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the size of rendered text.
int stretchFactor() const
Returns the text's stretch factor.
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 setTabStopDistanceUnit(Qgis::RenderUnit unit)
Sets the unit used for the tab stop distance.
void setOpacity(double opacity)
Sets the text's opacity.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing 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...
void setLineHeightUnit(Qgis::RenderUnit unit)
Sets the unit for the line height for text.
Qgis::RenderUnit lineHeightUnit() const
Returns the units for the line height for text.
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 setTabStopDistanceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the tab stop distance.
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
Qgis::RenderUnit sizeUnit() const
Returns the units for the size of rendered text.
bool allowHtmlFormatting() const
Returns true if text should be treated as a HTML document and HTML tags should be used for formatting...
double opacity() const
Returns the text's opacity.
void setTabStopDistance(double distance)
Sets the distance for tab stops.
Qgis::TextOrientation orientation() const
Returns the orientation of the text.
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 setTabPositions(const QList< QgsTextFormat::Tab > &positions)
Sets the list of tab positions for tab stops.
Qgis::RenderUnit tabStopDistanceUnit() const
Returns the units for the tab stop distance.
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.
QgsMapUnitScale tabStopDistanceMapUnitScale() const
Returns the map unit scale object for the tab stop distance.
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.
Qgis::RenderUnit sizeUnit() const
Returns the units for the buffer size.
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.
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.
double opacity() const
Returns the mask's opacity.
bool enabled() const
Returns whether the mask is enabled.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units used for the buffer size.
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.
void setBlurRadiusUnit(Qgis::RenderUnit units)
Sets the units used for the shadow's blur radius.
bool enabled() const
Returns whether the shadow is enabled.
void setOffsetUnit(Qgis::RenderUnit units)
Sets the units used for the shadow's offset.
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
Qgis::RenderUnit offsetUnit() const
Returns the units used for the shadow's offset.
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.
Qgis::RenderUnit blurRadiusUnit() const
Returns the units used for the shadow's blur radius.
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.
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.
double blurRadius() const
Returns the blur radius for the shadow.
void setBlurRadius(double blurRadius)
Sets the blur radius for the shadow.
void setEnabled(bool enabled)
Sets whether the text shadow will be drawn.
QList< Qgis::RenderUnit > RenderUnitList
List of render units.
Represents a vector layer which manages a vector based data sets.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
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.