32 #include <QButtonGroup> 36 , mMapCanvas( mapCanvas )
39 setWidgetMode(
Text );
46 , mMapCanvas( mapCanvas )
49 setWidgetMode( mode );
52 void QgsTextFormatWidget::initWidget()
55 connect( mShapeSVGPathLineEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged );
56 connect( mFontSizeSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontSizeSpinBox_valueChanged );
57 connect( mFontCapitalsComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mFontCapitalsComboBox_currentIndexChanged );
58 connect( mFontFamilyCmbBx, &QFontComboBox::currentFontChanged,
this, &QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged );
59 connect( mFontStyleComboBox,
static_cast<void ( QComboBox::* )(
const QString & )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged );
60 connect( mFontUnderlineBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontUnderlineBtn_toggled );
61 connect( mFontStrikethroughBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontStrikethroughBtn_toggled );
62 connect( mFontWordSpacingSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged );
63 connect( mFontLetterSpacingSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged );
65 connect( mFontMinPixelSpinBox, static_cast <
void ( QSpinBox::* )(
int ) > ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged );
66 connect( mFontMaxPixelSpinBox, static_cast <
void ( QSpinBox::* )(
int ) > ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged );
70 connect( mShapeTypeCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged );
71 connect( mShapeRotationCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged );
72 connect( mShapeSVGParamsBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGParamsBtn_clicked );
73 connect( mShapeSVGSelectorBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked );
74 connect( mPreviewTextEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mPreviewTextEdit_textChanged );
75 connect( mPreviewTextBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mPreviewTextBtn_clicked );
77 connect( mDirectSymbLeftToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked );
78 connect( mDirectSymbRightToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked );
79 connect( mChkNoObstacle, &QCheckBox::toggled,
this, &QgsTextFormatWidget::mChkNoObstacle_toggled );
80 connect( chkLineOrientationDependent, &QCheckBox::toggled,
this, &QgsTextFormatWidget::chkLineOrientationDependent_toggled );
81 connect( mToolButtonConfigureSubstitutes, &QToolButton::clicked,
this, &QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked );
84 mOptionsTab->setIconSize( QSize( iconSize, iconSize ) );
88 mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
89 mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
90 mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );
91 mPointOffsetLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
92 mPointOffsetOver ->setIconSize( QSize( iconSize32, iconSize18 ) );
93 mPointOffsetRight->setIconSize( QSize( iconSize32, iconSize18 ) );
94 mPointOffsetBelowLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
95 mPointOffsetBelow->setIconSize( QSize( iconSize32, iconSize18 ) );
96 mPointOffsetBelowRight->setIconSize( QSize( iconSize32, iconSize18 ) );
97 mLabelMinScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomOut.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
98 mLabelMaxScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomIn.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
101 mFontUnderlineBtn->setMinimumSize( buttonSize, buttonSize );
102 mFontUnderlineBtn->setMaximumSize( buttonSize, buttonSize );
103 mFontStrikethroughBtn->setMinimumSize( buttonSize, buttonSize );
104 mFontStrikethroughBtn->setMaximumSize( buttonSize, buttonSize );
105 mFontBoldBtn->setMinimumSize( buttonSize, buttonSize );
106 mFontBoldBtn->setMaximumSize( buttonSize, buttonSize );
107 mFontItalicBtn->setMinimumSize( buttonSize, buttonSize );
108 mFontItalicBtn->setMaximumSize( buttonSize, buttonSize );
110 mPreviewScaleComboBox->setMapCanvas( mMapCanvas );
111 mPreviewScaleComboBox->setShowCurrentScaleButton(
true );
142 mFontLineHeightSpinBox->setClearValue( 1.0 );
143 mShapeRotationDblSpnBx->setClearValue( 0.0 );
144 mShapeOffsetXSpnBx->setClearValue( 0.0 );
145 mShapeOffsetYSpnBx->setClearValue( 0.0 );
146 mPointOffsetXSpinBox->setClearValue( 0.0 );
147 mPointOffsetYSpinBox->setClearValue( 0.0 );
148 mPointAngleSpinBox->setClearValue( 0.0 );
149 mFontLetterSpacingSpinBox->setClearValue( 0.0 );
150 mFontWordSpacingSpinBox->setClearValue( 0.0 );
151 mZIndexSpinBox->setClearValue( 0.0 );
152 mLineDistanceSpnBx->setClearValue( 0.0 );
162 mRefFont = lblFontPreview->font();
165 connect( mShadowOffsetAngleDial, &QAbstractSlider::valueChanged, mShadowOffsetAngleSpnBx, &QSpinBox::setValue );
166 connect( mShadowOffsetAngleSpnBx, static_cast <
void ( QSpinBox::* )(
int ) > ( &QSpinBox::valueChanged ), mShadowOffsetAngleDial, &QAbstractSlider::setValue );
167 connect( mLimitLabelChkBox, &QAbstractButton::toggled, mLimitLabelSpinBox, &QWidget::setEnabled );
168 connect( mCheckBoxSubstituteText, &QAbstractButton::toggled, mToolButtonConfigureSubstitutes, &QWidget::setEnabled );
175 populateFontCapitalsComboBox();
178 mPreviewBackgroundBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
179 mPreviewBackgroundBtn->setContext( QStringLiteral(
"labeling" ) );
180 mPreviewBackgroundBtn->setColor( QColor( 255, 255, 255 ) );
181 btnTextColor->setColorDialogTitle( tr(
"Select Text Color" ) );
182 btnTextColor->setContext( QStringLiteral(
"labeling" ) );
183 btnTextColor->setDefaultColor( Qt::black );
184 btnBufferColor->setColorDialogTitle( tr(
"Select Buffer Color" ) );
185 btnBufferColor->setContext( QStringLiteral(
"labeling" ) );
186 btnBufferColor->setDefaultColor( Qt::white );
187 mShapeStrokeColorBtn->setColorDialogTitle( tr(
"Select Stroke Color" ) );
188 mShapeStrokeColorBtn->setContext( QStringLiteral(
"labeling" ) );
189 mShapeFillColorBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
190 mShapeFillColorBtn->setContext( QStringLiteral(
"labeling" ) );
191 mShadowColorBtn->setColorDialogTitle( tr(
"Select Shadow Color" ) );
192 mShadowColorBtn->setContext( QStringLiteral(
"labeling" ) );
193 mShadowColorBtn->setDefaultColor( Qt::black );
262 connect( groupBox_mPreview,
265 &QgsTextFormatWidget::collapseSample );
268 mLabelingOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect,
false );
273 QSizePolicy policy( mLabelingOptionsListFrame->sizePolicy() );
274 policy.setHorizontalStretch( 0 );
275 mLabelingOptionsListFrame->setSizePolicy( policy );
276 if ( !settings.
contains( QStringLiteral(
"/Windows/Labeling/OptionsSplitState" ) ) )
279 QList<int> splitsizes;
281 mLabelingOptionsSplitter->setSizes( splitsizes );
285 connect( mLabelStackedWidget, &QStackedWidget::currentChanged,
this, &QgsTextFormatWidget::optionsStackedWidget_CurrentChanged );
288 mFontPreviewSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ) ).toByteArray() );
289 mLabelingOptionsSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ) ).toByteArray() );
291 mLabelingOptionsListWidget->setCurrentRow( settings.
value( QStringLiteral(
"Windows/Labeling/Tab" ), 0 ).toInt() );
295 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
298 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
303 QList<QWidget *> widgets;
304 widgets << btnBufferColor
306 << chkLabelPerFeaturePart
310 << chkLineOrientationDependent
312 << chkPreserveRotation
314 << comboBufferBlendMode
316 << mBufferBlendModeDDBtn
320 << mBufferJoinStyleComboBox
321 << mBufferJoinStyleDDBtn
323 << mBufferOpacityDDBtn
324 << mBufferTranspFillChbx
325 << mBufferOpacityWidget
328 << mCentroidInsideCheckBox
330 << mCoordAlignmentHDDBtn
331 << mCoordAlignmentVDDBtn
332 << mCoordRotationDDBtn
337 << mDirectSymbLeftDDBtn
338 << mDirectSymbLeftLineEdit
339 << mDirectSymbPlacementDDBtn
340 << mDirectSymbRevChkBx
341 << mDirectSymbRevDDBtn
342 << mDirectSymbRightDDBtn
343 << mDirectSymbRightLineEdit
344 << mFitInsidePolygonCheckBox
345 << mFontBlendModeDDBtn
347 << mFontCapitalsComboBox
352 << mFontLetterSpacingDDBtn
353 << mFontLetterSpacingSpinBox
354 << mFontLimitPixelChkBox
355 << mFontLimitPixelDDBtn
356 << mFontLineHeightDDBtn
357 << mFontLineHeightSpinBox
358 << mFontMaxPixelDDBtn
359 << mFontMaxPixelSpinBox
360 << mFontMinPixelDDBtn
361 << mFontMinPixelSpinBox
362 << mFontMultiLineAlignComboBox
363 << mFontMultiLineAlignDDBtn
366 << mFontStrikeoutDDBtn
367 << mFontStyleComboBox
370 << mTextOpacityWidget
371 << mFontUnderlineDDBtn
373 << mFontWordSpacingDDBtn
374 << mFontWordSpacingSpinBox
377 << mFormatNumDecimalsDDBtn
378 << mFormatNumDecimalsSpnBx
379 << mFormatNumPlusSignChkBx
380 << mFormatNumPlusSignDDBtn
383 << mLimitLabelSpinBox
384 << mLineDistanceDDBtn
385 << mLineDistanceSpnBx
386 << mLineDistanceUnitDDBtn
387 << mLineDistanceUnitWidget
388 << mMaxCharAngleDDBtn
389 << mMaxCharAngleInDSpinBox
390 << mMaxCharAngleOutDSpinBox
392 << mObstacleFactorDDBtn
393 << mObstacleFactorSlider
394 << mObstacleTypeComboBox
395 << mOffsetTypeComboBox
396 << mPalShowAllLabelsForLayerChkBx
397 << mPointAngleSpinBox
399 << mPointOffsetUnitsDDBtn
400 << mPointOffsetUnitWidget
401 << mPointOffsetXSpinBox
402 << mPointOffsetYSpinBox
403 << mPointPositionOrderDDBtn
404 << mPointQuadOffsetDDBtn
405 << mPreviewBackgroundBtn
409 << mRepeatDistanceDDBtn
410 << mRepeatDistanceSpinBox
411 << mRepeatDistanceUnitDDBtn
412 << mRepeatDistanceUnitWidget
413 << mScaleBasedVisibilityChkBx
414 << mScaleBasedVisibilityDDBtn
415 << mScaleBasedVisibilityMaxDDBtn
417 << mScaleBasedVisibilityMinDDBtn
425 << mShadowOffsetAngleDDBtn
426 << mShadowOffsetAngleSpnBx
427 << mShadowOffsetDDBtn
428 << mShadowOffsetGlobalChkBx
429 << mShadowOffsetSpnBx
430 << mShadowOffsetUnitsDDBtn
431 << mShadowOffsetUnitWidget
432 << mShadowRadiusAlphaChkBx
433 << mShadowRadiusDDBtn
434 << mShadowRadiusDblSpnBx
435 << mShadowRadiusUnitsDDBtn
436 << mShadowRadiusUnitWidget
439 << mShadowOpacityDDBtn
440 << mShadowOpacityWidget
444 << mShapeBlendModeDDBtn
445 << mShapeStrokeColorBtn
446 << mShapeStrokeColorDDBtn
447 << mShapeStrokeUnitsDDBtn
448 << mShapeStrokeWidthDDBtn
449 << mShapeStrokeWidthSpnBx
450 << mShapeStrokeWidthUnitWidget
453 << mShapeFillColorBtn
454 << mShapeFillColorDDBtn
456 << mShapeOffsetUnitsDDBtn
457 << mShapeOffsetXSpnBx
458 << mShapeOffsetYSpnBx
459 << mShapeOffsetUnitWidget
460 << mShapePenStyleCmbBx
461 << mShapePenStyleDDBtn
463 << mShapeRadiusUnitsDDBtn
464 << mShapeRadiusXDbSpnBx
465 << mShapeRadiusYDbSpnBx
466 << mShapeRotationCmbBx
467 << mShapeRotationDDBtn
468 << mShapeRotationDblSpnBx
469 << mShapeRotationTypeDDBtn
470 << mShapeRadiusUnitWidget
471 << mShapeSVGPathDDBtn
472 << mShapeSVGPathLineEdit
474 << mShapeSizeTypeDDBtn
475 << mShapeSizeUnitsDDBtn
476 << mShapeSizeUnitWidget
481 << mShapeOpacityDDBtn
482 << mBackgroundOpacityWidget
487 << mAutoWrapLengthDDBtn
492 << mAutoWrapLengthSpinBox
493 << mAutoWrapTypeComboBox
494 << mCentroidRadioVisible
495 << mCentroidRadioWhole
496 << mDirectSymbRadioBtnAbove
497 << mDirectSymbRadioBtnBelow
498 << mDirectSymbRadioBtnLR
499 << mUpsidedownRadioAll
500 << mUpsidedownRadioDefined
501 << mUpsidedownRadioOff
510 << radPolygonHorizontal
511 << radPolygonPerimeter
512 << radPolygonPerimeterCurved
513 << radPredefinedOrder
514 << mFieldExpressionWidget
515 << mCheckBoxSubstituteText
516 << mLinePlacementFlagsDDBtn;
517 connectValueChanged( widgets, SLOT( updatePreview() ) );
519 connect(
mQuadrantBtnGrp,
static_cast<void ( QButtonGroup::* )(
int )
>( &QButtonGroup::buttonClicked ),
this, &QgsTextFormatWidget::updatePreview );
522 whileBlocking( mOptionsTab )->setCurrentIndex( mLabelStackedWidget->currentIndex() );
537 toggleDDButtons(
true );
541 toggleDDButtons(
false );
542 delete mLabelingOptionsListWidget->takeItem( 6 );
543 delete mLabelingOptionsListWidget->takeItem( 5 );
544 mOptionsTab->removeTab( 6 );
545 mOptionsTab->removeTab( 5 );
547 frameLabelWith->hide();
548 mDirectSymbolsFrame->hide();
549 mFormatNumFrame->hide();
550 mFormatNumChkBx->hide();
551 mFormatNumDDBtn->hide();
552 mSubstitutionsFrame->hide();
553 mFontBoldBtn->hide();
554 mFontItalicBtn->hide();
560 void QgsTextFormatWidget::toggleDDButtons(
bool visible )
564 button->setVisible( visible );
570 mOptionsTab->setVisible( enabled );
571 mOptionsTab->setTabToolTip( 0, tr(
"Text" ) );
572 mOptionsTab->setTabToolTip( 1, tr(
"Formatting" ) );
573 mOptionsTab->setTabToolTip( 2, tr(
"Buffer" ) );
574 mOptionsTab->setTabToolTip( 3, tr(
"Background" ) );
575 mOptionsTab->setTabToolTip( 4, tr(
"Shadow" ) );
576 mOptionsTab->setTabToolTip( 5, tr(
"Placement" ) );
577 mOptionsTab->setTabToolTip( 6, tr(
"Rendering" ) );
579 mLabelingOptionsListFrame->setVisible( !enabled );
580 groupBox_mPreview->setVisible( !enabled );
584 void QgsTextFormatWidget::connectValueChanged(
const QList<QWidget *> &widgets,
const char *slot )
586 Q_FOREACH ( QWidget *widget, widgets )
590 connect( w, SIGNAL( changed() ),
this, slot );
594 connect( w, SIGNAL( fieldChanged( QString ) ),
this, slot );
596 else if (
QgsOpacityWidget *w = qobject_cast< QgsOpacityWidget *>( widget ) )
598 connect( w, SIGNAL( opacityChanged(
double ) ),
this, slot );
600 else if (
QgsScaleWidget *w = qobject_cast< QgsScaleWidget *>( widget ) )
602 connect( w, SIGNAL( scaleChanged(
double ) ),
this, slot );
606 connect( w, SIGNAL( changed() ),
this, slot );
608 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
610 connect( w, SIGNAL( currentIndexChanged(
int ) ),
this, slot );
612 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
614 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
616 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
618 connect( w, SIGNAL( valueChanged(
double ) ),
this, slot );
620 else if (
QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
622 connect( w, SIGNAL( colorChanged( QColor ) ),
this, slot );
624 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
626 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
628 else if ( QRadioButton *w = qobject_cast<QRadioButton *>( widget ) )
630 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
632 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
634 connect( w, SIGNAL( textEdited( QString ) ),
this, slot );
636 else if ( QSlider *w = qobject_cast<QSlider *>( widget ) )
638 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
642 QgsLogger::warning( QStringLiteral(
"Could not create connection for widget %1" ).arg( widget->objectName() ) );
654 mBufferDrawChkBx->setChecked( buffer.
enabled() );
655 spinBufferSize->setValue( buffer.
size() );
656 mBufferUnitWidget->setUnit( buffer.
sizeUnit() );
659 mBufferOpacityWidget->setOpacity( buffer.
opacity() );
660 mBufferJoinStyleComboBox->setPenJoinStyle( buffer.
joinStyle() );
662 comboBufferBlendMode->setBlendMode( buffer.
blendMode() );
668 mBufferEffect->setEnabled(
false );
670 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
672 mFontSizeUnitWidget->setUnit( format.
sizeUnit() );
674 mRefFont = format.
font();
675 mFontSizeSpinBox->setValue( format.
size() );
676 btnTextColor->setColor( format.
color() );
677 mTextOpacityWidget->setOpacity( format.
opacity() );
678 comboBlendMode->setBlendMode( format.
blendMode() );
680 mFontWordSpacingSpinBox->setValue( format.
font().wordSpacing() );
681 mFontLetterSpacingSpinBox->setValue( format.
font().letterSpacing() );
684 updateFont( mRefFont );
687 mFontMissingLabel->setVisible( !format.
fontFound() );
690 QString missingTxt = tr(
"%1 not found. Default substituted." );
691 QString txtPrepend = tr(
"Chosen font" );
696 mFontMissingLabel->setText( missingTxt.arg( txtPrepend ) );
699 mLabelingOptionsListWidget->setCurrentRow( 0 );
701 mFontLineHeightSpinBox->setValue( format.
lineHeight() );
704 mShapeDrawChkBx->setChecked( background.
enabled() );
705 mShapeTypeCmbBx->blockSignals(
true );
706 mShapeTypeCmbBx->setCurrentIndex( background.
type() );
707 mShapeTypeCmbBx->blockSignals(
false );
708 mShapeSVGPathLineEdit->setText( background.
svgFile() );
710 mShapeSizeCmbBx->setCurrentIndex( background.
sizeType() );
711 mShapeSizeXSpnBx->setValue( background.
size().width() );
712 mShapeSizeYSpnBx->setValue( background.
size().height() );
713 mShapeSizeUnitWidget->setUnit( background.
sizeUnit() );
715 mShapeRotationCmbBx->setCurrentIndex( background.
rotationType() );
718 mShapeRotationDblSpnBx->setValue( background.
rotation() );
719 mShapeOffsetXSpnBx->setValue( background.
offset().x() );
720 mShapeOffsetYSpnBx->setValue( background.
offset().y() );
721 mShapeOffsetUnitWidget->setUnit( background.
offsetUnit() );
723 mShapeRadiusXDbSpnBx->setValue( background.
radii().width() );
724 mShapeRadiusYDbSpnBx->setValue( background.
radii().height() );
725 mShapeRadiusUnitWidget->setUnit( background.
radiiUnit() );
728 mShapeFillColorBtn->setColor( background.
fillColor() );
729 mShapeStrokeColorBtn->setColor( background.
strokeColor() );
730 mShapeStrokeWidthSpnBx->setValue( background.
strokeWidth() );
733 mShapePenStyleCmbBx->setPenJoinStyle( background.
joinStyle() );
735 mBackgroundOpacityWidget->setOpacity( background.
opacity() );
736 mShapeBlendCmbBx->setBlendMode( background.
blendMode() );
738 mLoadSvgParams =
false;
739 mShapeTypeCmbBx_currentIndexChanged( background.
type() );
746 mBackgroundEffect->setEnabled(
false );
748 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
751 mShadowDrawChkBx->setChecked( shadow.
enabled() );
753 mShadowOffsetAngleSpnBx->setValue( shadow.
offsetAngle() );
755 mShadowOffsetUnitWidget->setUnit( shadow.
offsetUnit() );
757 mShadowOffsetGlobalChkBx->setChecked( shadow.
offsetGlobal() );
759 mShadowRadiusDblSpnBx->setValue( shadow.
blurRadius() );
762 mShadowRadiusAlphaChkBx->setChecked( shadow.
blurAlphaOnly() );
763 mShadowOpacityWidget->setOpacity( shadow.
opacity() );
764 mShadowScaleSpnBx->setValue( shadow.
scale() );
766 mShadowColorBtn->setColor( shadow.
color() );
767 mShadowBlendCmbBx->setBlendMode( shadow.
blendMode() );
774 settings.
setValue( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ), mFontPreviewSplitter->saveState() );
775 settings.
setValue( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ), mLabelingOptionsSplitter->saveState() );
776 settings.
setValue( QStringLiteral(
"Windows/Labeling/Tab" ), mLabelingOptionsListWidget->currentRow() );
782 format.
setColor( btnTextColor->color() );
784 format.
setSize( mFontSizeSpinBox->value() );
786 format.
setOpacity( mTextOpacityWidget->opacity() );
794 buffer.
setEnabled( mBufferDrawChkBx->isChecked() );
795 buffer.
setSize( spinBufferSize->value() );
796 buffer.
setColor( btnBufferColor->color() );
797 buffer.
setOpacity( mBufferOpacityWidget->opacity() );
800 buffer.
setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
802 buffer.
setBlendMode( comboBufferBlendMode->blendMode() );
811 background.
setEnabled( mShapeDrawChkBx->isChecked() );
813 background.
setSvgFile( mShapeSVGPathLineEdit->text() );
815 background.
setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
816 background.
setSizeUnit( mShapeSizeUnitWidget->unit() );
819 background.
setRotation( mShapeRotationDblSpnBx->value() );
820 background.
setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
823 background.
setRadii( QSizeF( mShapeRadiusXDbSpnBx->value(), mShapeRadiusYDbSpnBx->value() ) );
824 background.
setRadiiUnit( mShapeRadiusUnitWidget->unit() );
832 background.
setJoinStyle( mShapePenStyleCmbBx->penJoinStyle() );
833 background.
setOpacity( mBackgroundOpacityWidget->opacity() );
834 background.
setBlendMode( mShapeBlendCmbBx->blendMode() );
843 shadow.
setEnabled( mShadowDrawChkBx->isChecked() );
854 shadow.
setOpacity( mShadowOpacityWidget->opacity() );
855 shadow.
setScale( mShadowScaleSpnBx->value() );
856 shadow.
setColor( mShadowColorBtn->color() );
868 void QgsTextFormatWidget::optionsStackedWidget_CurrentChanged(
int indx )
870 mLabelingOptionsListWidget->blockSignals(
true );
871 mLabelingOptionsListWidget->setCurrentRow( indx );
872 mLabelingOptionsListWidget->blockSignals(
false );
875 void QgsTextFormatWidget::collapseSample(
bool collapse )
879 QList<int> splitSizes = mFontPreviewSplitter->sizes();
880 if ( splitSizes[0] > groupBox_mPreview->height() )
882 int delta = splitSizes[0] - groupBox_mPreview->height();
883 splitSizes[0] -= delta;
884 splitSizes[1] += delta;
885 mFontPreviewSplitter->setSizes( splitSizes );
890 void QgsTextFormatWidget::changeTextColor(
const QColor &color )
896 void QgsTextFormatWidget::updateFont(
const QFont &font )
899 if ( font != mRefFont )
908 mDirectSymbLeftLineEdit->setFont( mRefFont );
909 mDirectSymbRightLineEdit->setFont( mRefFont );
911 blockFontChangeSignals(
true );
912 mFontFamilyCmbBx->setCurrentFont( mRefFont );
913 populateFontStyleComboBox();
914 int idx = mFontCapitalsComboBox->findData( QVariant( (
unsigned int ) mRefFont.capitalization() ) );
915 mFontCapitalsComboBox->setCurrentIndex( idx == -1 ? 0 : idx );
916 mFontUnderlineBtn->setChecked( mRefFont.underline() );
917 mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
918 blockFontChangeSignals(
false );
926 void QgsTextFormatWidget::blockFontChangeSignals(
bool blk )
928 mFontFamilyCmbBx->blockSignals( blk );
929 mFontStyleComboBox->blockSignals( blk );
930 mFontCapitalsComboBox->blockSignals( blk );
931 mFontUnderlineBtn->blockSignals( blk );
932 mFontStrikethroughBtn->blockSignals( blk );
933 mFontWordSpacingSpinBox->blockSignals( blk );
934 mFontLetterSpacingSpinBox->blockSignals( blk );
937 void QgsTextFormatWidget::updatePreview()
949 lblFontPreview->setFormat(
format() );
952 void QgsTextFormatWidget::scrollPreview()
954 scrollArea_mPreview->ensureVisible( 0, 0, 0, 0 );
959 scrollArea_mPreview->widget()->setStyleSheet( QStringLiteral(
"background: rgb(%1, %2, %3);" ).arg( QString::number( color.red() ),
960 QString::number( color.green() ),
961 QString::number( color.blue() ) ) );
964 void QgsTextFormatWidget::changeBufferColor(
const QColor &color )
972 QWidget *curWdgt = stackedPlacement->currentWidget();
974 bool showLineFrame =
false;
975 bool showCentroidFrame =
false;
976 bool showQuadrantFrame =
false;
977 bool showFixedQuadrantFrame =
false;
978 bool showPlacementPriorityFrame =
false;
979 bool showOffsetTypeFrame =
false;
980 bool showOffsetFrame =
false;
981 bool showDistanceFrame =
false;
982 bool showRotationFrame =
false;
983 bool showMaxCharAngleFrame =
false;
985 bool enableMultiLinesFrame =
true;
987 if ( ( curWdgt == pagePoint && radAroundPoint->isChecked() )
988 || ( curWdgt == pagePolygon && radAroundCentroid->isChecked() ) )
990 showCentroidFrame = ( curWdgt == pagePolygon && radAroundCentroid->isChecked() );
991 showDistanceFrame =
true;
993 if ( curWdgt == pagePoint )
995 showQuadrantFrame =
true;
998 else if ( ( curWdgt == pagePoint && radOverPoint->isChecked() )
999 || ( curWdgt == pagePolygon && radOverCentroid->isChecked() ) )
1001 showCentroidFrame = ( curWdgt == pagePolygon && radOverCentroid->isChecked() );
1002 showQuadrantFrame =
true;
1003 showFixedQuadrantFrame =
true;
1004 showOffsetFrame =
true;
1005 showRotationFrame =
true;
1007 else if ( curWdgt == pagePoint && radPredefinedOrder->isChecked() )
1009 showDistanceFrame =
true;
1010 showPlacementPriorityFrame =
true;
1011 showOffsetTypeFrame =
true;
1013 else if ( ( curWdgt == pageLine && radLineParallel->isChecked() )
1014 || ( curWdgt == pagePolygon && radPolygonPerimeter->isChecked() )
1015 || ( curWdgt == pageLine && radLineCurved->isChecked() )
1016 || ( curWdgt == pagePolygon && radPolygonPerimeterCurved->isChecked() ) )
1018 showLineFrame =
true;
1019 showDistanceFrame =
true;
1022 bool offline = chkLineAbove->isChecked() || chkLineBelow->isChecked();
1023 chkLineOrientationDependent->setEnabled( offline );
1024 mPlacementDistanceFrame->setEnabled( offline );
1026 bool isCurved = ( curWdgt == pageLine && radLineCurved->isChecked() )
1027 || ( curWdgt == pagePolygon && radPolygonPerimeterCurved->isChecked() );
1028 showMaxCharAngleFrame = isCurved;
1030 enableMultiLinesFrame = !isCurved;
1033 mPlacementLineFrame->setVisible( showLineFrame );
1034 mPlacementCentroidFrame->setVisible( showCentroidFrame );
1035 mPlacementQuadrantFrame->setVisible( showQuadrantFrame );
1036 mPlacementFixedQuadrantFrame->setVisible( showFixedQuadrantFrame );
1037 mPlacementCartographicFrame->setVisible( showPlacementPriorityFrame );
1038 mPlacementOffsetFrame->setVisible( showOffsetFrame );
1039 mPlacementDistanceFrame->setVisible( showDistanceFrame );
1040 mPlacementOffsetTypeFrame->setVisible( showOffsetTypeFrame );
1041 mPlacementRotationFrame->setVisible( showRotationFrame );
1042 mPlacementRepeatDistanceFrame->setVisible( curWdgt == pageLine || ( curWdgt == pagePolygon &&
1043 ( radPolygonPerimeter->isChecked() || radPolygonPerimeterCurved->isChecked() ) ) );
1044 mPlacementMaxCharAngleFrame->setVisible( showMaxCharAngleFrame );
1046 mMultiLinesFrame->setEnabled( enableMultiLinesFrame );
1049 void QgsTextFormatWidget::populateFontCapitalsComboBox()
1051 mFontCapitalsComboBox->addItem( tr(
"No change" ), QVariant( 0 ) );
1052 mFontCapitalsComboBox->addItem( tr(
"All uppercase" ), QVariant( 1 ) );
1053 mFontCapitalsComboBox->addItem( tr(
"All lowercase" ), QVariant( 2 ) );
1057 mFontCapitalsComboBox->addItem( tr(
"Capitalize first letter" ), QVariant( 4 ) );
1060 void QgsTextFormatWidget::populateFontStyleComboBox()
1062 mFontStyleComboBox->clear();
1063 QStringList styles = mFontDB.styles( mRefFont.family() );
1064 Q_FOREACH (
const QString &style, styles )
1066 mFontStyleComboBox->addItem( style );
1069 QString targetStyle = mFontDB.styleString( mRefFont );
1070 if ( !styles.contains( targetStyle ) )
1072 QFont f = QFont( mRefFont.family() );
1073 targetStyle = QFontInfo( f ).styleName();
1074 mRefFont.setStyleName( targetStyle );
1077 int stylIndx = mFontStyleComboBox->findText( targetStyle );
1078 if ( stylIndx > -1 )
1083 mFontStyleComboBox->setCurrentIndex( curIndx );
1086 void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged(
double d )
1088 mRefFont.setPointSizeF( d );
1089 updateFont( mRefFont );
1092 void QgsTextFormatWidget::mFontCapitalsComboBox_currentIndexChanged(
int index )
1094 int capitalsindex = mFontCapitalsComboBox->itemData( index ).toUInt();
1095 mRefFont.setCapitalization( ( QFont::Capitalization ) capitalsindex );
1096 updateFont( mRefFont );
1099 void QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged(
const QFont &f )
1101 mRefFont.setFamily( f.family() );
1102 updateFont( mRefFont );
1105 void QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged(
const QString &text )
1108 updateFont( mRefFont );
1111 void QgsTextFormatWidget::mFontUnderlineBtn_toggled(
bool ckd )
1113 mRefFont.setUnderline( ckd );
1114 updateFont( mRefFont );
1117 void QgsTextFormatWidget::mFontStrikethroughBtn_toggled(
bool ckd )
1119 mRefFont.setStrikeOut( ckd );
1120 updateFont( mRefFont );
1123 void QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged(
double spacing )
1125 mRefFont.setWordSpacing( spacing );
1126 updateFont( mRefFont );
1129 void QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged(
double spacing )
1131 mRefFont.setLetterSpacing( QFont::AbsoluteSpacing, spacing );
1132 updateFont( mRefFont );
1135 void QgsTextFormatWidget::mFontSizeUnitWidget_changed()
1140 mFontLimitPixelChkBox->setChecked(
false );
1146 mFontLimitPixelChkBox->setChecked(
true );
1148 updateFont( mRefFont );
1151 void QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged(
int px )
1154 mFontMaxPixelSpinBox->setMinimum( px );
1155 mFontMaxPixelSpinBox->update();
1158 void QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged(
int px )
1161 if ( px < mFontMinPixelSpinBox->value() )
1163 mFontMaxPixelSpinBox->blockSignals(
true );
1164 mFontMaxPixelSpinBox->setValue( mFontMinPixelSpinBox->value() );
1165 mFontMaxPixelSpinBox->blockSignals(
false );
1167 mFontMaxPixelSpinBox->setMinimum( mFontMinPixelSpinBox->value() );
1170 void QgsTextFormatWidget::mBufferUnitWidget_changed()
1172 updateFont( mRefFont );
1175 void QgsTextFormatWidget::mCoordXDDBtn_activated(
bool active )
1181 else if ( mCoordYDDBtn->isActive() )
1187 void QgsTextFormatWidget::mCoordYDDBtn_activated(
bool active )
1193 else if ( mCoordXDDBtn->isActive() )
1199 void QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged(
int index )
1206 showBackgroundPenStyle( isRect );
1207 showBackgroundRadius( isRect );
1209 mShapeSVGPathFrame->setVisible( isSVG );
1211 mShapeSizeYLabel->setVisible( !isSVG );
1212 mShapeSizeYSpnBx->setVisible( !isSVG );
1213 mShapeSizeYDDBtn->setVisible( !isSVG && mWidgetMode ==
Labeling );
1214 mShapeSizeXLabel->setText( tr(
"Size%1" ).arg( !isSVG ? tr(
" X" ) : QString() ) );
1217 mShapeFillColorBtn->setAllowOpacity( !isSVG );
1218 mShapeFillColorBtn->setButtonBackground();
1219 mShapeStrokeColorBtn->setAllowOpacity( !isSVG );
1220 mShapeStrokeColorBtn->setButtonBackground();
1223 mShapeSVGParamsBtn->setVisible( isSVG );
1226 updateSvgWidgets( mShapeSVGPathLineEdit->text() );
1230 mShapeFillColorLabel->setEnabled(
true );
1231 mShapeFillColorBtn->setEnabled(
true );
1232 mShapeFillColorDDBtn->setEnabled(
true );
1233 mShapeStrokeColorLabel->setEnabled(
true );
1234 mShapeStrokeColorBtn->setEnabled(
true );
1235 mShapeStrokeColorDDBtn->setEnabled(
true );
1236 mShapeStrokeWidthLabel->setEnabled(
true );
1237 mShapeStrokeWidthSpnBx->setEnabled(
true );
1238 mShapeStrokeWidthDDBtn->setEnabled(
true );
1242 mShapeStrokeWidthUnitWidget->setVisible( !isSVG );
1243 mShapeSVGUnitsLabel->setVisible( isSVG );
1244 mShapeStrokeUnitsDDBtn->setEnabled( !isSVG );
1247 void QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged(
const QString &text )
1249 updateSvgWidgets( text );
1254 int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) +
1255 ( chkLineBelow->isChecked() ? 1 : 0 ) +
1256 ( chkLineOn->isChecked() ? 1 : 0 );
1258 if ( numOptionsChecked == 1 )
1261 chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
1262 chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
1263 chkLineOn->setEnabled( !chkLineOn->isChecked() );
1267 chkLineAbove->setEnabled(
true );
1268 chkLineBelow->setEnabled(
true );
1269 chkLineOn->setEnabled(
true );
1279 void QgsTextFormatWidget::previewScaleChanged(
double scale )
1281 lblFontPreview->setScale( scale );
1284 void QgsTextFormatWidget::updateSvgWidgets(
const QString &svgPath )
1286 if ( mShapeSVGPathLineEdit->text() != svgPath )
1288 mShapeSVGPathLineEdit->setText( svgPath );
1291 QString resolvedPath;
1292 bool validSVG =
true;
1293 if ( ! svgPath.startsWith( QLatin1String(
"base64:" ), Qt::CaseInsensitive ) )
1296 validSVG = QFileInfo::exists( resolvedPath );
1300 resolvedPath = svgPath;
1305 mShapeSVGPathLineEdit->setStyleSheet( !validSVG ? QStringLiteral(
"QLineEdit{ color: rgb(225, 0, 0); }" ) : QString() );
1306 mShapeSVGPathLineEdit->setToolTip( !validSVG ? tr(
"File not found" ) : resolvedPath );
1308 QColor fill, stroke;
1309 double strokeWidth = 0.0;
1310 bool fillParam =
false, strokeParam =
false, strokeWidthParam =
false;
1316 mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || strokeParam || strokeWidthParam ) );
1318 mShapeFillColorLabel->setEnabled( validSVG && fillParam );
1319 mShapeFillColorBtn->setEnabled( validSVG && fillParam );
1320 mShapeFillColorDDBtn->setEnabled( validSVG && fillParam );
1321 if ( mLoadSvgParams && validSVG && fillParam )
1322 mShapeFillColorBtn->setColor( fill );
1324 mShapeStrokeColorLabel->setEnabled( validSVG && strokeParam );
1325 mShapeStrokeColorBtn->setEnabled( validSVG && strokeParam );
1326 mShapeStrokeColorDDBtn->setEnabled( validSVG && strokeParam );
1327 if ( mLoadSvgParams && validSVG && strokeParam )
1328 mShapeStrokeColorBtn->setColor( stroke );
1330 mShapeStrokeWidthLabel->setEnabled( validSVG && strokeWidthParam );
1331 mShapeStrokeWidthSpnBx->setEnabled( validSVG && strokeWidthParam );
1332 mShapeStrokeWidthDDBtn->setEnabled( validSVG && strokeWidthParam );
1333 if ( mLoadSvgParams && validSVG && strokeWidthParam )
1334 mShapeStrokeWidthSpnBx->setValue( strokeWidth );
1340 mShapeSVGUnitsLabel->setEnabled( validSVG && strokeWidthParam );
1343 void QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked()
1346 svgDlg.setWindowTitle( tr(
"Select SVG file" ) );
1349 if ( svgDlg.exec() == QDialog::Accepted )
1352 if ( !svgPath.isEmpty() )
1354 mShapeSVGPathLineEdit->setText( svgPath );
1360 void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
1362 QString svgPath = mShapeSVGPathLineEdit->text();
1363 mLoadSvgParams =
true;
1364 updateSvgWidgets( svgPath );
1365 mLoadSvgParams =
false;
1368 void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged(
int index )
1374 void QgsTextFormatWidget::mPreviewTextEdit_textChanged(
const QString &text )
1376 lblFontPreview->setText( text );
1380 void QgsTextFormatWidget::mPreviewTextBtn_clicked()
1382 mPreviewTextEdit->setText( QStringLiteral(
"Lorem Ipsum" ) );
1386 void QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged(
const QColor &color )
1391 void QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked()
1393 bool gotChar =
false;
1394 QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ) );
1399 if ( !dirSymb.isNull() )
1400 mDirectSymbLeftLineEdit->setText( QString( dirSymb ) );
1403 void QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked()
1405 bool gotChar =
false;
1406 QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ) );
1411 if ( !dirSymb.isNull() )
1412 mDirectSymbRightLineEdit->setText( QString( dirSymb ) );
1415 void QgsTextFormatWidget::mChkNoObstacle_toggled(
bool active )
1417 mPolygonObstacleTypeFrame->setEnabled( active );
1418 mObstaclePriorityFrame->setEnabled( active );
1421 void QgsTextFormatWidget::chkLineOrientationDependent_toggled(
bool active )
1425 chkLineAbove->setText( tr(
"Left of line" ) );
1426 chkLineBelow->setText( tr(
"Right of line" ) );
1430 chkLineAbove->setText( tr(
"Above line" ) );
1431 chkLineBelow->setText( tr(
"Below line" ) );
1436 void QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked()
1451 if ( dlg.exec() == QDialog::Accepted )
1458 void QgsTextFormatWidget::showBackgroundRadius(
bool show )
1460 mShapeRadiusLabel->setVisible( show );
1461 mShapeRadiusXDbSpnBx->setVisible( show );
1463 mShapeRadiusYDbSpnBx->setVisible( show );
1465 mShapeRadiusUnitWidget->setVisible( show );
1467 mShapeRadiusDDBtn->setVisible( show && mWidgetMode ==
Labeling );
1468 mShapeRadiusUnitsDDBtn->setVisible( show && mWidgetMode ==
Labeling );
1471 void QgsTextFormatWidget::showBackgroundPenStyle(
bool show )
1473 mShapePenStyleLabel->setVisible( show );
1474 mShapePenStyleCmbBx->setVisible( show );
1476 mShapePenStyleDDBtn->setVisible( show && mWidgetMode ==
Labeling );
1481 mCoordAlignmentFrame->setEnabled( enable );
1490 : QDialog( parent, fl )
1492 setWindowTitle( tr(
"Text Settings" ) );
1495 mFormatWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
1497 QVBoxLayout *layout =
new QVBoxLayout(
this );
1498 layout->addWidget( mFormatWidget );
1500 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal,
this );
1501 layout->addWidget( buttonBox );
1503 setLayout( layout );
1506 restoreGeometry( settings.
value( QStringLiteral(
"Windows/TextFormatDialog/geometry" ) ).toByteArray() );
1508 connect( buttonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked,
this, &QDialog::accept );
1509 connect( buttonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked,
this, &QDialog::reject );
1520 return mFormatWidget->
format();
1532 return mFormatWidget->
format();
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units used for the shape's stroke width.
QgsUnitTypes::DistanceUnit mapUnits() const
Gets units of map's geographical coordinates - used for scale calculation.
ShapeType type() const
Returns the type of background shape (e.g., square, ellipse, SVG).
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
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).
RotationType
Methods for determining the rotation of the background shape.
QPointF offset() const
Returns the offset used for drawing the background shape.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow offset distance.
void setOpacity(double opacity)
Sets the text's opacity.
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.
QFont font() const
Returns the font used for rendering text.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the shape's size.
QSizeF size() const
Returns the size of the background shape.
double opacity() const
Returns the buffer opacity.
double scale() const
Returns the calculated map scale.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the drop shadow.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shadow offset distance.
Qt::PenJoinStyle joinStyle() const
Returns the join style used for drawing the background shape.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the buffer.
void setDockMode(bool enabled)
Sets whether the widget should be shown in a compact dock mode.
This class is a composition of two QSettings instances:
A groupbox that collapses/expands when toggled and can save its collapsed and checked states...
QgsUnitTypes::RenderUnit blurRadiusUnit() const
Returns the units used for the shadow's blur radius.
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
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.
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
QgsTextShadowSettings & shadow()
Returns a reference to the text drop shadow settings.
static void warning(const QString &msg)
Goes to qWarning.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the size.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
void setStrokeColor(const QColor &color)
Sets the color used for outlining the background shape.
void setSize(double size)
Sets the size of the buffer.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
QgsMapUnitScale blurRadiusMapUnitScale() const
Returns the map unit scale object for the shadow blur radius.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
QButtonGroup * mUpsidedownBtnGrp
Upside down labels button group.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the background shape.
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...
double size() const
Returns the size for rendered text.
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's offset.
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.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape size.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
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.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the shape's offset.
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.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
bool enabled() const
Returns whether the background is enabled.
double opacity() const
Returns the text's opacity.
QColor color() const
Returns the color that text will be rendered in.
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)
QSizeF radii() const
Returns the radii used for rounding the corners of shapes.
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.
bool enabled() const
Returns whether the shadow is enabled.
void setBlurRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow blur radius.
double blurRadius() const
Returns the blur radius for the shadow.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
QgsMapUnitScale strokeWidthMapUnitScale() const
Returns the map unit scale object for the shape stroke width.
Map canvas is a class for displaying all GIS data types on a canvas.
QColor color() const
Returns the color of the buffer.
Show labeling settings in addition to text formatting settings.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the background shape.
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.
Arranges candidates following the curvature of a line feature. Applies to line layers only...
void saveGeometry(QWidget *widget, const QString &keyName)
Save the wigget geometry into settings.
QColor strokeColor() const
Returns the color used for outlining the background shape.
Place direction symbols on left/right of label.
bool restoreGeometry(QWidget *widget, const QString &keyName)
Restore the wigget geometry from settings.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the background shape.
QString namedStyle() const
Returns the named style for the font used for rendering text (e.g., "bold").
void setSize(double size)
Sets the size for rendered text.
bool enabled() const
Returns whether the buffer is enabled.
void setOffsetDistance(double distance)
Sets the distance for offsetting the position of the shadow from 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 ...
void widgetChanged()
Emitted when the text format defined by the widget changes.
double offsetDistance() const
Returns the distance for offsetting the position of the shadow from the text.
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects. ...
Offset distance applies from point geometry.
Default mode, show text formatting settings only.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the shadow's offset.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the buffer.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape offset.
void setBlurAlphaOnly(bool alphaOnly)
Sets whether only the alpha channel for the shadow should be blurred.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
Show upside down for all labels, including dynamic ones.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the drop shadow.
void enableDataDefinedAlignment(bool enable)
Controls whether data defined alignment buttons are enabled.
void setColor(const QColor &color)
Sets the color for the drop shadow.
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
points (e.g., for font sizes)
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.
QString svgFile() const
Returns the absolute path to the background SVG file, if set.
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.
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.
double opacity() const
Returns the background shape's opacity.
Upside-down labels (90 <= angle < 270) are shown upright.
bool offsetGlobal() const
Returns true if the global shadow offset will be used.
SizeType
Methods for determining the background shape size.
void updateLinePlacementOptions()
Updates line placement options to reflect current state of widget.
void setSize(QSizeF size)
Sets the size of the background shape.
QgsStringReplacementCollection mSubstitutions
Text substitution list.
void setSettingGroup(const QString &group)
Sets this to a defined string to share save/restore states across different parent dialogs...
void setRadii(QSizeF radii)
Sets the radii used for rounding the corners of shapes.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the size.
void setPreviewBackground(const QColor &color)
Sets the background color for the text preview widget.
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 QChar & selectCharacter(bool *gotChar, const QFont &font, const QString &style)
int offsetAngle() const
Returns the angle for offsetting the position of the shadow from the text.
void setType(ShapeType type)
Sets the type of background shape to draw (e.g., square, ellipse, SVG).
Place direction symbols on above label.
QButtonGroup * mPlaceLineBtnGrp
Line placement button group.
void setEnabled(bool enabled)
Sets whether the text background will be drawn.
ShapeType
Background shape types.
bool fillBufferInterior() const
Returns whether the interior of the buffer will be filled in.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units used for the shape's size.
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth) const
Tests if an svg file contains parameters for fill, stroke color, stroke width.
QgsSvgSelectorWidget * svgSelector()
Returns pointer to the embedded SVG selector widget.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the text.
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
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.
QgsTextFormatWidget(const QgsTextFormat &format=QgsTextFormat(), QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr)
Constructor for QgsTextFormatWidget.
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.
QColor color() const
Returns the color of the drop shadow.
QgsUnitTypes::RenderUnit radiiUnit() const
Returns the units used for the shape's radii.
Container for settings relating to a text shadow.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the size of rendered text.
A collection of string replacements (specified using QgsStringReplacement objects).
Container for settings relating to a text buffer.
void setFillColor(const QColor &color)
Sets the color used for filing the background shape.
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
QgsMapUnitScale radiiMapUnitScale() const
Returns the map unit scale object for the shape radii.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's stroke width.
RotationType rotationType() const
Returns the method used for rotating the background shape.
QString resolvedFontFamily() const
Returns the family for the resolved font, ie if the specified font was not found on the system this w...
int mMinPixelLimit
Pixel size font limit.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shape offset.
double size() const
Returns the size of the buffer.
~QgsTextFormatDialog() override
void setSubstitutions(const QgsStringReplacementCollection &substitutions)
Sets the list of substitutions to show in the dialog.
bool blurAlphaOnly() const
Returns whether only the alpha channel for the shadow will be blurred.
Shape rotation is synced with text rotation.
QButtonGroup * mQuadrantBtnGrp
Quadrant button group.
void setShadowPlacement(QgsTextShadowSettings::ShadowPlacement placement)
Sets the placement for the drop shadow.
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.
double rotation() const
Returns the rotation for the background shape, in degrees clockwise.
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
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.
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
Show upside down when rotation is layer- or data-defined.
void updatePlacementWidgets()
Updates label placement options to reflect current state of widget.
Container for all settings relating to text rendering.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the buffer.
void setSvgFile(const QString &file)
Sets the path to the background SVG file.
double opacity() const
Returns the shadow's opacity.
double lineHeight() const
Returns the line height for text.
void setOffsetGlobal(bool global)
Sets whether the global shadow offset should be used.
QButtonGroup * mPlacePointBtnGrp
Point placement button group.
void setOpacity(double opacity)
Sets the buffer opacity.
Square - buffered sizes only.
QgsStringReplacementCollection substitutions
double strokeWidth() const
Returns the width of the shape's stroke (stroke).
QgsTextFormatPanelWidget(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr)
Constructor for QgsTextFormatPanelWidget.
QColor fillColor() const
Returns the color used for filing the background shape.
QgsTextShadowSettings::ShadowPlacement shadowPlacement() const
Returns the placement for the drop shadow.
void setRotationType(RotationType type)
Sets the method used for rotating the background shape.
void setColor(const QColor &color)
Sets the color for the buffer.
QButtonGroup * mDirectSymbBtnGrp
Symbol direction button group.
void setOpacity(double opacity)
Sets the background shape's opacity.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the background shape.
QgsTextFormatDialog(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
Constructor for QgsTextFormatDialog.
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.