42 #include "qgsconfig.h"
45 #include <QButtonGroup>
46 #include <QMessageBox>
50 , mMapCanvas( mapCanvas )
54 setWidgetMode(
Text );
61 , mMapCanvas( mapCanvas )
68 setWidgetMode( mode );
71 void QgsTextFormatWidget::initWidget()
75 mGeometryGeneratorGroupBox->setCollapsed(
true );
77 connect( mShapeSVGPathLineEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged );
78 connect( mFontSizeSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontSizeSpinBox_valueChanged );
79 connect( mFontFamilyCmbBx, &QFontComboBox::currentFontChanged,
this, &QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged );
80 connect( mFontStyleComboBox, &QComboBox::currentTextChanged,
this, &QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged );
81 connect( mFontUnderlineBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontUnderlineBtn_toggled );
82 connect( mFontStrikethroughBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontStrikethroughBtn_toggled );
83 connect( mFontWordSpacingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged );
84 connect( mFontLetterSpacingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged );
86 connect( mFontMinPixelSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged );
87 connect( mFontMaxPixelSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged );
96 connect( mShapeTypeCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged );
97 connect( mShapeRotationCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged );
98 connect( mShapeSVGParamsBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGParamsBtn_clicked );
99 connect( mShapeSVGSelectorBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked );
100 connect( mPreviewTextEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mPreviewTextEdit_textChanged );
101 connect( mPreviewTextBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mPreviewTextBtn_clicked );
103 connect( mDirectSymbLeftToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked );
104 connect( mDirectSymbRightToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked );
105 connect( chkLineOrientationDependent, &QCheckBox::toggled,
this, &QgsTextFormatWidget::chkLineOrientationDependent_toggled );
106 connect( mToolButtonConfigureSubstitutes, &QToolButton::clicked,
this, &QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked );
107 connect( mKerningCheckBox, &QCheckBox::toggled,
this, &QgsTextFormatWidget::kerningToggled );
108 connect( mComboOverlapHandling, qOverload< int >( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::overlapModeChanged );
118 mPreviewTextBtn->setIconSize( QSize( iconSize16, iconSize16 ) );
119 mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
120 mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
121 mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );
122 mPointOffsetLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
123 mPointOffsetOver ->setIconSize( QSize( iconSize32, iconSize18 ) );
124 mPointOffsetRight->setIconSize( QSize( iconSize32, iconSize18 ) );
125 mPointOffsetBelowLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
126 mPointOffsetBelow->setIconSize( QSize( iconSize32, iconSize18 ) );
127 mPointOffsetBelowRight->setIconSize( QSize( iconSize32, iconSize18 ) );
128 mLabelMinScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomOut.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
129 mLabelMaxScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomIn.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
132 mFontUnderlineBtn->setMinimumSize( buttonSize, buttonSize );
133 mFontUnderlineBtn->setMaximumSize( buttonSize, buttonSize );
134 mFontStrikethroughBtn->setMinimumSize( buttonSize, buttonSize );
135 mFontStrikethroughBtn->setMaximumSize( buttonSize, buttonSize );
136 mFontBoldBtn->setMinimumSize( buttonSize, buttonSize );
137 mFontBoldBtn->setMaximumSize( buttonSize, buttonSize );
138 mFontItalicBtn->setMinimumSize( buttonSize, buttonSize );
139 mFontItalicBtn->setMaximumSize( buttonSize, buttonSize );
141 mPreviewScaleComboBox->setMapCanvas(
mMapCanvas );
142 mPreviewScaleComboBox->setShowCurrentScaleButton(
true );
145 const auto unitWidgets = findChildren<QgsUnitSelectionWidget *>();
146 for ( QgsUnitSelectionWidget *unitWidget : unitWidgets )
177 mFontLineHeightSpinBox->setClearValue( 1.0 );
178 mShapeRotationDblSpnBx->setClearValue( 0.0 );
179 mShapeOffsetXSpnBx->setClearValue( 0.0 );
180 mShapeOffsetYSpnBx->setClearValue( 0.0 );
181 mPointOffsetXSpinBox->setClearValue( 0.0 );
182 mPointOffsetYSpinBox->setClearValue( 0.0 );
183 mPointAngleSpinBox->setClearValue( 0.0 );
184 mFontLetterSpacingSpinBox->setClearValue( 0.0 );
185 mFontWordSpacingSpinBox->setClearValue( 0.0 );
186 mZIndexSpinBox->setClearValue( 0.0 );
187 mLineDistanceSpnBx->setClearValue( 0.0 );
188 mSpinStretch->setClearValue( 100 );
204 updateAvailableShadowPositions();
207 mBackgroundMarkerSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
208 mBackgroundMarkerSymbolButton->registerExpressionContextGenerator(
this );
209 mBackgroundMarkerSymbolButton->setMapCanvas(
mMapCanvas );
211 mBackgroundFillSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
212 mBackgroundFillSymbolButton->registerExpressionContextGenerator(
this );
213 mBackgroundFillSymbolButton->setMapCanvas(
mMapCanvas );
217 mRefFont = lblFontPreview->font();
220 connect( mShadowOffsetAngleDial, &QAbstractSlider::valueChanged, mShadowOffsetAngleSpnBx, &QSpinBox::setValue );
221 connect( mShadowOffsetAngleSpnBx,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mShadowOffsetAngleDial, &QAbstractSlider::setValue );
222 connect( mLimitLabelChkBox, &QAbstractButton::toggled, mLimitLabelSpinBox, &QWidget::setEnabled );
223 connect( mCheckBoxSubstituteText, &QAbstractButton::toggled, mToolButtonConfigureSubstitutes, &QWidget::setEnabled );
233 populateFontCapitalsComboBox();
236 mPreviewBackgroundBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
237 mPreviewBackgroundBtn->setContext( QStringLiteral(
"labeling" ) );
238 mPreviewBackgroundBtn->setColor( QColor( 255, 255, 255 ) );
239 btnTextColor->setColorDialogTitle( tr(
"Select Text Color" ) );
240 btnTextColor->setContext( QStringLiteral(
"labeling" ) );
241 btnTextColor->setDefaultColor( Qt::black );
242 btnBufferColor->setColorDialogTitle( tr(
"Select Buffer Color" ) );
243 btnBufferColor->setContext( QStringLiteral(
"labeling" ) );
244 btnBufferColor->setDefaultColor( Qt::white );
245 mShapeStrokeColorBtn->setColorDialogTitle( tr(
"Select Stroke Color" ) );
246 mShapeStrokeColorBtn->setContext( QStringLiteral(
"labeling" ) );
247 mShapeFillColorBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
248 mShapeFillColorBtn->setContext( QStringLiteral(
"labeling" ) );
249 mShadowColorBtn->setColorDialogTitle( tr(
"Select Shadow Color" ) );
250 mShadowColorBtn->setContext( QStringLiteral(
"labeling" ) );
251 mShadowColorBtn->setDefaultColor( Qt::black );
253 mFontColorDDBtn->registerLinkedWidget( btnTextColor );
254 mBufferColorDDBtn->registerLinkedWidget( btnBufferColor );
255 mShapeStrokeColorDDBtn->registerLinkedWidget( mShapeStrokeColorBtn );
256 mShapeFillColorDDBtn->registerLinkedWidget( mShapeFillColorBtn );
257 mShadowColorDDBtn->registerLinkedWidget( mShadowColorBtn );
261 mQuadrantBtnGrp->addButton( mPointOffsetAboveLeft,
static_cast<int>( Qgis::LabelQuadrantPosition::AboveLeft ) );
262 mQuadrantBtnGrp->addButton( mPointOffsetAbove,
static_cast<int>( Qgis::LabelQuadrantPosition::Above ) );
263 mQuadrantBtnGrp->addButton( mPointOffsetAboveRight,
static_cast<int>( Qgis::LabelQuadrantPosition::AboveRight ) );
264 mQuadrantBtnGrp->addButton( mPointOffsetLeft,
static_cast<int>( Qgis::LabelQuadrantPosition::Left ) );
265 mQuadrantBtnGrp->addButton( mPointOffsetOver,
static_cast<int>( Qgis::LabelQuadrantPosition::Over ) );
266 mQuadrantBtnGrp->addButton( mPointOffsetRight,
static_cast<int>( Qgis::LabelQuadrantPosition::Right ) );
267 mQuadrantBtnGrp->addButton( mPointOffsetBelowLeft,
static_cast<int>( Qgis::LabelQuadrantPosition::BelowLeft ) );
268 mQuadrantBtnGrp->addButton( mPointOffsetBelow,
static_cast<int>( Qgis::LabelQuadrantPosition::Below ) );
269 mQuadrantBtnGrp->addButton( mPointOffsetBelowRight,
static_cast<int>( Qgis::LabelQuadrantPosition::BelowRight ) );
281 mUpsidedownBtnGrp->addButton( mUpsidedownRadioOff,
static_cast<int>( Qgis::UpsideDownLabelHandling::FlipUpsideDownLabels ) );
282 mUpsidedownBtnGrp->addButton( mUpsidedownRadioDefined,
static_cast<int>( Qgis::UpsideDownLabelHandling::AllowUpsideDownWhenRotationIsDefined ) );
283 mUpsidedownBtnGrp->addButton( mUpsidedownRadioAll,
static_cast<int>( Qgis::UpsideDownLabelHandling::AlwaysAllowUpsideDown ) );
298 const auto groupBoxes = findChildren<QgsCollapsibleGroupBox *>();
301 grpbox->setSettingGroup( QStringLiteral(
"mAdvLabelingDlg" ) );
307 mLabelingOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect,
false );
312 QSizePolicy policy( mLabelingOptionsListFrame->sizePolicy() );
313 policy.setHorizontalStretch( 0 );
314 mLabelingOptionsListFrame->setSizePolicy( policy );
315 if ( !settings.
contains( QStringLiteral(
"/Windows/Labeling/OptionsSplitState" ) ) )
318 QList<int> splitsizes;
320 mLabelingOptionsSplitter->setSizes( splitsizes );
324 connect( mLabelStackedWidget, &QStackedWidget::currentChanged,
this, &QgsTextFormatWidget::optionsStackedWidget_CurrentChanged );
327 mFontPreviewSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ) ).toByteArray() );
328 mLabelingOptionsSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ) ).toByteArray() );
330 mLabelingOptionsListWidget->setCurrentRow( settings.
value( QStringLiteral(
"Windows/Labeling/Tab" ), 0 ).toInt() );
334 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
338 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
342 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
344 overlapModeChanged();
346 #ifndef HAS_KDE_QT5_FONT_STRETCH_FIX
347 mLabelStretch->hide();
348 mSpinStretch->hide();
349 mFontStretchDDBtn->hide();
354 QList<QWidget *> widgets;
355 widgets << btnBufferColor
357 << chkLabelPerFeaturePart
361 << chkLineOrientationDependent
363 << chkPreserveRotation
365 << comboBufferBlendMode
367 << mBufferJoinStyleComboBox
368 << mBufferTranspFillChbx
369 << mBufferOpacityWidget
370 << mCentroidInsideCheckBox
372 << mCoordRotationUnitComboBox
374 << mDirectSymbLeftLineEdit
375 << mDirectSymbRevChkBx
376 << mDirectSymbRightLineEdit
377 << mFitInsidePolygonCheckBox
378 << mFontCapitalsComboBox
379 << mFontLetterSpacingSpinBox
380 << mFontLimitPixelChkBox
381 << mFontLineHeightSpinBox
382 << mFontMaxPixelSpinBox
383 << mFontMinPixelSpinBox
384 << mFontMultiLineAlignComboBox
386 << mFontStyleComboBox
387 << mTextOrientationComboBox
388 << mTextOpacityWidget
390 << mFontWordSpacingSpinBox
392 << mFormatNumDecimalsSpnBx
393 << mFormatNumPlusSignChkBx
395 << mLimitLabelSpinBox
396 << mLineDistanceSpnBx
397 << mLineDistanceUnitWidget
398 << mMaxCharAngleInDSpinBox
399 << mMaxCharAngleOutDSpinBox
401 << mOffsetTypeComboBox
402 << mCheckAllowDegradedPlacement
403 << mComboOverlapHandling
404 << mPointAngleSpinBox
405 << mPointOffsetUnitWidget
406 << mPointOffsetXSpinBox
407 << mPointOffsetYSpinBox
408 << mPreviewBackgroundBtn
411 << mRepeatDistanceSpinBox
412 << mRepeatDistanceUnitWidget
413 << mOverrunDistanceSpinBox
414 << mOverrunDistanceUnitWidget
415 << mScaleBasedVisibilityChkBx
421 << mShadowOffsetAngleSpnBx
422 << mShadowOffsetGlobalChkBx
423 << mShadowOffsetSpnBx
424 << mShadowOffsetUnitWidget
425 << mShadowRadiusAlphaChkBx
426 << mShadowRadiusDblSpnBx
427 << mShadowRadiusUnitWidget
429 << mShadowOpacityWidget
432 << mShapeStrokeColorBtn
433 << mShapeStrokeWidthSpnBx
434 << mShapeStrokeWidthUnitWidget
436 << mShapeFillColorBtn
437 << mShapeOffsetXSpnBx
438 << mShapeOffsetYSpnBx
439 << mShapeOffsetUnitWidget
440 << mShapeRadiusXDbSpnBx
441 << mShapeRadiusYDbSpnBx
442 << mShapeRotationCmbBx
443 << mShapeRotationDblSpnBx
444 << mShapeRadiusUnitWidget
445 << mShapeSVGPathLineEdit
447 << mShapeSizeUnitWidget
450 << mBackgroundOpacityWidget
455 << mAutoWrapLengthSpinBox
456 << mAutoWrapTypeComboBox
457 << mCentroidRadioVisible
458 << mCentroidRadioWhole
459 << mDirectSymbRadioBtnAbove
460 << mDirectSymbRadioBtnBelow
461 << mDirectSymbRadioBtnLR
462 << mUpsidedownRadioAll
463 << mUpsidedownRadioDefined
464 << mUpsidedownRadioOff
465 << mPlacementModeComboBox
466 << mFieldExpressionWidget
467 << mCheckBoxSubstituteText
468 << mGeometryGeneratorGroupBox
469 << mGeometryGenerator
470 << mGeometryGeneratorType
471 << mBackgroundMarkerSymbolButton
472 << mBackgroundFillSymbolButton
473 << mCalloutsDrawCheckBox
474 << mCalloutStyleComboBox
477 << mMaskJoinStyleComboBox
478 << mMaskBufferSizeSpinBox
479 << mMaskOpacityWidget
480 << mCheckAllowLabelsOutsidePolygons
481 << mHtmlFormattingCheckBox;
488 connect( mBufferDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
490 updateBufferFrameStatus();
493 connect( mShapeDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
495 updateShapeFrameStatus();
498 connect( mShadowDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
500 updateShadowFrameStatus();
503 connect( mCalloutsDrawCheckBox, &QCheckBox::stateChanged,
this, [ = ](
int )
505 updateCalloutFrameStatus();
513 whileBlocking( mOptionsTab )->setCurrentIndex( mLabelStackedWidget->currentIndex() );
514 mOptionsTab->tabBar()->setUsesScrollButtons(
true );
535 toggleDDButtons(
true );
542 const int prevIndex = mOptionsTab->currentIndex();
543 toggleDDButtons(
true );
544 delete mLabelingOptionsListWidget->takeItem( 8 );
545 delete mLabelingOptionsListWidget->takeItem( 7 );
546 delete mLabelingOptionsListWidget->takeItem( 6 );
547 delete mLabelingOptionsListWidget->takeItem( 3 );
548 mOptionsTab->removeTab( 8 );
549 mOptionsTab->removeTab( 7 );
550 mOptionsTab->removeTab( 6 );
551 mOptionsTab->removeTab( 3 );
552 mLabelStackedWidget->removeWidget( mLabelPage_Rendering );
553 mLabelStackedWidget->removeWidget( mLabelPage_Callouts );
554 mLabelStackedWidget->removeWidget( mLabelPage_Mask );
555 mLabelStackedWidget->removeWidget( mLabelPage_Placement );
565 mLabelStackedWidget->setCurrentIndex( prevIndex - 1 );
566 mOptionsTab->setCurrentIndex( prevIndex - 1 );
573 mLabelStackedWidget->setCurrentIndex( 0 );
574 mOptionsTab->setCurrentIndex( 0 );
578 frameLabelWith->hide();
579 mDirectSymbolsFrame->hide();
580 mFormatNumFrame->hide();
581 mFormatNumChkBx->hide();
582 mFormatNumDDBtn->hide();
583 mCheckBoxSubstituteText->hide();
584 mToolButtonConfigureSubstitutes->hide();
585 mLabelWrapOnCharacter->hide();
586 wrapCharacterEdit->hide();
587 mWrapCharDDBtn->hide();
588 mLabelWrapLinesTo->hide();
589 mAutoWrapLengthSpinBox->hide();
590 mAutoWrapLengthDDBtn->hide();
591 mAutoWrapTypeComboBox->hide();
592 mFontMultiLineLabel->hide();
593 mFontMultiLineAlignComboBox->hide();
594 mFontMultiLineAlignDDBtn->hide();
602 void QgsTextFormatWidget::toggleDDButtons(
bool visible )
604 const auto buttons = findChildren< QgsPropertyOverrideButton * >();
607 #ifndef HAS_KDE_QT5_FONT_STRETCH_FIX
608 if ( button == mFontStretchDDBtn )
611 button->setVisible( visible );
617 mOptionsTab->setVisible( enabled );
618 mOptionsTab->setTabToolTip( 0, tr(
"Text" ) );
619 mOptionsTab->setTabToolTip( 1, tr(
"Formatting" ) );
620 mOptionsTab->setTabToolTip( 2, tr(
"Buffer" ) );
621 mOptionsTab->setTabToolTip( 3, tr(
"Mask" ) );
622 mOptionsTab->setTabToolTip( 4, tr(
"Background" ) );
623 mOptionsTab->setTabToolTip( 5, tr(
"Shadow" ) );
624 mOptionsTab->setTabToolTip( 6, tr(
"Callouts" ) );
625 mOptionsTab->setTabToolTip( 7, tr(
"Placement" ) );
626 mOptionsTab->setTabToolTip( 8, tr(
"Rendering" ) );
628 mLabelingOptionsListFrame->setVisible( !enabled );
629 groupBox_mPreview->setVisible( !enabled );
633 void QgsTextFormatWidget::connectValueChanged(
const QList<QWidget *> &widgets,
const char *slot )
635 const auto constWidgets = widgets;
636 for ( QWidget *widget : constWidgets )
640 connect( w, SIGNAL( changed() ),
this, slot );
644 connect( w, SIGNAL( fieldChanged( QString ) ),
this, slot );
646 else if (
QgsOpacityWidget *w = qobject_cast< QgsOpacityWidget *>( widget ) )
648 connect( w, SIGNAL( opacityChanged(
double ) ),
this, slot );
650 else if (
QgsScaleWidget *w = qobject_cast< QgsScaleWidget *>( widget ) )
652 connect( w, SIGNAL( scaleChanged(
double ) ),
this, slot );
654 else if ( QgsUnitSelectionWidget *w = qobject_cast<QgsUnitSelectionWidget *>( widget ) )
656 connect( w, SIGNAL( changed() ),
this, slot );
658 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
660 connect( w, SIGNAL( currentIndexChanged(
int ) ),
this, slot );
662 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
664 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
666 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
668 connect( w, SIGNAL( valueChanged(
double ) ),
this, slot );
670 else if (
QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
672 connect( w, SIGNAL( colorChanged( QColor ) ),
this, slot );
674 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
676 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
678 else if ( QRadioButton *w = qobject_cast<QRadioButton *>( widget ) )
680 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
682 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
684 connect( w, SIGNAL( textEdited( QString ) ),
this, slot );
686 else if ( QSlider *w = qobject_cast<QSlider *>( widget ) )
688 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
690 else if ( QGroupBox *w = qobject_cast<QGroupBox *>( widget ) )
692 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
696 connect( w, SIGNAL( textChanged() ),
this, slot );
700 QgsLogger::warning( QStringLiteral(
"Could not create connection for widget %1" ).arg( widget->objectName() ) );
732 mDirectSymbDDBtn->registerCheckedWidget( mDirectSymbChkBx );
740 mFormatNumDDBtn->registerCheckedWidget( mFormatNumChkBx );
755 mEnableMaskDDBtn->registerCheckedWidget( mEnableMaskChkBx );
763 mShapeDrawDDBtn->registerCheckedWidget( mShapeDrawChkBx );
785 mShadowDrawDDBtn->registerCheckedWidget( mShadowDrawChkBx );
827 updateDataDefinedAlignment();
830 const QString ddScaleVisInfo = tr(
"Value < 0 represents a scale closer than 1:1, e.g. -10 = 10:1<br>"
831 "Value of 0 disables the specific limit." );
833 mScaleBasedVisibilityDDBtn->registerCheckedWidget( mScaleBasedVisibilityChkBx );
835 mScaleBasedVisibilityMinDDBtn->setUsageInfo( ddScaleVisInfo );
837 mScaleBasedVisibilityMaxDDBtn->setUsageInfo( ddScaleVisInfo );
840 mFontLimitPixelDDBtn->registerCheckedWidget( mFontLimitPixelChkBox );
859 if ( !mButtons.contains( key ) )
864 mButtons[key] = button;
881 mBufferDrawChkBx->setChecked( buffer.
enabled() );
882 mBufferFrame->setEnabled( buffer.
enabled() );
883 spinBufferSize->setValue( buffer.
size() );
884 mBufferUnitWidget->setUnit( buffer.
sizeUnit() );
886 btnBufferColor->setColor( buffer.
color() );
887 mBufferOpacityWidget->setOpacity( buffer.
opacity() );
888 mBufferJoinStyleComboBox->setPenJoinStyle( buffer.
joinStyle() );
890 comboBufferBlendMode->setBlendMode( buffer.
blendMode() );
892 mBufferEffect.reset( lPaintEffect->clone() );
896 mBufferEffect->setEnabled(
false );
898 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
902 mEnableMaskChkBx->setChecked( mask.
enabled() );
903 mMaskBufferSizeSpinBox->setValue( mask.
size() );
904 mMaskBufferUnitWidget->setUnit( mask.
sizeUnit() );
906 mMaskOpacityWidget->setOpacity( mask.
opacity() );
907 mMaskJoinStyleComboBox->setPenJoinStyle( mask.
joinStyle() );
909 mMaskEffect.reset( lPaintEffect->clone() );
913 mMaskEffect->setEnabled(
false );
915 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
925 mTextOrientationComboBox->setCurrentIndex( mTextOrientationComboBox->findData(
format.
orientation() ) );
928 mFontWordSpacingSpinBox->setValue(
format.
font().wordSpacing() );
929 mFontLetterSpacingSpinBox->setValue(
format.
font().letterSpacing() );
934 updateFont( mRefFont );
940 const QString missingTxt = tr(
"%1 not found. Default substituted." );
941 QString txtPrepend = tr(
"Chosen font" );
946 mFontMissingLabel->setText( missingTxt.arg( txtPrepend ) );
949 mLabelingOptionsListWidget->setCurrentRow( 0 );
955 mShapeDrawChkBx->setChecked( background.
enabled() );
956 mShapeFrame->setEnabled( background.
enabled() );
957 mShapeTypeCmbBx->blockSignals(
true );
958 mShapeTypeCmbBx->setCurrentIndex( mShapeTypeCmbBx->findData( background.
type() ) );
959 mShapeTypeCmbBx->blockSignals(
false );
960 updateAvailableShadowPositions();
961 mShapeSVGPathLineEdit->setText( background.
svgFile() );
963 mShapeSizeCmbBx->setCurrentIndex( background.
sizeType() );
964 mShapeSizeXSpnBx->setValue( background.
size().width() );
965 mShapeSizeYSpnBx->setValue( background.
size().height() );
966 mShapeSizeUnitWidget->setUnit( background.
sizeUnit() );
968 mShapeRotationCmbBx->setCurrentIndex( background.
rotationType() );
971 mShapeRotationDblSpnBx->setValue( background.
rotation() );
972 mShapeOffsetXSpnBx->setValue( background.
offset().x() );
973 mShapeOffsetYSpnBx->setValue( background.
offset().y() );
974 mShapeOffsetUnitWidget->setUnit( background.
offsetUnit() );
976 mShapeRadiusXDbSpnBx->setValue( background.
radii().width() );
977 mShapeRadiusYDbSpnBx->setValue( background.
radii().height() );
978 mShapeRadiusUnitWidget->setUnit( background.
radiiUnit() );
981 mShapeFillColorBtn->setColor( background.
fillColor() );
982 mShapeStrokeColorBtn->setColor( background.
strokeColor() );
983 mShapeStrokeWidthSpnBx->setValue( background.
strokeWidth() );
987 mBackgroundOpacityWidget->setOpacity( background.
opacity() );
988 mShapeBlendCmbBx->setBlendMode( background.
blendMode() );
990 mLoadSvgParams =
false;
991 mShapeTypeCmbBx_currentIndexChanged( background.
type() );
993 if (
auto *lPaintEffect = background.
paintEffect() )
994 mBackgroundEffect.reset( lPaintEffect->clone() );
998 mBackgroundEffect->setEnabled(
false );
1000 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
1006 mShadowDrawChkBx->setChecked( shadow.
enabled() );
1007 mShadowFrame->setEnabled( shadow.
enabled() );
1008 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( shadow.
shadowPlacement() ) );
1009 mShadowOffsetAngleSpnBx->setValue( shadow.
offsetAngle() );
1011 mShadowOffsetUnitWidget->setUnit( shadow.
offsetUnit() );
1013 mShadowOffsetGlobalChkBx->setChecked( shadow.
offsetGlobal() );
1015 mShadowRadiusDblSpnBx->setValue( shadow.
blurRadius() );
1018 mShadowRadiusAlphaChkBx->setChecked( shadow.
blurAlphaOnly() );
1019 mShadowOpacityWidget->setOpacity( shadow.
opacity() );
1020 mShadowScaleSpnBx->setValue( shadow.
scale() );
1022 mShadowColorBtn->setColor( shadow.
color() );
1023 mShadowBlendCmbBx->setBlendMode( shadow.
blendMode() );
1035 settings.
setValue( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ), mFontPreviewSplitter->saveState() );
1036 settings.
setValue( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ), mLabelingOptionsSplitter->saveState() );
1038 int prevIndex = mLabelingOptionsListWidget->currentRow();
1039 if ( mWidgetMode ==
Text )
1041 switch ( prevIndex )
1050 settings.
setValue( QStringLiteral(
"Windows/Labeling/Tab" ), prevIndex );
1073 buffer.
setEnabled( mBufferDrawChkBx->isChecked() );
1074 buffer.
setSize( spinBufferSize->value() );
1075 buffer.
setColor( btnBufferColor->color() );
1076 buffer.
setOpacity( mBufferOpacityWidget->opacity() );
1079 buffer.
setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
1081 buffer.
setBlendMode( comboBufferBlendMode->blendMode() );
1090 mask.
setEnabled( mEnableMaskChkBx->isChecked() );
1091 mask.
setSize( mMaskBufferSizeSpinBox->value() );
1092 mask.
setOpacity( mMaskOpacityWidget->opacity() );
1093 mask.
setSizeUnit( mMaskBufferUnitWidget->unit() );
1095 mask.
setJoinStyle( mMaskJoinStyleComboBox->penJoinStyle() );
1105 background.
setEnabled( mShapeDrawChkBx->isChecked() );
1107 background.
setSvgFile( mShapeSVGPathLineEdit->text() );
1109 background.
setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
1110 background.
setSizeUnit( mShapeSizeUnitWidget->unit() );
1113 background.
setRotation( mShapeRotationDblSpnBx->value() );
1114 background.
setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
1117 background.
setRadii( QSizeF( mShapeRadiusXDbSpnBx->value(), mShapeRadiusYDbSpnBx->value() ) );
1118 background.
setRadiiUnit( mShapeRadiusUnitWidget->unit() );
1121 background.
setFillColor( mShapeFillColorBtn->color() );
1126 background.
setOpacity( mBackgroundOpacityWidget->opacity() );
1127 background.
setBlendMode( mShapeBlendCmbBx->blendMode() );
1138 shadow.
setEnabled( mShadowDrawChkBx->isChecked() );
1149 shadow.
setOpacity( mShadowOpacityWidget->opacity() );
1150 shadow.
setScale( mShadowScaleSpnBx->value() );
1151 shadow.
setColor( mShadowColorBtn->color() );
1155 if ( includeDataDefinedProperties )
1186 if ( mButtons.contains( key ) )
1195 void QgsTextFormatWidget::optionsStackedWidget_CurrentChanged(
int indx )
1197 mLabelingOptionsListWidget->blockSignals(
true );
1198 mLabelingOptionsListWidget->setCurrentRow( indx );
1199 mLabelingOptionsListWidget->blockSignals(
false );
1208 mPreviewExpressionContext = *lExpressionContext;
1213 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
1221 void QgsTextFormatWidget::collapseSample(
bool collapse )
1225 QList<int> splitSizes = mFontPreviewSplitter->sizes();
1226 if ( splitSizes[0] > groupBox_mPreview->height() )
1228 const int delta = splitSizes[0] - groupBox_mPreview->height();
1229 splitSizes[0] -= delta;
1230 splitSizes[1] += delta;
1231 mFontPreviewSplitter->setSizes( splitSizes );
1236 void QgsTextFormatWidget::changeTextColor(
const QColor &color )
1242 void QgsTextFormatWidget::updateFont(
const QFont &font )
1245 if ( font != mRefFont )
1254 mDirectSymbLeftLineEdit->setFont( mRefFont );
1255 mDirectSymbRightLineEdit->setFont( mRefFont );
1257 blockFontChangeSignals(
true );
1258 mFontFamilyCmbBx->setCurrentFont( mRefFont );
1259 populateFontStyleComboBox();
1260 mFontUnderlineBtn->setChecked( mRefFont.underline() );
1261 mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
1262 mKerningCheckBox->setChecked( mRefFont.kerning() );
1263 blockFontChangeSignals(
false );
1271 void QgsTextFormatWidget::blockFontChangeSignals(
bool blk )
1273 mFontFamilyCmbBx->blockSignals( blk );
1274 mFontStyleComboBox->blockSignals( blk );
1275 mFontCapitalsComboBox->blockSignals( blk );
1276 mFontUnderlineBtn->blockSignals( blk );
1277 mFontStrikethroughBtn->blockSignals( blk );
1278 mFontWordSpacingSpinBox->blockSignals( blk );
1279 mFontLetterSpacingSpinBox->blockSignals( blk );
1280 mKerningCheckBox->blockSignals( blk );
1295 lblFontPreview->setFormat(
format() );
1298 void QgsTextFormatWidget::scrollPreview()
1300 scrollArea_mPreview->ensureVisible( 0, 0, 0, 0 );
1305 mPreviewBackgroundColor = color;
1307 scrollArea_mPreview->widget()->setStyleSheet( QStringLiteral(
"background: rgb(%1, %2, %3);" ).arg( QString::number( color.red() ),
1308 QString::number( color.green() ),
1309 QString::number( color.blue() ) ) );
1312 void QgsTextFormatWidget::changeBufferColor(
const QColor &color )
1321 bool showLineFrame =
false;
1322 bool showCentroidFrame =
false;
1323 bool showQuadrantFrame =
false;
1324 bool showFixedQuadrantFrame =
false;
1325 bool showPlacementPriorityFrame =
false;
1326 bool showOffsetTypeFrame =
false;
1327 bool showOffsetFrame =
false;
1328 bool showDistanceFrame =
false;
1329 bool showRotationFrame =
false;
1330 bool showMaxCharAngleFrame =
false;
1335 bool enableMultiLinesFrame =
true;
1341 showDistanceFrame =
true;
1349 showQuadrantFrame =
true;
1350 showFixedQuadrantFrame =
true;
1351 showOffsetFrame =
true;
1352 showRotationFrame =
true;
1356 showDistanceFrame =
true;
1357 showPlacementPriorityFrame =
true;
1358 showOffsetTypeFrame =
true;
1365 showLineFrame =
true;
1366 showDistanceFrame =
true;
1369 const bool offline = chkLineAbove->isChecked() || chkLineBelow->isChecked();
1370 chkLineOrientationDependent->setEnabled( offline );
1371 mPlacementDistanceFrame->setEnabled( offline );
1375 showMaxCharAngleFrame = isCurved;
1377 enableMultiLinesFrame = !isCurved;
1382 showDistanceFrame =
true;
1385 mPlacementLineFrame->setVisible( showLineFrame );
1386 mPlacementPolygonFrame->setVisible( showPolygonPlacementOptions );
1387 mPlacementCentroidFrame->setVisible( showCentroidFrame );
1388 mPlacementQuadrantFrame->setVisible( showQuadrantFrame );
1389 mPlacementFixedQuadrantFrame->setVisible( showFixedQuadrantFrame );
1390 mPlacementCartographicFrame->setVisible( showPlacementPriorityFrame );
1391 mPlacementOffsetFrame->setVisible( showOffsetFrame );
1392 mPlacementDistanceFrame->setVisible( showDistanceFrame );
1393 mPlacementOffsetTypeFrame->setVisible( showOffsetTypeFrame );
1394 mPlacementRotationFrame->setVisible( showRotationFrame );
1399 mPlacementMaxCharAngleFrame->setVisible( showMaxCharAngleFrame );
1401 mMultiLinesFrame->setEnabled( enableMultiLinesFrame );
1405 switch ( currentPlacement )
1409 helperText = tr(
"Arranges label candidates in a clockwise circle around the feature, preferring placements to the top-right of the feature." );
1411 helperText = tr(
"Arranges label candidates in a cluster around the feature's centroid, preferring placements directly over the centroid." );
1415 helperText = tr(
"Arranges label candidates directly over the feature or at a preset offset from the feature." );
1417 helperText = tr(
"Arranges label candidates directly over the feature's centroid, or at a preset offset from the centroid." );
1421 helperText = tr(
"Arranges label candidates parallel to a generalised line representing the feature. Placements which fall over straighter portions of the line are preferred." );
1423 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." );
1427 helperText = tr(
"Arranges candidates following the curvature of a line feature. Placements which fall over straighter portions of the line are preferred." );
1431 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." );
1433 helperText = tr(
"Label candidates are arranged horizontally along the length of the feature." );
1437 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." );
1441 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." );
1445 helperText = tr(
"Arranges candidates following the curvature of the feature's perimeter. Placements which fall over straighter portions of the perimeter are preferred." );
1449 helperText = tr(
"Label candidates are placed outside of the features, preferring placements which give greatest visual association between the label and the feature." );
1452 mPlacementModeDescriptionLabel->setText( QStringLiteral(
"<i>%1</i>" ).arg( helperText ) );
1455 void QgsTextFormatWidget::populateFontCapitalsComboBox()
1460 #if defined(HAS_KDE_QT5_SMALL_CAPS_FIX) || QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
1470 void QgsTextFormatWidget::populateFontStyleComboBox()
1472 mFontStyleComboBox->clear();
1473 const QStringList styles = mFontDB.styles( mRefFont.family() );
1474 const auto constStyles = styles;
1475 for (
const QString &style : constStyles )
1477 mFontStyleComboBox->addItem( style );
1480 QString targetStyle = mFontDB.styleString( mRefFont );
1481 if ( !styles.contains( targetStyle ) )
1483 const QFont f = QFont( mRefFont.family() );
1484 targetStyle = QFontInfo( f ).styleName();
1485 mRefFont.setStyleName( targetStyle );
1488 const int stylIndx = mFontStyleComboBox->findText( targetStyle );
1489 if ( stylIndx > -1 )
1494 mFontStyleComboBox->setCurrentIndex( curIndx );
1497 void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged(
double d )
1499 mRefFont.setPointSizeF( d );
1500 updateFont( mRefFont );
1503 void QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged(
const QFont &f )
1505 mRefFont.setFamily( f.family() );
1506 updateFont( mRefFont );
1509 void QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged(
const QString &text )
1512 updateFont( mRefFont );
1515 void QgsTextFormatWidget::mFontUnderlineBtn_toggled(
bool ckd )
1517 mRefFont.setUnderline( ckd );
1518 updateFont( mRefFont );
1521 void QgsTextFormatWidget::mFontStrikethroughBtn_toggled(
bool ckd )
1523 mRefFont.setStrikeOut( ckd );
1524 updateFont( mRefFont );
1527 void QgsTextFormatWidget::kerningToggled(
bool checked )
1529 mRefFont.setKerning( checked );
1530 updateFont( mRefFont );
1533 void QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged(
double spacing )
1535 mRefFont.setWordSpacing( spacing );
1536 updateFont( mRefFont );
1539 void QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged(
double spacing )
1541 mRefFont.setLetterSpacing( QFont::AbsoluteSpacing, spacing );
1542 updateFont( mRefFont );
1545 void QgsTextFormatWidget::mFontSizeUnitWidget_changed()
1550 mFontLimitPixelChkBox->setChecked(
false );
1556 mFontLimitPixelChkBox->setChecked(
true );
1558 updateFont( mRefFont );
1561 void QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged(
int px )
1564 mFontMaxPixelSpinBox->setMinimum( px );
1565 mFontMaxPixelSpinBox->update();
1568 void QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged(
int px )
1571 if ( px < mFontMinPixelSpinBox->value() )
1573 mFontMaxPixelSpinBox->blockSignals(
true );
1574 mFontMaxPixelSpinBox->setValue( mFontMinPixelSpinBox->value() );
1575 mFontMaxPixelSpinBox->blockSignals(
false );
1577 mFontMaxPixelSpinBox->setMinimum( mFontMinPixelSpinBox->value() );
1580 void QgsTextFormatWidget::mBufferUnitWidget_changed()
1582 updateFont( mRefFont );
1585 void QgsTextFormatWidget::mMaskBufferUnitWidget_changed()
1587 updateFont( mRefFont );
1590 void QgsTextFormatWidget::mCoordXDDBtn_changed()
1592 updateDataDefinedAlignment();
1595 void QgsTextFormatWidget::mCoordXDDBtn_activated(
bool isActive )
1600 mCoordPointDDBtn->setActive(
false );
1603 void QgsTextFormatWidget::mCoordYDDBtn_changed()
1605 updateDataDefinedAlignment();
1608 void QgsTextFormatWidget::mCoordYDDBtn_activated(
bool isActive )
1613 mCoordPointDDBtn->setActive(
false );
1616 void QgsTextFormatWidget::mCoordPointDDBtn_changed()
1618 updateDataDefinedAlignment();
1621 void QgsTextFormatWidget::mCoordPointDDBtn_activated(
bool isActive )
1626 mCoordXDDBtn->setActive(
false );
1627 mCoordYDDBtn->setActive(
false );
1630 void QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged(
int )
1638 showBackgroundRadius( isRect );
1640 mShapeSVGPathFrame->setVisible( isSVG );
1641 mBackgroundMarkerSymbolButton->setVisible( isMarker );
1642 mBackgroundFillSymbolButton->setVisible( !isSVG && !isMarker );
1646 mShapeSizeYLabel->setVisible( !isSVG && !isMarker );
1647 mShapeSizeYSpnBx->setVisible( !isSVG && !isMarker );
1648 mShapeSizeYDDBtn->setVisible( !isSVG && !isMarker );
1649 mShapeSizeXLabel->setText( tr(
"Size%1" ).arg( !isSVG && !isMarker ? tr(
" X" ) : QString() ) );
1652 mShapeFillColorBtn->setAllowOpacity( !isSVG );
1653 mShapeFillColorBtn->setButtonBackground();
1654 mShapeStrokeColorBtn->setAllowOpacity( !isSVG );
1655 mShapeStrokeColorBtn->setButtonBackground();
1658 mShapeFillColorLabel->setVisible( isSVG );
1659 mShapeFillColorLabel->setEnabled( isSVG );
1660 mShapeFillColorBtn->setVisible( isSVG );
1661 mShapeFillColorBtn->setEnabled( isSVG );
1662 mShapeFillColorDDBtn->setVisible( isSVG );
1663 mShapeFillColorDDBtn->setEnabled( isSVG );
1664 mShapeStrokeColorLabel->setVisible( isSVG );
1665 mShapeStrokeColorLabel->setEnabled( isSVG );
1666 mShapeStrokeColorBtn->setVisible( isSVG );
1667 mShapeStrokeColorBtn->setEnabled( isSVG );
1668 mShapeStrokeColorDDBtn->setVisible( isSVG );
1669 mShapeStrokeColorDDBtn->setEnabled( isSVG );
1670 mShapeStrokeWidthLabel->setVisible( isSVG );
1671 mShapeStrokeWidthLabel->setEnabled( isSVG );
1672 mShapeStrokeWidthSpnBx->setVisible( isSVG );
1673 mShapeStrokeWidthSpnBx->setEnabled( isSVG );
1674 mShapeStrokeWidthDDBtn->setVisible( isSVG );
1675 mShapeStrokeWidthDDBtn->setEnabled( isSVG );
1678 mShapeSVGParamsBtn->setVisible( isSVG );
1681 updateSvgWidgets( mShapeSVGPathLineEdit->text() );
1685 mShapeSVGUnitsLabel->setVisible( isSVG );
1686 mShapeStrokeWidthUnitWidget->setVisible(
false );
1687 mShapeStrokeUnitsDDBtn->setVisible(
false );
1688 mShapeStrokeUnitsDDBtn->setEnabled(
false );
1690 updateAvailableShadowPositions();
1693 void QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged(
const QString &text )
1695 updateSvgWidgets( text );
1700 const int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) +
1701 ( chkLineBelow->isChecked() ? 1 : 0 ) +
1702 ( chkLineOn->isChecked() ? 1 : 0 );
1704 if ( numOptionsChecked == 1 )
1707 chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
1708 chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
1709 chkLineOn->setEnabled( !chkLineOn->isChecked() );
1713 chkLineAbove->setEnabled(
true );
1714 chkLineBelow->setEnabled(
true );
1715 chkLineOn->setEnabled(
true );
1725 void QgsTextFormatWidget::previewScaleChanged(
double scale )
1727 lblFontPreview->setScale( scale );
1730 void QgsTextFormatWidget::updateSvgWidgets(
const QString &svgPath )
1732 if ( mShapeSVGPathLineEdit->text() != svgPath )
1734 mShapeSVGPathLineEdit->setText( svgPath );
1737 QString resolvedPath;
1738 bool validSVG =
true;
1739 if ( ! svgPath.startsWith( QLatin1String(
"base64:" ), Qt::CaseInsensitive ) )
1742 validSVG = QFileInfo::exists( resolvedPath );
1746 resolvedPath = svgPath;
1751 mShapeSVGPathLineEdit->setStyleSheet( !validSVG ? QStringLiteral(
"QLineEdit{ color: rgb(225, 0, 0); }" ) : QString() );
1752 mShapeSVGPathLineEdit->setToolTip( !validSVG ? tr(
"File not found" ) : resolvedPath );
1754 QColor fill, stroke;
1755 double strokeWidth = 0.0;
1756 bool fillParam =
false, strokeParam =
false, strokeWidthParam =
false;
1762 mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || strokeParam || strokeWidthParam ) );
1764 mShapeFillColorLabel->setEnabled( validSVG && fillParam );
1765 mShapeFillColorBtn->setEnabled( validSVG && fillParam );
1766 mShapeFillColorDDBtn->setEnabled( validSVG && fillParam );
1767 if ( mLoadSvgParams && validSVG && fillParam )
1768 mShapeFillColorBtn->setColor( fill );
1770 mShapeStrokeColorLabel->setEnabled( validSVG && strokeParam );
1771 mShapeStrokeColorBtn->setEnabled( validSVG && strokeParam );
1772 mShapeStrokeColorDDBtn->setEnabled( validSVG && strokeParam );
1773 if ( mLoadSvgParams && validSVG && strokeParam )
1774 mShapeStrokeColorBtn->setColor( stroke );
1776 mShapeStrokeWidthLabel->setEnabled( validSVG && strokeWidthParam );
1777 mShapeStrokeWidthSpnBx->setEnabled( validSVG && strokeWidthParam );
1778 mShapeStrokeWidthDDBtn->setEnabled( validSVG && strokeWidthParam );
1779 if ( mLoadSvgParams && validSVG && strokeWidthParam )
1780 mShapeStrokeWidthSpnBx->setValue( strokeWidth );
1786 mShapeSVGUnitsLabel->setEnabled( validSVG && strokeWidthParam );
1789 void QgsTextFormatWidget::updateAvailableShadowPositions()
1791 if ( mShadowUnderCmbBx->count() == 0
1797 mShadowUnderCmbBx->clear();
1805 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( currentPlacement ) );
1806 if ( mShadowUnderCmbBx->currentIndex() == -1 )
1807 mShadowUnderCmbBx->setCurrentIndex( 0 );
1811 void QgsTextFormatWidget::updateProperty()
1819 void QgsTextFormatWidget::createAuxiliaryField()
1846 property.setActive(
true );
1855 void QgsTextFormatWidget::updateShapeFrameStatus()
1857 mShapeFrame->setEnabled( mShapeDrawDDBtn->isActive() || mShapeDrawChkBx->isChecked() );
1860 void QgsTextFormatWidget::updateBufferFrameStatus()
1862 mBufferFrame->setEnabled( mBufferDrawDDBtn->isActive() || mBufferDrawChkBx->isChecked() );
1865 void QgsTextFormatWidget::updateShadowFrameStatus()
1867 mShadowFrame->setEnabled( mShadowDrawDDBtn->isActive() || mShadowDrawChkBx->isChecked() );
1870 void QgsTextFormatWidget::updateCalloutFrameStatus()
1872 mCalloutFrame->setEnabled( mCalloutDrawDDBtn->isActive() || mCalloutsDrawCheckBox->isChecked() );
1875 void QgsTextFormatWidget::updateDataDefinedAlignment()
1878 mCoordAlignmentFrame->setEnabled( ( mCoordXDDBtn->isActive() && mCoordYDDBtn->isActive() )
1879 || mCoordPointDDBtn->isActive() );
1882 void QgsTextFormatWidget::overlapModeChanged()
1884 QString description;
1888 description = tr(
"Overlapping labels will never be placed for the layer, even if it means some labels will be missing. (To see unplaced labels use the \"Show Unplaced Labels\" toolbar action.)" );
1891 description = tr(
"If a label cannot otherwise be placed for a feature then an overlapping label is permitted." );
1894 description = tr(
"Labels from this layer may freely overlap other labels or label obstacles without penalty." );
1898 mOverlapModeDescriptionLabel->setText( QStringLiteral(
"<i>%1</i>" ).arg( description ) );
1903 if ( name.isEmpty() )
1907 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
1951 saveDlg.setDefaultTags( mTextFormatsListWidget->currentTagFilter() );
1952 if ( !saveDlg.exec() )
1955 if ( saveDlg.name().isEmpty() )
1958 QgsStyle *style = saveDlg.destinationStyle();
1965 const int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1966 tr(
"Format with name '%1' already exists. Overwrite?" )
1967 .arg( saveDlg.name() ),
1968 QMessageBox::Yes | QMessageBox::No );
1969 if ( res != QMessageBox::Yes )
1976 const QStringList symbolTags = saveDlg.tags().split(
',' );
1980 style->
saveTextFormat( saveDlg.name(), newFormat, saveDlg.isFavorite(), symbolTags );
1983 void QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked()
1986 svgDlg.setWindowTitle( tr(
"Select SVG file" ) );
1987 svgDlg.svgSelector()->setSvgPath( mShapeSVGPathLineEdit->text().trimmed() );
1989 if ( svgDlg.exec() == QDialog::Accepted )
1991 const QString svgPath = svgDlg.svgSelector()->currentSvgPath();
1992 if ( !svgPath.isEmpty() )
1994 mShapeSVGPathLineEdit->setText( svgPath );
2000 void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
2002 const QString svgPath = mShapeSVGPathLineEdit->text();
2003 mLoadSvgParams =
true;
2004 updateSvgWidgets( svgPath );
2005 mLoadSvgParams =
false;
2008 void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged(
int index )
2014 void QgsTextFormatWidget::mPreviewTextEdit_textChanged(
const QString &text )
2016 lblFontPreview->setText( text );
2020 void QgsTextFormatWidget::mPreviewTextBtn_clicked()
2022 mPreviewTextEdit->setText( QStringLiteral(
"Lorem Ipsum" ) );
2026 void QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged(
const QColor &color )
2031 void QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked()
2033 bool gotChar =
false;
2035 const QChar initial = !mDirectSymbLeftLineEdit->text().isEmpty() ? mDirectSymbLeftLineEdit->text().at( 0 ) : QChar();
2036 const QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
2041 if ( !dirSymb.isNull() )
2042 mDirectSymbLeftLineEdit->setText( QString( dirSymb ) );
2045 void QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked()
2047 bool gotChar =
false;
2048 const QChar initial = !mDirectSymbRightLineEdit->text().isEmpty() ? mDirectSymbRightLineEdit->text().at( 0 ) : QChar();
2049 const QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
2054 if ( !dirSymb.isNull() )
2055 mDirectSymbRightLineEdit->setText( QString( dirSymb ) );
2058 void QgsTextFormatWidget::chkLineOrientationDependent_toggled(
bool active )
2062 chkLineAbove->setText( tr(
"Left of line" ) );
2063 chkLineBelow->setText( tr(
"Right of line" ) );
2067 chkLineAbove->setText( tr(
"Above line" ) );
2068 chkLineBelow->setText( tr(
"Below line" ) );
2073 void QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked()
2088 if ( dlg.exec() == QDialog::Accepted )
2095 void QgsTextFormatWidget::showBackgroundRadius(
bool show )
2097 mShapeRadiusLabel->setVisible( show );
2098 mShapeRadiusXDbSpnBx->setVisible( show );
2100 mShapeRadiusYDbSpnBx->setVisible( show );
2102 mShapeRadiusUnitWidget->setVisible( show );
2104 mShapeRadiusDDBtn->setVisible( show );
2105 mShapeRadiusUnitsDDBtn->setVisible( show );
2111 return *lExpressionContext;
2132 if ( mGeometryGeneratorGroupBox->isChecked() )
2146 : QDialog( parent, fl )
2148 setWindowTitle( tr(
"Text Settings" ) );
2151 mFormatWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
2153 QVBoxLayout *layout =
new QVBoxLayout(
this );
2154 layout->addWidget( mFormatWidget );
2156 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, Qt::Horizontal,
this );
2157 layout->addWidget( mButtonBox );
2159 setLayout( layout );
2162 connect( mButtonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked,
this, &QDialog::accept );
2163 connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked,
this, &QDialog::reject );
2164 connect( mButtonBox->button( QDialogButtonBox::Help ), &QAbstractButton::clicked,
this, &QgsTextFormatDialog::showHelp );
2169 return mFormatWidget->
format();
2172 void QgsTextFormatDialog::showHelp()
2174 QgsHelp::openHelp( QStringLiteral(
"style_library/label_settings.html#formatting-the-label-text" ) );
2190 mFormatWidget = qobject_cast< QgsTextFormatWidget * >(
widget() );
2193 if ( !mBlockSignals )
2200 return mFormatWidget->
format();
2205 mBlockSignals =
true;
2207 mBlockSignals =
false;