39 #include <QButtonGroup> 40 #include <QMessageBox> 44 , mMapCanvas( mapCanvas )
48 setWidgetMode(
Text );
62 setWidgetMode( mode );
65 void QgsTextFormatWidget::initWidget()
68 connect( mShapeSVGPathLineEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged );
69 connect( mFontSizeSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontSizeSpinBox_valueChanged );
70 connect( mFontCapitalsComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mFontCapitalsComboBox_currentIndexChanged );
71 connect( mFontFamilyCmbBx, &QFontComboBox::currentFontChanged,
this, &QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged );
72 connect( mFontStyleComboBox, &QComboBox::currentTextChanged,
this, &QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged );
73 connect( mFontUnderlineBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontUnderlineBtn_toggled );
74 connect( mFontStrikethroughBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontStrikethroughBtn_toggled );
75 connect( mFontWordSpacingSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged );
76 connect( mFontLetterSpacingSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged );
78 connect( mFontMinPixelSpinBox, static_cast <
void ( QSpinBox::* )(
int ) > ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged );
79 connect( mFontMaxPixelSpinBox, static_cast <
void ( QSpinBox::* )(
int ) > ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged );
84 connect( mShapeTypeCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged );
85 connect( mShapeRotationCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged );
86 connect( mShapeSVGParamsBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGParamsBtn_clicked );
87 connect( mShapeSVGSelectorBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked );
88 connect( mPreviewTextEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mPreviewTextEdit_textChanged );
89 connect( mPreviewTextBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mPreviewTextBtn_clicked );
91 connect( mDirectSymbLeftToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked );
92 connect( mDirectSymbRightToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked );
93 connect( chkLineOrientationDependent, &QCheckBox::toggled,
this, &QgsTextFormatWidget::chkLineOrientationDependent_toggled );
94 connect( mToolButtonConfigureSubstitutes, &QToolButton::clicked,
this, &QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked );
95 connect( mKerningCheckBox, &QCheckBox::toggled,
this, &QgsTextFormatWidget::kerningToggled );
98 mOptionsTab->setIconSize( QSize( iconSize, iconSize ) );
102 mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
103 mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
104 mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );
105 mPointOffsetLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
106 mPointOffsetOver ->setIconSize( QSize( iconSize32, iconSize18 ) );
107 mPointOffsetRight->setIconSize( QSize( iconSize32, iconSize18 ) );
108 mPointOffsetBelowLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
109 mPointOffsetBelow->setIconSize( QSize( iconSize32, iconSize18 ) );
110 mPointOffsetBelowRight->setIconSize( QSize( iconSize32, iconSize18 ) );
111 mLabelMinScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomOut.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
112 mLabelMaxScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomIn.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
115 mFontUnderlineBtn->setMinimumSize( buttonSize, buttonSize );
116 mFontUnderlineBtn->setMaximumSize( buttonSize, buttonSize );
117 mFontStrikethroughBtn->setMinimumSize( buttonSize, buttonSize );
118 mFontStrikethroughBtn->setMaximumSize( buttonSize, buttonSize );
119 mFontBoldBtn->setMinimumSize( buttonSize, buttonSize );
120 mFontBoldBtn->setMaximumSize( buttonSize, buttonSize );
121 mFontItalicBtn->setMinimumSize( buttonSize, buttonSize );
122 mFontItalicBtn->setMaximumSize( buttonSize, buttonSize );
124 mPreviewScaleComboBox->setMapCanvas(
mMapCanvas );
125 mPreviewScaleComboBox->setShowCurrentScaleButton(
true );
128 const auto unitWidgets = findChildren<QgsUnitSelectionWidget *>();
129 for ( QgsUnitSelectionWidget *unitWidget : unitWidgets )
159 mFontLineHeightSpinBox->setClearValue( 1.0 );
160 mShapeRotationDblSpnBx->setClearValue( 0.0 );
161 mShapeOffsetXSpnBx->setClearValue( 0.0 );
162 mShapeOffsetYSpnBx->setClearValue( 0.0 );
163 mPointOffsetXSpinBox->setClearValue( 0.0 );
164 mPointOffsetYSpinBox->setClearValue( 0.0 );
165 mPointAngleSpinBox->setClearValue( 0.0 );
166 mFontLetterSpacingSpinBox->setClearValue( 0.0 );
167 mFontWordSpacingSpinBox->setClearValue( 0.0 );
168 mZIndexSpinBox->setClearValue( 0.0 );
169 mLineDistanceSpnBx->setClearValue( 0.0 );
181 updateAvailableShadowPositions();
184 mBackgroundSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
185 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
186 mBackgroundSymbolButton->setMapCanvas(
mMapCanvas );
190 mRefFont = lblFontPreview->font();
193 connect( mShadowOffsetAngleDial, &QAbstractSlider::valueChanged, mShadowOffsetAngleSpnBx, &QSpinBox::setValue );
194 connect( mShadowOffsetAngleSpnBx, static_cast <
void ( QSpinBox::* )(
int ) > ( &QSpinBox::valueChanged ), mShadowOffsetAngleDial, &QAbstractSlider::setValue );
195 connect( mLimitLabelChkBox, &QAbstractButton::toggled, mLimitLabelSpinBox, &QWidget::setEnabled );
196 connect( mCheckBoxSubstituteText, &QAbstractButton::toggled, mToolButtonConfigureSubstitutes, &QWidget::setEnabled );
206 populateFontCapitalsComboBox();
209 mPreviewBackgroundBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
210 mPreviewBackgroundBtn->setContext( QStringLiteral(
"labeling" ) );
211 mPreviewBackgroundBtn->setColor( QColor( 255, 255, 255 ) );
212 btnTextColor->setColorDialogTitle( tr(
"Select Text Color" ) );
213 btnTextColor->setContext( QStringLiteral(
"labeling" ) );
214 btnTextColor->setDefaultColor( Qt::black );
215 btnBufferColor->setColorDialogTitle( tr(
"Select Buffer Color" ) );
216 btnBufferColor->setContext( QStringLiteral(
"labeling" ) );
217 btnBufferColor->setDefaultColor( Qt::white );
218 mShapeStrokeColorBtn->setColorDialogTitle( tr(
"Select Stroke Color" ) );
219 mShapeStrokeColorBtn->setContext( QStringLiteral(
"labeling" ) );
220 mShapeFillColorBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
221 mShapeFillColorBtn->setContext( QStringLiteral(
"labeling" ) );
222 mShadowColorBtn->setColorDialogTitle( tr(
"Select Shadow Color" ) );
223 mShadowColorBtn->setContext( QStringLiteral(
"labeling" ) );
224 mShadowColorBtn->setDefaultColor( Qt::black );
226 mFontColorDDBtn->registerLinkedWidget( btnTextColor );
227 mBufferColorDDBtn->registerLinkedWidget( btnBufferColor );
228 mShapeStrokeColorDDBtn->registerLinkedWidget( mShapeStrokeColorBtn );
229 mShapeFillColorDDBtn->registerLinkedWidget( mShapeFillColorBtn );
230 mShadowColorDDBtn->registerLinkedWidget( mShadowColorBtn );
294 const auto groupBoxes = findChildren<QgsCollapsibleGroupBox *>();
297 grpbox->setSettingGroup( QStringLiteral(
"mAdvLabelingDlg" ) );
303 mLabelingOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect,
false );
308 QSizePolicy policy( mLabelingOptionsListFrame->sizePolicy() );
309 policy.setHorizontalStretch( 0 );
310 mLabelingOptionsListFrame->setSizePolicy( policy );
311 if ( !settings.
contains( QStringLiteral(
"/Windows/Labeling/OptionsSplitState" ) ) )
314 QList<int> splitsizes;
316 mLabelingOptionsSplitter->setSizes( splitsizes );
320 connect( mLabelStackedWidget, &QStackedWidget::currentChanged,
this, &QgsTextFormatWidget::optionsStackedWidget_CurrentChanged );
323 mFontPreviewSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ) ).toByteArray() );
324 mLabelingOptionsSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ) ).toByteArray() );
326 mLabelingOptionsListWidget->setCurrentRow( settings.
value( QStringLiteral(
"Windows/Labeling/Tab" ), 0 ).toInt() );
330 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
334 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
338 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
342 QList<QWidget *> widgets;
343 widgets << btnBufferColor
345 << chkLabelPerFeaturePart
349 << chkLineOrientationDependent
351 << chkPreserveRotation
353 << comboBufferBlendMode
355 << mBufferJoinStyleComboBox
356 << mBufferTranspFillChbx
357 << mBufferOpacityWidget
358 << mCentroidInsideCheckBox
361 << mDirectSymbLeftLineEdit
362 << mDirectSymbRevChkBx
363 << mDirectSymbRightLineEdit
364 << mFitInsidePolygonCheckBox
365 << mFontCapitalsComboBox
366 << mFontLetterSpacingSpinBox
367 << mFontLimitPixelChkBox
368 << mFontLineHeightSpinBox
369 << mFontMaxPixelSpinBox
370 << mFontMinPixelSpinBox
371 << mFontMultiLineAlignComboBox
373 << mFontStyleComboBox
374 << mTextOrientationComboBox
375 << mTextOpacityWidget
376 << mFontWordSpacingSpinBox
378 << mFormatNumDecimalsSpnBx
379 << mFormatNumPlusSignChkBx
381 << mLimitLabelSpinBox
382 << mLineDistanceSpnBx
383 << mLineDistanceUnitWidget
384 << mMaxCharAngleInDSpinBox
385 << mMaxCharAngleOutDSpinBox
387 << mOffsetTypeComboBox
388 << mPalShowAllLabelsForLayerChkBx
389 << mPointAngleSpinBox
390 << mPointOffsetUnitWidget
391 << mPointOffsetXSpinBox
392 << mPointOffsetYSpinBox
393 << mPreviewBackgroundBtn
396 << mRepeatDistanceSpinBox
397 << mRepeatDistanceUnitWidget
398 << mOverrunDistanceSpinBox
399 << mOverrunDistanceUnitWidget
400 << mScaleBasedVisibilityChkBx
406 << mShadowOffsetAngleSpnBx
407 << mShadowOffsetGlobalChkBx
408 << mShadowOffsetSpnBx
409 << mShadowOffsetUnitWidget
410 << mShadowRadiusAlphaChkBx
411 << mShadowRadiusDblSpnBx
412 << mShadowRadiusUnitWidget
414 << mShadowOpacityWidget
417 << mShapeStrokeColorBtn
418 << mShapeStrokeWidthSpnBx
419 << mShapeStrokeWidthUnitWidget
421 << mShapeFillColorBtn
422 << mShapeOffsetXSpnBx
423 << mShapeOffsetYSpnBx
424 << mShapeOffsetUnitWidget
425 << mShapePenStyleCmbBx
426 << mShapeRadiusXDbSpnBx
427 << mShapeRadiusYDbSpnBx
428 << mShapeRotationCmbBx
429 << mShapeRotationDblSpnBx
430 << mShapeRadiusUnitWidget
431 << mShapeSVGPathLineEdit
433 << mShapeSizeUnitWidget
436 << mBackgroundOpacityWidget
441 << mAutoWrapLengthSpinBox
442 << mAutoWrapTypeComboBox
443 << mCentroidRadioVisible
444 << mCentroidRadioWhole
445 << mDirectSymbRadioBtnAbove
446 << mDirectSymbRadioBtnBelow
447 << mDirectSymbRadioBtnLR
448 << mUpsidedownRadioAll
449 << mUpsidedownRadioDefined
450 << mUpsidedownRadioOff
459 << radPolygonHorizontal
460 << radPolygonPerimeter
461 << radPolygonPerimeterCurved
462 << radPredefinedOrder
463 << mFieldExpressionWidget
464 << mCheckBoxSubstituteText
465 << mGeometryGeneratorGroupBox
466 << mGeometryGenerator
467 << mGeometryGeneratorType
468 << mBackgroundSymbolButton
469 << mCalloutsDrawCheckBox
470 << mCalloutStyleComboBox
473 << mMaskJoinStyleComboBox
474 << mMaskBufferSizeSpinBox
475 << mMaskOpacityWidget;
482 connect( mBufferDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
484 updateBufferFrameStatus();
487 connect( mShapeDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
489 updateShapeFrameStatus();
492 connect( mShadowDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
494 updateShadowFrameStatus();
497 mGeometryGeneratorType->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mIconPolygonLayer.svg" ) ), tr(
"Polygon / MultiPolygon" ), QgsWkbTypes::GeometryType::PolygonGeometry );
498 mGeometryGeneratorType->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mIconLineLayer.svg" ) ), tr(
"LineString / MultiLineString" ), QgsWkbTypes::GeometryType::LineGeometry );
499 mGeometryGeneratorType->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mIconPointLayer.svg" ) ), tr(
"Point / MultiPoint" ), QgsWkbTypes::GeometryType::PointGeometry );
502 whileBlocking( mOptionsTab )->setCurrentIndex( mLabelStackedWidget->currentIndex() );
522 toggleDDButtons(
true );
528 toggleDDButtons(
true );
529 delete mLabelingOptionsListWidget->takeItem( 8 );
530 delete mLabelingOptionsListWidget->takeItem( 7 );
531 delete mLabelingOptionsListWidget->takeItem( 6 );
532 delete mLabelingOptionsListWidget->takeItem( 3 );
533 mOptionsTab->removeTab( 8 );
534 mOptionsTab->removeTab( 7 );
535 mOptionsTab->removeTab( 6 );
536 mOptionsTab->removeTab( 5 );
538 frameLabelWith->hide();
539 mDirectSymbolsFrame->hide();
540 mFormatNumFrame->hide();
541 mFormatNumChkBx->hide();
542 mFormatNumDDBtn->hide();
543 mSubstitutionsFrame->hide();
549 void QgsTextFormatWidget::toggleDDButtons(
bool visible )
551 const auto buttons = findChildren< QgsPropertyOverrideButton * >();
554 button->setVisible( visible );
560 mOptionsTab->setVisible( enabled );
561 mOptionsTab->setTabToolTip( 0, tr(
"Text" ) );
562 mOptionsTab->setTabToolTip( 1, tr(
"Formatting" ) );
563 mOptionsTab->setTabToolTip( 2, tr(
"Buffer" ) );
564 mOptionsTab->setTabToolTip( 3, tr(
"Mask" ) );
565 mOptionsTab->setTabToolTip( 4, tr(
"Background" ) );
566 mOptionsTab->setTabToolTip( 5, tr(
"Shadow" ) );
567 mOptionsTab->setTabToolTip( 6, tr(
"Callouts" ) );
568 mOptionsTab->setTabToolTip( 7, tr(
"Placement" ) );
569 mOptionsTab->setTabToolTip( 8, tr(
"Rendering" ) );
571 mLabelingOptionsListFrame->setVisible( !enabled );
572 groupBox_mPreview->setVisible( !enabled );
576 void QgsTextFormatWidget::connectValueChanged(
const QList<QWidget *> &widgets,
const char *slot )
578 const auto constWidgets = widgets;
579 for ( QWidget *widget : constWidgets )
583 connect( w, SIGNAL( changed() ),
this, slot );
587 connect( w, SIGNAL( fieldChanged( QString ) ),
this, slot );
589 else if (
QgsOpacityWidget *w = qobject_cast< QgsOpacityWidget *>( widget ) )
591 connect( w, SIGNAL( opacityChanged(
double ) ),
this, slot );
593 else if (
QgsScaleWidget *w = qobject_cast< QgsScaleWidget *>( widget ) )
595 connect( w, SIGNAL( scaleChanged(
double ) ),
this, slot );
597 else if ( QgsUnitSelectionWidget *w = qobject_cast<QgsUnitSelectionWidget *>( widget ) )
599 connect( w, SIGNAL( changed() ),
this, slot );
601 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
603 connect( w, SIGNAL( currentIndexChanged(
int ) ),
this, slot );
605 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
607 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
609 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
611 connect( w, SIGNAL( valueChanged(
double ) ),
this, slot );
613 else if (
QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
615 connect( w, SIGNAL( colorChanged( QColor ) ),
this, slot );
617 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
619 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
621 else if ( QRadioButton *w = qobject_cast<QRadioButton *>( widget ) )
623 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
625 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
627 connect( w, SIGNAL( textEdited( QString ) ),
this, slot );
629 else if ( QSlider *w = qobject_cast<QSlider *>( widget ) )
631 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
633 else if ( QGroupBox *w = qobject_cast<QGroupBox *>( widget ) )
635 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
639 connect( w, SIGNAL( textChanged() ),
this, slot );
643 QgsLogger::warning( QStringLiteral(
"Could not create connection for widget %1" ).arg( widget->objectName() ) );
674 mDirectSymbDDBtn->registerCheckedWidget( mDirectSymbChkBx );
682 mFormatNumDDBtn->registerCheckedWidget( mFormatNumChkBx );
688 mBufferDrawDDBtn->registerCheckedWidget( mBufferDrawChkBx );
698 mEnableMaskDDBtn->registerCheckedWidget( mEnableMaskChkBx );
706 mShapeDrawDDBtn->registerCheckedWidget( mShapeDrawChkBx );
729 mShadowDrawDDBtn->registerCheckedWidget( mShadowDrawChkBx );
761 QString ddPlaceInfo = tr(
"In edit mode, layer's relevant labeling map tool is:<br>" 762 " Defined attribute field -> <i>enabled</i><br>" 763 " Defined expression -> <i>disabled</i>" );
765 mCoordXDDBtn->setUsageInfo( ddPlaceInfo );
767 mCoordYDDBtn->setUsageInfo( ddPlaceInfo );
769 mCoordAlignmentHDDBtn->setUsageInfo( ddPlaceInfo );
771 mCoordAlignmentVDDBtn->setUsageInfo( ddPlaceInfo );
773 mCoordRotationDDBtn->setUsageInfo( ddPlaceInfo );
776 QString ddScaleVisInfo = tr(
"Value < 0 represents a scale closer than 1:1, e.g. -10 = 10:1<br>" 777 "Value of 0 disables the specific limit." );
779 mScaleBasedVisibilityDDBtn->registerCheckedWidget( mScaleBasedVisibilityChkBx );
781 mScaleBasedVisibilityMinDDBtn->setUsageInfo( ddScaleVisInfo );
783 mScaleBasedVisibilityMaxDDBtn->setUsageInfo( ddScaleVisInfo );
786 mFontLimitPixelDDBtn->registerCheckedWidget( mFontLimitPixelChkBox );
804 if ( !mButtons.contains( key ) )
809 mButtons[key] = button;
826 mBufferDrawChkBx->setChecked( buffer.
enabled() );
827 mBufferFrame->setEnabled( buffer.
enabled() );
828 spinBufferSize->setValue( buffer.
size() );
829 mBufferUnitWidget->setUnit( buffer.
sizeUnit() );
831 btnBufferColor->setColor( buffer.
color() );
832 mBufferOpacityWidget->setOpacity( buffer.
opacity() );
833 mBufferJoinStyleComboBox->setPenJoinStyle( buffer.
joinStyle() );
835 comboBufferBlendMode->setBlendMode( buffer.
blendMode() );
841 mBufferEffect->setEnabled(
false );
843 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
847 mEnableMaskChkBx->setChecked( mask.
enabled() );
848 mMaskBufferSizeSpinBox->setValue( mask.
size() );
849 mMaskBufferUnitWidget->setUnit( mask.
sizeUnit() );
851 mMaskOpacityWidget->setOpacity( mask.
opacity() );
852 mMaskJoinStyleComboBox->setPenJoinStyle( mask.
joinStyle() );
858 mMaskEffect->setEnabled(
false );
860 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
862 mFontSizeUnitWidget->setUnit( format.
sizeUnit() );
864 mRefFont = format.
font();
865 mFontSizeSpinBox->setValue( format.
size() );
866 btnTextColor->setColor( format.
color() );
867 mTextOpacityWidget->setOpacity( format.
opacity() );
868 comboBlendMode->setBlendMode( format.
blendMode() );
869 mTextOrientationComboBox->setCurrentIndex( mTextOrientationComboBox->findData( format.
orientation() ) );
871 mFontWordSpacingSpinBox->setValue( format.
font().wordSpacing() );
872 mFontLetterSpacingSpinBox->setValue( format.
font().letterSpacing() );
876 updateFont( mRefFont );
879 mFontMissingLabel->setVisible( !format.
fontFound() );
882 QString missingTxt = tr(
"%1 not found. Default substituted." );
883 QString txtPrepend = tr(
"Chosen font" );
888 mFontMissingLabel->setText( missingTxt.arg( txtPrepend ) );
891 mLabelingOptionsListWidget->setCurrentRow( 0 );
893 mFontLineHeightSpinBox->setValue( format.
lineHeight() );
896 mShapeDrawChkBx->setChecked( background.
enabled() );
897 mShapeFrame->setEnabled( background.
enabled() );
898 mShapeTypeCmbBx->blockSignals(
true );
899 mShapeTypeCmbBx->setCurrentIndex( mShapeTypeCmbBx->findData( background.
type() ) );
900 mShapeTypeCmbBx->blockSignals(
false );
901 updateAvailableShadowPositions();
902 mShapeSVGPathLineEdit->setText( background.
svgFile() );
904 mShapeSizeCmbBx->setCurrentIndex( background.
sizeType() );
905 mShapeSizeXSpnBx->setValue( background.
size().width() );
906 mShapeSizeYSpnBx->setValue( background.
size().height() );
907 mShapeSizeUnitWidget->setUnit( background.
sizeUnit() );
909 mShapeRotationCmbBx->setCurrentIndex( background.
rotationType() );
912 mShapeRotationDblSpnBx->setValue( background.
rotation() );
913 mShapeOffsetXSpnBx->setValue( background.
offset().x() );
914 mShapeOffsetYSpnBx->setValue( background.
offset().y() );
915 mShapeOffsetUnitWidget->setUnit( background.
offsetUnit() );
917 mShapeRadiusXDbSpnBx->setValue( background.
radii().width() );
918 mShapeRadiusYDbSpnBx->setValue( background.
radii().height() );
919 mShapeRadiusUnitWidget->setUnit( background.
radiiUnit() );
922 mShapeFillColorBtn->setColor( background.
fillColor() );
923 mShapeStrokeColorBtn->setColor( background.
strokeColor() );
924 mShapeStrokeWidthSpnBx->setValue( background.
strokeWidth() );
927 mShapePenStyleCmbBx->setPenJoinStyle( background.
joinStyle() );
929 mBackgroundOpacityWidget->setOpacity( background.
opacity() );
930 mShapeBlendCmbBx->setBlendMode( background.
blendMode() );
932 mLoadSvgParams =
false;
933 mShapeTypeCmbBx_currentIndexChanged( background.
type() );
940 mBackgroundEffect->setEnabled(
false );
942 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
947 mShadowDrawChkBx->setChecked( shadow.
enabled() );
948 mShadowFrame->setEnabled( shadow.
enabled() );
949 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( shadow.
shadowPlacement() ) );
950 mShadowOffsetAngleSpnBx->setValue( shadow.
offsetAngle() );
952 mShadowOffsetUnitWidget->setUnit( shadow.
offsetUnit() );
954 mShadowOffsetGlobalChkBx->setChecked( shadow.
offsetGlobal() );
956 mShadowRadiusDblSpnBx->setValue( shadow.
blurRadius() );
959 mShadowRadiusAlphaChkBx->setChecked( shadow.
blurAlphaOnly() );
960 mShadowOpacityWidget->setOpacity( shadow.
opacity() );
961 mShadowScaleSpnBx->setValue( shadow.
scale() );
963 mShadowColorBtn->setColor( shadow.
color() );
964 mShadowBlendCmbBx->setBlendMode( shadow.
blendMode() );
976 settings.
setValue( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ), mFontPreviewSplitter->saveState() );
977 settings.
setValue( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ), mLabelingOptionsSplitter->saveState() );
978 settings.
setValue( QStringLiteral(
"Windows/Labeling/Tab" ), mLabelingOptionsListWidget->currentRow() );
984 format.
setColor( btnTextColor->color() );
986 format.
setSize( mFontSizeSpinBox->value() );
988 format.
setOpacity( mTextOpacityWidget->opacity() );
994 format.
setOrientation( static_cast< QgsTextFormat::TextOrientation >( mTextOrientationComboBox->currentData().toInt() ) );
998 buffer.
setEnabled( mBufferDrawChkBx->isChecked() );
999 buffer.
setSize( spinBufferSize->value() );
1000 buffer.
setColor( btnBufferColor->color() );
1001 buffer.
setOpacity( mBufferOpacityWidget->opacity() );
1004 buffer.
setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
1006 buffer.
setBlendMode( comboBufferBlendMode->blendMode() );
1015 mask.
setEnabled( mEnableMaskChkBx->isChecked() );
1016 mask.
setSize( mMaskBufferSizeSpinBox->value() );
1017 mask.
setOpacity( mMaskOpacityWidget->opacity() );
1018 mask.
setSizeUnit( mMaskBufferUnitWidget->unit() );
1020 mask.
setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
1030 background.
setEnabled( mShapeDrawChkBx->isChecked() );
1031 background.
setType( static_cast< QgsTextBackgroundSettings::ShapeType >( mShapeTypeCmbBx->currentData().toInt() ) );
1032 background.
setSvgFile( mShapeSVGPathLineEdit->text() );
1033 background.
setSizeType( static_cast< QgsTextBackgroundSettings::SizeType >( mShapeSizeCmbBx->currentIndex() ) );
1034 background.
setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
1035 background.
setSizeUnit( mShapeSizeUnitWidget->unit() );
1037 background.
setRotationType( static_cast< QgsTextBackgroundSettings::RotationType >( mShapeRotationCmbBx->currentIndex() ) );
1038 background.
setRotation( mShapeRotationDblSpnBx->value() );
1039 background.
setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
1042 background.
setRadii( QSizeF( mShapeRadiusXDbSpnBx->value(), mShapeRadiusYDbSpnBx->value() ) );
1043 background.
setRadiiUnit( mShapeRadiusUnitWidget->unit() );
1046 background.
setFillColor( mShapeFillColorBtn->color() );
1051 background.
setJoinStyle( mShapePenStyleCmbBx->penJoinStyle() );
1052 background.
setOpacity( mBackgroundOpacityWidget->opacity() );
1053 background.
setBlendMode( mShapeBlendCmbBx->blendMode() );
1063 shadow.
setEnabled( mShadowDrawChkBx->isChecked() );
1064 shadow.
setShadowPlacement( static_cast< QgsTextShadowSettings::ShadowPlacement >( mShadowUnderCmbBx->currentData().toInt() ) );
1074 shadow.
setOpacity( mShadowOpacityWidget->opacity() );
1075 shadow.
setScale( mShadowScaleSpnBx->value() );
1076 shadow.
setColor( mShadowColorBtn->color() );
1080 if ( includeDataDefinedProperties )
1111 if ( mButtons.contains( key ) )
1123 void QgsTextFormatWidget::optionsStackedWidget_CurrentChanged(
int indx )
1125 mLabelingOptionsListWidget->blockSignals(
true );
1126 mLabelingOptionsListWidget->setCurrentRow( indx );
1127 mLabelingOptionsListWidget->blockSignals(
false );
1141 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
1149 void QgsTextFormatWidget::collapseSample(
bool collapse )
1153 QList<int> splitSizes = mFontPreviewSplitter->sizes();
1154 if ( splitSizes[0] > groupBox_mPreview->height() )
1156 int delta = splitSizes[0] - groupBox_mPreview->height();
1157 splitSizes[0] -= delta;
1158 splitSizes[1] += delta;
1159 mFontPreviewSplitter->setSizes( splitSizes );
1164 void QgsTextFormatWidget::changeTextColor(
const QColor &color )
1170 void QgsTextFormatWidget::updateFont(
const QFont &font )
1173 if ( font != mRefFont )
1182 mDirectSymbLeftLineEdit->setFont( mRefFont );
1183 mDirectSymbRightLineEdit->setFont( mRefFont );
1185 blockFontChangeSignals(
true );
1186 mFontFamilyCmbBx->setCurrentFont( mRefFont );
1187 populateFontStyleComboBox();
1188 int idx = mFontCapitalsComboBox->findData( QVariant( static_cast< unsigned int >( mRefFont.capitalization() ) ) );
1189 mFontCapitalsComboBox->setCurrentIndex( idx == -1 ? 0 : idx );
1190 mFontUnderlineBtn->setChecked( mRefFont.underline() );
1191 mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
1192 mKerningCheckBox->setChecked( mRefFont.kerning() );
1193 blockFontChangeSignals(
false );
1201 void QgsTextFormatWidget::blockFontChangeSignals(
bool blk )
1203 mFontFamilyCmbBx->blockSignals( blk );
1204 mFontStyleComboBox->blockSignals( blk );
1205 mFontCapitalsComboBox->blockSignals( blk );
1206 mFontUnderlineBtn->blockSignals( blk );
1207 mFontStrikethroughBtn->blockSignals( blk );
1208 mFontWordSpacingSpinBox->blockSignals( blk );
1209 mFontLetterSpacingSpinBox->blockSignals( blk );
1210 mKerningCheckBox->blockSignals( blk );
1225 lblFontPreview->setFormat(
format() );
1228 void QgsTextFormatWidget::scrollPreview()
1230 scrollArea_mPreview->ensureVisible( 0, 0, 0, 0 );
1235 mPreviewBackgroundColor = color;
1237 scrollArea_mPreview->widget()->setStyleSheet( QStringLiteral(
"background: rgb(%1, %2, %3);" ).arg( QString::number( color.red() ),
1238 QString::number( color.green() ),
1239 QString::number( color.blue() ) ) );
1242 void QgsTextFormatWidget::changeBufferColor(
const QColor &color )
1250 QWidget *curWdgt = stackedPlacement->currentWidget();
1252 bool showLineFrame =
false;
1253 bool showCentroidFrame =
false;
1254 bool showQuadrantFrame =
false;
1255 bool showFixedQuadrantFrame =
false;
1256 bool showPlacementPriorityFrame =
false;
1257 bool showOffsetTypeFrame =
false;
1258 bool showOffsetFrame =
false;
1259 bool showDistanceFrame =
false;
1260 bool showRotationFrame =
false;
1261 bool showMaxCharAngleFrame =
false;
1263 bool enableMultiLinesFrame =
true;
1265 if ( ( curWdgt == pagePoint && radAroundPoint->isChecked() )
1266 || ( curWdgt == pagePolygon && radAroundCentroid->isChecked() ) )
1268 showCentroidFrame = ( curWdgt == pagePolygon && radAroundCentroid->isChecked() );
1269 showDistanceFrame =
true;
1271 if ( curWdgt == pagePoint )
1273 showQuadrantFrame =
true;
1276 else if ( ( curWdgt == pagePoint && radOverPoint->isChecked() )
1277 || ( curWdgt == pagePolygon && radOverCentroid->isChecked() ) )
1279 showCentroidFrame = ( curWdgt == pagePolygon && radOverCentroid->isChecked() );
1280 showQuadrantFrame =
true;
1281 showFixedQuadrantFrame =
true;
1282 showOffsetFrame =
true;
1283 showRotationFrame =
true;
1285 else if ( curWdgt == pagePoint && radPredefinedOrder->isChecked() )
1287 showDistanceFrame =
true;
1288 showPlacementPriorityFrame =
true;
1289 showOffsetTypeFrame =
true;
1291 else if ( ( curWdgt == pageLine && radLineParallel->isChecked() )
1292 || ( curWdgt == pagePolygon && radPolygonPerimeter->isChecked() )
1293 || ( curWdgt == pageLine && radLineCurved->isChecked() )
1294 || ( curWdgt == pagePolygon && radPolygonPerimeterCurved->isChecked() ) )
1296 showLineFrame =
true;
1297 showDistanceFrame =
true;
1300 bool offline = chkLineAbove->isChecked() || chkLineBelow->isChecked();
1301 chkLineOrientationDependent->setEnabled( offline );
1302 mPlacementDistanceFrame->setEnabled( offline );
1304 bool isCurved = ( curWdgt == pageLine && radLineCurved->isChecked() )
1305 || ( curWdgt == pagePolygon && radPolygonPerimeterCurved->isChecked() );
1306 showMaxCharAngleFrame = isCurved;
1308 enableMultiLinesFrame = !isCurved;
1311 mPlacementLineFrame->setVisible( showLineFrame );
1312 mPlacementCentroidFrame->setVisible( showCentroidFrame );
1313 mPlacementQuadrantFrame->setVisible( showQuadrantFrame );
1314 mPlacementFixedQuadrantFrame->setVisible( showFixedQuadrantFrame );
1315 mPlacementCartographicFrame->setVisible( showPlacementPriorityFrame );
1316 mPlacementOffsetFrame->setVisible( showOffsetFrame );
1317 mPlacementDistanceFrame->setVisible( showDistanceFrame );
1318 mPlacementOffsetTypeFrame->setVisible( showOffsetTypeFrame );
1319 mPlacementRotationFrame->setVisible( showRotationFrame );
1320 mPlacementRepeatDistanceFrame->setVisible( curWdgt == pageLine || ( curWdgt == pagePolygon &&
1321 ( radPolygonPerimeter->isChecked() || radPolygonPerimeterCurved->isChecked() ) ) );
1322 mPlacementOverrunDistanceFrame->setVisible( curWdgt == pageLine );
1323 mPlacementMaxCharAngleFrame->setVisible( showMaxCharAngleFrame );
1325 mMultiLinesFrame->setEnabled( enableMultiLinesFrame );
1328 void QgsTextFormatWidget::populateFontCapitalsComboBox()
1330 mFontCapitalsComboBox->addItem( tr(
"No change" ), QVariant( 0 ) );
1331 mFontCapitalsComboBox->addItem( tr(
"All uppercase" ), QVariant( 1 ) );
1332 mFontCapitalsComboBox->addItem( tr(
"All lowercase" ), QVariant( 2 ) );
1336 mFontCapitalsComboBox->addItem( tr(
"Capitalize first letter" ), QVariant( 4 ) );
1339 void QgsTextFormatWidget::populateFontStyleComboBox()
1341 mFontStyleComboBox->clear();
1342 QStringList styles = mFontDB.styles( mRefFont.family() );
1343 const auto constStyles = styles;
1344 for (
const QString &style : constStyles )
1346 mFontStyleComboBox->addItem( style );
1349 QString targetStyle = mFontDB.styleString( mRefFont );
1350 if ( !styles.contains( targetStyle ) )
1352 QFont f = QFont( mRefFont.family() );
1353 targetStyle = QFontInfo( f ).styleName();
1354 mRefFont.setStyleName( targetStyle );
1357 int stylIndx = mFontStyleComboBox->findText( targetStyle );
1358 if ( stylIndx > -1 )
1363 mFontStyleComboBox->setCurrentIndex( curIndx );
1366 void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged(
double d )
1368 mRefFont.setPointSizeF( d );
1369 updateFont( mRefFont );
1372 void QgsTextFormatWidget::mFontCapitalsComboBox_currentIndexChanged(
int index )
1374 int capitalsindex = mFontCapitalsComboBox->itemData( index ).toInt();
1375 mRefFont.setCapitalization( static_cast< QFont::Capitalization >( capitalsindex ) );
1376 updateFont( mRefFont );
1379 void QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged(
const QFont &f )
1381 mRefFont.setFamily( f.family() );
1382 updateFont( mRefFont );
1385 void QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged(
const QString &text )
1388 updateFont( mRefFont );
1391 void QgsTextFormatWidget::mFontUnderlineBtn_toggled(
bool ckd )
1393 mRefFont.setUnderline( ckd );
1394 updateFont( mRefFont );
1397 void QgsTextFormatWidget::mFontStrikethroughBtn_toggled(
bool ckd )
1399 mRefFont.setStrikeOut( ckd );
1400 updateFont( mRefFont );
1403 void QgsTextFormatWidget::kerningToggled(
bool checked )
1405 mRefFont.setKerning( checked );
1406 updateFont( mRefFont );
1409 void QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged(
double spacing )
1411 mRefFont.setWordSpacing( spacing );
1412 updateFont( mRefFont );
1415 void QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged(
double spacing )
1417 mRefFont.setLetterSpacing( QFont::AbsoluteSpacing, spacing );
1418 updateFont( mRefFont );
1421 void QgsTextFormatWidget::mFontSizeUnitWidget_changed()
1426 mFontLimitPixelChkBox->setChecked(
false );
1432 mFontLimitPixelChkBox->setChecked(
true );
1434 updateFont( mRefFont );
1437 void QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged(
int px )
1440 mFontMaxPixelSpinBox->setMinimum( px );
1441 mFontMaxPixelSpinBox->update();
1444 void QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged(
int px )
1447 if ( px < mFontMinPixelSpinBox->value() )
1449 mFontMaxPixelSpinBox->blockSignals(
true );
1450 mFontMaxPixelSpinBox->setValue( mFontMinPixelSpinBox->value() );
1451 mFontMaxPixelSpinBox->blockSignals(
false );
1453 mFontMaxPixelSpinBox->setMinimum( mFontMinPixelSpinBox->value() );
1456 void QgsTextFormatWidget::mBufferUnitWidget_changed()
1458 updateFont( mRefFont );
1461 void QgsTextFormatWidget::mMaskBufferUnitWidget_changed()
1463 updateFont( mRefFont );
1466 void QgsTextFormatWidget::mCoordXDDBtn_activated(
bool active )
1472 else if ( mCoordYDDBtn->isActive() )
1478 void QgsTextFormatWidget::mCoordYDDBtn_activated(
bool active )
1484 else if ( mCoordXDDBtn->isActive() )
1490 void QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged(
int )
1498 showBackgroundPenStyle( isRect );
1499 showBackgroundRadius( isRect );
1501 mShapeSVGPathFrame->setVisible( isSVG );
1502 mBackgroundSymbolButton->setVisible( isMarker );
1506 mShapeSizeYLabel->setVisible( !isSVG && !isMarker );
1507 mShapeSizeYSpnBx->setVisible( !isSVG && !isMarker );
1508 mShapeSizeYDDBtn->setVisible( !isSVG && !isMarker );
1509 mShapeSizeXLabel->setText( tr(
"Size%1" ).arg( !isSVG && !isMarker ? tr(
" X" ) : QString() ) );
1512 mShapeFillColorBtn->setAllowOpacity( !isSVG );
1513 mShapeFillColorBtn->setButtonBackground();
1514 mShapeStrokeColorBtn->setAllowOpacity( !isSVG );
1515 mShapeStrokeColorBtn->setButtonBackground();
1518 mShapeFillColorLabel->setVisible( !isMarker );
1519 mShapeFillColorLabel->setEnabled( !isMarker );
1520 mShapeFillColorBtn->setVisible( !isMarker );
1521 mShapeFillColorBtn->setEnabled( !isMarker );
1522 mShapeFillColorDDBtn->setVisible( !isMarker );
1523 mShapeFillColorDDBtn->setEnabled( !isMarker );
1524 mShapeStrokeColorLabel->setVisible( !isMarker );
1525 mShapeStrokeColorLabel->setEnabled( !isMarker );
1526 mShapeStrokeColorBtn->setVisible( !isMarker );
1527 mShapeStrokeColorBtn->setEnabled( !isMarker );
1528 mShapeStrokeColorDDBtn->setVisible( !isMarker );
1529 mShapeStrokeColorDDBtn->setEnabled( !isMarker );
1530 mShapeStrokeWidthLabel->setVisible( !isMarker );
1531 mShapeStrokeWidthLabel->setEnabled( !isMarker );
1532 mShapeStrokeWidthSpnBx->setVisible( !isMarker );
1533 mShapeStrokeWidthSpnBx->setEnabled( !isMarker );
1534 mShapeStrokeWidthDDBtn->setVisible( !isMarker );
1535 mShapeStrokeWidthDDBtn->setEnabled( !isMarker );
1538 mShapeSVGParamsBtn->setVisible( isSVG );
1541 updateSvgWidgets( mShapeSVGPathLineEdit->text() );
1545 mShapeStrokeWidthUnitWidget->setVisible( !isSVG && !isMarker );
1546 mShapeSVGUnitsLabel->setVisible( isSVG );
1547 mShapeStrokeUnitsDDBtn->setVisible( !isSVG && !isMarker );
1548 mShapeStrokeUnitsDDBtn->setEnabled( !isSVG && !isMarker );
1550 updateAvailableShadowPositions();
1553 void QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged(
const QString &text )
1555 updateSvgWidgets( text );
1560 int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) +
1561 ( chkLineBelow->isChecked() ? 1 : 0 ) +
1562 ( chkLineOn->isChecked() ? 1 : 0 );
1564 if ( numOptionsChecked == 1 )
1567 chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
1568 chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
1569 chkLineOn->setEnabled( !chkLineOn->isChecked() );
1573 chkLineAbove->setEnabled(
true );
1574 chkLineBelow->setEnabled(
true );
1575 chkLineOn->setEnabled(
true );
1585 void QgsTextFormatWidget::previewScaleChanged(
double scale )
1587 lblFontPreview->setScale( scale );
1590 void QgsTextFormatWidget::updateSvgWidgets(
const QString &svgPath )
1592 if ( mShapeSVGPathLineEdit->text() != svgPath )
1594 mShapeSVGPathLineEdit->setText( svgPath );
1597 QString resolvedPath;
1598 bool validSVG =
true;
1599 if ( ! svgPath.startsWith( QLatin1String(
"base64:" ), Qt::CaseInsensitive ) )
1602 validSVG = QFileInfo::exists( resolvedPath );
1606 resolvedPath = svgPath;
1611 mShapeSVGPathLineEdit->setStyleSheet( !validSVG ? QStringLiteral(
"QLineEdit{ color: rgb(225, 0, 0); }" ) : QString() );
1612 mShapeSVGPathLineEdit->setToolTip( !validSVG ? tr(
"File not found" ) : resolvedPath );
1614 QColor fill, stroke;
1615 double strokeWidth = 0.0;
1616 bool fillParam =
false, strokeParam =
false, strokeWidthParam =
false;
1622 mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || strokeParam || strokeWidthParam ) );
1624 mShapeFillColorLabel->setEnabled( validSVG && fillParam );
1625 mShapeFillColorBtn->setEnabled( validSVG && fillParam );
1626 mShapeFillColorDDBtn->setEnabled( validSVG && fillParam );
1627 if ( mLoadSvgParams && validSVG && fillParam )
1628 mShapeFillColorBtn->setColor( fill );
1630 mShapeStrokeColorLabel->setEnabled( validSVG && strokeParam );
1631 mShapeStrokeColorBtn->setEnabled( validSVG && strokeParam );
1632 mShapeStrokeColorDDBtn->setEnabled( validSVG && strokeParam );
1633 if ( mLoadSvgParams && validSVG && strokeParam )
1634 mShapeStrokeColorBtn->setColor( stroke );
1636 mShapeStrokeWidthLabel->setEnabled( validSVG && strokeWidthParam );
1637 mShapeStrokeWidthSpnBx->setEnabled( validSVG && strokeWidthParam );
1638 mShapeStrokeWidthDDBtn->setEnabled( validSVG && strokeWidthParam );
1639 if ( mLoadSvgParams && validSVG && strokeWidthParam )
1640 mShapeStrokeWidthSpnBx->setValue( strokeWidth );
1646 mShapeSVGUnitsLabel->setEnabled( validSVG && strokeWidthParam );
1649 void QgsTextFormatWidget::updateAvailableShadowPositions()
1651 if ( mShadowUnderCmbBx->count() == 0
1657 mShadowUnderCmbBx->clear();
1665 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( currentPlacement ) );
1666 if ( mShadowUnderCmbBx->currentIndex() == -1 )
1667 mShadowUnderCmbBx->setCurrentIndex( 0 );
1671 void QgsTextFormatWidget::updateProperty()
1679 void QgsTextFormatWidget::createAuxiliaryField()
1706 property.setActive(
true );
1715 void QgsTextFormatWidget::updateShapeFrameStatus()
1717 mShapeFrame->setEnabled( mShapeDrawDDBtn->isActive() || mShapeDrawChkBx->isChecked() );
1720 void QgsTextFormatWidget::updateBufferFrameStatus()
1722 mBufferFrame->setEnabled( mBufferDrawDDBtn->isActive() || mBufferDrawChkBx->isChecked() );
1725 void QgsTextFormatWidget::updateShadowFrameStatus()
1727 mShadowFrame->setEnabled( mShadowDrawDDBtn->isActive() || mShadowDrawChkBx->isChecked() );
1768 QgsStyleSaveDialog saveDlg(
this );
1769 saveDlg.setDefaultTags( mTextFormatsListWidget->currentTagFilter() );
1770 if ( !saveDlg.exec() )
1773 if ( saveDlg.name().isEmpty() )
1779 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1780 tr(
"Format with name '%1' already exists. Overwrite?" )
1781 .arg( saveDlg.name() ),
1782 QMessageBox::Yes | QMessageBox::No );
1783 if ( res != QMessageBox::Yes )
1790 QStringList symbolTags = saveDlg.tags().split(
',' );
1794 style->
saveTextFormat( saveDlg.name(), newFormat, saveDlg.isFavorite(), symbolTags );
1797 void QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked()
1800 svgDlg.setWindowTitle( tr(
"Select SVG file" ) );
1803 if ( svgDlg.exec() == QDialog::Accepted )
1806 if ( !svgPath.isEmpty() )
1808 mShapeSVGPathLineEdit->setText( svgPath );
1814 void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
1816 QString svgPath = mShapeSVGPathLineEdit->text();
1817 mLoadSvgParams =
true;
1818 updateSvgWidgets( svgPath );
1819 mLoadSvgParams =
false;
1822 void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged(
int index )
1828 void QgsTextFormatWidget::mPreviewTextEdit_textChanged(
const QString &text )
1830 lblFontPreview->setText( text );
1834 void QgsTextFormatWidget::mPreviewTextBtn_clicked()
1836 mPreviewTextEdit->setText( QStringLiteral(
"Lorem Ipsum" ) );
1840 void QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged(
const QColor &color )
1845 void QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked()
1847 bool gotChar =
false;
1849 const QChar initial = !mDirectSymbLeftLineEdit->text().isEmpty() ? mDirectSymbLeftLineEdit->text().at( 0 ) : QChar();
1850 QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
1855 if ( !dirSymb.isNull() )
1856 mDirectSymbLeftLineEdit->setText( QString( dirSymb ) );
1859 void QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked()
1861 bool gotChar =
false;
1862 const QChar initial = !mDirectSymbRightLineEdit->text().isEmpty() ? mDirectSymbRightLineEdit->text().at( 0 ) : QChar();
1863 QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
1868 if ( !dirSymb.isNull() )
1869 mDirectSymbRightLineEdit->setText( QString( dirSymb ) );
1872 void QgsTextFormatWidget::chkLineOrientationDependent_toggled(
bool active )
1876 chkLineAbove->setText( tr(
"Left of line" ) );
1877 chkLineBelow->setText( tr(
"Right of line" ) );
1881 chkLineAbove->setText( tr(
"Above line" ) );
1882 chkLineBelow->setText( tr(
"Below line" ) );
1887 void QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked()
1902 if ( dlg.exec() == QDialog::Accepted )
1909 void QgsTextFormatWidget::showBackgroundRadius(
bool show )
1911 mShapeRadiusLabel->setVisible( show );
1912 mShapeRadiusXDbSpnBx->setVisible( show );
1914 mShapeRadiusYDbSpnBx->setVisible( show );
1916 mShapeRadiusUnitWidget->setVisible( show );
1918 mShapeRadiusDDBtn->setVisible( show );
1919 mShapeRadiusUnitsDDBtn->setVisible( show );
1922 void QgsTextFormatWidget::showBackgroundPenStyle(
bool show )
1924 mShapePenStyleLabel->setVisible( show );
1925 mShapePenStyleCmbBx->setVisible( show );
1927 mShapePenStyleDDBtn->setVisible( show );
1932 mCoordAlignmentFrame->setEnabled( enable );
1963 : QDialog( parent, fl )
1965 setWindowTitle( tr(
"Text Settings" ) );
1968 mFormatWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
1970 QVBoxLayout *layout =
new QVBoxLayout(
this );
1971 layout->addWidget( mFormatWidget );
1973 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, Qt::Horizontal,
this );
1974 layout->addWidget( mButtonBox );
1976 setLayout( layout );
1979 connect( mButtonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked,
this, &QDialog::accept );
1980 connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked,
this, &QDialog::reject );
1981 connect( mButtonBox->button( QDialogButtonBox::Help ), &QAbstractButton::clicked,
this, &QgsTextFormatDialog::showHelp );
1986 return mFormatWidget->
format();
1989 void QgsTextFormatDialog::showHelp()
1991 QgsHelp::openHelp( QStringLiteral(
"style_library/label_settings.html#formatting-the-label-text" ) );
2013 return mFormatWidget->
format();
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the buffer.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the labeling property definitions.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
QColor strokeColor() const
Returns the color used for outlining the background shape.
void setScale(int scale)
Sets the scaling used for the drop shadow (in percentage of original size).
Meters value as Map units.
void setLineHeight(double height)
Sets the line height for text.
void setRadiiUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's radii.
void setStrokeWidth(double width)
Sets the width of the shape's stroke (stroke).
bool addTextFormat(const QString &name, const QgsTextFormat &format, bool update=false)
Adds a text format with the specified name to the style.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow offset distance.
Horizontally or vertically oriented text based on rotation (only available for map labeling) ...
void setOpacity(double opacity)
Sets the text's opacity.
void setMask(const QgsTextMaskSettings &maskSettings)
Sets the text's masking settings.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape stroke width.
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's offset.
QgsTextShadowSettings::ShadowPlacement shadowPlacement() const
Returns the placement for the drop shadow.
QSizeF radii() const
Returns the radii used for rounding the corners of shapes.
QSizeF size() const
Returns the size of the background shape.
double opacity() const
Returns the text's opacity.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the shape's size.
void setOrientation(TextOrientation orientation)
Sets the orientation for the text.
bool fontFound() const
Returns true if the specified font was found on the system, or false if the font was not found and a ...
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the drop shadow.
QPointF offset() const
Returns the offset used for drawing the background shape.
QColor fillColor() const
Returns the color used for filing the background shape.
QgsMapUnitScale strokeWidthMapUnitScale() const
Returns the map unit scale object for the shape stroke width.
void setDockMode(bool enabled)
Sets whether the widget should be shown in a compact dock mode.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
This class is a composition of two QSettings instances:
void populateDataDefinedButtons()
Sets up connections required for data defined buttons, or updates the existing definition of these bu...
A groupbox that collapses/expands when toggled and can save its collapsed and checked states...
void setPreviewBackgroundColor(const QColor &color)
Sets the background color that text will be rendered on for previews.
Draw shadow under buffer.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
ShadowPlacement
Placement positions for text shadow.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly...
Place direction symbols on below label.
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
QgsTextShadowSettings & shadow()
Returns a reference to the text drop shadow settings.
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.
double blurRadius() const
Returns the blur radius for the shadow.
Arranges candidates following the curvature of a line feature. Applies to line layers only...
double opacity() const
Returns the background shape's opacity.
static void warning(const QString &msg)
Goes to qWarning.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the size.
void setStrokeColor(const QColor &color)
Sets the color used for outlining the background shape.
void setSize(double size)
Sets the size of the buffer.
double strokeWidth() const
Returns the width of the shape's stroke (stroke).
A QGIS expression editor based on QScintilla2.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
double offsetDistance() const
Returns the distance for offsetting the position of the shadow from the text.
QButtonGroup * mUpsidedownBtnGrp
Upside down labels button group.
void setFont(const QFont &font)
Sets the font used for rendering text.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
void collapsedStateChanged(bool collapsed)
Signal emitted when groupbox collapsed/expanded state is changed, and when first shown.
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the mask.
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's offset.
QColor color() const
Returns the color that text will be rendered in.
double size() const
Returns the size of the buffer.
QgsSymbolWidgetContext mContext
Context in which widget is shown.
void setFillBufferInterior(bool fill)
Sets whether the interior of the buffer will be filled in.
void setBlurRadius(double blurRadius)
Sets the blur radius for the shadow.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the buffer.
void setOpacity(double opacity)
Sets the shadow's opacity.
X-coordinate data defined label position.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape size.
void setDockMode(bool dockMode) override
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs...
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
void updateWidgetForFormat(const QgsTextFormat &format)
Updates the widget's state to reflect the settings in a QgsTextFormat.
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
A dialog for selecting a single character from a single font.
void setBackground(const QgsTextBackgroundSettings &backgroundSettings)
Sets the text's background settings.q.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the background shape.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
void setMarkerSymbol(QgsMarkerSymbol *symbol)
Sets the current marker symbol for the background shape.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
Container for settings relating to a text background object.
A widget for customizing text formatting settings.
Percentage of another measurement (e.g., canvas size, feature size)
static QgsGui * instance()
Returns a pointer to the singleton instance.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shape offset.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
void setRadiiMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape radii.
void setBlurRadiusUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's blur radius.
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
void setBlurRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow blur radius.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Map canvas is a class for displaying all GIS data types on a canvas.
A marker symbol type, for rendering Point and MultiPoint geometries.
Show labeling settings in addition to text formatting settings.
static QgsStyle * defaultStyle()
Returns default application-wide style.
ShapeType type() const
Returns the type of background shape (e.g., square, ellipse, SVG).
void setOffset(QPointF offset)
Sets the offset used for drawing the background shape.
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
QgsUnitTypes::DistanceUnit mapUnits() const
Gets units of map's geographical coordinates - used for scale calculation.
StyleEntity
Enum for Entities involved in a style.
QgsSymbolLayerReferenceList maskedSymbolLayers() const
Returns a list of references to symbol layers that are masked by this buffer.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
Place direction symbols on left/right of label.
QgsVectorLayer * mLayer
Associated vector layer.
A dialog to create a new auxiliary layer.
void setField(const QString &field)
Sets the field name the property references.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the background shape.
Property
Data definable properties.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shadow offset distance.
QStringList textFormatNames() const
Returns a list of names of text formats in the style.
QgsPalLayerSettings labelSettings(const QString &name) const
Returns the label settings with the specified name.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the text.
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
QColor color() const
Returns the color of the drop shadow.
void setSize(double size)
Sets the size for rendered text.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
void setOffsetDistance(double distance)
Sets the distance for offsetting the position of the shadow from the text.
void widgetChanged()
Emitted when the text format defined by the widget changes.
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects. ...
QColor previewBackgroundColor() const
Returns the background color for text previews.
QgsMapUnitScale blurRadiusMapUnitScale() const
Returns the map unit scale object for the shadow blur radius.
Offset distance applies from point geometry.
Default mode, show text formatting settings only.
QgsPropertyCollection mDataDefinedProperties
Data defined properties as defined in the widget.
bool fillBufferInterior() const
Returns whether the interior of the buffer will be filled in.
TextOrientation orientation() const
Returns the orientation of the text.
double opacity() const
Returns the mask's opacity.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape offset.
Maximum map scale (ie most "zoomed in")
void setBlurAlphaOnly(bool alphaOnly)
Sets whether only the alpha channel for the shadow should be blurred.
RotationType rotationType() const
Returns the method used for rotating the background shape.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
double scale() const
Returns the calculated map scale.
Show upside down for all labels, including dynamic ones.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the background shape.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the drop shadow.
Vertically oriented text.
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.
void enableDataDefinedAlignment(bool enable)
Controls whether data defined alignment buttons are enabled.
void setActive(bool active)
Sets whether the property is currently active.
void setColor(const QColor &color)
Sets the color for the drop shadow.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setEnabled(bool enabled)
Sets whether the text shadow will be drawn.
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
void setFormat(const QgsTextFormat &format)
Sets the current formatting settings.
Horizontal alignment for data defined label position (Left, Center, Right)
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
void setColor(const QColor &color)
Sets the color that text will be rendered in.
QgsMapUnitScale radiiMapUnitScale() const
Returns the map unit scale object for the shape radii.
QString svgFile() const
Returns the absolute path to the background SVG file, if set.
Qt::PenJoinStyle joinStyle() const
Returns the join style used for drawing the background shape.
void setNamedStyle(const QString &style)
Sets the named style for the font used for rendering text.
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the size of rendered text.
Upside-down labels (90 <= angle < 270) are shown upright.
double opacity() const
Returns the buffer opacity.
QgsTextMaskSettings & mask()
Returns a reference to the masking settings.
void updateLinePlacementOptions()
Updates line placement options to reflect current state of widget.
void auxiliaryFieldCreated()
Emitted when an auxiliary field is created in the widget.
void setSize(QSizeF size)
Sets the size of the background shape.
QgsStringReplacementCollection mSubstitutions
Text substitution list.
A store for object properties.
void setRadii(QSizeF radii)
Sets the radii used for rounding the corners of shapes.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the format's property collection, used for data defined overrides.
void setPreviewBackground(const QColor &color)
Sets the background color for the text preview widget.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units used for the shape's stroke width.
Minimum map scale (ie most "zoomed out")
QgsTextFormat textFormat(const QString &name) const
Returns the text format with the specified name.
Offset distance applies from rendered symbol bounds.
void setSizeType(SizeType type)
Sets the method used to determine the size of the background shape (e.g., fixed size or buffer around...
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc...
Definition for a property.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
void setType(ShapeType type)
Sets the type of background shape to draw (e.g., square, ellipse, SVG).
Place direction symbols on above label.
Draw shadow below all text components.
virtual void setFormatFromStyle(const QString &name, QgsStyle::StyleEntity type)
Sets the current text settings from a style entry.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the background shape.
QgsSymbolLayerReferenceList mMaskedSymbolLayers
void setMaskedSymbolLayers(QgsSymbolLayerReferenceList maskedLayers)
Sets the symbol layers that will be masked by this buffer.
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.
double lineHeight() const
Returns the line height for text.
QButtonGroup * mPlaceLineBtnGrp
Line placement button group.
void setEnabled(bool enabled)
Sets whether the text background will be drawn.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
int offsetAngle() const
Returns the angle for offsetting the position of the shadow from the text.
ShapeType
Background shape types.
QgsSymbolWidgetContext context() const
Returns the context in which the widget is shown, e.g., the associated map canvas and expression cont...
bool saveTextFormat(const QString &name, const QgsTextFormat &format, bool favorite, const QStringList &tags)
Adds a text format to the database.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the mask.
virtual void saveFormat()
Saves the current text settings to a style entry.
bool removeTextFormat(const QString &name)
Removes a text format from the style.
QgsSvgSelectorWidget * svgSelector()
Returns pointer to the embedded SVG selector widget.
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
void updatePreview()
Updates the text preview.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
~QgsTextFormatWidget() override
static bool fontFamilyMatchOnSystem(const QString &family, QString *chosen=nullptr, bool *match=nullptr)
Check whether font family is on system.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object...
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the size.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
Points (e.g., for font sizes)
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the shadow's offset.
bool enabled() const
Returns whether the shadow is enabled.
QgsTextFormatDialog(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QgsVectorLayer *layer=nullptr)
Constructor for QgsTextFormatDialog.
QButtonGroup * mPlacePolygonBtnGrp
Polygon placement button group.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Container for settings relating to a text shadow.
A collection of string replacements (specified using QgsStringReplacement objects).
bool offsetGlobal() const
Returns true if the global shadow offset will be used.
QColor color() const
Returns the color of the buffer.
double size() const
Returns the size of the buffer.
QgsUnitTypes::RenderUnit radiiUnit() const
Returns the units used for the shape's radii.
Container for settings relating to a text buffer.
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
void setFillColor(const QColor &color)
Sets the color used for filing the background shape.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
static QgsProject * instance()
Returns the QgsProject singleton instance.
double size() const
Returns the size for rendered text.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's stroke width.
bool enabled() const
Returns whether the background is enabled.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the format's property collection, used for data defined overrides.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
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...
int mMinPixelLimit
Pixel size font limit.
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
void setSubstitutions(const QgsStringReplacementCollection &substitutions)
Sets the list of substitutions to show in the dialog.
QgsUnitTypes::RenderUnit blurRadiusUnit() const
Returns the units used for the shadow's blur radius.
bool enabled() const
Returns whether the buffer is enabled.
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
QSet< int > propertyKeys() const override
Returns a list of property keys contained within the collection.
Shape rotation is synced with text rotation.
QButtonGroup * mQuadrantBtnGrp
Quadrant button group.
void setShadowPlacement(QgsTextShadowSettings::ShadowPlacement placement)
Sets the placement for the drop shadow.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the text.
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
Draw shadow under background shape.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user...
Distance which labels can extend past either end of linear features.
Whether the mask is enabled.
void setEnabled(bool)
Returns whether the mask is enabled.
void setShadow(const QgsTextShadowSettings &shadowSettings)
Sets the text's drop shadow settings.
A dialog which allows users to specify a list of substitutions to apply to a string, with options for exporting and importing substitution lists.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the buffer.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Show upside down when rotation is layer- or data-defined.
Y-coordinate data defined label position.
void setOpacity(double opacity)
Sets the mask's opacity.
void deactivateField(QgsPalLayerSettings::Property key)
Deactivate a field from data defined properties and update the corresponding button.
void updatePlacementWidgets()
Updates label placement options to reflect current state of widget.
Container for all settings relating to text rendering.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the size of rendered text.
QgsMapCanvas * mMapCanvas
Associated map canvas.
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the buffer.
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
void setSvgFile(const QString &file)
Sets the path to the background SVG file.
void setSize(double size)
Sets the size of the buffer.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
bool blurAlphaOnly() const
Returns whether only the alpha channel for the shadow will be blurred.
void setOffsetGlobal(bool global)
Sets whether the global shadow offset should be used.
Represents a vector layer which manages a vector based data sets.
QButtonGroup * mPlacePointBtnGrp
Point placement button group.
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only...
void setOpacity(double opacity)
Sets the buffer opacity.
Square - buffered sizes only.
QgsStringReplacementCollection substitutions
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top) ...
Whether all parts of multi-part features should be labeled.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
QgsTextFormatWidget(const QgsTextFormat &format=QgsTextFormat(), QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsVectorLayer *layer=nullptr)
Constructor for QgsTextFormatWidget.
QString namedStyle() const
Returns the named style for the font used for rendering text (e.g., "bold").
QFont font() const
Returns the font used for rendering text.
void setRotationType(RotationType type)
Sets the method used for rotating the background shape.
void setColor(const QColor &color)
Sets the color for the buffer.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units used for the shape's size.
QButtonGroup * mDirectSymbBtnGrp
Symbol direction button group.
bool enabled() const
Returns whether the mask is enabled.
double opacity() const
Returns the shadow's opacity.
Container for settings relating to a selective masking around a text.
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
QgsTextFormatPanelWidget(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsVectorLayer *layer=nullptr)
Constructor for QgsTextFormatPanelWidget.
void setOpacity(double opacity)
Sets the background shape's opacity.
QgsMarkerSymbol * markerSymbol() const
Returns the marker symbol to be rendered in the background.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the background shape.
Horizontally oriented text.
QString resolvedFontFamily() const
Returns the family for the resolved font, ie if the specified font was not found on the system this w...
void setOffsetAngle(int angle)
Sets the angle for offsetting the position of the shadow from the text.
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...
void setRotation(double rotation)
Sets the rotation for the background shape, in degrees clockwise.