39 #include <QButtonGroup>
40 #include <QMessageBox>
44 , mMapCanvas( mapCanvas )
48 setWidgetMode(
Text );
55 , mMapCanvas( mapCanvas )
62 setWidgetMode( mode );
65 void QgsTextFormatWidget::initWidget()
68 connect( mShapeSVGPathLineEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged );
69 connect( mFontSizeSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontSizeSpinBox_valueChanged );
70 connect( mFontCapitalsComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mFontCapitalsComboBox_currentIndexChanged );
71 connect( mFontFamilyCmbBx, &QFontComboBox::currentFontChanged,
this, &QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged );
72 connect( mFontStyleComboBox, &QComboBox::currentTextChanged,
this, &QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged );
73 connect( mFontUnderlineBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontUnderlineBtn_toggled );
74 connect( mFontStrikethroughBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontStrikethroughBtn_toggled );
75 connect( mFontWordSpacingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged );
76 connect( mFontLetterSpacingSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged );
78 connect( mFontMinPixelSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged );
79 connect( mFontMaxPixelSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged );
84 connect( mShapeTypeCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged );
85 connect( mShapeRotationCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged );
86 connect( mShapeSVGParamsBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGParamsBtn_clicked );
87 connect( mShapeSVGSelectorBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked );
88 connect( mPreviewTextEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mPreviewTextEdit_textChanged );
89 connect( mPreviewTextBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mPreviewTextBtn_clicked );
91 connect( mDirectSymbLeftToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked );
92 connect( mDirectSymbRightToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked );
93 connect( chkLineOrientationDependent, &QCheckBox::toggled,
this, &QgsTextFormatWidget::chkLineOrientationDependent_toggled );
94 connect( mToolButtonConfigureSubstitutes, &QToolButton::clicked,
this, &QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked );
95 connect( mKerningCheckBox, &QCheckBox::toggled,
this, &QgsTextFormatWidget::kerningToggled );
105 mPreviewTextBtn->setIconSize( QSize( iconSize16, iconSize16 ) );
106 mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
107 mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
108 mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );
109 mPointOffsetLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
110 mPointOffsetOver ->setIconSize( QSize( iconSize32, iconSize18 ) );
111 mPointOffsetRight->setIconSize( QSize( iconSize32, iconSize18 ) );
112 mPointOffsetBelowLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
113 mPointOffsetBelow->setIconSize( QSize( iconSize32, iconSize18 ) );
114 mPointOffsetBelowRight->setIconSize( QSize( iconSize32, iconSize18 ) );
115 mLabelMinScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomOut.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
116 mLabelMaxScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomIn.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
119 mFontUnderlineBtn->setMinimumSize( buttonSize, buttonSize );
120 mFontUnderlineBtn->setMaximumSize( buttonSize, buttonSize );
121 mFontStrikethroughBtn->setMinimumSize( buttonSize, buttonSize );
122 mFontStrikethroughBtn->setMaximumSize( buttonSize, buttonSize );
123 mFontBoldBtn->setMinimumSize( buttonSize, buttonSize );
124 mFontBoldBtn->setMaximumSize( buttonSize, buttonSize );
125 mFontItalicBtn->setMinimumSize( buttonSize, buttonSize );
126 mFontItalicBtn->setMaximumSize( buttonSize, buttonSize );
128 mPreviewScaleComboBox->setMapCanvas(
mMapCanvas );
129 mPreviewScaleComboBox->setShowCurrentScaleButton(
true );
132 const auto unitWidgets = findChildren<QgsUnitSelectionWidget *>();
133 for ( QgsUnitSelectionWidget *unitWidget : unitWidgets )
163 mFontLineHeightSpinBox->setClearValue( 1.0 );
164 mShapeRotationDblSpnBx->setClearValue( 0.0 );
165 mShapeOffsetXSpnBx->setClearValue( 0.0 );
166 mShapeOffsetYSpnBx->setClearValue( 0.0 );
167 mPointOffsetXSpinBox->setClearValue( 0.0 );
168 mPointOffsetYSpinBox->setClearValue( 0.0 );
169 mPointAngleSpinBox->setClearValue( 0.0 );
170 mFontLetterSpacingSpinBox->setClearValue( 0.0 );
171 mFontWordSpacingSpinBox->setClearValue( 0.0 );
172 mZIndexSpinBox->setClearValue( 0.0 );
173 mLineDistanceSpnBx->setClearValue( 0.0 );
185 updateAvailableShadowPositions();
188 mBackgroundSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
189 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
190 mBackgroundSymbolButton->setMapCanvas(
mMapCanvas );
194 mRefFont = lblFontPreview->font();
197 connect( mShadowOffsetAngleDial, &QAbstractSlider::valueChanged, mShadowOffsetAngleSpnBx, &QSpinBox::setValue );
198 connect( mShadowOffsetAngleSpnBx,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ), mShadowOffsetAngleDial, &QAbstractSlider::setValue );
199 connect( mLimitLabelChkBox, &QAbstractButton::toggled, mLimitLabelSpinBox, &QWidget::setEnabled );
200 connect( mCheckBoxSubstituteText, &QAbstractButton::toggled, mToolButtonConfigureSubstitutes, &QWidget::setEnabled );
210 populateFontCapitalsComboBox();
213 mPreviewBackgroundBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
214 mPreviewBackgroundBtn->setContext( QStringLiteral(
"labeling" ) );
215 mPreviewBackgroundBtn->setColor( QColor( 255, 255, 255 ) );
216 btnTextColor->setColorDialogTitle( tr(
"Select Text Color" ) );
217 btnTextColor->setContext( QStringLiteral(
"labeling" ) );
218 btnTextColor->setDefaultColor( Qt::black );
219 btnBufferColor->setColorDialogTitle( tr(
"Select Buffer Color" ) );
220 btnBufferColor->setContext( QStringLiteral(
"labeling" ) );
221 btnBufferColor->setDefaultColor( Qt::white );
222 mShapeStrokeColorBtn->setColorDialogTitle( tr(
"Select Stroke Color" ) );
223 mShapeStrokeColorBtn->setContext( QStringLiteral(
"labeling" ) );
224 mShapeFillColorBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
225 mShapeFillColorBtn->setContext( QStringLiteral(
"labeling" ) );
226 mShadowColorBtn->setColorDialogTitle( tr(
"Select Shadow Color" ) );
227 mShadowColorBtn->setContext( QStringLiteral(
"labeling" ) );
228 mShadowColorBtn->setDefaultColor( Qt::black );
230 mFontColorDDBtn->registerLinkedWidget( btnTextColor );
231 mBufferColorDDBtn->registerLinkedWidget( btnBufferColor );
232 mShapeStrokeColorDDBtn->registerLinkedWidget( mShapeStrokeColorBtn );
233 mShapeFillColorDDBtn->registerLinkedWidget( mShapeFillColorBtn );
234 mShadowColorDDBtn->registerLinkedWidget( mShadowColorBtn );
301 const auto groupBoxes = findChildren<QgsCollapsibleGroupBox *>();
304 grpbox->setSettingGroup( QStringLiteral(
"mAdvLabelingDlg" ) );
310 mLabelingOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect,
false );
315 QSizePolicy policy( mLabelingOptionsListFrame->sizePolicy() );
316 policy.setHorizontalStretch( 0 );
317 mLabelingOptionsListFrame->setSizePolicy( policy );
318 if ( !settings.
contains( QStringLiteral(
"/Windows/Labeling/OptionsSplitState" ) ) )
321 QList<int> splitsizes;
323 mLabelingOptionsSplitter->setSizes( splitsizes );
327 connect( mLabelStackedWidget, &QStackedWidget::currentChanged,
this, &QgsTextFormatWidget::optionsStackedWidget_CurrentChanged );
330 mFontPreviewSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ) ).toByteArray() );
331 mLabelingOptionsSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ) ).toByteArray() );
333 mLabelingOptionsListWidget->setCurrentRow( settings.
value( QStringLiteral(
"Windows/Labeling/Tab" ), 0 ).toInt() );
337 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
341 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
345 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
349 QList<QWidget *> widgets;
350 widgets << btnBufferColor
352 << chkLabelPerFeaturePart
356 << chkLineOrientationDependent
358 << chkPreserveRotation
360 << comboBufferBlendMode
362 << mBufferJoinStyleComboBox
363 << mBufferTranspFillChbx
364 << mBufferOpacityWidget
365 << mCentroidInsideCheckBox
368 << mDirectSymbLeftLineEdit
369 << mDirectSymbRevChkBx
370 << mDirectSymbRightLineEdit
371 << mFitInsidePolygonCheckBox
372 << mFontCapitalsComboBox
373 << mFontLetterSpacingSpinBox
374 << mFontLimitPixelChkBox
375 << mFontLineHeightSpinBox
376 << mFontMaxPixelSpinBox
377 << mFontMinPixelSpinBox
378 << mFontMultiLineAlignComboBox
380 << mFontStyleComboBox
381 << mTextOrientationComboBox
382 << mTextOpacityWidget
383 << mFontWordSpacingSpinBox
385 << mFormatNumDecimalsSpnBx
386 << mFormatNumPlusSignChkBx
388 << mLimitLabelSpinBox
389 << mLineDistanceSpnBx
390 << mLineDistanceUnitWidget
391 << mMaxCharAngleInDSpinBox
392 << mMaxCharAngleOutDSpinBox
394 << mOffsetTypeComboBox
395 << mPalShowAllLabelsForLayerChkBx
396 << mPointAngleSpinBox
397 << mPointOffsetUnitWidget
398 << mPointOffsetXSpinBox
399 << mPointOffsetYSpinBox
400 << mPreviewBackgroundBtn
403 << mRepeatDistanceSpinBox
404 << mRepeatDistanceUnitWidget
405 << mOverrunDistanceSpinBox
406 << mOverrunDistanceUnitWidget
407 << mScaleBasedVisibilityChkBx
413 << mShadowOffsetAngleSpnBx
414 << mShadowOffsetGlobalChkBx
415 << mShadowOffsetSpnBx
416 << mShadowOffsetUnitWidget
417 << mShadowRadiusAlphaChkBx
418 << mShadowRadiusDblSpnBx
419 << mShadowRadiusUnitWidget
421 << mShadowOpacityWidget
424 << mShapeStrokeColorBtn
425 << mShapeStrokeWidthSpnBx
426 << mShapeStrokeWidthUnitWidget
428 << mShapeFillColorBtn
429 << mShapeOffsetXSpnBx
430 << mShapeOffsetYSpnBx
431 << mShapeOffsetUnitWidget
432 << mShapePenStyleCmbBx
433 << mShapeRadiusXDbSpnBx
434 << mShapeRadiusYDbSpnBx
435 << mShapeRotationCmbBx
436 << mShapeRotationDblSpnBx
437 << mShapeRadiusUnitWidget
438 << mShapeSVGPathLineEdit
440 << mShapeSizeUnitWidget
443 << mBackgroundOpacityWidget
448 << mAutoWrapLengthSpinBox
449 << mAutoWrapTypeComboBox
450 << mCentroidRadioVisible
451 << mCentroidRadioWhole
452 << mDirectSymbRadioBtnAbove
453 << mDirectSymbRadioBtnBelow
454 << mDirectSymbRadioBtnLR
455 << mUpsidedownRadioAll
456 << mUpsidedownRadioDefined
457 << mUpsidedownRadioOff
466 << radPolygonHorizontal
467 << radPolygonPerimeter
468 << radPolygonPerimeterCurved
470 << radPredefinedOrder
471 << mFieldExpressionWidget
472 << mCheckBoxSubstituteText
473 << mGeometryGeneratorGroupBox
474 << mGeometryGenerator
475 << mGeometryGeneratorType
476 << mBackgroundSymbolButton
477 << mCalloutsDrawCheckBox
478 << mCalloutStyleComboBox
481 << mMaskJoinStyleComboBox
482 << mMaskBufferSizeSpinBox
483 << mMaskOpacityWidget
484 << mCheckAllowLabelsOutsidePolygons
485 << mHtmlFormattingCheckBox;
492 connect( mBufferDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
494 updateBufferFrameStatus();
497 connect( mShapeDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
499 updateShapeFrameStatus();
502 connect( mShadowDrawChkBx, &QCheckBox::stateChanged,
this, [ = ](
int )
504 updateShadowFrameStatus();
507 connect( mCalloutsDrawCheckBox, &QCheckBox::stateChanged,
this, [ = ](
int )
509 updateCalloutFrameStatus();
512 mGeometryGeneratorType->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mIconPolygonLayer.svg" ) ), tr(
"Polygon / MultiPolygon" ), QgsWkbTypes::GeometryType::PolygonGeometry );
513 mGeometryGeneratorType->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mIconLineLayer.svg" ) ), tr(
"LineString / MultiLineString" ), QgsWkbTypes::GeometryType::LineGeometry );
514 mGeometryGeneratorType->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mIconPointLayer.svg" ) ), tr(
"Point / MultiPoint" ), QgsWkbTypes::GeometryType::PointGeometry );
517 whileBlocking( mOptionsTab )->setCurrentIndex( mLabelStackedWidget->currentIndex() );
518 mOptionsTab->tabBar()->setUsesScrollButtons(
true );
539 toggleDDButtons(
true );
545 toggleDDButtons(
true );
546 delete mLabelingOptionsListWidget->takeItem( 8 );
547 delete mLabelingOptionsListWidget->takeItem( 7 );
548 delete mLabelingOptionsListWidget->takeItem( 6 );
549 delete mLabelingOptionsListWidget->takeItem( 3 );
550 mOptionsTab->removeTab( 8 );
551 mOptionsTab->removeTab( 7 );
552 mOptionsTab->removeTab( 6 );
553 mOptionsTab->removeTab( 3 );
554 mLabelStackedWidget->removeWidget( mLabelPage_Rendering );
555 mLabelStackedWidget->removeWidget( mLabelPage_Callouts );
556 mLabelStackedWidget->removeWidget( mLabelPage_Mask );
557 mLabelStackedWidget->removeWidget( mLabelPage_Placement );
558 mLabelStackedWidget->setCurrentIndex( 0 );
560 frameLabelWith->hide();
561 mDirectSymbolsFrame->hide();
562 mFormatNumFrame->hide();
563 mFormatNumChkBx->hide();
564 mFormatNumDDBtn->hide();
565 mSubstitutionsFrame->hide();
571 void QgsTextFormatWidget::toggleDDButtons(
bool visible )
573 const auto buttons = findChildren< QgsPropertyOverrideButton * >();
576 button->setVisible( visible );
582 mOptionsTab->setVisible( enabled );
583 mOptionsTab->setTabToolTip( 0, tr(
"Text" ) );
584 mOptionsTab->setTabToolTip( 1, tr(
"Formatting" ) );
585 mOptionsTab->setTabToolTip( 2, tr(
"Buffer" ) );
586 mOptionsTab->setTabToolTip( 3, tr(
"Mask" ) );
587 mOptionsTab->setTabToolTip( 4, tr(
"Background" ) );
588 mOptionsTab->setTabToolTip( 5, tr(
"Shadow" ) );
589 mOptionsTab->setTabToolTip( 6, tr(
"Callouts" ) );
590 mOptionsTab->setTabToolTip( 7, tr(
"Placement" ) );
591 mOptionsTab->setTabToolTip( 8, tr(
"Rendering" ) );
593 mLabelingOptionsListFrame->setVisible( !enabled );
594 groupBox_mPreview->setVisible( !enabled );
598 void QgsTextFormatWidget::connectValueChanged(
const QList<QWidget *> &widgets,
const char *slot )
600 const auto constWidgets = widgets;
601 for ( QWidget *widget : constWidgets )
605 connect( w, SIGNAL( changed() ),
this, slot );
609 connect( w, SIGNAL( fieldChanged( QString ) ),
this, slot );
611 else if (
QgsOpacityWidget *w = qobject_cast< QgsOpacityWidget *>( widget ) )
613 connect( w, SIGNAL( opacityChanged(
double ) ),
this, slot );
615 else if (
QgsScaleWidget *w = qobject_cast< QgsScaleWidget *>( widget ) )
617 connect( w, SIGNAL( scaleChanged(
double ) ),
this, slot );
619 else if ( QgsUnitSelectionWidget *w = qobject_cast<QgsUnitSelectionWidget *>( widget ) )
621 connect( w, SIGNAL( changed() ),
this, slot );
623 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
625 connect( w, SIGNAL( currentIndexChanged(
int ) ),
this, slot );
627 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
629 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
631 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
633 connect( w, SIGNAL( valueChanged(
double ) ),
this, slot );
635 else if (
QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
637 connect( w, SIGNAL( colorChanged( QColor ) ),
this, slot );
639 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
641 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
643 else if ( QRadioButton *w = qobject_cast<QRadioButton *>( widget ) )
645 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
647 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
649 connect( w, SIGNAL( textEdited( QString ) ),
this, slot );
651 else if ( QSlider *w = qobject_cast<QSlider *>( widget ) )
653 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
655 else if ( QGroupBox *w = qobject_cast<QGroupBox *>( widget ) )
657 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
661 connect( w, SIGNAL( textChanged() ),
this, slot );
665 QgsLogger::warning( QStringLiteral(
"Could not create connection for widget %1" ).arg( widget->objectName() ) );
696 mDirectSymbDDBtn->registerCheckedWidget( mDirectSymbChkBx );
704 mFormatNumDDBtn->registerCheckedWidget( mFormatNumChkBx );
710 mBufferDrawDDBtn->registerCheckedWidget( mBufferDrawChkBx );
720 mEnableMaskDDBtn->registerCheckedWidget( mEnableMaskChkBx );
728 mShapeDrawDDBtn->registerCheckedWidget( mShapeDrawChkBx );
751 mShadowDrawDDBtn->registerCheckedWidget( mShadowDrawChkBx );
784 QString ddPlaceInfo = tr(
"In edit mode, layer's relevant labeling map tool is:<br>"
785 " Defined attribute field -> <i>enabled</i><br>"
786 " Defined expression -> <i>disabled</i>" );
788 mCoordXDDBtn->setUsageInfo( ddPlaceInfo );
790 mCoordYDDBtn->setUsageInfo( ddPlaceInfo );
792 mCoordAlignmentHDDBtn->setUsageInfo( ddPlaceInfo );
794 mCoordAlignmentVDDBtn->setUsageInfo( ddPlaceInfo );
796 mCoordRotationDDBtn->setUsageInfo( ddPlaceInfo );
799 QString ddScaleVisInfo = tr(
"Value < 0 represents a scale closer than 1:1, e.g. -10 = 10:1<br>"
800 "Value of 0 disables the specific limit." );
802 mScaleBasedVisibilityDDBtn->registerCheckedWidget( mScaleBasedVisibilityChkBx );
804 mScaleBasedVisibilityMinDDBtn->setUsageInfo( ddScaleVisInfo );
806 mScaleBasedVisibilityMaxDDBtn->setUsageInfo( ddScaleVisInfo );
809 mFontLimitPixelDDBtn->registerCheckedWidget( mFontLimitPixelChkBox );
821 mCalloutDrawDDBtn->registerCheckedWidget( mCalloutsDrawCheckBox );
829 if ( !mButtons.contains( key ) )
834 mButtons[key] = button;
851 mBufferDrawChkBx->setChecked( buffer.
enabled() );
852 mBufferFrame->setEnabled( buffer.
enabled() );
853 spinBufferSize->setValue( buffer.
size() );
854 mBufferUnitWidget->setUnit( buffer.
sizeUnit() );
856 btnBufferColor->setColor( buffer.
color() );
857 mBufferOpacityWidget->setOpacity( buffer.
opacity() );
858 mBufferJoinStyleComboBox->setPenJoinStyle( buffer.
joinStyle() );
860 comboBufferBlendMode->setBlendMode( buffer.
blendMode() );
866 mBufferEffect->setEnabled(
false );
868 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
872 mEnableMaskChkBx->setChecked( mask.
enabled() );
873 mMaskBufferSizeSpinBox->setValue( mask.
size() );
874 mMaskBufferUnitWidget->setUnit( mask.
sizeUnit() );
876 mMaskOpacityWidget->setOpacity( mask.
opacity() );
877 mMaskJoinStyleComboBox->setPenJoinStyle( mask.
joinStyle() );
883 mMaskEffect->setEnabled(
false );
885 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
894 mTextOrientationComboBox->setCurrentIndex( mTextOrientationComboBox->findData(
format.
orientation() ) );
897 mFontWordSpacingSpinBox->setValue(
format.
font().wordSpacing() );
898 mFontLetterSpacingSpinBox->setValue(
format.
font().letterSpacing() );
902 updateFont( mRefFont );
908 QString missingTxt = tr(
"%1 not found. Default substituted." );
909 QString txtPrepend = tr(
"Chosen font" );
914 mFontMissingLabel->setText( missingTxt.arg( txtPrepend ) );
917 mLabelingOptionsListWidget->setCurrentRow( 0 );
922 mShapeDrawChkBx->setChecked( background.
enabled() );
923 mShapeFrame->setEnabled( background.
enabled() );
924 mShapeTypeCmbBx->blockSignals(
true );
925 mShapeTypeCmbBx->setCurrentIndex( mShapeTypeCmbBx->findData( background.
type() ) );
926 mShapeTypeCmbBx->blockSignals(
false );
927 updateAvailableShadowPositions();
928 mShapeSVGPathLineEdit->setText( background.
svgFile() );
930 mShapeSizeCmbBx->setCurrentIndex( background.
sizeType() );
931 mShapeSizeXSpnBx->setValue( background.
size().width() );
932 mShapeSizeYSpnBx->setValue( background.
size().height() );
933 mShapeSizeUnitWidget->setUnit( background.
sizeUnit() );
935 mShapeRotationCmbBx->setCurrentIndex( background.
rotationType() );
938 mShapeRotationDblSpnBx->setValue( background.
rotation() );
939 mShapeOffsetXSpnBx->setValue( background.
offset().x() );
940 mShapeOffsetYSpnBx->setValue( background.
offset().y() );
941 mShapeOffsetUnitWidget->setUnit( background.
offsetUnit() );
943 mShapeRadiusXDbSpnBx->setValue( background.
radii().width() );
944 mShapeRadiusYDbSpnBx->setValue( background.
radii().height() );
945 mShapeRadiusUnitWidget->setUnit( background.
radiiUnit() );
948 mShapeFillColorBtn->setColor( background.
fillColor() );
949 mShapeStrokeColorBtn->setColor( background.
strokeColor() );
950 mShapeStrokeWidthSpnBx->setValue( background.
strokeWidth() );
953 mShapePenStyleCmbBx->setPenJoinStyle( background.
joinStyle() );
955 mBackgroundOpacityWidget->setOpacity( background.
opacity() );
956 mShapeBlendCmbBx->setBlendMode( background.
blendMode() );
958 mLoadSvgParams =
false;
959 mShapeTypeCmbBx_currentIndexChanged( background.
type() );
966 mBackgroundEffect->setEnabled(
false );
968 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
973 mShadowDrawChkBx->setChecked( shadow.
enabled() );
974 mShadowFrame->setEnabled( shadow.
enabled() );
975 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( shadow.
shadowPlacement() ) );
976 mShadowOffsetAngleSpnBx->setValue( shadow.
offsetAngle() );
978 mShadowOffsetUnitWidget->setUnit( shadow.
offsetUnit() );
980 mShadowOffsetGlobalChkBx->setChecked( shadow.
offsetGlobal() );
982 mShadowRadiusDblSpnBx->setValue( shadow.
blurRadius() );
985 mShadowRadiusAlphaChkBx->setChecked( shadow.
blurAlphaOnly() );
986 mShadowOpacityWidget->setOpacity( shadow.
opacity() );
987 mShadowScaleSpnBx->setValue( shadow.
scale() );
989 mShadowColorBtn->setColor( shadow.
color() );
990 mShadowBlendCmbBx->setBlendMode( shadow.
blendMode() );
1002 settings.
setValue( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ), mFontPreviewSplitter->saveState() );
1003 settings.
setValue( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ), mLabelingOptionsSplitter->saveState() );
1004 settings.
setValue( QStringLiteral(
"Windows/Labeling/Tab" ), mLabelingOptionsListWidget->currentRow() );
1025 buffer.
setEnabled( mBufferDrawChkBx->isChecked() );
1026 buffer.
setSize( spinBufferSize->value() );
1027 buffer.
setColor( btnBufferColor->color() );
1028 buffer.
setOpacity( mBufferOpacityWidget->opacity() );
1031 buffer.
setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
1033 buffer.
setBlendMode( comboBufferBlendMode->blendMode() );
1042 mask.
setEnabled( mEnableMaskChkBx->isChecked() );
1043 mask.
setSize( mMaskBufferSizeSpinBox->value() );
1044 mask.
setOpacity( mMaskOpacityWidget->opacity() );
1045 mask.
setSizeUnit( mMaskBufferUnitWidget->unit() );
1047 mask.
setJoinStyle( mMaskJoinStyleComboBox->penJoinStyle() );
1057 background.
setEnabled( mShapeDrawChkBx->isChecked() );
1059 background.
setSvgFile( mShapeSVGPathLineEdit->text() );
1061 background.
setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
1062 background.
setSizeUnit( mShapeSizeUnitWidget->unit() );
1065 background.
setRotation( mShapeRotationDblSpnBx->value() );
1066 background.
setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
1069 background.
setRadii( QSizeF( mShapeRadiusXDbSpnBx->value(), mShapeRadiusYDbSpnBx->value() ) );
1070 background.
setRadiiUnit( mShapeRadiusUnitWidget->unit() );
1073 background.
setFillColor( mShapeFillColorBtn->color() );
1078 background.
setJoinStyle( mShapePenStyleCmbBx->penJoinStyle() );
1079 background.
setOpacity( mBackgroundOpacityWidget->opacity() );
1080 background.
setBlendMode( mShapeBlendCmbBx->blendMode() );
1090 shadow.
setEnabled( mShadowDrawChkBx->isChecked() );
1101 shadow.
setOpacity( mShadowOpacityWidget->opacity() );
1102 shadow.
setScale( mShadowScaleSpnBx->value() );
1103 shadow.
setColor( mShadowColorBtn->color() );
1107 if ( includeDataDefinedProperties )
1138 if ( mButtons.contains( key ) )
1150 void QgsTextFormatWidget::optionsStackedWidget_CurrentChanged(
int indx )
1152 mLabelingOptionsListWidget->blockSignals(
true );
1153 mLabelingOptionsListWidget->setCurrentRow( indx );
1154 mLabelingOptionsListWidget->blockSignals(
false );
1168 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
1176 void QgsTextFormatWidget::collapseSample(
bool collapse )
1180 QList<int> splitSizes = mFontPreviewSplitter->sizes();
1181 if ( splitSizes[0] > groupBox_mPreview->height() )
1183 int delta = splitSizes[0] - groupBox_mPreview->height();
1184 splitSizes[0] -= delta;
1185 splitSizes[1] += delta;
1186 mFontPreviewSplitter->setSizes( splitSizes );
1191 void QgsTextFormatWidget::changeTextColor(
const QColor &color )
1197 void QgsTextFormatWidget::updateFont(
const QFont &font )
1200 if ( font != mRefFont )
1209 mDirectSymbLeftLineEdit->setFont( mRefFont );
1210 mDirectSymbRightLineEdit->setFont( mRefFont );
1212 blockFontChangeSignals(
true );
1213 mFontFamilyCmbBx->setCurrentFont( mRefFont );
1214 populateFontStyleComboBox();
1215 int idx = mFontCapitalsComboBox->findData( QVariant(
static_cast< unsigned int >( mRefFont.capitalization() ) ) );
1216 mFontCapitalsComboBox->setCurrentIndex( idx == -1 ? 0 : idx );
1217 mFontUnderlineBtn->setChecked( mRefFont.underline() );
1218 mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
1219 mKerningCheckBox->setChecked( mRefFont.kerning() );
1220 blockFontChangeSignals(
false );
1228 void QgsTextFormatWidget::blockFontChangeSignals(
bool blk )
1230 mFontFamilyCmbBx->blockSignals( blk );
1231 mFontStyleComboBox->blockSignals( blk );
1232 mFontCapitalsComboBox->blockSignals( blk );
1233 mFontUnderlineBtn->blockSignals( blk );
1234 mFontStrikethroughBtn->blockSignals( blk );
1235 mFontWordSpacingSpinBox->blockSignals( blk );
1236 mFontLetterSpacingSpinBox->blockSignals( blk );
1237 mKerningCheckBox->blockSignals( blk );
1252 lblFontPreview->setFormat(
format() );
1255 void QgsTextFormatWidget::scrollPreview()
1257 scrollArea_mPreview->ensureVisible( 0, 0, 0, 0 );
1262 mPreviewBackgroundColor = color;
1264 scrollArea_mPreview->widget()->setStyleSheet( QStringLiteral(
"background: rgb(%1, %2, %3);" ).arg( QString::number( color.red() ),
1265 QString::number( color.green() ),
1266 QString::number( color.blue() ) ) );
1269 void QgsTextFormatWidget::changeBufferColor(
const QColor &color )
1277 QWidget *curWdgt = stackedPlacement->currentWidget();
1279 bool showLineFrame =
false;
1280 bool showCentroidFrame =
false;
1281 bool showQuadrantFrame =
false;
1282 bool showFixedQuadrantFrame =
false;
1283 bool showPlacementPriorityFrame =
false;
1284 bool showOffsetTypeFrame =
false;
1285 bool showOffsetFrame =
false;
1286 bool showDistanceFrame =
false;
1287 bool showRotationFrame =
false;
1288 bool showMaxCharAngleFrame =
false;
1289 bool showPolygonPlacementOptions = ( curWdgt == pagePolygon && !radPolygonPerimeter->isChecked() && !radPolygonPerimeterCurved->isChecked() && !radPolygonOutside->isChecked() );
1291 bool enableMultiLinesFrame =
true;
1293 if ( ( curWdgt == pagePoint && radAroundPoint->isChecked() )
1294 || ( curWdgt == pagePolygon && radAroundCentroid->isChecked() ) )
1296 showCentroidFrame = ( curWdgt == pagePolygon && radAroundCentroid->isChecked() );
1297 showDistanceFrame =
true;
1299 if ( curWdgt == pagePoint )
1301 showQuadrantFrame =
true;
1304 else if ( ( curWdgt == pagePoint && radOverPoint->isChecked() )
1305 || ( curWdgt == pagePolygon && radOverCentroid->isChecked() ) )
1307 showCentroidFrame = ( curWdgt == pagePolygon && radOverCentroid->isChecked() );
1308 showQuadrantFrame =
true;
1309 showFixedQuadrantFrame =
true;
1310 showOffsetFrame =
true;
1311 showRotationFrame =
true;
1313 else if ( curWdgt == pagePoint && radPredefinedOrder->isChecked() )
1315 showDistanceFrame =
true;
1316 showPlacementPriorityFrame =
true;
1317 showOffsetTypeFrame =
true;
1319 else if ( ( curWdgt == pageLine && radLineParallel->isChecked() )
1320 || ( curWdgt == pagePolygon && radPolygonPerimeter->isChecked() )
1321 || ( curWdgt == pageLine && radLineCurved->isChecked() )
1322 || ( curWdgt == pagePolygon && radPolygonPerimeterCurved->isChecked() ) )
1324 showLineFrame =
true;
1325 showDistanceFrame =
true;
1328 bool offline = chkLineAbove->isChecked() || chkLineBelow->isChecked();
1329 chkLineOrientationDependent->setEnabled( offline );
1330 mPlacementDistanceFrame->setEnabled( offline );
1332 bool isCurved = ( curWdgt == pageLine && radLineCurved->isChecked() )
1333 || ( curWdgt == pagePolygon && radPolygonPerimeterCurved->isChecked() );
1334 showMaxCharAngleFrame = isCurved;
1336 enableMultiLinesFrame = !isCurved;
1338 else if ( curWdgt == pagePolygon && ( radPolygonOutside->isChecked() || mCheckAllowLabelsOutsidePolygons->isChecked() || mAllowOutsidePolygonsDDBtn->isActive() ) )
1340 showDistanceFrame =
true;
1343 mPlacementLineFrame->setVisible( showLineFrame );
1344 mPlacementPolygonFrame->setVisible( showPolygonPlacementOptions );
1345 mPlacementCentroidFrame->setVisible( showCentroidFrame );
1346 mPlacementQuadrantFrame->setVisible( showQuadrantFrame );
1347 mPlacementFixedQuadrantFrame->setVisible( showFixedQuadrantFrame );
1348 mPlacementCartographicFrame->setVisible( showPlacementPriorityFrame );
1349 mPlacementOffsetFrame->setVisible( showOffsetFrame );
1350 mPlacementDistanceFrame->setVisible( showDistanceFrame );
1351 mPlacementOffsetTypeFrame->setVisible( showOffsetTypeFrame );
1352 mPlacementRotationFrame->setVisible( showRotationFrame );
1353 mPlacementRepeatDistanceFrame->setVisible( curWdgt == pageLine || ( curWdgt == pagePolygon &&
1354 ( radPolygonPerimeter->isChecked() || radPolygonPerimeterCurved->isChecked() ) ) );
1355 mPlacementOverrunDistanceFrame->setVisible( curWdgt == pageLine );
1356 mPlacementMaxCharAngleFrame->setVisible( showMaxCharAngleFrame );
1358 mMultiLinesFrame->setEnabled( enableMultiLinesFrame );
1361 void QgsTextFormatWidget::populateFontCapitalsComboBox()
1363 mFontCapitalsComboBox->addItem( tr(
"No Change" ), QVariant( 0 ) );
1364 mFontCapitalsComboBox->addItem( tr(
"All Uppercase" ), QVariant( 1 ) );
1365 mFontCapitalsComboBox->addItem( tr(
"All Lowercase" ), QVariant( 2 ) );
1369 mFontCapitalsComboBox->addItem( tr(
"Capitalize First Letter" ), QVariant( 4 ) );
1372 void QgsTextFormatWidget::populateFontStyleComboBox()
1374 mFontStyleComboBox->clear();
1375 QStringList styles = mFontDB.styles( mRefFont.family() );
1376 const auto constStyles = styles;
1377 for (
const QString &style : constStyles )
1379 mFontStyleComboBox->addItem( style );
1382 QString targetStyle = mFontDB.styleString( mRefFont );
1383 if ( !styles.contains( targetStyle ) )
1385 QFont f = QFont( mRefFont.family() );
1386 targetStyle = QFontInfo( f ).styleName();
1387 mRefFont.setStyleName( targetStyle );
1390 int stylIndx = mFontStyleComboBox->findText( targetStyle );
1391 if ( stylIndx > -1 )
1396 mFontStyleComboBox->setCurrentIndex( curIndx );
1399 void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged(
double d )
1401 mRefFont.setPointSizeF( d );
1402 updateFont( mRefFont );
1405 void QgsTextFormatWidget::mFontCapitalsComboBox_currentIndexChanged(
int index )
1407 int capitalsindex = mFontCapitalsComboBox->itemData( index ).toInt();
1408 mRefFont.setCapitalization(
static_cast< QFont::Capitalization
>( capitalsindex ) );
1409 updateFont( mRefFont );
1412 void QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged(
const QFont &f )
1414 mRefFont.setFamily( f.family() );
1415 updateFont( mRefFont );
1418 void QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged(
const QString &text )
1421 updateFont( mRefFont );
1424 void QgsTextFormatWidget::mFontUnderlineBtn_toggled(
bool ckd )
1426 mRefFont.setUnderline( ckd );
1427 updateFont( mRefFont );
1430 void QgsTextFormatWidget::mFontStrikethroughBtn_toggled(
bool ckd )
1432 mRefFont.setStrikeOut( ckd );
1433 updateFont( mRefFont );
1436 void QgsTextFormatWidget::kerningToggled(
bool checked )
1438 mRefFont.setKerning( checked );
1439 updateFont( mRefFont );
1442 void QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged(
double spacing )
1444 mRefFont.setWordSpacing( spacing );
1445 updateFont( mRefFont );
1448 void QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged(
double spacing )
1450 mRefFont.setLetterSpacing( QFont::AbsoluteSpacing, spacing );
1451 updateFont( mRefFont );
1454 void QgsTextFormatWidget::mFontSizeUnitWidget_changed()
1459 mFontLimitPixelChkBox->setChecked(
false );
1465 mFontLimitPixelChkBox->setChecked(
true );
1467 updateFont( mRefFont );
1470 void QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged(
int px )
1473 mFontMaxPixelSpinBox->setMinimum( px );
1474 mFontMaxPixelSpinBox->update();
1477 void QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged(
int px )
1480 if ( px < mFontMinPixelSpinBox->value() )
1482 mFontMaxPixelSpinBox->blockSignals(
true );
1483 mFontMaxPixelSpinBox->setValue( mFontMinPixelSpinBox->value() );
1484 mFontMaxPixelSpinBox->blockSignals(
false );
1486 mFontMaxPixelSpinBox->setMinimum( mFontMinPixelSpinBox->value() );
1489 void QgsTextFormatWidget::mBufferUnitWidget_changed()
1491 updateFont( mRefFont );
1494 void QgsTextFormatWidget::mMaskBufferUnitWidget_changed()
1496 updateFont( mRefFont );
1499 void QgsTextFormatWidget::mCoordXDDBtn_changed( )
1501 if ( !mCoordXDDBtn->isActive() )
1505 else if ( mCoordYDDBtn->isActive() )
1511 void QgsTextFormatWidget::mCoordYDDBtn_changed( )
1513 if ( !mCoordYDDBtn->isActive() )
1517 else if ( mCoordXDDBtn->isActive() )
1523 void QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged(
int )
1531 showBackgroundPenStyle( isRect );
1532 showBackgroundRadius( isRect );
1534 mShapeSVGPathFrame->setVisible( isSVG );
1535 mBackgroundSymbolButton->setVisible( isMarker );
1539 mShapeSizeYLabel->setVisible( !isSVG && !isMarker );
1540 mShapeSizeYSpnBx->setVisible( !isSVG && !isMarker );
1541 mShapeSizeYDDBtn->setVisible( !isSVG && !isMarker );
1542 mShapeSizeXLabel->setText( tr(
"Size%1" ).arg( !isSVG && !isMarker ? tr(
" X" ) : QString() ) );
1545 mShapeFillColorBtn->setAllowOpacity( !isSVG );
1546 mShapeFillColorBtn->setButtonBackground();
1547 mShapeStrokeColorBtn->setAllowOpacity( !isSVG );
1548 mShapeStrokeColorBtn->setButtonBackground();
1551 mShapeFillColorLabel->setVisible( !isMarker );
1552 mShapeFillColorLabel->setEnabled( !isMarker );
1553 mShapeFillColorBtn->setVisible( !isMarker );
1554 mShapeFillColorBtn->setEnabled( !isMarker );
1555 mShapeFillColorDDBtn->setVisible( !isMarker );
1556 mShapeFillColorDDBtn->setEnabled( !isMarker );
1557 mShapeStrokeColorLabel->setVisible( !isMarker );
1558 mShapeStrokeColorLabel->setEnabled( !isMarker );
1559 mShapeStrokeColorBtn->setVisible( !isMarker );
1560 mShapeStrokeColorBtn->setEnabled( !isMarker );
1561 mShapeStrokeColorDDBtn->setVisible( !isMarker );
1562 mShapeStrokeColorDDBtn->setEnabled( !isMarker );
1563 mShapeStrokeWidthLabel->setVisible( !isMarker );
1564 mShapeStrokeWidthLabel->setEnabled( !isMarker );
1565 mShapeStrokeWidthSpnBx->setVisible( !isMarker );
1566 mShapeStrokeWidthSpnBx->setEnabled( !isMarker );
1567 mShapeStrokeWidthDDBtn->setVisible( !isMarker );
1568 mShapeStrokeWidthDDBtn->setEnabled( !isMarker );
1571 mShapeSVGParamsBtn->setVisible( isSVG );
1574 updateSvgWidgets( mShapeSVGPathLineEdit->text() );
1578 mShapeStrokeWidthUnitWidget->setVisible( !isSVG && !isMarker );
1579 mShapeSVGUnitsLabel->setVisible( isSVG );
1580 mShapeStrokeUnitsDDBtn->setVisible( !isSVG && !isMarker );
1581 mShapeStrokeUnitsDDBtn->setEnabled( !isSVG && !isMarker );
1583 updateAvailableShadowPositions();
1586 void QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged(
const QString &text )
1588 updateSvgWidgets( text );
1593 int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) +
1594 ( chkLineBelow->isChecked() ? 1 : 0 ) +
1595 ( chkLineOn->isChecked() ? 1 : 0 );
1597 if ( numOptionsChecked == 1 )
1600 chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
1601 chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
1602 chkLineOn->setEnabled( !chkLineOn->isChecked() );
1606 chkLineAbove->setEnabled(
true );
1607 chkLineBelow->setEnabled(
true );
1608 chkLineOn->setEnabled(
true );
1618 void QgsTextFormatWidget::previewScaleChanged(
double scale )
1620 lblFontPreview->setScale( scale );
1623 void QgsTextFormatWidget::updateSvgWidgets(
const QString &svgPath )
1625 if ( mShapeSVGPathLineEdit->text() != svgPath )
1627 mShapeSVGPathLineEdit->setText( svgPath );
1630 QString resolvedPath;
1631 bool validSVG =
true;
1632 if ( ! svgPath.startsWith( QLatin1String(
"base64:" ), Qt::CaseInsensitive ) )
1635 validSVG = QFileInfo::exists( resolvedPath );
1639 resolvedPath = svgPath;
1644 mShapeSVGPathLineEdit->setStyleSheet( !validSVG ? QStringLiteral(
"QLineEdit{ color: rgb(225, 0, 0); }" ) : QString() );
1645 mShapeSVGPathLineEdit->setToolTip( !validSVG ? tr(
"File not found" ) : resolvedPath );
1647 QColor fill, stroke;
1648 double strokeWidth = 0.0;
1649 bool fillParam =
false, strokeParam =
false, strokeWidthParam =
false;
1655 mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || strokeParam || strokeWidthParam ) );
1657 mShapeFillColorLabel->setEnabled( validSVG && fillParam );
1658 mShapeFillColorBtn->setEnabled( validSVG && fillParam );
1659 mShapeFillColorDDBtn->setEnabled( validSVG && fillParam );
1660 if ( mLoadSvgParams && validSVG && fillParam )
1661 mShapeFillColorBtn->setColor( fill );
1663 mShapeStrokeColorLabel->setEnabled( validSVG && strokeParam );
1664 mShapeStrokeColorBtn->setEnabled( validSVG && strokeParam );
1665 mShapeStrokeColorDDBtn->setEnabled( validSVG && strokeParam );
1666 if ( mLoadSvgParams && validSVG && strokeParam )
1667 mShapeStrokeColorBtn->setColor( stroke );
1669 mShapeStrokeWidthLabel->setEnabled( validSVG && strokeWidthParam );
1670 mShapeStrokeWidthSpnBx->setEnabled( validSVG && strokeWidthParam );
1671 mShapeStrokeWidthDDBtn->setEnabled( validSVG && strokeWidthParam );
1672 if ( mLoadSvgParams && validSVG && strokeWidthParam )
1673 mShapeStrokeWidthSpnBx->setValue( strokeWidth );
1679 mShapeSVGUnitsLabel->setEnabled( validSVG && strokeWidthParam );
1682 void QgsTextFormatWidget::updateAvailableShadowPositions()
1684 if ( mShadowUnderCmbBx->count() == 0
1690 mShadowUnderCmbBx->clear();
1698 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( currentPlacement ) );
1699 if ( mShadowUnderCmbBx->currentIndex() == -1 )
1700 mShadowUnderCmbBx->setCurrentIndex( 0 );
1704 void QgsTextFormatWidget::updateProperty()
1712 void QgsTextFormatWidget::createAuxiliaryField()
1739 property.setActive(
true );
1748 void QgsTextFormatWidget::updateShapeFrameStatus()
1750 mShapeFrame->setEnabled( mShapeDrawDDBtn->isActive() || mShapeDrawChkBx->isChecked() );
1753 void QgsTextFormatWidget::updateBufferFrameStatus()
1755 mBufferFrame->setEnabled( mBufferDrawDDBtn->isActive() || mBufferDrawChkBx->isChecked() );
1758 void QgsTextFormatWidget::updateShadowFrameStatus()
1760 mShadowFrame->setEnabled( mShadowDrawDDBtn->isActive() || mShadowDrawChkBx->isChecked() );
1763 void QgsTextFormatWidget::updateCalloutFrameStatus()
1765 mCalloutFrame->setEnabled( mCalloutDrawDDBtn->isActive() || mCalloutsDrawCheckBox->isChecked() );
1808 saveDlg.setDefaultTags( mTextFormatsListWidget->currentTagFilter() );
1809 if ( !saveDlg.exec() )
1812 if ( saveDlg.name().isEmpty() )
1818 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ),
1819 tr(
"Format with name '%1' already exists. Overwrite?" )
1820 .arg( saveDlg.name() ),
1821 QMessageBox::Yes | QMessageBox::No );
1822 if ( res != QMessageBox::Yes )
1829 QStringList symbolTags = saveDlg.tags().split(
',' );
1833 style->
saveTextFormat( saveDlg.name(), newFormat, saveDlg.isFavorite(), symbolTags );
1836 void QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked()
1839 svgDlg.setWindowTitle( tr(
"Select SVG file" ) );
1840 svgDlg.svgSelector()->setSvgPath( mShapeSVGPathLineEdit->text().trimmed() );
1842 if ( svgDlg.exec() == QDialog::Accepted )
1844 QString svgPath = svgDlg.svgSelector()->currentSvgPath();
1845 if ( !svgPath.isEmpty() )
1847 mShapeSVGPathLineEdit->setText( svgPath );
1853 void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
1855 QString svgPath = mShapeSVGPathLineEdit->text();
1856 mLoadSvgParams =
true;
1857 updateSvgWidgets( svgPath );
1858 mLoadSvgParams =
false;
1861 void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged(
int index )
1867 void QgsTextFormatWidget::mPreviewTextEdit_textChanged(
const QString &text )
1869 lblFontPreview->setText( text );
1873 void QgsTextFormatWidget::mPreviewTextBtn_clicked()
1875 mPreviewTextEdit->setText( QStringLiteral(
"Lorem Ipsum" ) );
1879 void QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged(
const QColor &color )
1884 void QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked()
1886 bool gotChar =
false;
1888 const QChar initial = !mDirectSymbLeftLineEdit->text().isEmpty() ? mDirectSymbLeftLineEdit->text().at( 0 ) : QChar();
1889 QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
1894 if ( !dirSymb.isNull() )
1895 mDirectSymbLeftLineEdit->setText( QString( dirSymb ) );
1898 void QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked()
1900 bool gotChar =
false;
1901 const QChar initial = !mDirectSymbRightLineEdit->text().isEmpty() ? mDirectSymbRightLineEdit->text().at( 0 ) : QChar();
1902 QChar dirSymb = mCharDlg->
selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
1907 if ( !dirSymb.isNull() )
1908 mDirectSymbRightLineEdit->setText( QString( dirSymb ) );
1911 void QgsTextFormatWidget::chkLineOrientationDependent_toggled(
bool active )
1915 chkLineAbove->setText( tr(
"Left of line" ) );
1916 chkLineBelow->setText( tr(
"Right of line" ) );
1920 chkLineAbove->setText( tr(
"Above line" ) );
1921 chkLineBelow->setText( tr(
"Below line" ) );
1926 void QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked()
1941 if ( dlg.exec() == QDialog::Accepted )
1948 void QgsTextFormatWidget::showBackgroundRadius(
bool show )
1950 mShapeRadiusLabel->setVisible( show );
1951 mShapeRadiusXDbSpnBx->setVisible( show );
1953 mShapeRadiusYDbSpnBx->setVisible( show );
1955 mShapeRadiusUnitWidget->setVisible( show );
1957 mShapeRadiusDDBtn->setVisible( show );
1958 mShapeRadiusUnitsDDBtn->setVisible( show );
1961 void QgsTextFormatWidget::showBackgroundPenStyle(
bool show )
1963 mShapePenStyleLabel->setVisible( show );
1964 mShapePenStyleCmbBx->setVisible( show );
1966 mShapePenStyleDDBtn->setVisible( show );
1971 mCoordAlignmentFrame->setEnabled( enable );
2002 : QDialog( parent, fl )
2004 setWindowTitle( tr(
"Text Settings" ) );
2007 mFormatWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
2009 QVBoxLayout *layout =
new QVBoxLayout(
this );
2010 layout->addWidget( mFormatWidget );
2012 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, Qt::Horizontal,
this );
2013 layout->addWidget( mButtonBox );
2015 setLayout( layout );
2018 connect( mButtonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked,
this, &QDialog::accept );
2019 connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked,
this, &QDialog::reject );
2020 connect( mButtonBox->button( QDialogButtonBox::Help ), &QAbstractButton::clicked,
this, &QgsTextFormatDialog::showHelp );
2025 return mFormatWidget->
format();
2028 void QgsTextFormatDialog::showHelp()
2030 QgsHelp::openHelp( QStringLiteral(
"style_library/label_settings.html#formatting-the-label-text" ) );
2046 mFormatWidget = qobject_cast< QgsTextFormatWidget * >(
widget() );
2052 return mFormatWidget->
format();