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 );
83 mPreviewScaleComboBox->setMapCanvas( mMapCanvas );
84 mPreviewScaleComboBox->setShowCurrentScaleButton(
true );
115 mFontLineHeightSpinBox->setClearValue( 1.0 );
116 mShapeRotationDblSpnBx->setClearValue( 0.0 );
117 mShapeOffsetXSpnBx->setClearValue( 0.0 );
118 mShapeOffsetYSpnBx->setClearValue( 0.0 );
119 mPointOffsetXSpinBox->setClearValue( 0.0 );
120 mPointOffsetYSpinBox->setClearValue( 0.0 );
121 mPointAngleSpinBox->setClearValue( 0.0 );
122 mFontLetterSpacingSpinBox->setClearValue( 0.0 );
123 mFontWordSpacingSpinBox->setClearValue( 0.0 );
124 mZIndexSpinBox->setClearValue( 0.0 );
134 mRefFont = lblFontPreview->font();
137 connect( mShadowOffsetAngleDial, &QAbstractSlider::valueChanged, mShadowOffsetAngleSpnBx, &QSpinBox::setValue );
138 connect( mShadowOffsetAngleSpnBx, static_cast <
void ( QSpinBox::* )(
int ) > ( &QSpinBox::valueChanged ), mShadowOffsetAngleDial, &QAbstractSlider::setValue );
139 connect( mLimitLabelChkBox, &QAbstractButton::toggled, mLimitLabelSpinBox, &QWidget::setEnabled );
140 connect( mCheckBoxSubstituteText, &QAbstractButton::toggled, mToolButtonConfigureSubstitutes, &QWidget::setEnabled );
147 populateFontCapitalsComboBox();
150 mPreviewBackgroundBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
151 mPreviewBackgroundBtn->setContext( QStringLiteral(
"labeling" ) );
152 mPreviewBackgroundBtn->setColor( QColor( 255, 255, 255 ) );
153 btnTextColor->setColorDialogTitle( tr(
"Select Text Color" ) );
154 btnTextColor->setContext( QStringLiteral(
"labeling" ) );
155 btnTextColor->setDefaultColor( Qt::black );
156 btnBufferColor->setColorDialogTitle( tr(
"Select Buffer Color" ) );
157 btnBufferColor->setContext( QStringLiteral(
"labeling" ) );
158 btnBufferColor->setDefaultColor( Qt::white );
159 mShapeStrokeColorBtn->setColorDialogTitle( tr(
"Select Stroke Color" ) );
160 mShapeStrokeColorBtn->setContext( QStringLiteral(
"labeling" ) );
161 mShapeFillColorBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
162 mShapeFillColorBtn->setContext( QStringLiteral(
"labeling" ) );
163 mShadowColorBtn->setColorDialogTitle( tr(
"Select Shadow Color" ) );
164 mShadowColorBtn->setContext( QStringLiteral(
"labeling" ) );
165 mShadowColorBtn->setDefaultColor( Qt::black );
219 mPlacePolygonBtnGrp->addButton( radAroundCentroid, (
int )QgsPalLayerSettings::AroundPoint );
220 mPlacePolygonBtnGrp->addButton( radPolygonHorizontal, (
int )QgsPalLayerSettings::Horizontal );
234 connect( groupBox_mPreview,
237 &QgsTextFormatWidget::collapseSample );
240 mLabelingOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect,
false );
245 QSizePolicy policy( mLabelingOptionsListFrame->sizePolicy() );
246 policy.setHorizontalStretch( 0 );
247 mLabelingOptionsListFrame->setSizePolicy( policy );
248 if ( !settings.
contains( QStringLiteral(
"/Windows/Labeling/OptionsSplitState" ) ) )
251 QList<int> splitsizes;
253 mLabelingOptionsSplitter->setSizes( splitsizes );
257 connect( mLabelStackedWidget, &QStackedWidget::currentChanged,
this, &QgsTextFormatWidget::optionsStackedWidget_CurrentChanged );
260 mFontPreviewSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ) ).toByteArray() );
261 mLabelingOptionsSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ) ).toByteArray() );
263 mLabelingOptionsListWidget->setCurrentRow( settings.
value( QStringLiteral(
"Windows/Labeling/Tab" ), 0 ).toInt() );
267 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
270 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
275 QList<QWidget *> widgets;
276 widgets << btnBufferColor
278 << chkLabelPerFeaturePart
282 << chkLineOrientationDependent
284 << chkPreserveRotation
286 << comboBufferBlendMode
288 << mBufferBlendModeDDBtn
292 << mBufferJoinStyleComboBox
293 << mBufferJoinStyleDDBtn
295 << mBufferOpacityDDBtn
296 << mBufferTranspFillChbx
297 << mBufferOpacityWidget
300 << mCentroidInsideCheckBox
302 << mCoordAlignmentHDDBtn
303 << mCoordAlignmentVDDBtn
304 << mCoordRotationDDBtn
309 << mDirectSymbLeftDDBtn
310 << mDirectSymbLeftLineEdit
311 << mDirectSymbPlacementDDBtn
312 << mDirectSymbRevChkBx
313 << mDirectSymbRevDDBtn
314 << mDirectSymbRightDDBtn
315 << mDirectSymbRightLineEdit
316 << mFitInsidePolygonCheckBox
317 << mFontBlendModeDDBtn
319 << mFontCapitalsComboBox
324 << mFontLetterSpacingDDBtn
325 << mFontLetterSpacingSpinBox
326 << mFontLimitPixelChkBox
327 << mFontLimitPixelDDBtn
328 << mFontLineHeightDDBtn
329 << mFontLineHeightSpinBox
330 << mFontMaxPixelDDBtn
331 << mFontMaxPixelSpinBox
332 << mFontMinPixelDDBtn
333 << mFontMinPixelSpinBox
334 << mFontMultiLineAlignComboBox
335 << mFontMultiLineAlignDDBtn
338 << mFontStrikeoutDDBtn
339 << mFontStyleComboBox
342 << mTextOpacityWidget
343 << mFontUnderlineDDBtn
345 << mFontWordSpacingDDBtn
346 << mFontWordSpacingSpinBox
349 << mFormatNumDecimalsDDBtn
350 << mFormatNumDecimalsSpnBx
351 << mFormatNumPlusSignChkBx
352 << mFormatNumPlusSignDDBtn
355 << mLimitLabelSpinBox
356 << mLineDistanceDDBtn
357 << mLineDistanceSpnBx
358 << mLineDistanceUnitDDBtn
359 << mLineDistanceUnitWidget
360 << mMaxCharAngleDDBtn
361 << mMaxCharAngleInDSpinBox
362 << mMaxCharAngleOutDSpinBox
364 << mObstacleFactorDDBtn
365 << mObstacleFactorSlider
366 << mObstacleTypeComboBox
367 << mOffsetTypeComboBox
368 << mPalShowAllLabelsForLayerChkBx
369 << mPointAngleSpinBox
371 << mPointOffsetUnitsDDBtn
372 << mPointOffsetUnitWidget
373 << mPointOffsetXSpinBox
374 << mPointOffsetYSpinBox
375 << mPointPositionOrderDDBtn
376 << mPointQuadOffsetDDBtn
377 << mPreviewBackgroundBtn
381 << mRepeatDistanceDDBtn
382 << mRepeatDistanceSpinBox
383 << mRepeatDistanceUnitDDBtn
384 << mRepeatDistanceUnitWidget
385 << mScaleBasedVisibilityChkBx
386 << mScaleBasedVisibilityDDBtn
387 << mScaleBasedVisibilityMaxDDBtn
389 << mScaleBasedVisibilityMinDDBtn
397 << mShadowOffsetAngleDDBtn
398 << mShadowOffsetAngleSpnBx
399 << mShadowOffsetDDBtn
400 << mShadowOffsetGlobalChkBx
401 << mShadowOffsetSpnBx
402 << mShadowOffsetUnitsDDBtn
403 << mShadowOffsetUnitWidget
404 << mShadowRadiusAlphaChkBx
405 << mShadowRadiusDDBtn
406 << mShadowRadiusDblSpnBx
407 << mShadowRadiusUnitsDDBtn
408 << mShadowRadiusUnitWidget
411 << mShadowOpacityDDBtn
412 << mShadowOpacityWidget
416 << mShapeBlendModeDDBtn
417 << mShapeStrokeColorBtn
418 << mShapeStrokeColorDDBtn
419 << mShapeStrokeUnitsDDBtn
420 << mShapeStrokeWidthDDBtn
421 << mShapeStrokeWidthSpnBx
422 << mShapeStrokeWidthUnitWidget
425 << mShapeFillColorBtn
426 << mShapeFillColorDDBtn
428 << mShapeOffsetUnitsDDBtn
429 << mShapeOffsetXSpnBx
430 << mShapeOffsetYSpnBx
431 << mShapeOffsetUnitWidget
432 << mShapePenStyleCmbBx
433 << mShapePenStyleDDBtn
435 << mShapeRadiusUnitsDDBtn
436 << mShapeRadiusXDbSpnBx
437 << mShapeRadiusYDbSpnBx
438 << mShapeRotationCmbBx
439 << mShapeRotationDDBtn
440 << mShapeRotationDblSpnBx
441 << mShapeRotationTypeDDBtn
442 << mShapeRadiusUnitWidget
443 << mShapeSVGPathDDBtn
444 << mShapeSVGPathLineEdit
446 << mShapeSizeTypeDDBtn
447 << mShapeSizeUnitsDDBtn
448 << mShapeSizeUnitWidget
453 << mShapeOpacityDDBtn
454 << mBackgroundOpacityWidget
463 << mCentroidRadioVisible
464 << mCentroidRadioWhole
465 << mDirectSymbRadioBtnAbove
466 << mDirectSymbRadioBtnBelow
467 << mDirectSymbRadioBtnLR
468 << mUpsidedownRadioAll
469 << mUpsidedownRadioDefined
470 << mUpsidedownRadioOff
479 << radPolygonHorizontal
480 << radPolygonPerimeter
481 << radPolygonPerimeterCurved
482 << radPredefinedOrder
483 << mFieldExpressionWidget
484 << mCheckBoxSubstituteText;
485 connectValueChanged( widgets, SLOT( updatePreview() ) );
487 connect(
mQuadrantBtnGrp,
static_cast<void ( QButtonGroup::* )(
int )
>( &QButtonGroup::buttonClicked ),
this, &QgsTextFormatWidget::updatePreview );
490 whileBlocking( mOptionsTab )->setCurrentIndex( mLabelStackedWidget->currentIndex() );
505 toggleDDButtons(
true );
509 toggleDDButtons(
false );
510 delete mLabelingOptionsListWidget->takeItem( 6 );
511 delete mLabelingOptionsListWidget->takeItem( 5 );
512 mOptionsTab->removeTab( 6 );
513 mOptionsTab->removeTab( 5 );
515 frameLabelWith->hide();
516 mDirectSymbolsFrame->hide();
517 mFormatNumFrame->hide();
518 mFormatNumChkBx->hide();
519 mFormatNumDDBtn->hide();
520 mSubstitutionsFrame->hide();
521 mFontBoldBtn->hide();
522 mFontItalicBtn->hide();
528 void QgsTextFormatWidget::toggleDDButtons(
bool visible )
532 button->setVisible( visible );
538 mOptionsTab->setVisible( enabled );
539 mOptionsTab->setTabToolTip( 0, tr(
"Text" ) );
540 mOptionsTab->setTabToolTip( 1, tr(
"Formatting" ) );
541 mOptionsTab->setTabToolTip( 2, tr(
"Buffer" ) );
542 mOptionsTab->setTabToolTip( 3, tr(
"Background" ) );
543 mOptionsTab->setTabToolTip( 4, tr(
"Shadow" ) );
544 mOptionsTab->setTabToolTip( 5, tr(
"Placement" ) );
545 mOptionsTab->setTabToolTip( 6, tr(
"Rendering" ) );
547 mLabelingOptionsListFrame->setVisible( !enabled );
548 groupBox_mPreview->setVisible( !enabled );
552 void QgsTextFormatWidget::connectValueChanged(
const QList<QWidget *> &widgets,
const char *slot )
554 Q_FOREACH ( QWidget *widget, widgets )
558 connect( w, SIGNAL( changed() ),
this, slot );
562 connect( w, SIGNAL( fieldChanged( QString ) ),
this, slot );
564 else if (
QgsOpacityWidget *w = qobject_cast< QgsOpacityWidget *>( widget ) )
566 connect( w, SIGNAL( opacityChanged(
double ) ),
this, slot );
568 else if (
QgsScaleWidget *w = qobject_cast< QgsScaleWidget *>( widget ) )
570 connect( w, SIGNAL( scaleChanged(
double ) ),
this, slot );
574 connect( w, SIGNAL( changed() ),
this, slot );
576 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
578 connect( w, SIGNAL( currentIndexChanged(
int ) ),
this, slot );
580 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
582 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
584 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
586 connect( w, SIGNAL( valueChanged(
double ) ),
this, slot );
588 else if (
QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
590 connect( w, SIGNAL( colorChanged( QColor ) ),
this, slot );
592 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
594 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
596 else if ( QRadioButton *w = qobject_cast<QRadioButton *>( widget ) )
598 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
600 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
602 connect( w, SIGNAL( textEdited( QString ) ),
this, slot );
604 else if ( QSlider *w = qobject_cast<QSlider *>( widget ) )
606 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
610 QgsLogger::warning( QStringLiteral(
"Could not create connection for widget %1" ).arg( widget->objectName() ) );
622 mBufferDrawChkBx->setChecked( buffer.
enabled() );
623 spinBufferSize->setValue( buffer.
size() );
624 mBufferUnitWidget->setUnit( buffer.
sizeUnit() );
627 mBufferOpacityWidget->setOpacity( buffer.
opacity() );
628 mBufferJoinStyleComboBox->setPenJoinStyle( buffer.
joinStyle() );
630 comboBufferBlendMode->setBlendMode( buffer.
blendMode() );
636 mBufferEffect->setEnabled(
false );
638 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
640 mFontSizeUnitWidget->setUnit( format.
sizeUnit() );
642 mRefFont = format.
font();
643 mFontSizeSpinBox->setValue( format.
size() );
644 btnTextColor->setColor( format.
color() );
645 mTextOpacityWidget->setOpacity( format.
opacity() );
646 comboBlendMode->setBlendMode( format.
blendMode() );
648 mFontWordSpacingSpinBox->setValue( format.
font().wordSpacing() );
649 mFontLetterSpacingSpinBox->setValue( format.
font().letterSpacing() );
652 updateFont( mRefFont );
655 mFontMissingLabel->setVisible( !format.
fontFound() );
658 QString missingTxt = tr(
"%1 not found. Default substituted." );
659 QString txtPrepend = tr(
"Chosen font" );
664 mFontMissingLabel->setText( missingTxt.arg( txtPrepend ) );
667 mLabelingOptionsListWidget->setCurrentRow( 0 );
669 mFontLineHeightSpinBox->setValue( format.
lineHeight() );
672 mShapeDrawChkBx->setChecked( background.
enabled() );
673 mShapeTypeCmbBx->blockSignals(
true );
674 mShapeTypeCmbBx->setCurrentIndex( background.
type() );
675 mShapeTypeCmbBx->blockSignals(
false );
676 mShapeSVGPathLineEdit->setText( background.
svgFile() );
678 mShapeSizeCmbBx->setCurrentIndex( background.
sizeType() );
679 mShapeSizeXSpnBx->setValue( background.
size().width() );
680 mShapeSizeYSpnBx->setValue( background.
size().height() );
681 mShapeSizeUnitWidget->setUnit( background.
sizeUnit() );
683 mShapeRotationCmbBx->setCurrentIndex( background.
rotationType() );
686 mShapeRotationDblSpnBx->setValue( background.
rotation() );
687 mShapeOffsetXSpnBx->setValue( background.
offset().x() );
688 mShapeOffsetYSpnBx->setValue( background.
offset().y() );
689 mShapeOffsetUnitWidget->setUnit( background.
offsetUnit() );
691 mShapeRadiusXDbSpnBx->setValue( background.
radii().width() );
692 mShapeRadiusYDbSpnBx->setValue( background.
radii().height() );
693 mShapeRadiusUnitWidget->setUnit( background.
radiiUnit() );
696 mShapeFillColorBtn->setColor( background.
fillColor() );
697 mShapeStrokeColorBtn->setColor( background.
strokeColor() );
698 mShapeStrokeWidthSpnBx->setValue( background.
strokeWidth() );
701 mShapePenStyleCmbBx->setPenJoinStyle( background.
joinStyle() );
703 mBackgroundOpacityWidget->setOpacity( background.
opacity() );
704 mShapeBlendCmbBx->setBlendMode( background.
blendMode() );
706 mLoadSvgParams =
false;
707 mShapeTypeCmbBx_currentIndexChanged( background.
type() );
714 mBackgroundEffect->setEnabled(
false );
716 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
719 mShadowDrawChkBx->setChecked( shadow.
enabled() );
721 mShadowOffsetAngleSpnBx->setValue( shadow.
offsetAngle() );
723 mShadowOffsetUnitWidget->setUnit( shadow.
offsetUnit() );
725 mShadowOffsetGlobalChkBx->setChecked( shadow.
offsetGlobal() );
727 mShadowRadiusDblSpnBx->setValue( shadow.
blurRadius() );
730 mShadowRadiusAlphaChkBx->setChecked( shadow.
blurAlphaOnly() );
731 mShadowOpacityWidget->setOpacity( shadow.
opacity() );
732 mShadowScaleSpnBx->setValue( shadow.
scale() );
734 mShadowColorBtn->setColor( shadow.
color() );
735 mShadowBlendCmbBx->setBlendMode( shadow.
blendMode() );
742 settings.
setValue( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ), mFontPreviewSplitter->saveState() );
743 settings.
setValue( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ), mLabelingOptionsSplitter->saveState() );
744 settings.
setValue( QStringLiteral(
"Windows/Labeling/Tab" ), mLabelingOptionsListWidget->currentRow() );
750 format.
setColor( btnTextColor->color() );
752 format.
setSize( mFontSizeSpinBox->value() );
754 format.
setOpacity( mTextOpacityWidget->opacity() );
762 buffer.
setEnabled( mBufferDrawChkBx->isChecked() );
763 buffer.
setSize( spinBufferSize->value() );
764 buffer.
setColor( btnBufferColor->color() );
765 buffer.
setOpacity( mBufferOpacityWidget->opacity() );
768 buffer.
setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
770 buffer.
setBlendMode( comboBufferBlendMode->blendMode() );
779 background.
setEnabled( mShapeDrawChkBx->isChecked() );
781 background.
setSvgFile( mShapeSVGPathLineEdit->text() );
783 background.
setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
784 background.
setSizeUnit( mShapeSizeUnitWidget->unit() );
787 background.
setRotation( mShapeRotationDblSpnBx->value() );
788 background.
setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
791 background.
setRadii( QSizeF( mShapeRadiusXDbSpnBx->value(), mShapeRadiusYDbSpnBx->value() ) );
792 background.
setRadiiUnit( mShapeRadiusUnitWidget->unit() );
800 background.
setJoinStyle( mShapePenStyleCmbBx->penJoinStyle() );
801 background.
setOpacity( mBackgroundOpacityWidget->opacity() );
802 background.
setBlendMode( mShapeBlendCmbBx->blendMode() );
811 shadow.
setEnabled( mShadowDrawChkBx->isChecked() );
822 shadow.
setOpacity( mShadowOpacityWidget->opacity() );
823 shadow.
setScale( mShadowScaleSpnBx->value() );
824 shadow.
setColor( mShadowColorBtn->color() );
831 void QgsTextFormatWidget::optionsStackedWidget_CurrentChanged(
int indx )
833 mLabelingOptionsListWidget->blockSignals(
true );
834 mLabelingOptionsListWidget->setCurrentRow( indx );
835 mLabelingOptionsListWidget->blockSignals(
false );
838 void QgsTextFormatWidget::collapseSample(
bool collapse )
842 QList<int> splitSizes = mFontPreviewSplitter->sizes();
843 if ( splitSizes[0] > groupBox_mPreview->height() )
845 int delta = splitSizes[0] - groupBox_mPreview->height();
846 splitSizes[0] -= delta;
847 splitSizes[1] += delta;
848 mFontPreviewSplitter->setSizes( splitSizes );
853 void QgsTextFormatWidget::changeTextColor(
const QColor &color )
859 void QgsTextFormatWidget::updateFont(
const QFont &font )
862 if ( font != mRefFont )
871 mDirectSymbLeftLineEdit->setFont( mRefFont );
872 mDirectSymbRightLineEdit->setFont( mRefFont );
874 blockFontChangeSignals(
true );
875 mFontFamilyCmbBx->setCurrentFont( mRefFont );
876 populateFontStyleComboBox();
877 int idx = mFontCapitalsComboBox->findData( QVariant( (
unsigned int ) mRefFont.capitalization() ) );
878 mFontCapitalsComboBox->setCurrentIndex( idx == -1 ? 0 : idx );
879 mFontUnderlineBtn->setChecked( mRefFont.underline() );
880 mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
881 blockFontChangeSignals(
false );
889 void QgsTextFormatWidget::blockFontChangeSignals(
bool blk )
891 mFontFamilyCmbBx->blockSignals( blk );
892 mFontStyleComboBox->blockSignals( blk );
893 mFontCapitalsComboBox->blockSignals( blk );
894 mFontUnderlineBtn->blockSignals( blk );
895 mFontStrikethroughBtn->blockSignals( blk );
896 mFontWordSpacingSpinBox->blockSignals( blk );
897 mFontLetterSpacingSpinBox->blockSignals( blk );
900 void QgsTextFormatWidget::updatePreview()
912 lblFontPreview->setFormat(
format() );
915 void QgsTextFormatWidget::scrollPreview()
917 scrollArea_mPreview->ensureVisible( 0, 0, 0, 0 );
922 scrollArea_mPreview->widget()->setStyleSheet( QStringLiteral(
"background: rgb(%1, %2, %3);" ).arg( QString::number( color.red() ),
923 QString::number( color.green() ),
924 QString::number( color.blue() ) ) );
927 void QgsTextFormatWidget::changeBufferColor(
const QColor &color )
935 QWidget *curWdgt = stackedPlacement->currentWidget();
937 bool showLineFrame =
false;
938 bool showCentroidFrame =
false;
939 bool showQuadrantFrame =
false;
940 bool showFixedQuadrantFrame =
false;
941 bool showPlacementPriorityFrame =
false;
942 bool showOffsetTypeFrame =
false;
943 bool showOffsetFrame =
false;
944 bool showDistanceFrame =
false;
945 bool showRotationFrame =
false;
946 bool showMaxCharAngleFrame =
false;
948 bool enableMultiLinesFrame =
true;
950 if ( ( curWdgt == pagePoint && radAroundPoint->isChecked() )
951 || ( curWdgt == pagePolygon && radAroundCentroid->isChecked() ) )
953 showCentroidFrame = ( curWdgt == pagePolygon && radAroundCentroid->isChecked() );
954 showDistanceFrame =
true;
956 if ( curWdgt == pagePoint )
958 showQuadrantFrame =
true;
961 else if ( ( curWdgt == pagePoint && radOverPoint->isChecked() )
962 || ( curWdgt == pagePolygon && radOverCentroid->isChecked() ) )
964 showCentroidFrame = ( curWdgt == pagePolygon && radOverCentroid->isChecked() );
965 showQuadrantFrame =
true;
966 showFixedQuadrantFrame =
true;
967 showOffsetFrame =
true;
968 showRotationFrame =
true;
970 else if ( curWdgt == pagePoint && radPredefinedOrder->isChecked() )
972 showDistanceFrame =
true;
973 showPlacementPriorityFrame =
true;
974 showOffsetTypeFrame =
true;
976 else if ( ( curWdgt == pageLine && radLineParallel->isChecked() )
977 || ( curWdgt == pagePolygon && radPolygonPerimeter->isChecked() )
978 || ( curWdgt == pageLine && radLineCurved->isChecked() )
979 || ( curWdgt == pagePolygon && radPolygonPerimeterCurved->isChecked() ) )
981 showLineFrame =
true;
982 showDistanceFrame =
true;
985 bool offline = chkLineAbove->isChecked() || chkLineBelow->isChecked();
986 chkLineOrientationDependent->setEnabled( offline );
987 mPlacementDistanceFrame->setEnabled( offline );
989 bool isCurved = ( curWdgt == pageLine && radLineCurved->isChecked() )
990 || ( curWdgt == pagePolygon && radPolygonPerimeterCurved->isChecked() );
991 showMaxCharAngleFrame = isCurved;
993 enableMultiLinesFrame = !isCurved;
996 mPlacementLineFrame->setVisible( showLineFrame );
997 mPlacementCentroidFrame->setVisible( showCentroidFrame );
998 mPlacementQuadrantFrame->setVisible( showQuadrantFrame );
999 mPlacementFixedQuadrantFrame->setVisible( showFixedQuadrantFrame );
1000 mPlacementCartographicFrame->setVisible( showPlacementPriorityFrame );
1001 mPlacementOffsetFrame->setVisible( showOffsetFrame );
1002 mPlacementDistanceFrame->setVisible( showDistanceFrame );
1003 mPlacementOffsetTypeFrame->setVisible( showOffsetTypeFrame );
1004 mPlacementRotationFrame->setVisible( showRotationFrame );
1005 mPlacementRepeatDistanceFrame->setVisible( curWdgt == pageLine || ( curWdgt == pagePolygon &&
1006 ( radPolygonPerimeter->isChecked() || radPolygonPerimeterCurved->isChecked() ) ) );
1007 mPlacementMaxCharAngleFrame->setVisible( showMaxCharAngleFrame );
1009 mMultiLinesFrame->setEnabled( enableMultiLinesFrame );
1012 void QgsTextFormatWidget::populateFontCapitalsComboBox()
1014 mFontCapitalsComboBox->addItem( tr(
"No change" ), QVariant( 0 ) );
1015 mFontCapitalsComboBox->addItem( tr(
"All uppercase" ), QVariant( 1 ) );
1016 mFontCapitalsComboBox->addItem( tr(
"All lowercase" ), QVariant( 2 ) );
1020 mFontCapitalsComboBox->addItem( tr(
"Capitalize first letter" ), QVariant( 4 ) );
1023 void QgsTextFormatWidget::populateFontStyleComboBox()
1025 mFontStyleComboBox->clear();
1026 QStringList styles = mFontDB.styles( mRefFont.family() );
1027 Q_FOREACH (
const QString &style, styles )
1029 mFontStyleComboBox->addItem( style );
1032 QString targetStyle = mFontDB.styleString( mRefFont );
1033 if ( !styles.contains( targetStyle ) )
1035 QFont
f = QFont( mRefFont.family() );
1036 targetStyle = QFontInfo( f ).styleName();
1037 mRefFont.setStyleName( targetStyle );
1040 int stylIndx = mFontStyleComboBox->findText( targetStyle );
1041 if ( stylIndx > -1 )
1046 mFontStyleComboBox->setCurrentIndex( curIndx );
1049 void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged(
double d )
1051 mRefFont.setPointSizeF( d );
1052 updateFont( mRefFont );
1055 void QgsTextFormatWidget::mFontCapitalsComboBox_currentIndexChanged(
int index )
1057 int capitalsindex = mFontCapitalsComboBox->itemData( index ).toUInt();
1058 mRefFont.setCapitalization( ( QFont::Capitalization ) capitalsindex );
1059 updateFont( mRefFont );
1062 void QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged(
const QFont &
f )
1064 mRefFont.setFamily( f.family() );
1065 updateFont( mRefFont );
1068 void QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged(
const QString &text )
1071 updateFont( mRefFont );
1074 void QgsTextFormatWidget::mFontUnderlineBtn_toggled(
bool ckd )
1076 mRefFont.setUnderline( ckd );
1077 updateFont( mRefFont );
1080 void QgsTextFormatWidget::mFontStrikethroughBtn_toggled(
bool ckd )
1082 mRefFont.setStrikeOut( ckd );
1083 updateFont( mRefFont );
1086 void QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged(
double spacing )
1088 mRefFont.setWordSpacing( spacing );
1089 updateFont( mRefFont );
1092 void QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged(
double spacing )
1094 mRefFont.setLetterSpacing( QFont::AbsoluteSpacing, spacing );
1095 updateFont( mRefFont );
1098 void QgsTextFormatWidget::mFontSizeUnitWidget_changed()
1103 mFontLimitPixelChkBox->setChecked(
false );
1109 mFontLimitPixelChkBox->setChecked(
true );
1111 updateFont( mRefFont );
1114 void QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged(
int px )
1117 mFontMaxPixelSpinBox->setMinimum( px );
1118 mFontMaxPixelSpinBox->update();
1121 void QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged(
int px )
1124 if ( px < mFontMinPixelSpinBox->value() )
1126 mFontMaxPixelSpinBox->blockSignals(
true );
1127 mFontMaxPixelSpinBox->setValue( mFontMinPixelSpinBox->value() );
1128 mFontMaxPixelSpinBox->blockSignals(
false );
1130 mFontMaxPixelSpinBox->setMinimum( mFontMinPixelSpinBox->value() );
1133 void QgsTextFormatWidget::mBufferUnitWidget_changed()
1135 updateFont( mRefFont );
1138 void QgsTextFormatWidget::mCoordXDDBtn_activated(
bool active )
1144 else if ( mCoordYDDBtn->isActive() )
1150 void QgsTextFormatWidget::mCoordYDDBtn_activated(
bool active )
1156 else if ( mCoordXDDBtn->isActive() )
1162 void QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged(
int index )
1169 showBackgroundPenStyle( isRect );
1170 showBackgroundRadius( isRect );
1172 mShapeSVGPathFrame->setVisible( isSVG );
1174 mShapeSizeYLabel->setVisible( !isSVG );
1175 mShapeSizeYSpnBx->setVisible( !isSVG );
1176 mShapeSizeYDDBtn->setVisible( !isSVG );
1177 mShapeSizeXLabel->setText( tr(
"Size%1" ).arg( !isSVG ? tr(
" X" ) : QLatin1String(
"" ) ) );
1180 mShapeFillColorBtn->setAllowOpacity( !isSVG );
1181 mShapeFillColorBtn->setButtonBackground();
1182 mShapeStrokeColorBtn->setAllowOpacity( !isSVG );
1183 mShapeStrokeColorBtn->setButtonBackground();
1186 mShapeSVGParamsBtn->setVisible( isSVG );
1189 updateSvgWidgets( mShapeSVGPathLineEdit->text() );
1193 mShapeFillColorLabel->setEnabled(
true );
1194 mShapeFillColorBtn->setEnabled(
true );
1195 mShapeFillColorDDBtn->setEnabled(
true );
1196 mShapeStrokeColorLabel->setEnabled(
true );
1197 mShapeStrokeColorBtn->setEnabled(
true );
1198 mShapeStrokeColorDDBtn->setEnabled(
true );
1199 mShapeStrokeWidthLabel->setEnabled(
true );
1200 mShapeStrokeWidthSpnBx->setEnabled(
true );
1201 mShapeStrokeWidthDDBtn->setEnabled(
true );
1205 mShapeStrokeWidthUnitWidget->setVisible( !isSVG );
1206 mShapeSVGUnitsLabel->setVisible( isSVG );
1207 mShapeStrokeUnitsDDBtn->setEnabled( !isSVG );
1210 void QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged(
const QString &text )
1212 updateSvgWidgets( text );
1217 int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) +
1218 ( chkLineBelow->isChecked() ? 1 : 0 ) +
1219 ( chkLineOn->isChecked() ? 1 : 0 );
1221 if ( numOptionsChecked == 1 )
1224 chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
1225 chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
1226 chkLineOn->setEnabled( !chkLineOn->isChecked() );
1230 chkLineAbove->setEnabled(
true );
1231 chkLineBelow->setEnabled(
true );
1232 chkLineOn->setEnabled(
true );
1242 void QgsTextFormatWidget::previewScaleChanged(
double scale )
1244 lblFontPreview->setScale( scale );
1247 void QgsTextFormatWidget::updateSvgWidgets(
const QString &svgPath )
1249 if ( mShapeSVGPathLineEdit->text() != svgPath )
1251 mShapeSVGPathLineEdit->setText( svgPath );
1255 bool validSVG = QFileInfo::exists( resolvedPath );
1258 mShapeSVGPathLineEdit->setStyleSheet( QString( !validSVG ?
"QLineEdit{ color: rgb(225, 0, 0); }" :
"" ) );
1259 mShapeSVGPathLineEdit->setToolTip( !validSVG ? tr(
"File not found" ) : resolvedPath );
1261 QColor fill, stroke;
1262 double strokeWidth = 0.0;
1263 bool fillParam =
false, strokeParam =
false, strokeWidthParam =
false;
1269 mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || strokeParam || strokeWidthParam ) );
1271 mShapeFillColorLabel->setEnabled( validSVG && fillParam );
1272 mShapeFillColorBtn->setEnabled( validSVG && fillParam );
1273 mShapeFillColorDDBtn->setEnabled( validSVG && fillParam );
1274 if ( mLoadSvgParams && validSVG && fillParam )
1275 mShapeFillColorBtn->setColor( fill );
1277 mShapeStrokeColorLabel->setEnabled( validSVG && strokeParam );
1278 mShapeStrokeColorBtn->setEnabled( validSVG && strokeParam );
1279 mShapeStrokeColorDDBtn->setEnabled( validSVG && strokeParam );
1280 if ( mLoadSvgParams && validSVG && strokeParam )
1281 mShapeStrokeColorBtn->setColor( stroke );
1283 mShapeStrokeWidthLabel->setEnabled( validSVG && strokeWidthParam );
1284 mShapeStrokeWidthSpnBx->setEnabled( validSVG && strokeWidthParam );
1285 mShapeStrokeWidthDDBtn->setEnabled( validSVG && strokeWidthParam );
1286 if ( mLoadSvgParams && validSVG && strokeWidthParam )
1287 mShapeStrokeWidthSpnBx->setValue( strokeWidth );
1293 mShapeSVGUnitsLabel->setEnabled( validSVG && strokeWidthParam );
1296 void QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked()
1299 svgDlg.setWindowTitle( tr(
"Select SVG file" ) );
1302 if ( svgDlg.exec() == QDialog::Accepted )
1305 if ( !svgPath.isEmpty() )
1307 mShapeSVGPathLineEdit->setText( svgPath );
1312 void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
1314 QString svgPath = mShapeSVGPathLineEdit->text();
1315 mLoadSvgParams =
true;
1316 updateSvgWidgets( svgPath );
1317 mLoadSvgParams =
false;
1320 void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged(
int index )
1326 void QgsTextFormatWidget::mPreviewTextEdit_textChanged(
const QString &text )
1328 lblFontPreview->setText( text );
1332 void QgsTextFormatWidget::mPreviewTextBtn_clicked()
1334 mPreviewTextEdit->setText( QStringLiteral(
"Lorem Ipsum" ) );
1338 void QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged(
const QColor &color )
1343 void QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked()
1345 bool gotChar =
false;
1346 QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ) );
1351 if ( !dirSymb.isNull() )
1352 mDirectSymbLeftLineEdit->setText( QString( dirSymb ) );
1355 void QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked()
1357 bool gotChar =
false;
1358 QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ) );
1363 if ( !dirSymb.isNull() )
1364 mDirectSymbRightLineEdit->setText( QString( dirSymb ) );
1367 void QgsTextFormatWidget::mChkNoObstacle_toggled(
bool active )
1369 mPolygonObstacleTypeFrame->setEnabled( active );
1370 mObstaclePriorityFrame->setEnabled( active );
1373 void QgsTextFormatWidget::chkLineOrientationDependent_toggled(
bool active )
1377 chkLineAbove->setText( tr(
"Left of line" ) );
1378 chkLineBelow->setText( tr(
"Right of line" ) );
1382 chkLineAbove->setText( tr(
"Above line" ) );
1383 chkLineBelow->setText( tr(
"Below line" ) );
1388 void QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked()
1403 if ( dlg.exec() == QDialog::Accepted )
1410 void QgsTextFormatWidget::showBackgroundRadius(
bool show )
1412 mShapeRadiusLabel->setVisible( show );
1413 mShapeRadiusXDbSpnBx->setVisible( show );
1415 mShapeRadiusYDbSpnBx->setVisible( show );
1417 mShapeRadiusUnitWidget->setVisible( show );
1419 mShapeRadiusDDBtn->setVisible( show );
1420 mShapeRadiusUnitsDDBtn->setVisible( show );
1423 void QgsTextFormatWidget::showBackgroundPenStyle(
bool show )
1425 mShapePenStyleLabel->setVisible( show );
1426 mShapePenStyleCmbBx->setVisible( show );
1428 mShapePenStyleDDBtn->setVisible( show );
1433 mCoordAlignmentFrame->setEnabled( enable );
1442 : QDialog( parent, fl )
1444 setWindowTitle( tr(
"Text Settings" ) );
1447 mFormatWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
1449 QVBoxLayout *layout =
new QVBoxLayout(
this );
1450 layout->addWidget( mFormatWidget );
1452 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal,
this );
1453 layout->addWidget( buttonBox );
1455 setLayout( layout );
1458 restoreGeometry( settings.
value( QStringLiteral(
"Windows/TextFormatDialog/geometry" ) ).toByteArray() );
1460 connect( buttonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked,
this, &QDialog::accept );
1461 connect( buttonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked,
this, &QDialog::reject );
1472 return mFormatWidget->
format();
1484 return mFormatWidget->
format();
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the buffer.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
QColor strokeColor() const
Returns the color used for outlining the background shape.
void setScale(int scale)
Sets the scaling used for the drop shadow (in percentage of original size).
Meters value as Map units.
void setLineHeight(double height)
Sets the line height for text.
void setRadiiUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's radii.
void setStrokeWidth(double width)
Sets the width of the shape's stroke (stroke).
RotationType
Methods for determining the rotation of 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.
QgsTextShadowSettings::ShadowPlacement shadowPlacement() const
Returns the placement for the drop shadow.
QSizeF radii() const
Returns the radii used for rounding the corners of shapes.
QSizeF size() const
Returns the size of the background shape.
double opacity() const
Returns the text's opacity.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the shape's size.
bool fontFound() const
Returns true if the specified font was found on the system, or false if the font was not found and a ...
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the drop shadow.
QPointF offset() const
Returns the offset used for drawing the background shape.
QColor fillColor() const
Returns the color used for filing the background shape.
QgsMapUnitScale strokeWidthMapUnitScale() const
Returns the map unit scale object for the shape stroke width.
void setDockMode(bool enabled)
Sets whether the widget should be shown in a compact dock mode.
This class is a composition of two QSettings instances:
bool contains(const QString &key, const QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
A groupbox that collapses/expands when toggled and can save its collapsed and checked states...
ShadowPlacement
Placement positions for text shadow.
Place direction symbols on below label.
QgsTextShadowSettings & shadow()
Returns a reference to the text drop shadow settings.
double blurRadius() const
Returns the blur radius for the shadow.
double opacity() const
Returns the background shape's opacity.
static void warning(const QString &msg)
Goes to qWarning.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the size.
void setStrokeColor(const QColor &color)
Sets the color used for outlining the background shape.
void setSize(double size)
Sets the size of the buffer.
double strokeWidth() const
Returns the width of the shape's stroke (stroke).
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
double offsetDistance() const
Returns the distance for offsetting the position of the shadow from the text.
QButtonGroup * mUpsidedownBtnGrp
Upside down labels button group.
void setFont(const QFont &font)
Sets the font used for rendering text.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
void collapsedStateChanged(bool collapsed)
Signal emitted when groupbox collapsed/expanded state is changed, and when first shown.
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's offset.
QColor color() const
Returns the color that text will be rendered in.
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.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape size.
void setDockMode(bool dockMode) override
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs...
void updateWidgetForFormat(const QgsTextFormat &format)
Updates the widget's state to reflect the settings in a QgsTextFormat.
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
A dialog for selecting a single character from a single font.
void setBackground(const QgsTextBackgroundSettings &backgroundSettings)
Sets the text's background settings.q.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the background shape.
static QString svgSymbolNameToPath(QString name, const QgsPathResolver &pathResolver)
Get SVG symbol's path from its name.
Container for settings relating to a text background object.
A widget for customising text formatting settings.
Percentage of another measurement (e.g., canvas size, feature size)
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shape offset.
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.
void setBlurRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow blur radius.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Map canvas is a class for displaying all GIS data types on a canvas.
Show labeling settings in addition to text formatting settings.
ShapeType type() const
Returns the type of background shape (e.g., square, ellipse, SVG).
void setOffset(QPointF offset)
Sets the offset used for drawing the background shape.
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
Arranges candidates following the curvature of a line feature. Applies to line layers only...
QgsUnitTypes::DistanceUnit mapUnits() const
Get units of map's geographical coordinates - used for scale calculation.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
void saveGeometry(QWidget *widget, const QString &keyName)
Save the wigget geometry into settings.
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.
void setValue(const QString &key, const QVariant &value, const QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shadow offset distance.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the text.
QColor color() const
Returns the color of the drop shadow.
void setSize(double size)
Sets the size for rendered text.
void setOffsetDistance(double distance)
Sets the distance for offsetting the position of the shadow from the text.
void widgetChanged()
Emitted when the text format defined by the widget changes.
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects. ...
QgsMapUnitScale blurRadiusMapUnitScale() const
Returns the map unit scale object for the shadow blur radius.
Offset distance applies from point geometry.
Default mode, show text formatting settings only.
bool fillBufferInterior() const
Returns whether the interior of the buffer will be filled in.
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.
RotationType rotationType() const
Returns the method used for rotating the background shape.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
double scale() const
Returns the calculated map scale.
Show upside down for all labels, including dynamic ones.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the background shape.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the drop shadow.
void enableDataDefinedAlignment(bool enable)
Controls whether data defined alignment buttons are enabled.
void setColor(const QColor &color)
Sets the color for the drop shadow.
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.
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
void setColor(const QColor &color)
Sets the color that text will be rendered in.
QgsMapUnitScale radiiMapUnitScale() const
Returns the map unit scale object for the shape radii.
QString svgFile() const
Returns the absolute path to the background SVG file, if set.
Qt::PenJoinStyle joinStyle() const
Returns the join style used for drawing the background shape.
void setNamedStyle(const QString &style)
Sets the named style for the font used for rendering text.
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the size of rendered text.
Upside-down labels (90 <= angle < 270) are shown upright.
SizeType
Methods for determining the background shape size.
double opacity() const
Returns the buffer opacity.
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)
Set 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.
void setPreviewBackground(const QColor &color)
Sets the background color for the text preview widget.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units used for the shape's stroke width.
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)
void setType(ShapeType type)
Sets the type of background shape to draw (e.g., square, ellipse, SVG).
Place direction symbols on above label.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the background shape.
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
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.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the shape's offset.
double rotation() const
Returns the rotation for the background shape, in degrees clockwise.
double lineHeight() const
Returns the line height for text.
QButtonGroup * mPlaceLineBtnGrp
Line placement button group.
void setEnabled(bool enabled)
Sets whether the text background will be drawn.
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
int offsetAngle() const
Returns the angle for offsetting the position of the shadow from the text.
ShapeType
Background shape types.
QgsSvgSelectorWidget * svgSelector()
Returns pointer to the embedded SVG selector widget.
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.
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.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the size.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the shadow's offset.
bool enabled() const
Returns whether the shadow is enabled.
QgsTextFormatWidget(const QgsTextFormat &format=QgsTextFormat(), QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr)
Constructor for QgsTextFormatWidget.
QButtonGroup * mPlacePolygonBtnGrp
Polygon placement button group.
Container for settings relating to a text shadow.
A collection of string replacements (specified using QgsStringReplacement objects).
bool offsetGlobal() const
Returns true if the global shadow offset will be used.
QColor color() const
Returns the color of the buffer.
double size() const
Returns the size of the buffer.
QgsUnitTypes::RenderUnit radiiUnit() const
Returns the units used for the shape's radii.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), const Section section=NoSection) const
Returns the value for setting key.
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.
static QgsProject * instance()
Returns the QgsProject singleton instance.
double size() const
Returns the size for rendered text.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's stroke width.
bool enabled() const
Returns whether the background is enabled.
int mMinPixelLimit
Pixel size font limit.
~QgsTextFormatDialog() override
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
void setSubstitutions(const QgsStringReplacementCollection &substitutions)
Sets the list of substitutions to show in the dialog.
QgsUnitTypes::RenderUnit blurRadiusUnit() const
Returns the units used for the shadow's blur radius.
bool enabled() const
Returns whether the buffer is enabled.
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
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.
void setShadow(const QgsTextShadowSettings &shadowSettings)
Sets the text's drop shadow settings.
A dialog which allows users to specify a list of substitutions to apply to a string, with options for exporting and importing substitution lists.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the buffer.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
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.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the size of rendered text.
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.
bool blurAlphaOnly() const
Returns whether only the alpha channel for the shadow will be blurred.
void setOffsetGlobal(bool global)
Sets whether the global shadow offset should be used.
QButtonGroup * mPlacePointBtnGrp
Point placement button group.
void setOpacity(double opacity)
Sets the buffer opacity.
Square - buffered sizes only.
QgsStringReplacementCollection substitutions
QgsTextFormatPanelWidget(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr)
Constructor for QgsTextFormatPanelWidget.
QString namedStyle() const
Returns the named style for the font used for rendering text (e.g., "bold").
QFont font() const
Returns the font used for rendering text.
void setRotationType(RotationType type)
Sets the method used for rotating the background shape.
void setColor(const QColor &color)
Sets the color for the buffer.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units used for the shape's size.
QButtonGroup * mDirectSymbBtnGrp
Symbol direction button group.
double opacity() const
Returns the shadow's opacity.
void setOpacity(double opacity)
Sets the background shape's opacity.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for 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...
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.