40 #include <QButtonGroup>
41 #include <QMessageBox>
45 , mMapCanvas( mapCanvas )
49 setWidgetMode(
Text );
56 , mMapCanvas( mapCanvas )
63 setWidgetMode( mode );
66 void QgsTextFormatWidget::initWidget()
70 mGeometryGeneratorGroupBox->setCollapsed(
true );
72 connect( mShapeSVGPathLineEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged );
73 connect( mFontSizeSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontSizeSpinBox_valueChanged );
74 connect( mFontFamilyCmbBx, &QFontComboBox::currentFontChanged,
this, &QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged );
75 connect( mFontStyleComboBox, &QComboBox::currentTextChanged,
this, &QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged );
76 connect( mFontUnderlineBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontUnderlineBtn_toggled );
77 connect( mFontStrikethroughBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontStrikethroughBtn_toggled );
78 connect( mFontWordSpacingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged );
79 connect( mFontLetterSpacingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged );
81 connect( mFontMinPixelSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged );
82 connect( mFontMaxPixelSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged );
87 connect( mShapeTypeCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged );
88 connect( mShapeRotationCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged );
89 connect( mShapeSVGParamsBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGParamsBtn_clicked );
90 connect( mShapeSVGSelectorBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked );
91 connect( mPreviewTextEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mPreviewTextEdit_textChanged );
92 connect( mPreviewTextBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mPreviewTextBtn_clicked );
94 connect( mDirectSymbLeftToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked );
95 connect( mDirectSymbRightToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked );
96 connect( chkLineOrientationDependent, &QCheckBox::toggled,
this, &QgsTextFormatWidget::chkLineOrientationDependent_toggled );
97 connect( mToolButtonConfigureSubstitutes, &QToolButton::clicked,
this, &QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked );
98 connect( mKerningCheckBox, &QCheckBox::toggled,
this, &QgsTextFormatWidget::kerningToggled );
108 mPreviewTextBtn->setIconSize( QSize( iconSize16, iconSize16 ) );
109 mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
110 mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
111 mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );
112 mPointOffsetLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
113 mPointOffsetOver ->setIconSize( QSize( iconSize32, iconSize18 ) );
114 mPointOffsetRight->setIconSize( QSize( iconSize32, iconSize18 ) );
115 mPointOffsetBelowLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
116 mPointOffsetBelow->setIconSize( QSize( iconSize32, iconSize18 ) );
117 mPointOffsetBelowRight->setIconSize( QSize( iconSize32, iconSize18 ) );
118 mLabelMinScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomOut.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
119 mLabelMaxScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomIn.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
122 mFontUnderlineBtn->setMinimumSize( buttonSize, buttonSize );
123 mFontUnderlineBtn->setMaximumSize( buttonSize, buttonSize );
124 mFontStrikethroughBtn->setMinimumSize( buttonSize, buttonSize );
125 mFontStrikethroughBtn->setMaximumSize( buttonSize, buttonSize );
126 mFontBoldBtn->setMinimumSize( buttonSize, buttonSize );
127 mFontBoldBtn->setMaximumSize( buttonSize, buttonSize );
128 mFontItalicBtn->setMinimumSize( buttonSize, buttonSize );
129 mFontItalicBtn->setMaximumSize( buttonSize, buttonSize );
131 mPreviewScaleComboBox->setMapCanvas(
mMapCanvas );
132 mPreviewScaleComboBox->setShowCurrentScaleButton(
true );
135 const auto unitWidgets = findChildren<QgsUnitSelectionWidget *>();
166 mFontLineHeightSpinBox->setClearValue( 1.0 );
167 mShapeRotationDblSpnBx->setClearValue( 0.0 );
168 mShapeOffsetXSpnBx->setClearValue( 0.0 );
169 mShapeOffsetYSpnBx->setClearValue( 0.0 );
170 mPointOffsetXSpinBox->setClearValue( 0.0 );
171 mPointOffsetYSpinBox->setClearValue( 0.0 );
172 mPointAngleSpinBox->setClearValue( 0.0 );
173 mFontLetterSpacingSpinBox->setClearValue( 0.0 );
174 mFontWordSpacingSpinBox->setClearValue( 0.0 );
175 mZIndexSpinBox->setClearValue( 0.0 );
176 mLineDistanceSpnBx->setClearValue( 0.0 );
188 updateAvailableShadowPositions();
191 mBackgroundSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
192 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
193 mBackgroundSymbolButton->setMapCanvas(
mMapCanvas );
197 mRefFont = lblFontPreview->font();
200 connect( mShadowOffsetAngleDial, &QAbstractSlider::valueChanged, mShadowOffsetAngleSpnBx, &QSpinBox::setValue );
201 connect( mShadowOffsetAngleSpnBx,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mShadowOffsetAngleDial, &QAbstractSlider::setValue );
202 connect( mLimitLabelChkBox, &QAbstractButton::toggled, mLimitLabelSpinBox, &QWidget::setEnabled );
203 connect( mCheckBoxSubstituteText, &QAbstractButton::toggled, mToolButtonConfigureSubstitutes, &QWidget::setEnabled );
213 populateFontCapitalsComboBox();
216 mPreviewBackgroundBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
217 mPreviewBackgroundBtn->setContext( QStringLiteral(
"labeling" ) );
218 mPreviewBackgroundBtn->setColor( QColor( 255, 255, 255 ) );
219 btnTextColor->setColorDialogTitle( tr(
"Select Text Color" ) );
220 btnTextColor->setContext( QStringLiteral(
"labeling" ) );
221 btnTextColor->setDefaultColor( Qt::black );
222 btnBufferColor->setColorDialogTitle( tr(
"Select Buffer Color" ) );
223 btnBufferColor->setContext( QStringLiteral(
"labeling" ) );
224 btnBufferColor->setDefaultColor( Qt::white );
225 mShapeStrokeColorBtn->setColorDialogTitle( tr(
"Select Stroke Color" ) );
226 mShapeStrokeColorBtn->setContext( QStringLiteral(
"labeling" ) );
227 mShapeFillColorBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
228 mShapeFillColorBtn->setContext( QStringLiteral(
"labeling" ) );
229 mShadowColorBtn->setColorDialogTitle( tr(
"Select Shadow Color" ) );
230 mShadowColorBtn->setContext( QStringLiteral(
"labeling" ) );
231 mShadowColorBtn->setDefaultColor( Qt::black );
233 mFontColorDDBtn->registerLinkedWidget( btnTextColor );
234 mBufferColorDDBtn->registerLinkedWidget( btnBufferColor );
235 mShapeStrokeColorDDBtn->registerLinkedWidget( mShapeStrokeColorBtn );
236 mShapeFillColorDDBtn->registerLinkedWidget( mShapeFillColorBtn );
237 mShadowColorDDBtn->registerLinkedWidget( mShadowColorBtn );
278 const auto groupBoxes = findChildren<QgsCollapsibleGroupBox *>();
281 grpbox->setSettingGroup( QStringLiteral(
"mAdvLabelingDlg" ) );
287 mLabelingOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect,
false );
292 QSizePolicy policy( mLabelingOptionsListFrame->sizePolicy() );
293 policy.setHorizontalStretch( 0 );
294 mLabelingOptionsListFrame->setSizePolicy( policy );
295 if ( !settings.
contains( QStringLiteral(
"/Windows/Labeling/OptionsSplitState" ) ) )
298 QList<int> splitsizes;
300 mLabelingOptionsSplitter->setSizes( splitsizes );
304 connect( mLabelStackedWidget, &QStackedWidget::currentChanged,
this, &QgsTextFormatWidget::optionsStackedWidget_CurrentChanged );
307 mFontPreviewSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ) ).toByteArray() );
308 mLabelingOptionsSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ) ).toByteArray() );
310 mLabelingOptionsListWidget->setCurrentRow( settings.
value( QStringLiteral(
"Windows/Labeling/Tab" ), 0 ).toInt() );
314 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
318 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
322 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
326 QList<QWidget *> widgets;
327 widgets << btnBufferColor
329 << chkLabelPerFeaturePart
333 << chkLineOrientationDependent
335 << chkPreserveRotation
337 << comboBufferBlendMode
339 << mBufferJoinStyleComboBox
340 << mBufferTranspFillChbx
341 << mBufferOpacityWidget
342 << mCentroidInsideCheckBox
345 << mDirectSymbLeftLineEdit
346 << mDirectSymbRevChkBx
347 << mDirectSymbRightLineEdit
348 << mFitInsidePolygonCheckBox
349 << mFontCapitalsComboBox
350 << mFontLetterSpacingSpinBox
351 << mFontLimitPixelChkBox
352 << mFontLineHeightSpinBox
353 << mFontMaxPixelSpinBox
354 << mFontMinPixelSpinBox
355 << mFontMultiLineAlignComboBox
357 << mFontStyleComboBox
358 << mTextOrientationComboBox
359 << mTextOpacityWidget
360 << mFontWordSpacingSpinBox
362 << mFormatNumDecimalsSpnBx
363 << mFormatNumPlusSignChkBx
365 << mLimitLabelSpinBox
366 << mLineDistanceSpnBx
367 << mLineDistanceUnitWidget
368 << mMaxCharAngleInDSpinBox
369 << mMaxCharAngleOutDSpinBox
371 << mOffsetTypeComboBox
372 << mPalShowAllLabelsForLayerChkBx
373 << mPointAngleSpinBox
374 << mPointOffsetUnitWidget
375 << mPointOffsetXSpinBox
376 << mPointOffsetYSpinBox
377 << mPreviewBackgroundBtn
380 << mRepeatDistanceSpinBox
381 << mRepeatDistanceUnitWidget
382 << mOverrunDistanceSpinBox
383 << mOverrunDistanceUnitWidget
384 << mScaleBasedVisibilityChkBx
390 << mShadowOffsetAngleSpnBx
391 << mShadowOffsetGlobalChkBx
392 << mShadowOffsetSpnBx
393 << mShadowOffsetUnitWidget
394 << mShadowRadiusAlphaChkBx
395 << mShadowRadiusDblSpnBx
396 << mShadowRadiusUnitWidget
398 << mShadowOpacityWidget
401 << mShapeStrokeColorBtn
402 << mShapeStrokeWidthSpnBx
403 << mShapeStrokeWidthUnitWidget
405 << mShapeFillColorBtn
406 << mShapeOffsetXSpnBx
407 << mShapeOffsetYSpnBx
408 << mShapeOffsetUnitWidget
409 << mShapePenStyleCmbBx
410 << mShapeRadiusXDbSpnBx
411 << mShapeRadiusYDbSpnBx
412 << mShapeRotationCmbBx
413 << mShapeRotationDblSpnBx
414 << mShapeRadiusUnitWidget
415 << mShapeSVGPathLineEdit
417 << mShapeSizeUnitWidget
420 << mBackgroundOpacityWidget
425 << mAutoWrapLengthSpinBox
426 << mAutoWrapTypeComboBox
427 << mCentroidRadioVisible
428 << mCentroidRadioWhole
429 << mDirectSymbRadioBtnAbove
430 << mDirectSymbRadioBtnBelow
431 << mDirectSymbRadioBtnLR
432 << mUpsidedownRadioAll
433 << mUpsidedownRadioDefined
434 << mUpsidedownRadioOff
435 << mPlacementModeComboBox
436 << mFieldExpressionWidget
437 << mCheckBoxSubstituteText
438 << mGeometryGeneratorGroupBox
439 << mGeometryGenerator
440 << mGeometryGeneratorType
441 << mBackgroundSymbolButton
442 << mCalloutsDrawCheckBox
443 << mCalloutStyleComboBox
446 << mMaskJoinStyleComboBox
447 << mMaskBufferSizeSpinBox
448 << mMaskOpacityWidget
449 << mCheckAllowLabelsOutsidePolygons
450 << mHtmlFormattingCheckBox;
457 connect( mBufferDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
459 updateBufferFrameStatus();
462 connect( mShapeDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
464 updateShapeFrameStatus();
467 connect( mShadowDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
469 updateShadowFrameStatus();
472 connect( mCalloutsDrawCheckBox, &QCheckBox::stateChanged,
this, [ = ](
int )
474 updateCalloutFrameStatus();
482 whileBlocking( mOptionsTab )->setCurrentIndex( mLabelStackedWidget->currentIndex() );
483 mOptionsTab->tabBar()->setUsesScrollButtons(
true );
504 toggleDDButtons(
true );
511 const int prevIndex = mOptionsTab->currentIndex();
512 toggleDDButtons(
true );
513 delete mLabelingOptionsListWidget->takeItem( 8 );
514 delete mLabelingOptionsListWidget->takeItem( 7 );
515 delete mLabelingOptionsListWidget->takeItem( 6 );
516 delete mLabelingOptionsListWidget->takeItem( 3 );
517 mOptionsTab->removeTab( 8 );
518 mOptionsTab->removeTab( 7 );
519 mOptionsTab->removeTab( 6 );
520 mOptionsTab->removeTab( 3 );
521 mLabelStackedWidget->removeWidget( mLabelPage_Rendering );
522 mLabelStackedWidget->removeWidget( mLabelPage_Callouts );
523 mLabelStackedWidget->removeWidget( mLabelPage_Mask );
524 mLabelStackedWidget->removeWidget( mLabelPage_Placement );
534 mLabelStackedWidget->setCurrentIndex( prevIndex - 1 );
535 mOptionsTab->setCurrentIndex( prevIndex - 1 );
542 mLabelStackedWidget->setCurrentIndex( 0 );
543 mOptionsTab->setCurrentIndex( 0 );
547 frameLabelWith->hide();
548 mDirectSymbolsFrame->hide();
549 mFormatNumFrame->hide();
550 mFormatNumChkBx->hide();
551 mFormatNumDDBtn->hide();
552 mCheckBoxSubstituteText->hide();
553 mToolButtonConfigureSubstitutes->hide();
554 mLabelWrapOnCharacter->hide();
555 wrapCharacterEdit->hide();
556 mWrapCharDDBtn->hide();
557 mLabelWrapLinesTo->hide();
558 mAutoWrapLengthSpinBox->hide();
559 mAutoWrapLengthDDBtn->hide();
560 mAutoWrapTypeComboBox->hide();
561 mFontMultiLineLabel->hide();
562 mFontMultiLineAlignComboBox->hide();
563 mFontMultiLineAlignDDBtn->hide();
571 void QgsTextFormatWidget::toggleDDButtons(
bool visible )
573 const auto buttons = findChildren< QgsPropertyOverrideButton * >();
576 button->setVisible( visible );
582 mOptionsTab->setVisible( enabled );
583 mOptionsTab->setTabToolTip( 0, tr(
"Text" ) );
584 mOptionsTab->setTabToolTip( 1, tr(
"Formatting" ) );
585 mOptionsTab->setTabToolTip( 2, tr(
"Buffer" ) );
586 mOptionsTab->setTabToolTip( 3, tr(
"Mask" ) );
587 mOptionsTab->setTabToolTip( 4, tr(
"Background" ) );
588 mOptionsTab->setTabToolTip( 5, tr(
"Shadow" ) );
589 mOptionsTab->setTabToolTip( 6, tr(
"Callouts" ) );
590 mOptionsTab->setTabToolTip( 7, tr(
"Placement" ) );
591 mOptionsTab->setTabToolTip( 8, tr(
"Rendering" ) );
593 mLabelingOptionsListFrame->setVisible( !enabled );
594 groupBox_mPreview->setVisible( !enabled );
598 void QgsTextFormatWidget::connectValueChanged(
const QList<QWidget *> &widgets,
const char *slot )
600 const auto constWidgets = widgets;
601 for ( QWidget *widget : constWidgets )
605 connect( w, SIGNAL( changed() ),
this, slot );
609 connect( w, SIGNAL( fieldChanged( QString ) ),
this, slot );
611 else if (
QgsOpacityWidget *w = qobject_cast< QgsOpacityWidget *>( widget ) )
613 connect( w, SIGNAL( opacityChanged(
double ) ),
this, slot );
615 else if (
QgsScaleWidget *w = qobject_cast< QgsScaleWidget *>( widget ) )
617 connect( w, SIGNAL( scaleChanged(
double ) ),
this, slot );
621 connect( w, SIGNAL( changed() ),
this, slot );
623 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
625 connect( w, SIGNAL( currentIndexChanged(
int ) ),
this, slot );
627 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
629 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
631 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
633 connect( w, SIGNAL( valueChanged(
double ) ),
this, slot );
635 else if (
QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
637 connect( w, SIGNAL( colorChanged( QColor ) ),
this, slot );
639 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
641 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
643 else if ( QRadioButton *w = qobject_cast<QRadioButton *>( widget ) )
645 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
647 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
649 connect( w, SIGNAL( textEdited( QString ) ),
this, slot );
651 else if ( QSlider *w = qobject_cast<QSlider *>( widget ) )
653 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
655 else if ( QGroupBox *w = qobject_cast<QGroupBox *>( widget ) )
657 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
661 connect( w, SIGNAL( textChanged() ),
this, slot );
665 QgsLogger::warning( QStringLiteral(
"Could not create connection for widget %1" ).arg( widget->objectName() ) );
696 mDirectSymbDDBtn->registerCheckedWidget( mDirectSymbChkBx );
704 mFormatNumDDBtn->registerCheckedWidget( mFormatNumChkBx );
710 mBufferDrawDDBtn->registerCheckedWidget( mBufferDrawChkBx );
720 mEnableMaskDDBtn->registerCheckedWidget( mEnableMaskChkBx );
728 mShapeDrawDDBtn->registerCheckedWidget( mShapeDrawChkBx );
751 mShadowDrawDDBtn->registerCheckedWidget( mShadowDrawChkBx );
791 QString ddScaleVisInfo = tr(
"Value < 0 represents a scale closer than 1:1, e.g. -10 = 10:1<br>"
792 "Value of 0 disables the specific limit." );
794 mScaleBasedVisibilityDDBtn->registerCheckedWidget( mScaleBasedVisibilityChkBx );
796 mScaleBasedVisibilityMinDDBtn->setUsageInfo( ddScaleVisInfo );
798 mScaleBasedVisibilityMaxDDBtn->setUsageInfo( ddScaleVisInfo );
801 mFontLimitPixelDDBtn->registerCheckedWidget( mFontLimitPixelChkBox );
813 mCalloutDrawDDBtn->registerCheckedWidget( mCalloutsDrawCheckBox );
821 if ( !mButtons.contains( key ) )
826 mButtons[key] = button;
843 mBufferDrawChkBx->setChecked( buffer.
enabled() );
844 mBufferFrame->setEnabled( buffer.
enabled() );
845 spinBufferSize->setValue( buffer.
size() );
846 mBufferUnitWidget->setUnit( buffer.
sizeUnit() );
848 btnBufferColor->setColor( buffer.
color() );
849 mBufferOpacityWidget->setOpacity( buffer.
opacity() );
850 mBufferJoinStyleComboBox->setPenJoinStyle( buffer.
joinStyle() );
852 comboBufferBlendMode->setBlendMode( buffer.
blendMode() );
854 mBufferEffect.reset( lPaintEffect->clone() );
858 mBufferEffect->setEnabled(
false );
860 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
864 mEnableMaskChkBx->setChecked( mask.
enabled() );
865 mMaskBufferSizeSpinBox->setValue( mask.
size() );
866 mMaskBufferUnitWidget->setUnit( mask.
sizeUnit() );
868 mMaskOpacityWidget->setOpacity( mask.
opacity() );
869 mMaskJoinStyleComboBox->setPenJoinStyle( mask.
joinStyle() );
871 mMaskEffect.reset( lPaintEffect->clone() );
875 mMaskEffect->setEnabled(
false );
877 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
886 mTextOrientationComboBox->setCurrentIndex( mTextOrientationComboBox->findData(
format.
orientation() ) );
889 mFontWordSpacingSpinBox->setValue(
format.
font().wordSpacing() );
890 mFontLetterSpacingSpinBox->setValue(
format.
font().letterSpacing() );
895 updateFont( mRefFont );
901 QString missingTxt = tr(
"%1 not found. Default substituted." );
902 QString txtPrepend = tr(
"Chosen font" );
907 mFontMissingLabel->setText( missingTxt.arg( txtPrepend ) );
910 mLabelingOptionsListWidget->setCurrentRow( 0 );
916 mShapeDrawChkBx->setChecked( background.
enabled() );
917 mShapeFrame->setEnabled( background.
enabled() );
918 mShapeTypeCmbBx->blockSignals(
true );
919 mShapeTypeCmbBx->setCurrentIndex( mShapeTypeCmbBx->findData( background.
type() ) );
920 mShapeTypeCmbBx->blockSignals(
false );
921 updateAvailableShadowPositions();
922 mShapeSVGPathLineEdit->setText( background.
svgFile() );
924 mShapeSizeCmbBx->setCurrentIndex( background.
sizeType() );
925 mShapeSizeXSpnBx->setValue( background.
size().width() );
926 mShapeSizeYSpnBx->setValue( background.
size().height() );
927 mShapeSizeUnitWidget->setUnit( background.
sizeUnit() );
929 mShapeRotationCmbBx->setCurrentIndex( background.
rotationType() );
932 mShapeRotationDblSpnBx->setValue( background.
rotation() );
933 mShapeOffsetXSpnBx->setValue( background.
offset().x() );
934 mShapeOffsetYSpnBx->setValue( background.
offset().y() );
935 mShapeOffsetUnitWidget->setUnit( background.
offsetUnit() );
937 mShapeRadiusXDbSpnBx->setValue( background.
radii().width() );
938 mShapeRadiusYDbSpnBx->setValue( background.
radii().height() );
939 mShapeRadiusUnitWidget->setUnit( background.
radiiUnit() );
942 mShapeFillColorBtn->setColor( background.
fillColor() );
943 mShapeStrokeColorBtn->setColor( background.
strokeColor() );
944 mShapeStrokeWidthSpnBx->setValue( background.
strokeWidth() );
947 mShapePenStyleCmbBx->setPenJoinStyle( background.
joinStyle() );
949 mBackgroundOpacityWidget->setOpacity( background.
opacity() );
950 mShapeBlendCmbBx->setBlendMode( background.
blendMode() );
952 mLoadSvgParams =
false;
953 mShapeTypeCmbBx_currentIndexChanged( background.
type() );
955 if (
auto *lPaintEffect = background.
paintEffect() )
956 mBackgroundEffect.reset( lPaintEffect->clone() );
960 mBackgroundEffect->setEnabled(
false );
962 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
967 mShadowDrawChkBx->setChecked( shadow.
enabled() );
968 mShadowFrame->setEnabled( shadow.
enabled() );
969 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( shadow.
shadowPlacement() ) );
970 mShadowOffsetAngleSpnBx->setValue( shadow.
offsetAngle() );
972 mShadowOffsetUnitWidget->setUnit( shadow.
offsetUnit() );
974 mShadowOffsetGlobalChkBx->setChecked( shadow.
offsetGlobal() );
976 mShadowRadiusDblSpnBx->setValue( shadow.
blurRadius() );
979 mShadowRadiusAlphaChkBx->setChecked( shadow.
blurAlphaOnly() );
980 mShadowOpacityWidget->setOpacity( shadow.
opacity() );
981 mShadowScaleSpnBx->setValue( shadow.
scale() );
983 mShadowColorBtn->setColor( shadow.
color() );
984 mShadowBlendCmbBx->setBlendMode( shadow.
blendMode() );
996 settings.
setValue( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ), mFontPreviewSplitter->saveState() );
997 settings.
setValue( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ), mLabelingOptionsSplitter->saveState() );
999 int prevIndex = mLabelingOptionsListWidget->currentRow();
1000 if ( mWidgetMode ==
Text )
1002 switch ( prevIndex )
1011 settings.
setValue( QStringLiteral(
"Windows/Labeling/Tab" ), prevIndex );
1033 buffer.
setEnabled( mBufferDrawChkBx->isChecked() );
1034 buffer.
setSize( spinBufferSize->value() );
1035 buffer.
setColor( btnBufferColor->color() );
1036 buffer.
setOpacity( mBufferOpacityWidget->opacity() );
1039 buffer.
setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
1041 buffer.
setBlendMode( comboBufferBlendMode->blendMode() );
1050 mask.
setEnabled( mEnableMaskChkBx->isChecked() );
1051 mask.
setSize( mMaskBufferSizeSpinBox->value() );
1052 mask.
setOpacity( mMaskOpacityWidget->opacity() );
1053 mask.
setSizeUnit( mMaskBufferUnitWidget->unit() );
1055 mask.
setJoinStyle( mMaskJoinStyleComboBox->penJoinStyle() );
1065 background.
setEnabled( mShapeDrawChkBx->isChecked() );
1067 background.
setSvgFile( mShapeSVGPathLineEdit->text() );
1069 background.
setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
1070 background.
setSizeUnit( mShapeSizeUnitWidget->unit() );
1073 background.
setRotation( mShapeRotationDblSpnBx->value() );
1074 background.
setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
1077 background.
setRadii( QSizeF( mShapeRadiusXDbSpnBx->value(), mShapeRadiusYDbSpnBx->value() ) );
1078 background.
setRadiiUnit( mShapeRadiusUnitWidget->unit() );
1081 background.
setFillColor( mShapeFillColorBtn->color() );
1086 background.
setJoinStyle( mShapePenStyleCmbBx->penJoinStyle() );
1087 background.
setOpacity( mBackgroundOpacityWidget->opacity() );
1088 background.
setBlendMode( mShapeBlendCmbBx->blendMode() );
1098 shadow.
setEnabled( mShadowDrawChkBx->isChecked() );
1109 shadow.
setOpacity( mShadowOpacityWidget->opacity() );
1110 shadow.
setScale( mShadowScaleSpnBx->value() );
1111 shadow.
setColor( mShadowColorBtn->color() );
1115 if ( includeDataDefinedProperties )
1146 if ( mButtons.contains( key ) )
1158 void QgsTextFormatWidget::optionsStackedWidget_CurrentChanged(
int indx )
1160 mLabelingOptionsListWidget->blockSignals(
true );
1161 mLabelingOptionsListWidget->setCurrentRow( indx );
1162 mLabelingOptionsListWidget->blockSignals(
false );
1171 mPreviewExpressionContext = *lExpressionContext;
1176 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
1184 void QgsTextFormatWidget::collapseSample(
bool collapse )
1188 QList<int> splitSizes = mFontPreviewSplitter->sizes();
1189 if ( splitSizes[0] > groupBox_mPreview->height() )
1191 int delta = splitSizes[0] - groupBox_mPreview->height();
1192 splitSizes[0] -= delta;
1193 splitSizes[1] += delta;
1194 mFontPreviewSplitter->setSizes( splitSizes );
1199 void QgsTextFormatWidget::changeTextColor(
const QColor &color )
1205 void QgsTextFormatWidget::updateFont(
const QFont &font )
1208 if ( font != mRefFont )
1217 mDirectSymbLeftLineEdit->setFont( mRefFont );
1218 mDirectSymbRightLineEdit->setFont( mRefFont );
1220 blockFontChangeSignals(
true );
1221 mFontFamilyCmbBx->setCurrentFont( mRefFont );
1222 populateFontStyleComboBox();
1223 mFontUnderlineBtn->setChecked( mRefFont.underline() );
1224 mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
1225 mKerningCheckBox->setChecked( mRefFont.kerning() );
1226 blockFontChangeSignals(
false );
1234 void QgsTextFormatWidget::blockFontChangeSignals(
bool blk )
1236 mFontFamilyCmbBx->blockSignals( blk );
1237 mFontStyleComboBox->blockSignals( blk );
1238 mFontCapitalsComboBox->blockSignals( blk );
1239 mFontUnderlineBtn->blockSignals( blk );
1240 mFontStrikethroughBtn->blockSignals( blk );
1241 mFontWordSpacingSpinBox->blockSignals( blk );
1242 mFontLetterSpacingSpinBox->blockSignals( blk );
1243 mKerningCheckBox->blockSignals( blk );
1258 lblFontPreview->setFormat(
format() );
1261 void QgsTextFormatWidget::scrollPreview()
1263 scrollArea_mPreview->ensureVisible( 0, 0, 0, 0 );
1268 mPreviewBackgroundColor = color;
1270 scrollArea_mPreview->widget()->setStyleSheet( QStringLiteral(
"background: rgb(%1, %2, %3);" ).arg( QString::number( color.red() ),
1271 QString::number( color.green() ),
1272 QString::number( color.blue() ) ) );
1275 void QgsTextFormatWidget::changeBufferColor(
const QColor &color )
1284 bool showLineFrame =
false;
1285 bool showCentroidFrame =
false;
1286 bool showQuadrantFrame =
false;
1287 bool showFixedQuadrantFrame =
false;
1288 bool showPlacementPriorityFrame =
false;
1289 bool showOffsetTypeFrame =
false;
1290 bool showOffsetFrame =
false;
1291 bool showDistanceFrame =
false;
1292 bool showRotationFrame =
false;
1293 bool showMaxCharAngleFrame =
false;
1298 bool enableMultiLinesFrame =
true;
1304 showDistanceFrame =
true;
1312 showQuadrantFrame =
true;
1313 showFixedQuadrantFrame =
true;
1314 showOffsetFrame =
true;
1315 showRotationFrame =
true;
1319 showDistanceFrame =
true;
1320 showPlacementPriorityFrame =
true;
1321 showOffsetTypeFrame =
true;
1328 showLineFrame =
true;
1329 showDistanceFrame =
true;
1332 bool offline = chkLineAbove->isChecked() || chkLineBelow->isChecked();
1333 chkLineOrientationDependent->setEnabled( offline );
1334 mPlacementDistanceFrame->setEnabled( offline );
1338 showMaxCharAngleFrame = isCurved;
1340 enableMultiLinesFrame = !isCurved;
1345 showDistanceFrame =
true;
1348 mPlacementLineFrame->setVisible( showLineFrame );
1349 mPlacementPolygonFrame->setVisible( showPolygonPlacementOptions );
1350 mPlacementCentroidFrame->setVisible( showCentroidFrame );
1351 mPlacementQuadrantFrame->setVisible( showQuadrantFrame );
1352 mPlacementFixedQuadrantFrame->setVisible( showFixedQuadrantFrame );
1353 mPlacementCartographicFrame->setVisible( showPlacementPriorityFrame );
1354 mPlacementOffsetFrame->setVisible( showOffsetFrame );
1355 mPlacementDistanceFrame->setVisible( showDistanceFrame );
1356 mPlacementOffsetTypeFrame->setVisible( showOffsetTypeFrame );
1357 mPlacementRotationFrame->setVisible( showRotationFrame );
1362 mPlacementMaxCharAngleFrame->setVisible( showMaxCharAngleFrame );
1364 mMultiLinesFrame->setEnabled( enableMultiLinesFrame );
1368 switch ( currentPlacement )
1372 helperText = tr(
"Arranges label candidates in a clockwise circle around the feature, preferring placements to the top-right of the feature." );
1374 helperText = tr(
"Arranges label candidates in a cluster around the feature's centroid, preferring placements directly over the centroid." );
1378 helperText = tr(
"Arranges label candidates directly over the feature or at a preset offset from the feature." );
1380 helperText = tr(
"Arranges label candidates directly over the feature's centroid, or at a preset offset from the centroid." );
1384 helperText = tr(
"Arranges label candidates parallel to a generalised line representing the feature. Placements which fall over straighter portions of the line are preferred." );
1386 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." );
1390 helperText = tr(
"Arranges candidates following the curvature of a line feature. Placements which fall over straighter portions of the line are preferred." );
1394 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." );
1396 helperText = tr(
"Label candidates are arranged horizontally along the length of the feature." );
1400 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." );
1404 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." );
1408 helperText = tr(
"Arranges candidates following the curvature of the feature's perimeter. Placements which fall over straighter portions of the perimeter are preferred." );
1412 helperText = tr(
"Label candidates are placed outside of the features, preferring placements which give greatest visual association between the label and the feature." );
1415 mPlacementModeDescriptionLabel->setText( QStringLiteral(
"<i>%1</i>" ).arg( helperText ) );
1418 void QgsTextFormatWidget::populateFontCapitalsComboBox()
1430 void QgsTextFormatWidget::populateFontStyleComboBox()
1432 mFontStyleComboBox->clear();
1433 QStringList styles = mFontDB.styles( mRefFont.family() );
1434 const auto constStyles = styles;
1435 for (
const QString &style : constStyles )
1437 mFontStyleComboBox->addItem( style );
1440 QString targetStyle = mFontDB.styleString( mRefFont );
1441 if ( !styles.contains( targetStyle ) )
1443 QFont f = QFont( mRefFont.family() );
1444 targetStyle = QFontInfo( f ).styleName();
1445 mRefFont.setStyleName( targetStyle );
1448 int stylIndx = mFontStyleComboBox->findText( targetStyle );
1449 if ( stylIndx > -1 )
1454 mFontStyleComboBox->setCurrentIndex( curIndx );
1457 void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged(
double d )
1459 mRefFont.setPointSizeF( d );
1460 updateFont( mRefFont );
1463 void QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged(
const QFont &f )
1465 mRefFont.setFamily( f.family() );
1466 updateFont( mRefFont );
1469 void QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged(
const QString &text )
1472 updateFont( mRefFont );
1475 void QgsTextFormatWidget::mFontUnderlineBtn_toggled(
bool ckd )
1477 mRefFont.setUnderline( ckd );
1478 updateFont( mRefFont );
1481 void QgsTextFormatWidget::mFontStrikethroughBtn_toggled(
bool ckd )
1483 mRefFont.setStrikeOut( ckd );
1484 updateFont( mRefFont );
1487 void QgsTextFormatWidget::kerningToggled(
bool checked )
1489 mRefFont.setKerning( checked );
1490 updateFont( mRefFont );
1493 void QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged(
double spacing )
1495 mRefFont.setWordSpacing( spacing );
1496 updateFont( mRefFont );
1499 void QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged(
double spacing )
1501 mRefFont.setLetterSpacing( QFont::AbsoluteSpacing, spacing );
1502 updateFont( mRefFont );
1505 void QgsTextFormatWidget::mFontSizeUnitWidget_changed()
1510 mFontLimitPixelChkBox->setChecked(
false );
1516 mFontLimitPixelChkBox->setChecked(
true );
1518 updateFont( mRefFont );
1521 void QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged(
int px )
1524 mFontMaxPixelSpinBox->setMinimum( px );
1525 mFontMaxPixelSpinBox->update();
1528 void QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged(
int px )
1531 if ( px < mFontMinPixelSpinBox->value() )
1533 mFontMaxPixelSpinBox->blockSignals(
true );
1534 mFontMaxPixelSpinBox->setValue( mFontMinPixelSpinBox->value() );
1535 mFontMaxPixelSpinBox->blockSignals(
false );
1537 mFontMaxPixelSpinBox->setMinimum( mFontMinPixelSpinBox->value() );
1540 void QgsTextFormatWidget::mBufferUnitWidget_changed()
1542 updateFont( mRefFont );
1545 void QgsTextFormatWidget::mMaskBufferUnitWidget_changed()
1547 updateFont( mRefFont );
1550 void QgsTextFormatWidget::mCoordXDDBtn_changed( )
1552 if ( !mCoordXDDBtn->isActive() )
1556 else if ( mCoordYDDBtn->isActive() )
1562 void QgsTextFormatWidget::mCoordYDDBtn_changed( )
1564 if ( !mCoordYDDBtn->isActive() )
1568 else if ( mCoordXDDBtn->isActive() )
1574 void QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged(
int )
1582 showBackgroundPenStyle( isRect );
1583 showBackgroundRadius( isRect );
1585 mShapeSVGPathFrame->setVisible( isSVG );
1586 mBackgroundSymbolButton->setVisible( isMarker );
1590 mShapeSizeYLabel->setVisible( !isSVG && !isMarker );
1591 mShapeSizeYSpnBx->setVisible( !isSVG && !isMarker );
1592 mShapeSizeYDDBtn->setVisible( !isSVG && !isMarker );
1593 mShapeSizeXLabel->setText( tr(
"Size%1" ).arg( !isSVG && !isMarker ? tr(
" X" ) : QString() ) );
1596 mShapeFillColorBtn->setAllowOpacity( !isSVG );
1597 mShapeFillColorBtn->setButtonBackground();
1598 mShapeStrokeColorBtn->setAllowOpacity( !isSVG );
1599 mShapeStrokeColorBtn->setButtonBackground();
1602 mShapeFillColorLabel->setVisible( !isMarker );
1603 mShapeFillColorLabel->setEnabled( !isMarker );
1604 mShapeFillColorBtn->setVisible( !isMarker );
1605 mShapeFillColorBtn->setEnabled( !isMarker );
1606 mShapeFillColorDDBtn->setVisible( !isMarker );
1607 mShapeFillColorDDBtn->setEnabled( !isMarker );
1608 mShapeStrokeColorLabel->setVisible( !isMarker );
1609 mShapeStrokeColorLabel->setEnabled( !isMarker );
1610 mShapeStrokeColorBtn->setVisible( !isMarker );
1611 mShapeStrokeColorBtn->setEnabled( !isMarker );
1612 mShapeStrokeColorDDBtn->setVisible( !isMarker );
1613 mShapeStrokeColorDDBtn->setEnabled( !isMarker );
1614 mShapeStrokeWidthLabel->setVisible( !isMarker );
1615 mShapeStrokeWidthLabel->setEnabled( !isMarker );
1616 mShapeStrokeWidthSpnBx->setVisible( !isMarker );
1617 mShapeStrokeWidthSpnBx->setEnabled( !isMarker );
1618 mShapeStrokeWidthDDBtn->setVisible( !isMarker );
1619 mShapeStrokeWidthDDBtn->setEnabled( !isMarker );
1622 mShapeSVGParamsBtn->setVisible( isSVG );
1625 updateSvgWidgets( mShapeSVGPathLineEdit->text() );
1629 mShapeStrokeWidthUnitWidget->setVisible( !isSVG && !isMarker );
1630 mShapeSVGUnitsLabel->setVisible( isSVG );
1631 mShapeStrokeUnitsDDBtn->setVisible( !isSVG && !isMarker );
1632 mShapeStrokeUnitsDDBtn->setEnabled( !isSVG && !isMarker );
1634 updateAvailableShadowPositions();
1637 void QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged(
const QString &text )
1639 updateSvgWidgets( text );
1644 int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) +
1645 ( chkLineBelow->isChecked() ? 1 : 0 ) +
1646 ( chkLineOn->isChecked() ? 1 : 0 );
1648 if ( numOptionsChecked == 1 )
1651 chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
1652 chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
1653 chkLineOn->setEnabled( !chkLineOn->isChecked() );
1657 chkLineAbove->setEnabled(
true );
1658 chkLineBelow->setEnabled(
true );
1659 chkLineOn->setEnabled(
true );
1669 void QgsTextFormatWidget::previewScaleChanged(
double scale )
1671 lblFontPreview->setScale( scale );
1674 void QgsTextFormatWidget::updateSvgWidgets(
const QString &svgPath )
1676 if ( mShapeSVGPathLineEdit->text() != svgPath )
1678 mShapeSVGPathLineEdit->setText( svgPath );
1681 QString resolvedPath;
1682 bool validSVG =
true;
1683 if ( ! svgPath.startsWith( QLatin1String(
"base64:" ), Qt::CaseInsensitive ) )
1686 validSVG = QFileInfo::exists( resolvedPath );
1690 resolvedPath = svgPath;
1695 mShapeSVGPathLineEdit->setStyleSheet( !validSVG ? QStringLiteral(
"QLineEdit{ color: rgb(225, 0, 0); }" ) : QString() );
1696 mShapeSVGPathLineEdit->setToolTip( !validSVG ? tr(
"File not found" ) : resolvedPath );
1698 QColor fill, stroke;
1699 double strokeWidth = 0.0;
1700 bool fillParam =
false, strokeParam =
false, strokeWidthParam =
false;
1706 mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || strokeParam || strokeWidthParam ) );
1708 mShapeFillColorLabel->setEnabled( validSVG && fillParam );
1709 mShapeFillColorBtn->setEnabled( validSVG && fillParam );
1710 mShapeFillColorDDBtn->setEnabled( validSVG && fillParam );
1711 if ( mLoadSvgParams && validSVG && fillParam )
1712 mShapeFillColorBtn->setColor( fill );
1714 mShapeStrokeColorLabel->setEnabled( validSVG && strokeParam );
1715 mShapeStrokeColorBtn->setEnabled( validSVG && strokeParam );
1716 mShapeStrokeColorDDBtn->setEnabled( validSVG && strokeParam );
1717 if ( mLoadSvgParams && validSVG && strokeParam )
1718 mShapeStrokeColorBtn->setColor( stroke );
1720 mShapeStrokeWidthLabel->setEnabled( validSVG && strokeWidthParam );
1721 mShapeStrokeWidthSpnBx->setEnabled( validSVG && strokeWidthParam );
1722 mShapeStrokeWidthDDBtn->setEnabled( validSVG && strokeWidthParam );
1723 if ( mLoadSvgParams && validSVG && strokeWidthParam )
1724 mShapeStrokeWidthSpnBx->setValue( strokeWidth );
1730 mShapeSVGUnitsLabel->setEnabled( validSVG && strokeWidthParam );
1733 void QgsTextFormatWidget::updateAvailableShadowPositions()
1735 if ( mShadowUnderCmbBx->count() == 0
1741 mShadowUnderCmbBx->clear();
1749 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( currentPlacement ) );
1750 if ( mShadowUnderCmbBx->currentIndex() == -1 )
1751 mShadowUnderCmbBx->setCurrentIndex( 0 );
1755 void QgsTextFormatWidget::updateProperty()
1763 void QgsTextFormatWidget::createAuxiliaryField()
1790 property.setActive(
true );
1799 void QgsTextFormatWidget::updateShapeFrameStatus()
1801 mShapeFrame->setEnabled( mShapeDrawDDBtn->isActive() || mShapeDrawChkBx->isChecked() );
1804 void QgsTextFormatWidget::updateBufferFrameStatus()
1806 mBufferFrame->setEnabled( mBufferDrawDDBtn->isActive() || mBufferDrawChkBx->isChecked() );
1809 void QgsTextFormatWidget::updateShadowFrameStatus()
1811 mShadowFrame->setEnabled( mShadowDrawDDBtn->isActive() || mShadowDrawChkBx->isChecked() );
1814 void QgsTextFormatWidget::updateCalloutFrameStatus()
1816 mCalloutFrame->setEnabled( mCalloutDrawDDBtn->isActive() || mCalloutsDrawCheckBox->isChecked() );
1860 saveDlg.
setDefaultTags( mTextFormatsListWidget->currentTagFilter() );
1861 if ( !saveDlg.exec() )
1864 if ( saveDlg.
name().isEmpty() )
1870 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1871 tr(
"Format with name '%1' already exists. Overwrite?" )
1872 .arg( saveDlg.
name() ),
1873 QMessageBox::Yes | QMessageBox::No );
1874 if ( res != QMessageBox::Yes )
1881 QStringList symbolTags = saveDlg.
tags().split(
',' );
1888 void QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked()
1891 svgDlg.setWindowTitle( tr(
"Select SVG file" ) );
1892 svgDlg.svgSelector()->setSvgPath( mShapeSVGPathLineEdit->text().trimmed() );
1894 if ( svgDlg.exec() == QDialog::Accepted )
1896 QString svgPath = svgDlg.svgSelector()->currentSvgPath();
1897 if ( !svgPath.isEmpty() )
1899 mShapeSVGPathLineEdit->setText( svgPath );
1905 void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
1907 QString svgPath = mShapeSVGPathLineEdit->text();
1908 mLoadSvgParams =
true;
1909 updateSvgWidgets( svgPath );
1910 mLoadSvgParams =
false;
1913 void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged(
int index )
1919 void QgsTextFormatWidget::mPreviewTextEdit_textChanged(
const QString &text )
1921 lblFontPreview->setText( text );
1925 void QgsTextFormatWidget::mPreviewTextBtn_clicked()
1927 mPreviewTextEdit->setText( QStringLiteral(
"Lorem Ipsum" ) );
1931 void QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged(
const QColor &color )
1936 void QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked()
1938 bool gotChar =
false;
1940 const QChar initial = !mDirectSymbLeftLineEdit->text().isEmpty() ? mDirectSymbLeftLineEdit->text().at( 0 ) : QChar();
1941 QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
1946 if ( !dirSymb.isNull() )
1947 mDirectSymbLeftLineEdit->setText( QString( dirSymb ) );
1950 void QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked()
1952 bool gotChar =
false;
1953 const QChar initial = !mDirectSymbRightLineEdit->text().isEmpty() ? mDirectSymbRightLineEdit->text().at( 0 ) : QChar();
1954 QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
1959 if ( !dirSymb.isNull() )
1960 mDirectSymbRightLineEdit->setText( QString( dirSymb ) );
1963 void QgsTextFormatWidget::chkLineOrientationDependent_toggled(
bool active )
1967 chkLineAbove->setText( tr(
"Left of line" ) );
1968 chkLineBelow->setText( tr(
"Right of line" ) );
1972 chkLineAbove->setText( tr(
"Above line" ) );
1973 chkLineBelow->setText( tr(
"Below line" ) );
1978 void QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked()
1993 if ( dlg.exec() == QDialog::Accepted )
2000 void QgsTextFormatWidget::showBackgroundRadius(
bool show )
2002 mShapeRadiusLabel->setVisible( show );
2003 mShapeRadiusXDbSpnBx->setVisible( show );
2005 mShapeRadiusYDbSpnBx->setVisible( show );
2007 mShapeRadiusUnitWidget->setVisible( show );
2009 mShapeRadiusDDBtn->setVisible( show );
2010 mShapeRadiusUnitsDDBtn->setVisible( show );
2013 void QgsTextFormatWidget::showBackgroundPenStyle(
bool show )
2015 mShapePenStyleLabel->setVisible( show );
2016 mShapePenStyleCmbBx->setVisible( show );
2018 mShapePenStyleDDBtn->setVisible( show );
2023 mCoordAlignmentFrame->setEnabled( enable );
2029 return *lExpressionContext;
2050 if ( mGeometryGeneratorGroupBox->isChecked() )
2064 : QDialog( parent, fl )
2066 setWindowTitle( tr(
"Text Settings" ) );
2069 mFormatWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
2071 QVBoxLayout *layout =
new QVBoxLayout(
this );
2072 layout->addWidget( mFormatWidget );
2074 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, Qt::Horizontal,
this );
2075 layout->addWidget( mButtonBox );
2077 setLayout( layout );
2080 connect( mButtonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked,
this, &QDialog::accept );
2081 connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked,
this, &QDialog::reject );
2082 connect( mButtonBox->button( QDialogButtonBox::Help ), &QAbstractButton::clicked,
this, &QgsTextFormatDialog::showHelp );
2087 return mFormatWidget->
format();
2090 void QgsTextFormatDialog::showHelp()
2092 QgsHelp::openHelp( QStringLiteral(
"style_library/label_settings.html#formatting-the-label-text" ) );
2108 mFormatWidget = qobject_cast< QgsTextFormatWidget * >(
widget() );
2111 if ( !mBlockSignals )
2118 return mFormatWidget->
format();
2123 mBlockSignals =
true;
2125 mBlockSignals =
false;
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
A dialog for selecting a single character from a single font.
QChar selectCharacter(bool *gotChar, const QFont &font, const QString &style, QChar initialSelection=QChar())
Opens the dialog modally and returns when the user has selected a character.
A QGIS expression editor based on QScintilla2.
void collapsedStateChanged(bool collapsed)
Signal emitted when groupbox collapsed/expanded state is changed, and when first shown.
A groupbox that collapses/expands when toggled and can save its collapsed and checked states.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
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 QgsGui * instance()
Returns a pointer to the singleton instance.
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.
@ SymbolLeftRight
Place direction symbols on left/right of label.
@ SymbolAbove
Place direction symbols on above label.
@ SymbolBelow
Place direction symbols on below label.
static QIcon iconForWkbType(QgsWkbTypes::Type type)
Returns the icon for a vector layer whose geometry type is provided.
static void warning(const QString &msg)
Goes to qWarning.
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
double scale() const
Returns the calculated map scale.
QgsUnitTypes::DistanceUnit mapUnits() const
Returns the units of the map's geographical coordinates - used for scale calculation.
A marker symbol type, for rendering Point and MultiPoint geometries.
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
A dialog to create a new auxiliary layer.
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
@ ShowDefined
Show upside down when rotation is layer- or data-defined.
@ Upright
Upside-down labels (90 <= angle < 270) are shown upright.
@ ShowAll
Show upside down for all labels, including dynamic ones.
Placement
Placement modes which determine how label candidates are generated for a feature.
@ PerimeterCurved
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only.
@ Curved
Arranges candidates following the curvature of a line feature. Applies to line layers only.
@ Horizontal
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
@ Free
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
@ OrderedPositionsAroundPoint
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
@ OutsidePolygons
Candidates are placed outside of polygon boundaries. Applies to polygon layers only....
Property
Data definable properties.
@ MaskEnabled
Whether the mask is enabled.
@ LabelRotation
Label rotation.
@ PositionY
Y-coordinate data defined label position.
@ OverrunDistance
Distance which labels can extend past either end of linear features.
@ Strikeout
Use strikeout.
@ FontStyle
Font style name.
@ PositionX
X-coordinate data defined label position.
@ CalloutDraw
Show callout.
@ Underline
Use underline.
@ FontLetterSpacing
Letter spacing.
@ MaskJoinStyle
Mask join style.
@ Hali
Horizontal alignment for data defined label position (Left, Center, Right)
@ MaskBufferUnit
Mask buffer size unit.
@ LabelAllParts
Whether all parts of multi-part features should be labeled.
@ ShadowOpacity
Shadow opacity.
@ BufferOpacity
Buffer opacity.
@ ShapeOpacity
Shape opacity.
@ FontSizeUnit
Font size units.
@ Italic
Use italic style.
@ PredefinedPositionOrder
@ FontWordSpacing
Word spacing.
@ MaskBufferSize
Mask buffer size.
@ MinimumScale
Minimum map scale (ie most "zoomed out")
@ FontBlendMode
Text blend mode.
@ MaximumScale
Maximum map scale (ie most "zoomed in")
@ MaskOpacity
Mask opacity.
@ PolygonLabelOutside
Whether labels outside a polygon feature are permitted, or should be forced (since QGIS 3....
@ FontCase
Label text case.
@ LinePlacementOptions
Line placement flags.
@ Vali
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
@ FontOpacity
Text opacity.
@ FromPoint
Offset distance applies from point geometry.
@ FromSymbolBounds
Offset distance applies from rendered symbol bounds.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the labeling property definitions.
static QgsProject * instance()
Returns the QgsProject singleton instance.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
QSet< int > propertyKeys() const override
Returns a list of property keys contained within the collection.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
Definition for a property.
A store for object properties.
void setField(const QString &field)
Sets the field name the property references.
void setActive(bool active)
Sets whether the property is currently active.
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).
Capitalization
Capitalization options.
@ 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...
@ AllUppercase
Convert all characters to uppercase.
@ ForceFirstLetterToCapital
Convert just the first letter of each word to uppercase, leave the rest untouched.
a dialog for setting properties of a newly saved style.
bool isFavorite() const
Returns true if the favorite is checked for the symbol.
QString name() const
Returns the entered name for the new symbol.
void setDefaultTags(const QString &tags)
Sets the default tags for the newly created item.
QString tags() const
Returns any tags entered for the new symbol (as a comma separated value list).
QgsTextFormat textFormat(const QString &name) const
Returns the text format with the specified name.
QStringList textFormatNames() const
Returns a list of names of text formats in the style.
bool removeTextFormat(const QString &name)
Removes a text format from the style.
StyleEntity
Enum for Entities involved in a style.
@ LabelSettingsEntity
Label settings.
@ TextFormatEntity
Text formats.
@ SmartgroupEntity
Smart groups.
@ Symbol3DEntity
3D symbol entity (since QGIS 3.14)
@ ColorrampEntity
Color ramps.
@ LegendPatchShapeEntity
Legend patch shape (since QGIS 3.14)
static QgsStyle * defaultStyle()
Returns default application-wide style.
bool addTextFormat(const QString &name, const QgsTextFormat &format, bool update=false)
Adds a text format with the specified name to the style.
QgsPalLayerSettings labelSettings(const QString &name) const
Returns the label settings with the specified name.
bool saveTextFormat(const QString &name, const QgsTextFormat &format, bool favorite, const QStringList &tags)
Adds a text format to the database.
A dialog which allows users to specify a list of substitutions to apply to a string,...
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth, bool blocking=false) const
Tests if an SVG file contains parameters for fill, stroke color, stroke width.
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Container for settings relating to a text background object.
QgsMapUnitScale strokeWidthMapUnitScale() const
Returns the map unit scale object for the shape stroke width.
RotationType rotationType() const
Returns the method used for rotating the background shape.
QString svgFile() const
Returns the absolute path to the background SVG file, if set.
QSizeF size() const
Returns the size of the background shape.
QSizeF radii() const
Returns the radii used for rounding the corners of shapes.
QgsMapUnitScale radiiMapUnitScale() const
Returns the map unit scale object for the shape radii.
void setOpacity(double opacity)
Sets the background shape's opacity.
void setStrokeColor(const QColor &color)
Sets the color used for outlining the background shape.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units used for the shape's stroke width.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape size.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the background shape.
Qt::PenJoinStyle joinStyle() const
Returns the join style used for drawing the background shape.
SizeType
Methods for determining the background shape size.
bool enabled() const
Returns whether the background is enabled.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the background shape.
void setRadiiUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's radii.
double opacity() const
Returns the background shape's opacity.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape stroke width.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the shape's offset.
double rotation() const
Returns the rotation for the background shape, in degrees clockwise.
QColor fillColor() const
Returns the color used for filing the background shape.
void setMarkerSymbol(QgsMarkerSymbol *symbol)
Sets the current marker symbol for the background shape.
void setRadii(QSizeF radii)
Sets the radii used for rounding the corners of shapes.
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
ShapeType type() const
Returns the type of background shape (e.g., square, ellipse, SVG).
double strokeWidth() const
Returns the width of the shape's stroke (stroke).
void setSizeType(SizeType type)
Sets the method used to determine the size of the background shape (e.g., fixed size or buffer around...
ShapeType
Background shape types.
@ ShapeMarkerSymbol
Marker symbol.
@ ShapeSquare
Square - buffered sizes only.
@ ShapeRectangle
Rectangle.
void setFillColor(const QColor &color)
Sets the color used for filing the background shape.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the background shape.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's stroke width.
QColor strokeColor() const
Returns the color used for outlining the background shape.
void setRotationType(RotationType type)
Sets the method used for rotating the background shape.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape offset.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the background shape.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
void setType(ShapeType type)
Sets the type of background shape to draw (e.g., square, ellipse, SVG).
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units used for the shape's size.
RotationType
Methods for determining the rotation of the background shape.
@ RotationSync
Shape rotation is synced with text rotation.
QgsUnitTypes::RenderUnit radiiUnit() const
Returns the units used for the shape's radii.
void setEnabled(bool enabled)
Sets whether the text background will be drawn.
QgsMarkerSymbol * markerSymbol() const
Returns the marker symbol to be rendered in the background.
void setRadiiMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape radii.
void setRotation(double rotation)
Sets the rotation for the background shape, in degrees clockwise.
void setOffset(QPointF offset)
Sets the offset used for drawing the background shape.
void setSize(QSizeF size)
Sets the size of the background shape.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the shape's size.
const QgsPaintEffect * paintEffect() const
Returns the current paint effect for the background shape.
void setSvgFile(const QString &file)
Sets the path to the background SVG file.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shape offset.
void setStrokeWidth(double width)
Sets the width of the shape's stroke (stroke).
QPointF offset() const
Returns the offset used for drawing the background shape.
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's offset.
Container for settings relating to a text buffer.
void setFillBufferInterior(bool fill)
Sets whether the interior of the buffer will be filled in.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the buffer.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
double size() const
Returns the size of the buffer.
void setColor(const QColor &color)
Sets the color for the buffer.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
void setOpacity(double opacity)
Sets the buffer opacity.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
bool enabled() const
Returns whether the buffer is enabled.
double opacity() const
Returns the buffer opacity.
bool fillBufferInterior() const
Returns whether the interior of the buffer will be filled in.
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the buffer.
const QgsPaintEffect * paintEffect() const
Returns the current paint effect for the buffer.
QColor color() const
Returns the color of the buffer.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the buffer.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
void setSize(double size)
Sets the size of the buffer.
QgsTextFormatDialog(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QgsVectorLayer *layer=nullptr)
Constructor for QgsTextFormatDialog.
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
void setFormat(const QgsTextFormat &format)
Sets the format to show in the widget.
void setDockMode(bool dockMode) override
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
QgsTextFormatPanelWidget(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsVectorLayer *layer=nullptr)
Constructor for QgsTextFormatPanelWidget.
A widget for customizing text formatting settings.
void updatePlacementWidgets()
Updates label placement options to reflect current state of widget.
QButtonGroup * mUpsidedownBtnGrp
Upside down labels button group.
QgsTextFormatWidget(const QgsTextFormat &format=QgsTextFormat(), QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsVectorLayer *layer=nullptr)
Constructor for QgsTextFormatWidget.
int mMinPixelLimit
Pixel size font limit.
void setDockMode(bool enabled)
Sets whether the widget should be shown in a compact dock mode.
void enableDataDefinedAlignment(bool enable)
Controls whether data defined alignment buttons are enabled.
QgsMapCanvas * mMapCanvas
Associated map canvas.
QgsSymbolWidgetContext context() const
Returns the context in which the widget is shown, e.g., the associated map canvas and expression cont...
~QgsTextFormatWidget() override
void deactivateField(QgsPalLayerSettings::Property key)
Deactivate a field from data defined properties and update the corresponding button.
void setFormat(const QgsTextFormat &format)
Sets the current formatting settings.
virtual void setFormatFromStyle(const QString &name, QgsStyle::StyleEntity type)
Sets the current text settings from a style entry.
QButtonGroup * mDirectSymbBtnGrp
Symbol direction button group.
void updateWidgetForFormat(const QgsTextFormat &format)
Updates the widget's state to reflect the settings in a QgsTextFormat.
void widgetChanged()
Emitted when the text format defined by the widget changes.
void setPreviewBackground(const QColor &color)
Sets the background color for the text preview widget.
QButtonGroup * mQuadrantBtnGrp
Quadrant button group.
QgsWkbTypes::GeometryType labelGeometryType() const
Returns the geometry type which will be used by the labeling engine when registering labels for the l...
QgsWkbTypes::GeometryType mGeomType
Geometry type for layer, if known.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsSymbolWidgetContext mContext
Context in which widget is shown.
void updateLinePlacementOptions()
Updates line placement options to reflect current state of widget.
void populateDataDefinedButtons()
Sets up connections required for data defined buttons, or updates the existing definition of these bu...
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
QgsSymbolLayerReferenceList mMaskedSymbolLayers
void updatePreview()
Updates the text preview.
void auxiliaryFieldCreated()
Emitted when an auxiliary field is created in the widget.
QgsStringReplacementCollection mSubstitutions
Text substitution list.
@ Text
Default mode, show text formatting settings only.
@ Labeling
Show labeling settings in addition to text formatting settings.
virtual void saveFormat()
Saves the current text settings to a style entry.
QgsPropertyCollection mDataDefinedProperties
Data defined properties as defined in the widget.
QgsVectorLayer * mLayer
Associated vector layer.
Container for all settings relating to text rendering.
void setColor(const QColor &color)
Sets the color that text will be rendered in.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the text.
void setSize(double size)
Sets the size for rendered text.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the size.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the format's property collection, used for data defined overrides.
void setFont(const QFont &font)
Sets the font used for rendering text.
double lineHeight() const
Returns the line height for text.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the size of rendered text.
void setOrientation(TextOrientation orientation)
Sets the orientation for the text.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the format's property collection, used for data defined overrides.
void setShadow(const QgsTextShadowSettings &shadowSettings)
Sets the text's drop shadow settings.
void setMask(const QgsTextMaskSettings &maskSettings)
Sets the text's masking settings.
bool fontFound() const
Returns true if the specified font was found on the system, or false if the font was not found and a ...
void setPreviewBackgroundColor(const QColor &color)
Sets the background color that text will be rendered on for previews.
void setOpacity(double opacity)
Sets the text's opacity.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the text.
TextOrientation orientation() const
Returns the orientation of the text.
void setAllowHtmlFormatting(bool allow)
Sets whether text should be treated as a HTML document and HTML tags should be used for formatting th...
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.
void setCapitalization(QgsStringUtils::Capitalization capitalization)
Sets the text capitalization style.
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
TextOrientation
Text orientation.
@ HorizontalOrientation
Vertically oriented text.
@ RotationBasedOrientation
Horizontally or vertically oriented text based on rotation (only available for map labeling)
@ VerticalOrientation
Horizontally oriented text.
bool allowHtmlFormatting() const
Returns true if text should be treated as a HTML document and HTML tags should be used for formatting...
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the size of rendered text.
double opacity() const
Returns the text's opacity.
QString namedStyle() const
Returns the named style for the font used for rendering text (e.g., "bold").
double size() const
Returns the size for rendered text.
QgsTextShadowSettings & shadow()
Returns a reference to the text drop shadow settings.
void setBackground(const QgsTextBackgroundSettings &backgroundSettings)
Sets the text's background settings.q.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the size.
void setNamedStyle(const QString &style)
Sets the named style for the font used for rendering text.
QgsStringUtils::Capitalization capitalization() const
Returns the text capitalization style.
QColor color() const
Returns the color that text will be rendered in.
QFont font() const
Returns the font used for rendering text.
QColor previewBackgroundColor() const
Returns the background color for text previews.
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
void setLineHeight(double height)
Sets the line height for text.
Container for settings relating to a selective masking around a text.
void setEnabled(bool)
Returns whether the mask is enabled.
void 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.
QgsSymbolLayerReferenceList maskedSymbolLayers() const
Returns a list of references to symbol layers that are masked by this buffer.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
void setMaskedSymbolLayers(QgsSymbolLayerReferenceList maskedLayers)
Sets the symbol layers that will be masked by this buffer.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the mask.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
double opacity() const
Returns the mask's opacity.
bool enabled() const
Returns whether the mask is enabled.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the mask.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
void setOpacity(double opacity)
Sets the mask's opacity.
Container for settings relating to a text shadow.
int offsetAngle() const
Returns the angle for offsetting the position of the shadow from the text.
void setBlurRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow blur radius.
bool enabled() const
Returns whether the shadow is enabled.
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
void setShadowPlacement(QgsTextShadowSettings::ShadowPlacement placement)
Sets the placement for the drop shadow.
double opacity() const
Returns the shadow's opacity.
QgsMapUnitScale blurRadiusMapUnitScale() const
Returns the map unit scale object for the shadow blur radius.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow offset distance.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the drop shadow.
void setColor(const QColor &color)
Sets the color for the drop shadow.
QColor color() const
Returns the color of the drop shadow.
void setOffsetGlobal(bool global)
Sets whether the global shadow offset should be used.
ShadowPlacement
Placement positions for text shadow.
@ ShadowBuffer
Draw shadow under buffer.
@ ShadowShape
Draw shadow under background shape.
@ ShadowLowest
Draw shadow below all text components.
@ ShadowText
Draw shadow under text.
void setScale(int scale)
Sets the scaling used for the drop shadow (in percentage of original size).
void setBlurAlphaOnly(bool alphaOnly)
Sets whether only the alpha channel for the shadow should be blurred.
QgsTextShadowSettings::ShadowPlacement shadowPlacement() const
Returns the placement for the drop shadow.
double offsetDistance() const
Returns the distance for offsetting the position of the shadow from the text.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the drop shadow.
void setOffsetDistance(double distance)
Sets the distance for offsetting the position of the shadow from the text.
void setOpacity(double opacity)
Sets the shadow's opacity.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shadow offset distance.
QgsUnitTypes::RenderUnit blurRadiusUnit() const
Returns the units used for the shadow's blur radius.
bool blurAlphaOnly() const
Returns whether only the alpha channel for the shadow will be blurred.
bool offsetGlobal() const
Returns true if the global shadow offset will be used.
void setOffsetAngle(int angle)
Sets the angle for offsetting the position of the shadow from the text.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the shadow's offset.
void setBlurRadiusUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's blur radius.
double blurRadius() const
Returns the blur radius for the shadow.
void setBlurRadius(double blurRadius)
Sets the blur radius for the shadow.
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's offset.
void setEnabled(bool enabled)
Sets whether the text shadow will be drawn.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
@ RenderMetersInMapUnits
Meters value as Map units.
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
@ RenderPoints
Points (e.g., for font sizes)
@ RenderMillimeters
Millimeters.
@ RenderMapUnits
Map units.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.