39 #include <QButtonGroup>
40 #include <QMessageBox>
44 , mMapCanvas( mapCanvas )
48 setWidgetMode(
Text );
55 , mMapCanvas( mapCanvas )
62 setWidgetMode( mode );
65 void QgsTextFormatWidget::initWidget()
69 mGeometryGeneratorGroupBox->setCollapsed(
true );
71 connect( mShapeSVGPathLineEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged );
72 connect( mFontSizeSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontSizeSpinBox_valueChanged );
73 connect( mFontFamilyCmbBx, &QFontComboBox::currentFontChanged,
this, &QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged );
74 connect( mFontStyleComboBox, &QComboBox::currentTextChanged,
this, &QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged );
75 connect( mFontUnderlineBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontUnderlineBtn_toggled );
76 connect( mFontStrikethroughBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontStrikethroughBtn_toggled );
77 connect( mFontWordSpacingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged );
78 connect( mFontLetterSpacingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged );
80 connect( mFontMinPixelSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged );
81 connect( mFontMaxPixelSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged );
86 connect( mShapeTypeCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged );
87 connect( mShapeRotationCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged );
88 connect( mShapeSVGParamsBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGParamsBtn_clicked );
89 connect( mShapeSVGSelectorBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked );
90 connect( mPreviewTextEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mPreviewTextEdit_textChanged );
91 connect( mPreviewTextBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mPreviewTextBtn_clicked );
93 connect( mDirectSymbLeftToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked );
94 connect( mDirectSymbRightToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked );
95 connect( chkLineOrientationDependent, &QCheckBox::toggled,
this, &QgsTextFormatWidget::chkLineOrientationDependent_toggled );
96 connect( mToolButtonConfigureSubstitutes, &QToolButton::clicked,
this, &QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked );
97 connect( mKerningCheckBox, &QCheckBox::toggled,
this, &QgsTextFormatWidget::kerningToggled );
107 mPreviewTextBtn->setIconSize( QSize( iconSize16, iconSize16 ) );
108 mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
109 mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
110 mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );
111 mPointOffsetLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
112 mPointOffsetOver ->setIconSize( QSize( iconSize32, iconSize18 ) );
113 mPointOffsetRight->setIconSize( QSize( iconSize32, iconSize18 ) );
114 mPointOffsetBelowLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
115 mPointOffsetBelow->setIconSize( QSize( iconSize32, iconSize18 ) );
116 mPointOffsetBelowRight->setIconSize( QSize( iconSize32, iconSize18 ) );
117 mLabelMinScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomOut.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
118 mLabelMaxScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomIn.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
121 mFontUnderlineBtn->setMinimumSize( buttonSize, buttonSize );
122 mFontUnderlineBtn->setMaximumSize( buttonSize, buttonSize );
123 mFontStrikethroughBtn->setMinimumSize( buttonSize, buttonSize );
124 mFontStrikethroughBtn->setMaximumSize( buttonSize, buttonSize );
125 mFontBoldBtn->setMinimumSize( buttonSize, buttonSize );
126 mFontBoldBtn->setMaximumSize( buttonSize, buttonSize );
127 mFontItalicBtn->setMinimumSize( buttonSize, buttonSize );
128 mFontItalicBtn->setMaximumSize( buttonSize, buttonSize );
130 mPreviewScaleComboBox->setMapCanvas(
mMapCanvas );
131 mPreviewScaleComboBox->setShowCurrentScaleButton(
true );
134 const auto unitWidgets = findChildren<QgsUnitSelectionWidget *>();
135 for ( QgsUnitSelectionWidget *unitWidget : unitWidgets )
165 mFontLineHeightSpinBox->setClearValue( 1.0 );
166 mShapeRotationDblSpnBx->setClearValue( 0.0 );
167 mShapeOffsetXSpnBx->setClearValue( 0.0 );
168 mShapeOffsetYSpnBx->setClearValue( 0.0 );
169 mPointOffsetXSpinBox->setClearValue( 0.0 );
170 mPointOffsetYSpinBox->setClearValue( 0.0 );
171 mPointAngleSpinBox->setClearValue( 0.0 );
172 mFontLetterSpacingSpinBox->setClearValue( 0.0 );
173 mFontWordSpacingSpinBox->setClearValue( 0.0 );
174 mZIndexSpinBox->setClearValue( 0.0 );
175 mLineDistanceSpnBx->setClearValue( 0.0 );
187 updateAvailableShadowPositions();
190 mBackgroundSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
191 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
192 mBackgroundSymbolButton->setMapCanvas(
mMapCanvas );
196 mRefFont = lblFontPreview->font();
199 connect( mShadowOffsetAngleDial, &QAbstractSlider::valueChanged, mShadowOffsetAngleSpnBx, &QSpinBox::setValue );
200 connect( mShadowOffsetAngleSpnBx,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mShadowOffsetAngleDial, &QAbstractSlider::setValue );
201 connect( mLimitLabelChkBox, &QAbstractButton::toggled, mLimitLabelSpinBox, &QWidget::setEnabled );
202 connect( mCheckBoxSubstituteText, &QAbstractButton::toggled, mToolButtonConfigureSubstitutes, &QWidget::setEnabled );
212 populateFontCapitalsComboBox();
215 mPreviewBackgroundBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
216 mPreviewBackgroundBtn->setContext( QStringLiteral(
"labeling" ) );
217 mPreviewBackgroundBtn->setColor( QColor( 255, 255, 255 ) );
218 btnTextColor->setColorDialogTitle( tr(
"Select Text Color" ) );
219 btnTextColor->setContext( QStringLiteral(
"labeling" ) );
220 btnTextColor->setDefaultColor( Qt::black );
221 btnBufferColor->setColorDialogTitle( tr(
"Select Buffer Color" ) );
222 btnBufferColor->setContext( QStringLiteral(
"labeling" ) );
223 btnBufferColor->setDefaultColor( Qt::white );
224 mShapeStrokeColorBtn->setColorDialogTitle( tr(
"Select Stroke Color" ) );
225 mShapeStrokeColorBtn->setContext( QStringLiteral(
"labeling" ) );
226 mShapeFillColorBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
227 mShapeFillColorBtn->setContext( QStringLiteral(
"labeling" ) );
228 mShadowColorBtn->setColorDialogTitle( tr(
"Select Shadow Color" ) );
229 mShadowColorBtn->setContext( QStringLiteral(
"labeling" ) );
230 mShadowColorBtn->setDefaultColor( Qt::black );
232 mFontColorDDBtn->registerLinkedWidget( btnTextColor );
233 mBufferColorDDBtn->registerLinkedWidget( btnBufferColor );
234 mShapeStrokeColorDDBtn->registerLinkedWidget( mShapeStrokeColorBtn );
235 mShapeFillColorDDBtn->registerLinkedWidget( mShapeFillColorBtn );
236 mShadowColorDDBtn->registerLinkedWidget( mShadowColorBtn );
277 const auto groupBoxes = findChildren<QgsCollapsibleGroupBox *>();
280 grpbox->setSettingGroup( QStringLiteral(
"mAdvLabelingDlg" ) );
286 mLabelingOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect,
false );
291 QSizePolicy policy( mLabelingOptionsListFrame->sizePolicy() );
292 policy.setHorizontalStretch( 0 );
293 mLabelingOptionsListFrame->setSizePolicy( policy );
294 if ( !settings.
contains( QStringLiteral(
"/Windows/Labeling/OptionsSplitState" ) ) )
297 QList<int> splitsizes;
299 mLabelingOptionsSplitter->setSizes( splitsizes );
303 connect( mLabelStackedWidget, &QStackedWidget::currentChanged,
this, &QgsTextFormatWidget::optionsStackedWidget_CurrentChanged );
306 mFontPreviewSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ) ).toByteArray() );
307 mLabelingOptionsSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ) ).toByteArray() );
309 mLabelingOptionsListWidget->setCurrentRow( settings.
value( QStringLiteral(
"Windows/Labeling/Tab" ), 0 ).toInt() );
313 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
317 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
321 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
325 QList<QWidget *> widgets;
326 widgets << btnBufferColor
328 << chkLabelPerFeaturePart
332 << chkLineOrientationDependent
334 << chkPreserveRotation
336 << comboBufferBlendMode
338 << mBufferJoinStyleComboBox
339 << mBufferTranspFillChbx
340 << mBufferOpacityWidget
341 << mCentroidInsideCheckBox
344 << mDirectSymbLeftLineEdit
345 << mDirectSymbRevChkBx
346 << mDirectSymbRightLineEdit
347 << mFitInsidePolygonCheckBox
348 << mFontCapitalsComboBox
349 << mFontLetterSpacingSpinBox
350 << mFontLimitPixelChkBox
351 << mFontLineHeightSpinBox
352 << mFontMaxPixelSpinBox
353 << mFontMinPixelSpinBox
354 << mFontMultiLineAlignComboBox
356 << mFontStyleComboBox
357 << mTextOrientationComboBox
358 << mTextOpacityWidget
359 << mFontWordSpacingSpinBox
361 << mFormatNumDecimalsSpnBx
362 << mFormatNumPlusSignChkBx
364 << mLimitLabelSpinBox
365 << mLineDistanceSpnBx
366 << mLineDistanceUnitWidget
367 << mMaxCharAngleInDSpinBox
368 << mMaxCharAngleOutDSpinBox
370 << mOffsetTypeComboBox
371 << mPalShowAllLabelsForLayerChkBx
372 << mPointAngleSpinBox
373 << mPointOffsetUnitWidget
374 << mPointOffsetXSpinBox
375 << mPointOffsetYSpinBox
376 << mPreviewBackgroundBtn
379 << mRepeatDistanceSpinBox
380 << mRepeatDistanceUnitWidget
381 << mOverrunDistanceSpinBox
382 << mOverrunDistanceUnitWidget
383 << mScaleBasedVisibilityChkBx
389 << mShadowOffsetAngleSpnBx
390 << mShadowOffsetGlobalChkBx
391 << mShadowOffsetSpnBx
392 << mShadowOffsetUnitWidget
393 << mShadowRadiusAlphaChkBx
394 << mShadowRadiusDblSpnBx
395 << mShadowRadiusUnitWidget
397 << mShadowOpacityWidget
400 << mShapeStrokeColorBtn
401 << mShapeStrokeWidthSpnBx
402 << mShapeStrokeWidthUnitWidget
404 << mShapeFillColorBtn
405 << mShapeOffsetXSpnBx
406 << mShapeOffsetYSpnBx
407 << mShapeOffsetUnitWidget
408 << mShapePenStyleCmbBx
409 << mShapeRadiusXDbSpnBx
410 << mShapeRadiusYDbSpnBx
411 << mShapeRotationCmbBx
412 << mShapeRotationDblSpnBx
413 << mShapeRadiusUnitWidget
414 << mShapeSVGPathLineEdit
416 << mShapeSizeUnitWidget
419 << mBackgroundOpacityWidget
424 << mAutoWrapLengthSpinBox
425 << mAutoWrapTypeComboBox
426 << mCentroidRadioVisible
427 << mCentroidRadioWhole
428 << mDirectSymbRadioBtnAbove
429 << mDirectSymbRadioBtnBelow
430 << mDirectSymbRadioBtnLR
431 << mUpsidedownRadioAll
432 << mUpsidedownRadioDefined
433 << mUpsidedownRadioOff
434 << mPlacementModeComboBox
435 << mFieldExpressionWidget
436 << mCheckBoxSubstituteText
437 << mGeometryGeneratorGroupBox
438 << mGeometryGenerator
439 << mGeometryGeneratorType
440 << mBackgroundSymbolButton
441 << mCalloutsDrawCheckBox
442 << mCalloutStyleComboBox
445 << mMaskJoinStyleComboBox
446 << mMaskBufferSizeSpinBox
447 << mMaskOpacityWidget
448 << mCheckAllowLabelsOutsidePolygons
449 << mHtmlFormattingCheckBox;
456 connect( mBufferDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
458 updateBufferFrameStatus();
461 connect( mShapeDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
463 updateShapeFrameStatus();
466 connect( mShadowDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
468 updateShadowFrameStatus();
471 connect( mCalloutsDrawCheckBox, &QCheckBox::stateChanged,
this, [ = ](
int )
473 updateCalloutFrameStatus();
476 mGeometryGeneratorType->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mIconPolygonLayer.svg" ) ), tr(
"Polygon / MultiPolygon" ), QgsWkbTypes::GeometryType::PolygonGeometry );
477 mGeometryGeneratorType->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mIconLineLayer.svg" ) ), tr(
"LineString / MultiLineString" ), QgsWkbTypes::GeometryType::LineGeometry );
478 mGeometryGeneratorType->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mIconPointLayer.svg" ) ), tr(
"Point / MultiPoint" ), QgsWkbTypes::GeometryType::PointGeometry );
481 whileBlocking( mOptionsTab )->setCurrentIndex( mLabelStackedWidget->currentIndex() );
482 mOptionsTab->tabBar()->setUsesScrollButtons(
true );
503 toggleDDButtons(
true );
510 const int prevIndex = mOptionsTab->currentIndex();
511 toggleDDButtons(
true );
512 delete mLabelingOptionsListWidget->takeItem( 8 );
513 delete mLabelingOptionsListWidget->takeItem( 7 );
514 delete mLabelingOptionsListWidget->takeItem( 6 );
515 delete mLabelingOptionsListWidget->takeItem( 3 );
516 mOptionsTab->removeTab( 8 );
517 mOptionsTab->removeTab( 7 );
518 mOptionsTab->removeTab( 6 );
519 mOptionsTab->removeTab( 3 );
520 mLabelStackedWidget->removeWidget( mLabelPage_Rendering );
521 mLabelStackedWidget->removeWidget( mLabelPage_Callouts );
522 mLabelStackedWidget->removeWidget( mLabelPage_Mask );
523 mLabelStackedWidget->removeWidget( mLabelPage_Placement );
533 mLabelStackedWidget->setCurrentIndex( prevIndex - 1 );
534 mOptionsTab->setCurrentIndex( prevIndex - 1 );
541 mLabelStackedWidget->setCurrentIndex( 0 );
542 mOptionsTab->setCurrentIndex( 0 );
546 frameLabelWith->hide();
547 mDirectSymbolsFrame->hide();
548 mFormatNumFrame->hide();
549 mFormatNumChkBx->hide();
550 mFormatNumDDBtn->hide();
551 mCheckBoxSubstituteText->hide();
552 mToolButtonConfigureSubstitutes->hide();
553 mLabelWrapOnCharacter->hide();
554 wrapCharacterEdit->hide();
555 mWrapCharDDBtn->hide();
556 mLabelWrapLinesTo->hide();
557 mAutoWrapLengthSpinBox->hide();
558 mAutoWrapLengthDDBtn->hide();
559 mAutoWrapTypeComboBox->hide();
560 mFontMultiLineLabel->hide();
561 mFontMultiLineAlignComboBox->hide();
562 mFontMultiLineAlignDDBtn->hide();
570 void QgsTextFormatWidget::toggleDDButtons(
bool visible )
572 const auto buttons = findChildren< QgsPropertyOverrideButton * >();
575 button->setVisible( visible );
581 mOptionsTab->setVisible( enabled );
582 mOptionsTab->setTabToolTip( 0, tr(
"Text" ) );
583 mOptionsTab->setTabToolTip( 1, tr(
"Formatting" ) );
584 mOptionsTab->setTabToolTip( 2, tr(
"Buffer" ) );
585 mOptionsTab->setTabToolTip( 3, tr(
"Mask" ) );
586 mOptionsTab->setTabToolTip( 4, tr(
"Background" ) );
587 mOptionsTab->setTabToolTip( 5, tr(
"Shadow" ) );
588 mOptionsTab->setTabToolTip( 6, tr(
"Callouts" ) );
589 mOptionsTab->setTabToolTip( 7, tr(
"Placement" ) );
590 mOptionsTab->setTabToolTip( 8, tr(
"Rendering" ) );
592 mLabelingOptionsListFrame->setVisible( !enabled );
593 groupBox_mPreview->setVisible( !enabled );
597 void QgsTextFormatWidget::connectValueChanged(
const QList<QWidget *> &widgets,
const char *slot )
599 const auto constWidgets = widgets;
600 for ( QWidget *widget : constWidgets )
604 connect( w, SIGNAL( changed() ),
this, slot );
608 connect( w, SIGNAL( fieldChanged( QString ) ),
this, slot );
610 else if (
QgsOpacityWidget *w = qobject_cast< QgsOpacityWidget *>( widget ) )
612 connect( w, SIGNAL( opacityChanged(
double ) ),
this, slot );
614 else if (
QgsScaleWidget *w = qobject_cast< QgsScaleWidget *>( widget ) )
616 connect( w, SIGNAL( scaleChanged(
double ) ),
this, slot );
618 else if ( QgsUnitSelectionWidget *w = qobject_cast<QgsUnitSelectionWidget *>( widget ) )
620 connect( w, SIGNAL( changed() ),
this, slot );
622 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
624 connect( w, SIGNAL( currentIndexChanged(
int ) ),
this, slot );
626 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
628 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
630 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
632 connect( w, SIGNAL( valueChanged(
double ) ),
this, slot );
634 else if (
QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
636 connect( w, SIGNAL( colorChanged( QColor ) ),
this, slot );
638 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
640 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
642 else if ( QRadioButton *w = qobject_cast<QRadioButton *>( widget ) )
644 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
646 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
648 connect( w, SIGNAL( textEdited( QString ) ),
this, slot );
650 else if ( QSlider *w = qobject_cast<QSlider *>( widget ) )
652 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
654 else if ( QGroupBox *w = qobject_cast<QGroupBox *>( widget ) )
656 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
660 connect( w, SIGNAL( textChanged() ),
this, slot );
664 QgsLogger::warning( QStringLiteral(
"Could not create connection for widget %1" ).arg( widget->objectName() ) );
695 mDirectSymbDDBtn->registerCheckedWidget( mDirectSymbChkBx );
703 mFormatNumDDBtn->registerCheckedWidget( mFormatNumChkBx );
709 mBufferDrawDDBtn->registerCheckedWidget( mBufferDrawChkBx );
719 mEnableMaskDDBtn->registerCheckedWidget( mEnableMaskChkBx );
727 mShapeDrawDDBtn->registerCheckedWidget( mShapeDrawChkBx );
750 mShadowDrawDDBtn->registerCheckedWidget( mShadowDrawChkBx );
790 QString ddScaleVisInfo = tr(
"Value < 0 represents a scale closer than 1:1, e.g. -10 = 10:1<br>"
791 "Value of 0 disables the specific limit." );
793 mScaleBasedVisibilityDDBtn->registerCheckedWidget( mScaleBasedVisibilityChkBx );
795 mScaleBasedVisibilityMinDDBtn->setUsageInfo( ddScaleVisInfo );
797 mScaleBasedVisibilityMaxDDBtn->setUsageInfo( ddScaleVisInfo );
800 mFontLimitPixelDDBtn->registerCheckedWidget( mFontLimitPixelChkBox );
812 mCalloutDrawDDBtn->registerCheckedWidget( mCalloutsDrawCheckBox );
820 if ( !mButtons.contains( key ) )
825 mButtons[key] = button;
842 mBufferDrawChkBx->setChecked( buffer.
enabled() );
843 mBufferFrame->setEnabled( buffer.
enabled() );
844 spinBufferSize->setValue( buffer.
size() );
845 mBufferUnitWidget->setUnit( buffer.
sizeUnit() );
847 btnBufferColor->setColor( buffer.
color() );
848 mBufferOpacityWidget->setOpacity( buffer.
opacity() );
849 mBufferJoinStyleComboBox->setPenJoinStyle( buffer.
joinStyle() );
851 comboBufferBlendMode->setBlendMode( buffer.
blendMode() );
853 mBufferEffect.reset( lPaintEffect->clone() );
857 mBufferEffect->setEnabled(
false );
859 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
863 mEnableMaskChkBx->setChecked( mask.
enabled() );
864 mMaskBufferSizeSpinBox->setValue( mask.
size() );
865 mMaskBufferUnitWidget->setUnit( mask.
sizeUnit() );
867 mMaskOpacityWidget->setOpacity( mask.
opacity() );
868 mMaskJoinStyleComboBox->setPenJoinStyle( mask.
joinStyle() );
870 mMaskEffect.reset( lPaintEffect->clone() );
874 mMaskEffect->setEnabled(
false );
876 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
885 mTextOrientationComboBox->setCurrentIndex( mTextOrientationComboBox->findData(
format.
orientation() ) );
888 mFontWordSpacingSpinBox->setValue(
format.
font().wordSpacing() );
889 mFontLetterSpacingSpinBox->setValue(
format.
font().letterSpacing() );
894 updateFont( mRefFont );
900 QString missingTxt = tr(
"%1 not found. Default substituted." );
901 QString txtPrepend = tr(
"Chosen font" );
906 mFontMissingLabel->setText( missingTxt.arg( txtPrepend ) );
909 mLabelingOptionsListWidget->setCurrentRow( 0 );
915 mShapeDrawChkBx->setChecked( background.
enabled() );
916 mShapeFrame->setEnabled( background.
enabled() );
917 mShapeTypeCmbBx->blockSignals(
true );
918 mShapeTypeCmbBx->setCurrentIndex( mShapeTypeCmbBx->findData( background.
type() ) );
919 mShapeTypeCmbBx->blockSignals(
false );
920 updateAvailableShadowPositions();
921 mShapeSVGPathLineEdit->setText( background.
svgFile() );
923 mShapeSizeCmbBx->setCurrentIndex( background.
sizeType() );
924 mShapeSizeXSpnBx->setValue( background.
size().width() );
925 mShapeSizeYSpnBx->setValue( background.
size().height() );
926 mShapeSizeUnitWidget->setUnit( background.
sizeUnit() );
928 mShapeRotationCmbBx->setCurrentIndex( background.
rotationType() );
931 mShapeRotationDblSpnBx->setValue( background.
rotation() );
932 mShapeOffsetXSpnBx->setValue( background.
offset().x() );
933 mShapeOffsetYSpnBx->setValue( background.
offset().y() );
934 mShapeOffsetUnitWidget->setUnit( background.
offsetUnit() );
936 mShapeRadiusXDbSpnBx->setValue( background.
radii().width() );
937 mShapeRadiusYDbSpnBx->setValue( background.
radii().height() );
938 mShapeRadiusUnitWidget->setUnit( background.
radiiUnit() );
941 mShapeFillColorBtn->setColor( background.
fillColor() );
942 mShapeStrokeColorBtn->setColor( background.
strokeColor() );
943 mShapeStrokeWidthSpnBx->setValue( background.
strokeWidth() );
946 mShapePenStyleCmbBx->setPenJoinStyle( background.
joinStyle() );
948 mBackgroundOpacityWidget->setOpacity( background.
opacity() );
949 mShapeBlendCmbBx->setBlendMode( background.
blendMode() );
951 mLoadSvgParams =
false;
952 mShapeTypeCmbBx_currentIndexChanged( background.
type() );
954 if (
auto *lPaintEffect = background.
paintEffect() )
955 mBackgroundEffect.reset( lPaintEffect->clone() );
959 mBackgroundEffect->setEnabled(
false );
961 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
966 mShadowDrawChkBx->setChecked( shadow.
enabled() );
967 mShadowFrame->setEnabled( shadow.
enabled() );
968 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( shadow.
shadowPlacement() ) );
969 mShadowOffsetAngleSpnBx->setValue( shadow.
offsetAngle() );
971 mShadowOffsetUnitWidget->setUnit( shadow.
offsetUnit() );
973 mShadowOffsetGlobalChkBx->setChecked( shadow.
offsetGlobal() );
975 mShadowRadiusDblSpnBx->setValue( shadow.
blurRadius() );
978 mShadowRadiusAlphaChkBx->setChecked( shadow.
blurAlphaOnly() );
979 mShadowOpacityWidget->setOpacity( shadow.
opacity() );
980 mShadowScaleSpnBx->setValue( shadow.
scale() );
982 mShadowColorBtn->setColor( shadow.
color() );
983 mShadowBlendCmbBx->setBlendMode( shadow.
blendMode() );
995 settings.
setValue( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ), mFontPreviewSplitter->saveState() );
996 settings.
setValue( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ), mLabelingOptionsSplitter->saveState() );
998 int prevIndex = mLabelingOptionsListWidget->currentRow();
999 if ( mWidgetMode ==
Text )
1001 switch ( prevIndex )
1010 settings.
setValue( QStringLiteral(
"Windows/Labeling/Tab" ), prevIndex );
1032 buffer.
setEnabled( mBufferDrawChkBx->isChecked() );
1033 buffer.
setSize( spinBufferSize->value() );
1034 buffer.
setColor( btnBufferColor->color() );
1035 buffer.
setOpacity( mBufferOpacityWidget->opacity() );
1038 buffer.
setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
1040 buffer.
setBlendMode( comboBufferBlendMode->blendMode() );
1049 mask.
setEnabled( mEnableMaskChkBx->isChecked() );
1050 mask.
setSize( mMaskBufferSizeSpinBox->value() );
1051 mask.
setOpacity( mMaskOpacityWidget->opacity() );
1052 mask.
setSizeUnit( mMaskBufferUnitWidget->unit() );
1054 mask.
setJoinStyle( mMaskJoinStyleComboBox->penJoinStyle() );
1064 background.
setEnabled( mShapeDrawChkBx->isChecked() );
1066 background.
setSvgFile( mShapeSVGPathLineEdit->text() );
1068 background.
setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
1069 background.
setSizeUnit( mShapeSizeUnitWidget->unit() );
1072 background.
setRotation( mShapeRotationDblSpnBx->value() );
1073 background.
setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
1076 background.
setRadii( QSizeF( mShapeRadiusXDbSpnBx->value(), mShapeRadiusYDbSpnBx->value() ) );
1077 background.
setRadiiUnit( mShapeRadiusUnitWidget->unit() );
1080 background.
setFillColor( mShapeFillColorBtn->color() );
1085 background.
setJoinStyle( mShapePenStyleCmbBx->penJoinStyle() );
1086 background.
setOpacity( mBackgroundOpacityWidget->opacity() );
1087 background.
setBlendMode( mShapeBlendCmbBx->blendMode() );
1097 shadow.
setEnabled( mShadowDrawChkBx->isChecked() );
1108 shadow.
setOpacity( mShadowOpacityWidget->opacity() );
1109 shadow.
setScale( mShadowScaleSpnBx->value() );
1110 shadow.
setColor( mShadowColorBtn->color() );
1114 if ( includeDataDefinedProperties )
1145 if ( mButtons.contains( key ) )
1157 void QgsTextFormatWidget::optionsStackedWidget_CurrentChanged(
int indx )
1159 mLabelingOptionsListWidget->blockSignals(
true );
1160 mLabelingOptionsListWidget->setCurrentRow( indx );
1161 mLabelingOptionsListWidget->blockSignals(
false );
1170 mPreviewExpressionContext = *lExpressionContext;
1175 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
1183 void QgsTextFormatWidget::collapseSample(
bool collapse )
1187 QList<int> splitSizes = mFontPreviewSplitter->sizes();
1188 if ( splitSizes[0] > groupBox_mPreview->height() )
1190 int delta = splitSizes[0] - groupBox_mPreview->height();
1191 splitSizes[0] -= delta;
1192 splitSizes[1] += delta;
1193 mFontPreviewSplitter->setSizes( splitSizes );
1198 void QgsTextFormatWidget::changeTextColor(
const QColor &color )
1204 void QgsTextFormatWidget::updateFont(
const QFont &font )
1207 if ( font != mRefFont )
1216 mDirectSymbLeftLineEdit->setFont( mRefFont );
1217 mDirectSymbRightLineEdit->setFont( mRefFont );
1219 blockFontChangeSignals(
true );
1220 mFontFamilyCmbBx->setCurrentFont( mRefFont );
1221 populateFontStyleComboBox();
1222 mFontUnderlineBtn->setChecked( mRefFont.underline() );
1223 mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
1224 mKerningCheckBox->setChecked( mRefFont.kerning() );
1225 blockFontChangeSignals(
false );
1233 void QgsTextFormatWidget::blockFontChangeSignals(
bool blk )
1235 mFontFamilyCmbBx->blockSignals( blk );
1236 mFontStyleComboBox->blockSignals( blk );
1237 mFontCapitalsComboBox->blockSignals( blk );
1238 mFontUnderlineBtn->blockSignals( blk );
1239 mFontStrikethroughBtn->blockSignals( blk );
1240 mFontWordSpacingSpinBox->blockSignals( blk );
1241 mFontLetterSpacingSpinBox->blockSignals( blk );
1242 mKerningCheckBox->blockSignals( blk );
1257 lblFontPreview->setFormat(
format() );
1260 void QgsTextFormatWidget::scrollPreview()
1262 scrollArea_mPreview->ensureVisible( 0, 0, 0, 0 );
1267 mPreviewBackgroundColor = color;
1269 scrollArea_mPreview->widget()->setStyleSheet( QStringLiteral(
"background: rgb(%1, %2, %3);" ).arg( QString::number( color.red() ),
1270 QString::number( color.green() ),
1271 QString::number( color.blue() ) ) );
1274 void QgsTextFormatWidget::changeBufferColor(
const QColor &color )
1283 bool showLineFrame =
false;
1284 bool showCentroidFrame =
false;
1285 bool showQuadrantFrame =
false;
1286 bool showFixedQuadrantFrame =
false;
1287 bool showPlacementPriorityFrame =
false;
1288 bool showOffsetTypeFrame =
false;
1289 bool showOffsetFrame =
false;
1290 bool showDistanceFrame =
false;
1291 bool showRotationFrame =
false;
1292 bool showMaxCharAngleFrame =
false;
1297 bool enableMultiLinesFrame =
true;
1303 showDistanceFrame =
true;
1311 showQuadrantFrame =
true;
1312 showFixedQuadrantFrame =
true;
1313 showOffsetFrame =
true;
1314 showRotationFrame =
true;
1318 showDistanceFrame =
true;
1319 showPlacementPriorityFrame =
true;
1320 showOffsetTypeFrame =
true;
1327 showLineFrame =
true;
1328 showDistanceFrame =
true;
1331 bool offline = chkLineAbove->isChecked() || chkLineBelow->isChecked();
1332 chkLineOrientationDependent->setEnabled( offline );
1333 mPlacementDistanceFrame->setEnabled( offline );
1337 showMaxCharAngleFrame = isCurved;
1339 enableMultiLinesFrame = !isCurved;
1344 showDistanceFrame =
true;
1347 mPlacementLineFrame->setVisible( showLineFrame );
1348 mPlacementPolygonFrame->setVisible( showPolygonPlacementOptions );
1349 mPlacementCentroidFrame->setVisible( showCentroidFrame );
1350 mPlacementQuadrantFrame->setVisible( showQuadrantFrame );
1351 mPlacementFixedQuadrantFrame->setVisible( showFixedQuadrantFrame );
1352 mPlacementCartographicFrame->setVisible( showPlacementPriorityFrame );
1353 mPlacementOffsetFrame->setVisible( showOffsetFrame );
1354 mPlacementDistanceFrame->setVisible( showDistanceFrame );
1355 mPlacementOffsetTypeFrame->setVisible( showOffsetTypeFrame );
1356 mPlacementRotationFrame->setVisible( showRotationFrame );
1361 mPlacementMaxCharAngleFrame->setVisible( showMaxCharAngleFrame );
1363 mMultiLinesFrame->setEnabled( enableMultiLinesFrame );
1367 switch ( currentPlacement )
1371 helperText = tr(
"Arranges label candidates in a clockwise circle around the feature, preferring placements to the top-right of the feature." );
1373 helperText = tr(
"Arranges label candidates in a cluster around the feature's centroid, preferring placements directly over the centroid." );
1377 helperText = tr(
"Arranges label candidates directly over the feature or at a preset offset from the feature." );
1379 helperText = tr(
"Arranges label candidates directly over the feature's centroid, or at a preset offset from the centroid." );
1383 helperText = tr(
"Arranges label candidates parallel to a generalised line representing the feature. Placements which fall over straighter portions of the line are preferred." );
1385 helperText = tr(
"Arranges label candidates parallel to a generalised line representing the polygon's perimeter. Placements which fall over straighter portions of the perimeter are preferred." );
1389 helperText = tr(
"Arranges candidates following the curvature of a line feature. Placements which fall over straighter portions of the line are preferred." );
1393 helperText = tr(
"Arranges label candidates scattered throughout the polygon. Labels will always be placed horizontally, with placements further from the edges of the polygon preferred." );
1395 helperText = tr(
"Label candidates are arranged horizontally along the length of the feature." );
1399 helperText = tr(
"Arranges label candidates scattered throughout the polygon. Labels are rotated to respect the polygon's orientation, with placements further from the edges of the polygon preferred." );
1403 helperText = tr(
"Label candidates are placed in predefined positions around the features. Preference is given to positions with greatest cartographic appeal, e.g., top right and bottom right of the feature." );
1407 helperText = tr(
"Arranges candidates following the curvature of the feature's perimeter. Placements which fall over straighter portions of the perimeter are preferred." );
1411 helperText = tr(
"Label candidates are placed outside of the features, preferring placements which give greatest visual association between the label and the feature." );
1414 mPlacementModeDescriptionLabel->setText( QStringLiteral(
"<i>%1</i>" ).arg( helperText ) );
1417 void QgsTextFormatWidget::populateFontCapitalsComboBox()
1429 void QgsTextFormatWidget::populateFontStyleComboBox()
1431 mFontStyleComboBox->clear();
1432 QStringList styles = mFontDB.styles( mRefFont.family() );
1433 const auto constStyles = styles;
1434 for (
const QString &style : constStyles )
1436 mFontStyleComboBox->addItem( style );
1439 QString targetStyle = mFontDB.styleString( mRefFont );
1440 if ( !styles.contains( targetStyle ) )
1442 QFont f = QFont( mRefFont.family() );
1443 targetStyle = QFontInfo( f ).styleName();
1444 mRefFont.setStyleName( targetStyle );
1447 int stylIndx = mFontStyleComboBox->findText( targetStyle );
1448 if ( stylIndx > -1 )
1453 mFontStyleComboBox->setCurrentIndex( curIndx );
1456 void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged(
double d )
1458 mRefFont.setPointSizeF( d );
1459 updateFont( mRefFont );
1462 void QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged(
const QFont &f )
1464 mRefFont.setFamily( f.family() );
1465 updateFont( mRefFont );
1468 void QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged(
const QString &text )
1471 updateFont( mRefFont );
1474 void QgsTextFormatWidget::mFontUnderlineBtn_toggled(
bool ckd )
1476 mRefFont.setUnderline( ckd );
1477 updateFont( mRefFont );
1480 void QgsTextFormatWidget::mFontStrikethroughBtn_toggled(
bool ckd )
1482 mRefFont.setStrikeOut( ckd );
1483 updateFont( mRefFont );
1486 void QgsTextFormatWidget::kerningToggled(
bool checked )
1488 mRefFont.setKerning( checked );
1489 updateFont( mRefFont );
1492 void QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged(
double spacing )
1494 mRefFont.setWordSpacing( spacing );
1495 updateFont( mRefFont );
1498 void QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged(
double spacing )
1500 mRefFont.setLetterSpacing( QFont::AbsoluteSpacing, spacing );
1501 updateFont( mRefFont );
1504 void QgsTextFormatWidget::mFontSizeUnitWidget_changed()
1509 mFontLimitPixelChkBox->setChecked(
false );
1515 mFontLimitPixelChkBox->setChecked(
true );
1517 updateFont( mRefFont );
1520 void QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged(
int px )
1523 mFontMaxPixelSpinBox->setMinimum( px );
1524 mFontMaxPixelSpinBox->update();
1527 void QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged(
int px )
1530 if ( px < mFontMinPixelSpinBox->value() )
1532 mFontMaxPixelSpinBox->blockSignals(
true );
1533 mFontMaxPixelSpinBox->setValue( mFontMinPixelSpinBox->value() );
1534 mFontMaxPixelSpinBox->blockSignals(
false );
1536 mFontMaxPixelSpinBox->setMinimum( mFontMinPixelSpinBox->value() );
1539 void QgsTextFormatWidget::mBufferUnitWidget_changed()
1541 updateFont( mRefFont );
1544 void QgsTextFormatWidget::mMaskBufferUnitWidget_changed()
1546 updateFont( mRefFont );
1549 void QgsTextFormatWidget::mCoordXDDBtn_changed( )
1551 if ( !mCoordXDDBtn->isActive() )
1555 else if ( mCoordYDDBtn->isActive() )
1561 void QgsTextFormatWidget::mCoordYDDBtn_changed( )
1563 if ( !mCoordYDDBtn->isActive() )
1567 else if ( mCoordXDDBtn->isActive() )
1573 void QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged(
int )
1581 showBackgroundPenStyle( isRect );
1582 showBackgroundRadius( isRect );
1584 mShapeSVGPathFrame->setVisible( isSVG );
1585 mBackgroundSymbolButton->setVisible( isMarker );
1589 mShapeSizeYLabel->setVisible( !isSVG && !isMarker );
1590 mShapeSizeYSpnBx->setVisible( !isSVG && !isMarker );
1591 mShapeSizeYDDBtn->setVisible( !isSVG && !isMarker );
1592 mShapeSizeXLabel->setText( tr(
"Size%1" ).arg( !isSVG && !isMarker ? tr(
" X" ) : QString() ) );
1595 mShapeFillColorBtn->setAllowOpacity( !isSVG );
1596 mShapeFillColorBtn->setButtonBackground();
1597 mShapeStrokeColorBtn->setAllowOpacity( !isSVG );
1598 mShapeStrokeColorBtn->setButtonBackground();
1601 mShapeFillColorLabel->setVisible( !isMarker );
1602 mShapeFillColorLabel->setEnabled( !isMarker );
1603 mShapeFillColorBtn->setVisible( !isMarker );
1604 mShapeFillColorBtn->setEnabled( !isMarker );
1605 mShapeFillColorDDBtn->setVisible( !isMarker );
1606 mShapeFillColorDDBtn->setEnabled( !isMarker );
1607 mShapeStrokeColorLabel->setVisible( !isMarker );
1608 mShapeStrokeColorLabel->setEnabled( !isMarker );
1609 mShapeStrokeColorBtn->setVisible( !isMarker );
1610 mShapeStrokeColorBtn->setEnabled( !isMarker );
1611 mShapeStrokeColorDDBtn->setVisible( !isMarker );
1612 mShapeStrokeColorDDBtn->setEnabled( !isMarker );
1613 mShapeStrokeWidthLabel->setVisible( !isMarker );
1614 mShapeStrokeWidthLabel->setEnabled( !isMarker );
1615 mShapeStrokeWidthSpnBx->setVisible( !isMarker );
1616 mShapeStrokeWidthSpnBx->setEnabled( !isMarker );
1617 mShapeStrokeWidthDDBtn->setVisible( !isMarker );
1618 mShapeStrokeWidthDDBtn->setEnabled( !isMarker );
1621 mShapeSVGParamsBtn->setVisible( isSVG );
1624 updateSvgWidgets( mShapeSVGPathLineEdit->text() );
1628 mShapeStrokeWidthUnitWidget->setVisible( !isSVG && !isMarker );
1629 mShapeSVGUnitsLabel->setVisible( isSVG );
1630 mShapeStrokeUnitsDDBtn->setVisible( !isSVG && !isMarker );
1631 mShapeStrokeUnitsDDBtn->setEnabled( !isSVG && !isMarker );
1633 updateAvailableShadowPositions();
1636 void QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged(
const QString &text )
1638 updateSvgWidgets( text );
1643 int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) +
1644 ( chkLineBelow->isChecked() ? 1 : 0 ) +
1645 ( chkLineOn->isChecked() ? 1 : 0 );
1647 if ( numOptionsChecked == 1 )
1650 chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
1651 chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
1652 chkLineOn->setEnabled( !chkLineOn->isChecked() );
1656 chkLineAbove->setEnabled(
true );
1657 chkLineBelow->setEnabled(
true );
1658 chkLineOn->setEnabled(
true );
1668 void QgsTextFormatWidget::previewScaleChanged(
double scale )
1670 lblFontPreview->setScale( scale );
1673 void QgsTextFormatWidget::updateSvgWidgets(
const QString &svgPath )
1675 if ( mShapeSVGPathLineEdit->text() != svgPath )
1677 mShapeSVGPathLineEdit->setText( svgPath );
1680 QString resolvedPath;
1681 bool validSVG =
true;
1682 if ( ! svgPath.startsWith( QLatin1String(
"base64:" ), Qt::CaseInsensitive ) )
1685 validSVG = QFileInfo::exists( resolvedPath );
1689 resolvedPath = svgPath;
1694 mShapeSVGPathLineEdit->setStyleSheet( !validSVG ? QStringLiteral(
"QLineEdit{ color: rgb(225, 0, 0); }" ) : QString() );
1695 mShapeSVGPathLineEdit->setToolTip( !validSVG ? tr(
"File not found" ) : resolvedPath );
1697 QColor fill, stroke;
1698 double strokeWidth = 0.0;
1699 bool fillParam =
false, strokeParam =
false, strokeWidthParam =
false;
1705 mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || strokeParam || strokeWidthParam ) );
1707 mShapeFillColorLabel->setEnabled( validSVG && fillParam );
1708 mShapeFillColorBtn->setEnabled( validSVG && fillParam );
1709 mShapeFillColorDDBtn->setEnabled( validSVG && fillParam );
1710 if ( mLoadSvgParams && validSVG && fillParam )
1711 mShapeFillColorBtn->setColor( fill );
1713 mShapeStrokeColorLabel->setEnabled( validSVG && strokeParam );
1714 mShapeStrokeColorBtn->setEnabled( validSVG && strokeParam );
1715 mShapeStrokeColorDDBtn->setEnabled( validSVG && strokeParam );
1716 if ( mLoadSvgParams && validSVG && strokeParam )
1717 mShapeStrokeColorBtn->setColor( stroke );
1719 mShapeStrokeWidthLabel->setEnabled( validSVG && strokeWidthParam );
1720 mShapeStrokeWidthSpnBx->setEnabled( validSVG && strokeWidthParam );
1721 mShapeStrokeWidthDDBtn->setEnabled( validSVG && strokeWidthParam );
1722 if ( mLoadSvgParams && validSVG && strokeWidthParam )
1723 mShapeStrokeWidthSpnBx->setValue( strokeWidth );
1729 mShapeSVGUnitsLabel->setEnabled( validSVG && strokeWidthParam );
1732 void QgsTextFormatWidget::updateAvailableShadowPositions()
1734 if ( mShadowUnderCmbBx->count() == 0
1740 mShadowUnderCmbBx->clear();
1748 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( currentPlacement ) );
1749 if ( mShadowUnderCmbBx->currentIndex() == -1 )
1750 mShadowUnderCmbBx->setCurrentIndex( 0 );
1754 void QgsTextFormatWidget::updateProperty()
1762 void QgsTextFormatWidget::createAuxiliaryField()
1789 property.setActive(
true );
1798 void QgsTextFormatWidget::updateShapeFrameStatus()
1800 mShapeFrame->setEnabled( mShapeDrawDDBtn->isActive() || mShapeDrawChkBx->isChecked() );
1803 void QgsTextFormatWidget::updateBufferFrameStatus()
1805 mBufferFrame->setEnabled( mBufferDrawDDBtn->isActive() || mBufferDrawChkBx->isChecked() );
1808 void QgsTextFormatWidget::updateShadowFrameStatus()
1810 mShadowFrame->setEnabled( mShadowDrawDDBtn->isActive() || mShadowDrawChkBx->isChecked() );
1813 void QgsTextFormatWidget::updateCalloutFrameStatus()
1815 mCalloutFrame->setEnabled( mCalloutDrawDDBtn->isActive() || mCalloutsDrawCheckBox->isChecked() );
1859 saveDlg.setDefaultTags( mTextFormatsListWidget->currentTagFilter() );
1860 if ( !saveDlg.exec() )
1863 if ( saveDlg.name().isEmpty() )
1869 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1870 tr(
"Format with name '%1' already exists. Overwrite?" )
1871 .arg( saveDlg.name() ),
1872 QMessageBox::Yes | QMessageBox::No );
1873 if ( res != QMessageBox::Yes )
1880 QStringList symbolTags = saveDlg.tags().split(
',' );
1884 style->
saveTextFormat( saveDlg.name(), newFormat, saveDlg.isFavorite(), symbolTags );
1887 void QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked()
1890 svgDlg.setWindowTitle( tr(
"Select SVG file" ) );
1891 svgDlg.svgSelector()->setSvgPath( mShapeSVGPathLineEdit->text().trimmed() );
1893 if ( svgDlg.exec() == QDialog::Accepted )
1895 QString svgPath = svgDlg.svgSelector()->currentSvgPath();
1896 if ( !svgPath.isEmpty() )
1898 mShapeSVGPathLineEdit->setText( svgPath );
1904 void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
1906 QString svgPath = mShapeSVGPathLineEdit->text();
1907 mLoadSvgParams =
true;
1908 updateSvgWidgets( svgPath );
1909 mLoadSvgParams =
false;
1912 void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged(
int index )
1918 void QgsTextFormatWidget::mPreviewTextEdit_textChanged(
const QString &text )
1920 lblFontPreview->setText( text );
1924 void QgsTextFormatWidget::mPreviewTextBtn_clicked()
1926 mPreviewTextEdit->setText( QStringLiteral(
"Lorem Ipsum" ) );
1930 void QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged(
const QColor &color )
1935 void QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked()
1937 bool gotChar =
false;
1939 const QChar initial = !mDirectSymbLeftLineEdit->text().isEmpty() ? mDirectSymbLeftLineEdit->text().at( 0 ) : QChar();
1940 QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
1945 if ( !dirSymb.isNull() )
1946 mDirectSymbLeftLineEdit->setText( QString( dirSymb ) );
1949 void QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked()
1951 bool gotChar =
false;
1952 const QChar initial = !mDirectSymbRightLineEdit->text().isEmpty() ? mDirectSymbRightLineEdit->text().at( 0 ) : QChar();
1953 QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
1958 if ( !dirSymb.isNull() )
1959 mDirectSymbRightLineEdit->setText( QString( dirSymb ) );
1962 void QgsTextFormatWidget::chkLineOrientationDependent_toggled(
bool active )
1966 chkLineAbove->setText( tr(
"Left of line" ) );
1967 chkLineBelow->setText( tr(
"Right of line" ) );
1971 chkLineAbove->setText( tr(
"Above line" ) );
1972 chkLineBelow->setText( tr(
"Below line" ) );
1977 void QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked()
1992 if ( dlg.exec() == QDialog::Accepted )
1999 void QgsTextFormatWidget::showBackgroundRadius(
bool show )
2001 mShapeRadiusLabel->setVisible( show );
2002 mShapeRadiusXDbSpnBx->setVisible( show );
2004 mShapeRadiusYDbSpnBx->setVisible( show );
2006 mShapeRadiusUnitWidget->setVisible( show );
2008 mShapeRadiusDDBtn->setVisible( show );
2009 mShapeRadiusUnitsDDBtn->setVisible( show );
2012 void QgsTextFormatWidget::showBackgroundPenStyle(
bool show )
2014 mShapePenStyleLabel->setVisible( show );
2015 mShapePenStyleCmbBx->setVisible( show );
2017 mShapePenStyleDDBtn->setVisible( show );
2022 mCoordAlignmentFrame->setEnabled( enable );
2028 return *lExpressionContext;
2049 if ( mGeometryGeneratorGroupBox->isChecked() )
2063 : QDialog( parent, fl )
2065 setWindowTitle( tr(
"Text Settings" ) );
2068 mFormatWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
2070 QVBoxLayout *layout =
new QVBoxLayout(
this );
2071 layout->addWidget( mFormatWidget );
2073 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, Qt::Horizontal,
this );
2074 layout->addWidget( mButtonBox );
2076 setLayout( layout );
2079 connect( mButtonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked,
this, &QDialog::accept );
2080 connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked,
this, &QDialog::reject );
2081 connect( mButtonBox->button( QDialogButtonBox::Help ), &QAbstractButton::clicked,
this, &QgsTextFormatDialog::showHelp );
2086 return mFormatWidget->
format();
2089 void QgsTextFormatDialog::showHelp()
2091 QgsHelp::openHelp( QStringLiteral(
"style_library/label_settings.html#formatting-the-label-text" ) );
2107 mFormatWidget = qobject_cast< QgsTextFormatWidget * >(
widget() );
2110 if ( !mBlockSignals )
2117 return mFormatWidget->
format();
2122 mBlockSignals =
true;
2124 mBlockSignals =
false;