50#include <QButtonGroup>
53#include "moc_qgstextformatwidget.cpp"
61 setWidgetMode(
Text );
75 setWidgetMode( mode );
78void QgsTextFormatWidget::initWidget()
82 mGeometryGeneratorGroupBox->setCollapsed(
true );
84 mTextItem =
new QListWidgetItem( tr(
"Text" ), mLabelingOptionsListWidget );
86 mTextItem->setToolTip( tr(
"Text style" ) );
88 mFormattingItem =
new QListWidgetItem( tr(
"Formatting" ), mLabelingOptionsListWidget );
92 mBufferItem =
new QListWidgetItem( tr(
"Buffer" ), mLabelingOptionsListWidget );
96 mMaskItem =
new QListWidgetItem( tr(
"Mask" ), mLabelingOptionsListWidget );
100 mBackgroundItem =
new QListWidgetItem( tr(
"Background" ), mLabelingOptionsListWidget );
104 mShadowItem =
new QListWidgetItem( tr(
"Shadow" ), mLabelingOptionsListWidget );
108 mCalloutItem =
new QListWidgetItem( tr(
"Callouts" ), mLabelingOptionsListWidget );
112 mPlacementItem =
new QListWidgetItem( tr(
"Placement" ), mLabelingOptionsListWidget );
116 mRenderingItem =
new QListWidgetItem( tr(
"Rendering" ), mLabelingOptionsListWidget );
120#if ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR < 10 )
121 mDuplicatesStackedWidget->setCurrentWidget( mDuplicatesNotAvailableWidget );
122 mLabelSpacingStackedWidget->setCurrentWidget( mLabelSpacingNotAvailableWidget );
125 mLabelingOptionsListWidget->addItem(
mTextItem );
127 mLabelingOptionsListWidget->addItem(
mBufferItem );
128 mLabelingOptionsListWidget->addItem(
mMaskItem );
130 mLabelingOptionsListWidget->addItem(
mShadowItem );
135 QObject::connect( mOptionsTab, &QTabWidget::currentChanged,
this, [
this](
int index ) {
136 if ( index == mOptionsTab->indexOf( textTab ) )
137 mLabelStackedWidget->setCurrentWidget( mLabelPage_Text );
138 else if ( index == mOptionsTab->indexOf( formattingTab ) )
139 mLabelStackedWidget->setCurrentWidget( mLabelPage_Formatting );
140 else if ( index == mOptionsTab->indexOf( maskTab ) )
141 mLabelStackedWidget->setCurrentWidget( mLabelPage_Mask );
142 else if ( index == mOptionsTab->indexOf( bufferTab ) )
143 mLabelStackedWidget->setCurrentWidget( mLabelPage_Buffer );
144 else if ( index == mOptionsTab->indexOf( backgroundTab ) )
145 mLabelStackedWidget->setCurrentWidget( mLabelPage_Background );
146 else if ( index == mOptionsTab->indexOf( shadowTab ) )
147 mLabelStackedWidget->setCurrentWidget( mLabelPage_Shadow );
148 else if ( index == mOptionsTab->indexOf( calloutsTab ) )
149 mLabelStackedWidget->setCurrentWidget( mLabelPage_Callouts );
150 else if ( index == mOptionsTab->indexOf( placementTab ) )
151 mLabelStackedWidget->setCurrentWidget( mLabelPage_Placement );
152 else if ( index == mOptionsTab->indexOf( renderingTab ) )
153 mLabelStackedWidget->setCurrentWidget( mLabelPage_Rendering );
156 QObject::connect( mLabelingOptionsListWidget, &QListWidget::currentRowChanged,
this, [
this](
int ) {
157 QListWidgetItem *currentItem = mLabelingOptionsListWidget->currentItem();
161 mLabelStackedWidget->setCurrentWidget( mLabelPage_Text );
163 mLabelStackedWidget->setCurrentWidget( mLabelPage_Formatting );
165 mLabelStackedWidget->setCurrentWidget( mLabelPage_Mask );
167 mLabelStackedWidget->setCurrentWidget( mLabelPage_Buffer );
169 mLabelStackedWidget->setCurrentWidget( mLabelPage_Background );
171 mLabelStackedWidget->setCurrentWidget( mLabelPage_Shadow );
173 mLabelStackedWidget->setCurrentWidget( mLabelPage_Callouts );
175 mLabelStackedWidget->setCurrentWidget( mLabelPage_Placement );
177 mLabelStackedWidget->setCurrentWidget( mLabelPage_Rendering );
180 QObject::connect( mLabelingOptionsListWidget, &QListWidget::currentRowChanged, mLabelStackedWidget, &QStackedWidget::setCurrentIndex );
182 connect( mShapeSVGPathLineEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged );
183 connect( mFontSizeSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontSizeSpinBox_valueChanged );
184 connect( mFontFamilyCmbBx, &QFontComboBox::currentFontChanged,
this, &QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged );
185 connect( mFontStyleComboBox, &QComboBox::currentTextChanged,
this, &QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged );
186 connect( mFontUnderlineBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontUnderlineBtn_toggled );
187 connect( mFontStrikethroughBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontStrikethroughBtn_toggled );
188 connect( mFontWordSpacingSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged );
189 connect( mFontLetterSpacingSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged );
191 connect( mFontMinPixelSpinBox,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged );
192 connect( mFontMaxPixelSpinBox,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged );
201 connect( mShapeTypeCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged );
202 connect( mShapeRotationCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged );
203 connect( mShapeSVGParamsBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGParamsBtn_clicked );
204 connect( mShapeSVGSelectorBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked );
205 connect( mPreviewTextEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mPreviewTextEdit_textChanged );
206 connect( mPreviewTextBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mPreviewTextBtn_clicked );
208 connect( mDirectSymbLeftToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked );
209 connect( mDirectSymbRightToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked );
210 connect( chkLineOrientationDependent, &QCheckBox::toggled,
this, &QgsTextFormatWidget::chkLineOrientationDependent_toggled );
211 connect( mToolButtonConfigureSubstitutes, &QToolButton::clicked,
this, &QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked );
212 connect( mKerningCheckBox, &QCheckBox::toggled,
this, &QgsTextFormatWidget::kerningToggled );
213 connect( mComboOverlapHandling, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::overlapModeChanged );
214 connect( mTabStopsButton, &QToolButton::clicked,
this, &QgsTextFormatWidget::configureTabStops );
217 mOptionsTab->setIconSize( QSize( iconSize, iconSize ) );
218 mLabelingOptionsListWidget->setIconSize( QSize( iconSize, iconSize ) );
224 mPreviewTextBtn->setIconSize( QSize( iconSize16, iconSize16 ) );
225 mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
226 mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
227 mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );
228 mPointOffsetLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
229 mPointOffsetOver->setIconSize( QSize( iconSize32, iconSize18 ) );
230 mPointOffsetRight->setIconSize( QSize( iconSize32, iconSize18 ) );
231 mPointOffsetBelowLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
232 mPointOffsetBelow->setIconSize( QSize( iconSize32, iconSize18 ) );
233 mPointOffsetBelowRight->setIconSize( QSize( iconSize32, iconSize18 ) );
234 mLabelMinScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomOut.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
235 mLabelMaxScale->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomIn.svg" ) ).pixmap( QSize( iconSize24, iconSize24 ) ) );
238 mFontUnderlineBtn->setMinimumSize( buttonSize, buttonSize );
239 mFontUnderlineBtn->setMaximumSize( buttonSize, buttonSize );
240 mFontStrikethroughBtn->setMinimumSize( buttonSize, buttonSize );
241 mFontStrikethroughBtn->setMaximumSize( buttonSize, buttonSize );
242 mFontBoldBtn->setMinimumSize( buttonSize, buttonSize );
243 mFontBoldBtn->setMaximumSize( buttonSize, buttonSize );
244 mFontItalicBtn->setMinimumSize( buttonSize, buttonSize );
245 mFontItalicBtn->setMaximumSize( buttonSize, buttonSize );
247 mPreviewScaleComboBox->setMapCanvas(
mMapCanvas );
248 mPreviewScaleComboBox->setShowCurrentScaleButton(
true );
251 const auto unitWidgets = findChildren<QgsUnitSelectionWidget *>();
252 for ( QgsUnitSelectionWidget *unitWidget : unitWidgets )
273 mFontLineHeightSpinBox->setClearValue( 100.0 );
274 mShapeRotationDblSpnBx->setClearValue( 0.0 );
275 mShapeOffsetXSpnBx->setClearValue( 0.0 );
276 mShapeOffsetYSpnBx->setClearValue( 0.0 );
277 mPointOffsetXSpinBox->setClearValue( 0.0 );
278 mPointOffsetYSpinBox->setClearValue( 0.0 );
279 mPointAngleSpinBox->setClearValue( 0.0 );
280 mFontLetterSpacingSpinBox->setClearValue( 0.0 );
281 mFontWordSpacingSpinBox->setClearValue( 0.0 );
282 mZIndexSpinBox->setClearValue( 0.0 );
283 mLineDistanceSpnBx->setClearValue( 0.0 );
284 mMaximumDistanceSpnBx->setMinimum( 0 );
285 mMaximumDistanceSpnBx->setClearValue( 0.0, tr(
"Not set" ) );
286 mSpinStretch->setClearValue( 100 );
287 mTabStopDistanceSpin->setMinimum( 0 );
291 mFontLineHeightSpinBox->setClearValue( 100.0 );
293 mFontLineHeightSpinBox->setClearValue( 10.0 );
313 updateAvailableShadowPositions();
316 mBackgroundMarkerSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
317 mBackgroundMarkerSymbolButton->registerExpressionContextGenerator(
this );
318 mBackgroundMarkerSymbolButton->setMapCanvas(
mMapCanvas );
320 mBackgroundFillSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
321 mBackgroundFillSymbolButton->registerExpressionContextGenerator(
this );
322 mBackgroundFillSymbolButton->setMapCanvas(
mMapCanvas );
324 mCharDlg =
new QgsCharacterSelectorDialog(
this );
326 mRefFont = lblFontPreview->font();
329 connect( mShadowOffsetAngleDial, &QAbstractSlider::valueChanged, mShadowOffsetAngleSpnBx, &QSpinBox::setValue );
330 connect( mShadowOffsetAngleSpnBx,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ), mShadowOffsetAngleDial, &QAbstractSlider::setValue );
331 connect( mLimitLabelChkBox, &QAbstractButton::toggled, mLimitLabelSpinBox, &QWidget::setEnabled );
332 connect( mCheckBoxSubstituteText, &QAbstractButton::toggled, mToolButtonConfigureSubstitutes, &QWidget::setEnabled );
342 populateFontCapitalsComboBox();
345 mPreviewBackgroundBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
346 mPreviewBackgroundBtn->setContext( QStringLiteral(
"labeling" ) );
347 mPreviewBackgroundBtn->setColor( QColor( 255, 255, 255 ) );
348 btnTextColor->setColorDialogTitle( tr(
"Select Text Color" ) );
349 btnTextColor->setContext( QStringLiteral(
"labeling" ) );
350 btnTextColor->setDefaultColor( Qt::black );
351 btnBufferColor->setColorDialogTitle( tr(
"Select Buffer Color" ) );
352 btnBufferColor->setContext( QStringLiteral(
"labeling" ) );
353 btnBufferColor->setDefaultColor( Qt::white );
354 mShapeStrokeColorBtn->setColorDialogTitle( tr(
"Select Stroke Color" ) );
355 mShapeStrokeColorBtn->setContext( QStringLiteral(
"labeling" ) );
356 mShapeFillColorBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
357 mShapeFillColorBtn->setContext( QStringLiteral(
"labeling" ) );
358 mShadowColorBtn->setColorDialogTitle( tr(
"Select Shadow Color" ) );
359 mShadowColorBtn->setContext( QStringLiteral(
"labeling" ) );
360 mShadowColorBtn->setDefaultColor( Qt::black );
362 mFontColorDDBtn->registerLinkedWidget( btnTextColor );
363 mBufferColorDDBtn->registerLinkedWidget( btnBufferColor );
364 mShapeStrokeColorDDBtn->registerLinkedWidget( mShapeStrokeColorBtn );
365 mShapeFillColorDDBtn->registerLinkedWidget( mShapeFillColorBtn );
366 mShadowColorDDBtn->registerLinkedWidget( mShadowColorBtn );
407 const auto groupBoxes = findChildren<QgsCollapsibleGroupBox *>();
408 for ( QgsCollapsibleGroupBox *grpbox : groupBoxes )
410 grpbox->setSettingGroup( QStringLiteral(
"mAdvLabelingDlg" ) );
416 mLabelingOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect,
false );
418 const QgsSettings settings;
421 QSizePolicy policy( mLabelingOptionsListFrame->sizePolicy() );
422 policy.setHorizontalStretch( 0 );
423 mLabelingOptionsListFrame->setSizePolicy( policy );
424 if ( !settings.
contains( QStringLiteral(
"/Windows/Labeling/OptionsSplitState" ) ) )
427 QList<int> splitsizes;
429 mLabelingOptionsSplitter->setSizes( splitsizes );
433 connect( mLabelStackedWidget, &QStackedWidget::currentChanged,
this, &QgsTextFormatWidget::optionsStackedWidget_CurrentChanged );
436 mFontPreviewSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ) ).toByteArray() );
437 mLabelingOptionsSplitter->restoreState( settings.
value( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ) ).toByteArray() );
439 mLabelingOptionsListWidget->setCurrentRow( settings.
value( QStringLiteral(
"Windows/Labeling/Tab" ), 0 ).toInt() );
443 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
447 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
451 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
453 overlapModeChanged();
455#if defined( HAS_KDE_QT5_FONT_STRETCH_FIX ) || ( QT_VERSION >= QT_VERSION_CHECK( 6, 3, 0 ) )
458 mLabelStretch->hide();
459 mSpinStretch->hide();
460 mFontStretchDDBtn->hide();
465 QList<QWidget *> widgets;
466 widgets << btnBufferColor
468 << chkLabelPerFeaturePart
472 << chkLineOrientationDependent
474 << chkPreserveRotation
476 << comboBufferBlendMode
478 << mBufferJoinStyleComboBox
479 << mBufferTranspFillChbx
480 << mBufferOpacityWidget
481 << mCentroidInsideCheckBox
483 << mCoordRotationUnitComboBox
485 << mDirectSymbLeftLineEdit
486 << mDirectSymbRevChkBx
487 << mDirectSymbRightLineEdit
488 << mFitInsidePolygonCheckBox
489 << mFontCapitalsComboBox
490 << mFontLetterSpacingSpinBox
491 << mFontLimitPixelChkBox
492 << mFontLineHeightSpinBox
493 << mLineHeightUnitWidget
494 << mFontMaxPixelSpinBox
495 << mFontMinPixelSpinBox
496 << mFontMultiLineAlignComboBox
498 << mFontStyleComboBox
499 << mTextOrientationComboBox
500 << mTextOpacityWidget
502 << mFontWordSpacingSpinBox
504 << mFormatNumDecimalsSpnBx
505 << mFormatNumPlusSignChkBx
507 << mLimitLabelSpinBox
508 << mLineDistanceSpnBx
509 << mLineDistanceUnitWidget
510 << mMaximumDistanceSpnBx
511 << mMaximumDistanceUnitWidget
512 << mMaxCharAngleInDSpinBox
513 << mMaxCharAngleOutDSpinBox
515 << mOffsetTypeComboBox
516 << mCheckAllowDegradedPlacement
517 << mComboOverlapHandling
518 << mPointAngleSpinBox
519 << mPointOffsetUnitWidget
520 << mPointOffsetXSpinBox
521 << mPointOffsetYSpinBox
522 << mPreviewBackgroundBtn
525 << mRepeatDistanceSpinBox
526 << mRepeatDistanceUnitWidget
527 << mOverrunDistanceSpinBox
528 << mOverrunDistanceUnitWidget
529 << mLabelMarginSpinBox
530 << mLabelMarginUnitWidget
531 << mScaleBasedVisibilityChkBx
537 << mShadowOffsetAngleSpnBx
538 << mShadowOffsetGlobalChkBx
539 << mShadowOffsetSpnBx
540 << mShadowOffsetUnitWidget
541 << mShadowRadiusAlphaChkBx
542 << mShadowRadiusDblSpnBx
543 << mShadowRadiusUnitWidget
545 << mShadowOpacityWidget
548 << mShapeStrokeColorBtn
549 << mShapeStrokeWidthSpnBx
550 << mShapeStrokeWidthUnitWidget
552 << mShapeFillColorBtn
553 << mShapeOffsetXSpnBx
554 << mShapeOffsetYSpnBx
555 << mShapeOffsetUnitWidget
556 << mShapeRadiusXDbSpnBx
557 << mShapeRadiusYDbSpnBx
558 << mShapeRotationCmbBx
559 << mShapeRotationDblSpnBx
560 << mShapeRadiusUnitWidget
561 << mShapeSVGPathLineEdit
563 << mShapeSizeUnitWidget
566 << mBackgroundOpacityWidget
571 << mAutoWrapLengthSpinBox
572 << mAutoWrapTypeComboBox
573 << mCentroidRadioVisible
574 << mCentroidRadioWhole
575 << mDirectSymbRadioBtnAbove
576 << mDirectSymbRadioBtnBelow
577 << mDirectSymbRadioBtnLR
578 << mUpsidedownRadioAll
579 << mUpsidedownRadioDefined
580 << mUpsidedownRadioOff
581 << mPlacementModeComboBox
582 << mFieldExpressionWidget
583 << mCheckBoxSubstituteText
584 << mGeometryGeneratorGroupBox
585 << mGeometryGenerator
586 << mGeometryGeneratorType
587 << mBackgroundMarkerSymbolButton
588 << mBackgroundFillSymbolButton
589 << mCalloutsDrawCheckBox
590 << mCalloutStyleComboBox
593 << mMaskJoinStyleComboBox
594 << mMaskBufferSizeSpinBox
595 << mMaskOpacityWidget
596 << mCheckAllowLabelsOutsidePolygons
597 << mHtmlFormattingCheckBox
598 << mPrioritizationComboBox
599 << mTabDistanceUnitWidget
600 << mTabStopDistanceSpin
603 connectValueChanged( widgets );
608 connect( mBufferDrawChkBx, &QCheckBox::stateChanged,
this, [
this](
int ) {
609 updateBufferFrameStatus();
612 connect( mShapeDrawChkBx, &QCheckBox::stateChanged,
this, [
this](
int ) {
613 updateShapeFrameStatus();
616 connect( mShadowDrawChkBx, &QCheckBox::stateChanged,
this, [
this](
int ) {
617 updateShadowFrameStatus();
620 connect( mCalloutsDrawCheckBox, &QCheckBox::stateChanged,
this, [
this](
int ) {
621 updateCalloutFrameStatus();
629 whileBlocking( mOptionsTab )->setCurrentIndex( mLabelStackedWidget->currentIndex() );
630 mOptionsTab->tabBar()->setUsesScrollButtons(
true );
635 lblFontPreview->setMapUnits(
mMapCanvas->mapSettings().mapUnits() );
636 mPreviewScaleComboBox->setScale(
mMapCanvas->mapSettings().scale() );
658 const int prevIndex = mOptionsTab->currentIndex();
668 mOptionsTab->removeTab( mOptionsTab->indexOf( renderingTab ) );
669 mOptionsTab->removeTab( mOptionsTab->indexOf( placementTab ) );
670 mOptionsTab->removeTab( mOptionsTab->indexOf( calloutsTab ) );
671 mOptionsTab->removeTab( mOptionsTab->indexOf( maskTab ) );
672 mLabelStackedWidget->removeWidget( mLabelPage_Rendering );
673 mLabelStackedWidget->removeWidget( mLabelPage_Callouts );
674 mLabelStackedWidget->removeWidget( mLabelPage_Mask );
675 mLabelStackedWidget->removeWidget( mLabelPage_Placement );
685 mLabelStackedWidget->setCurrentIndex( prevIndex - 1 );
686 mOptionsTab->setCurrentIndex( prevIndex - 1 );
693 mLabelStackedWidget->setCurrentIndex( 0 );
694 mOptionsTab->setCurrentIndex( 0 );
698 mStackedWidgetLabelWith->hide();
699 mDirectSymbolsFrame->hide();
700 mFormatNumFrame->hide();
701 mFormatNumChkBx->hide();
702 mFormatNumDDBtn->hide();
703 mCheckBoxSubstituteText->hide();
704 mToolButtonConfigureSubstitutes->hide();
705 mLabelWrapOnCharacter->hide();
706 wrapCharacterEdit->hide();
707 mWrapCharDDBtn->hide();
708 mLabelWrapLinesTo->hide();
709 mAutoWrapLengthSpinBox->hide();
710 mAutoWrapLengthDDBtn->hide();
711 mAutoWrapTypeComboBox->hide();
712 mFontMultiLineLabel->hide();
713 mFontMultiLineAlignComboBox->hide();
714 mFontMultiLineAlignDDBtn->hide();
724 const QList<QgsPropertyOverrideButton *> buttons = findChildren<QgsPropertyOverrideButton *>();
727#if defined( HAS_KDE_QT5_FONT_STRETCH_FIX ) || ( QT_VERSION >= QT_VERSION_CHECK( 6, 3, 0 ) )
730 if ( button == mFontStretchDDBtn )
733 button->setVisible( visible );
739 mOptionsTab->setVisible( enabled );
740 if (
int tabIndex = mOptionsTab->indexOf( textTab ); tabIndex >= 0 )
741 mOptionsTab->setTabToolTip( tabIndex, tr(
"Text" ) );
742 if (
int tabIndex = mOptionsTab->indexOf( formattingTab ); tabIndex >= 0 )
743 mOptionsTab->setTabToolTip( tabIndex, tr(
"Formatting" ) );
744 if (
int tabIndex = mOptionsTab->indexOf( bufferTab ); tabIndex >= 0 )
745 mOptionsTab->setTabToolTip( tabIndex, tr(
"Buffer" ) );
746 if (
int tabIndex = mOptionsTab->indexOf( maskTab ); tabIndex >= 0 )
747 mOptionsTab->setTabToolTip( tabIndex, tr(
"Mask" ) );
748 if (
int tabIndex = mOptionsTab->indexOf( backgroundTab ); tabIndex >= 0 )
749 mOptionsTab->setTabToolTip( tabIndex, tr(
"Background" ) );
750 if (
int tabIndex = mOptionsTab->indexOf( shadowTab ); tabIndex >= 0 )
751 mOptionsTab->setTabToolTip( tabIndex, tr(
"Shadow" ) );
752 if (
int tabIndex = mOptionsTab->indexOf( calloutsTab ); tabIndex >= 0 )
753 mOptionsTab->setTabToolTip( tabIndex, tr(
"Callouts" ) );
754 if (
int tabIndex = mOptionsTab->indexOf( placementTab ); tabIndex >= 0 )
755 mOptionsTab->setTabToolTip( tabIndex, tr(
"Placement" ) );
756 if (
int tabIndex = mOptionsTab->indexOf( renderingTab ); tabIndex >= 0 )
757 mOptionsTab->setTabToolTip( tabIndex, tr(
"Rendering" ) );
759 mLabelingOptionsListFrame->setVisible( !enabled );
760 groupBox_mPreview->setVisible( !enabled );
764void QgsTextFormatWidget::connectValueChanged(
const QList<QWidget *> &widgets )
766 const auto constWidgets = widgets;
767 for ( QWidget *widget : constWidgets )
773 else if ( QgsFieldExpressionWidget *w = qobject_cast<QgsFieldExpressionWidget *>( widget ) )
777 else if ( QgsOpacityWidget *w = qobject_cast<QgsOpacityWidget *>( widget ) )
781 else if ( QgsScaleWidget *w = qobject_cast<QgsScaleWidget *>( widget ) )
785 else if ( QgsUnitSelectionWidget *w = qobject_cast<QgsUnitSelectionWidget *>( widget ) )
789 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
793 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
797 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
801 else if ( QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
805 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
809 else if ( QRadioButton *w = qobject_cast<QRadioButton *>( widget ) )
813 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
817 else if ( QSlider *w = qobject_cast<QSlider *>( widget ) )
821 else if ( QGroupBox *w = qobject_cast<QGroupBox *>( widget ) )
825 else if ( QgsCodeEditorExpression *w = qobject_cast<QgsCodeEditorExpression *>( widget ) )
831 QgsLogger::warning( QStringLiteral(
"Could not create connection for widget %1" ).arg( widget->objectName() ) );
864 mDirectSymbDDBtn->registerCheckedWidget( mDirectSymbChkBx );
872 mFormatNumDDBtn->registerCheckedWidget( mFormatNumChkBx );
887 mEnableMaskDDBtn->registerCheckedWidget( mEnableMaskChkBx );
895 mShapeDrawDDBtn->registerCheckedWidget( mShapeDrawChkBx );
917 mShadowDrawDDBtn->registerCheckedWidget( mShadowDrawChkBx );
962 updateDataDefinedAlignment();
965 const QString ddScaleVisInfo = tr(
"Value < 0 represents a scale closer than 1:1, e.g. -10 = 10:1<br>"
966 "Value of 0 disables the specific limit." );
968 mScaleBasedVisibilityDDBtn->registerCheckedWidget( mScaleBasedVisibilityChkBx );
970 mScaleBasedVisibilityMinDDBtn->setUsageInfo( ddScaleVisInfo );
972 mScaleBasedVisibilityMaxDDBtn->setUsageInfo( ddScaleVisInfo );
978 mMinScaleWidget->setPredefinedScales( scales );
979 mMaxScaleWidget->setPredefinedScales( scales );
984 mMinScaleWidget->updateScales();
985 mMaxScaleWidget->updateScales();
989 mFontLimitPixelDDBtn->registerCheckedWidget( mFontLimitPixelChkBox );
1012 if ( !mButtons.contains( key ) )
1017 mButtons[key] = button;
1037 mBufferDrawChkBx->setChecked( buffer.
enabled() );
1038 mBufferFrame->setEnabled( buffer.
enabled() );
1039 spinBufferSize->setValue( buffer.
size() );
1040 mBufferUnitWidget->setUnit( buffer.
sizeUnit() );
1042 btnBufferColor->setColor( buffer.
color() );
1043 mBufferOpacityWidget->setOpacity( buffer.
opacity() );
1044 mBufferJoinStyleComboBox->setPenJoinStyle( buffer.
joinStyle() );
1046 comboBufferBlendMode->setBlendMode( buffer.
blendMode() );
1048 mBufferEffect.reset( lPaintEffect->clone() );
1052 mBufferEffect->setEnabled(
false );
1054 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
1058 mEnableMaskChkBx->setChecked( mask.
enabled() );
1059 mMaskBufferSizeSpinBox->setValue( mask.
size() );
1060 mMaskBufferUnitWidget->setUnit( mask.
sizeUnit() );
1062 mMaskOpacityWidget->setOpacity( mask.
opacity() );
1063 mMaskJoinStyleComboBox->setPenJoinStyle( mask.
joinStyle() );
1065 mMaskEffect.reset( lPaintEffect->clone() );
1069 mMaskEffect->setEnabled(
false );
1071 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
1073 mFontSizeUnitWidget->setUnit(
format.sizeUnit() );
1074 mFontSizeUnitWidget->setMapUnitScale(
format.sizeMapUnitScale() );
1075 mRefFont =
format.font();
1076 mFontSizeSpinBox->setValue(
format.size() );
1077 btnTextColor->setColor(
format.color() );
1079 mTextOpacityWidget->setOpacity(
format.opacity() );
1080 comboBlendMode->setBlendMode(
format.blendMode() );
1081 mTextOrientationComboBox->setCurrentIndex( mTextOrientationComboBox->findData(
static_cast<int>(
format.orientation() ) ) );
1082 mHtmlFormattingCheckBox->setChecked(
format.allowHtmlFormatting() );
1084 mFontWordSpacingSpinBox->setValue(
format.font().wordSpacing() );
1085 mFontLetterSpacingSpinBox->setValue(
format.font().letterSpacing() );
1088 mTabDistanceUnitWidget->setUnit(
format.tabStopDistanceUnit() );
1089 mTabDistanceUnitWidget->setMapUnitScale(
format.tabStopDistanceMapUnitScale() );
1092 whileBlocking( mFontCapitalsComboBox )->setCurrentIndex( mFontCapitalsComboBox->findData(
static_cast<int>(
format.capitalization() ) ) );
1094 updateFont( mRefFont );
1097 mFontMissingLabel->setVisible( !
format.fontFound() );
1098 if ( !
format.fontFound() )
1100 const QString missingTxt = tr(
"%1 not found. Default substituted." );
1101 QString txtPrepend = tr(
"Chosen font" );
1102 if ( !
format.resolvedFontFamily().isEmpty() )
1104 txtPrepend = QStringLiteral(
"'%1'" ).arg(
format.resolvedFontFamily() );
1106 mFontMissingLabel->setText( missingTxt.arg( txtPrepend ) );
1109 mLabelingOptionsListWidget->setCurrentItem(
mTextItem );
1110 whileBlocking( mOptionsTab )->setCurrentIndex( mOptionsTab->indexOf( textTab ) );
1113 mLineHeightUnitWidget->setUnit(
format.lineHeightUnit() );
1116 mShapeDrawChkBx->setChecked( background.
enabled() );
1117 mShapeFrame->setEnabled( background.
enabled() );
1118 mShapeTypeCmbBx->blockSignals(
true );
1119 mShapeTypeCmbBx->setCurrentIndex( mShapeTypeCmbBx->findData( background.
type() ) );
1120 mShapeTypeCmbBx->blockSignals(
false );
1121 updateAvailableShadowPositions();
1122 mShapeSVGPathLineEdit->setText( background.
svgFile() );
1124 mShapeSizeCmbBx->setCurrentIndex( background.
sizeType() );
1125 mShapeSizeXSpnBx->setValue( background.
size().width() );
1126 mShapeSizeYSpnBx->setValue( background.
size().height() );
1127 mShapeSizeUnitWidget->setUnit( background.
sizeUnit() );
1129 mShapeRotationCmbBx->setCurrentIndex( background.
rotationType() );
1132 mShapeRotationDblSpnBx->setValue( background.
rotation() );
1133 mShapeOffsetXSpnBx->setValue( background.
offset().x() );
1134 mShapeOffsetYSpnBx->setValue( background.
offset().y() );
1135 mShapeOffsetUnitWidget->setUnit( background.
offsetUnit() );
1137 mShapeRadiusXDbSpnBx->setValue( background.
radii().width() );
1138 mShapeRadiusYDbSpnBx->setValue( background.
radii().height() );
1139 mShapeRadiusUnitWidget->setUnit( background.
radiiUnit() );
1142 mShapeFillColorBtn->setColor( background.
fillColor() );
1143 mShapeStrokeColorBtn->setColor( background.
strokeColor() );
1144 mShapeStrokeWidthSpnBx->setValue( background.
strokeWidth() );
1148 mBackgroundOpacityWidget->setOpacity( background.
opacity() );
1149 mShapeBlendCmbBx->setBlendMode( background.
blendMode() );
1151 mLoadSvgParams =
false;
1152 mShapeTypeCmbBx_currentIndexChanged( background.
type() );
1154 if (
auto *lPaintEffect = background.
paintEffect() )
1155 mBackgroundEffect.reset( lPaintEffect->clone() );
1159 mBackgroundEffect->setEnabled(
false );
1161 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
1167 mShadowDrawChkBx->setChecked( shadow.
enabled() );
1168 mShadowFrame->setEnabled( shadow.
enabled() );
1169 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( shadow.
shadowPlacement() ) );
1170 mShadowOffsetAngleSpnBx->setValue( shadow.
offsetAngle() );
1172 mShadowOffsetUnitWidget->setUnit( shadow.
offsetUnit() );
1174 mShadowOffsetGlobalChkBx->setChecked( shadow.
offsetGlobal() );
1176 mShadowRadiusDblSpnBx->setValue( shadow.
blurRadius() );
1179 mShadowRadiusAlphaChkBx->setChecked( shadow.
blurAlphaOnly() );
1180 mShadowOpacityWidget->setOpacity( shadow.
opacity() );
1181 mShadowScaleSpnBx->setValue( shadow.
scale() );
1183 mShadowColorBtn->setColor( shadow.
color() );
1184 mShadowBlendCmbBx->setBlendMode( shadow.
blendMode() );
1186 mPreviewBackgroundBtn->setColor(
format.previewBackgroundColor() );
1187 mPreviewBackgroundBtn->setDefaultColor(
format.previewBackgroundColor() );
1196 settings.
setValue( QStringLiteral(
"Windows/Labeling/FontPreviewSplitState" ), mFontPreviewSplitter->saveState() );
1197 settings.
setValue( QStringLiteral(
"Windows/Labeling/OptionsSplitState" ), mLabelingOptionsSplitter->saveState() );
1199 int prevIndex = mLabelingOptionsListWidget->currentRow();
1200 if ( mWidgetMode ==
Text )
1202 switch ( prevIndex )
1211 settings.
setValue( QStringLiteral(
"Windows/Labeling/Tab" ), prevIndex );
1217 format.setColor( btnTextColor->color() );
1218 format.setFont( mRefFont );
1219 format.setSize( mFontSizeSpinBox->value() );
1220 format.setNamedStyle( mFontStyleComboBox->currentText() );
1221 format.setOpacity( mTextOpacityWidget->opacity() );
1222 format.setStretchFactor( mSpinStretch->value() );
1223 format.setBlendMode( comboBlendMode->blendMode() );
1224 format.setSizeUnit( mFontSizeUnitWidget->unit() );
1225 format.setSizeMapUnitScale( mFontSizeUnitWidget->getMapUnitScale() );
1227 format.setLineHeightUnit( mLineHeightUnitWidget->unit() );
1228 format.setPreviewBackgroundColor( mPreviewBackgroundColor );
1230 format.setAllowHtmlFormatting( mHtmlFormattingCheckBox->isChecked() );
1232 format.setTabStopDistance( mTabDistanceUnitWidget->unit() ==
Qgis::RenderUnit::Percentage ? ( mTabStopDistanceSpin->value() / 100 ) : mTabStopDistanceSpin->value() );
1233 format.setTabStopDistanceUnit( mTabDistanceUnitWidget->unit() );
1234 format.setTabStopDistanceMapUnitScale( mTabDistanceUnitWidget->getMapUnitScale() );
1239 buffer.
setEnabled( mBufferDrawChkBx->isChecked() );
1240 buffer.
setSize( spinBufferSize->value() );
1241 buffer.
setColor( btnBufferColor->color() );
1242 buffer.
setOpacity( mBufferOpacityWidget->opacity() );
1245 buffer.
setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
1247 buffer.
setBlendMode( comboBufferBlendMode->blendMode() );
1252 format.setBuffer( buffer );
1256 mask.
setEnabled( mEnableMaskChkBx->isChecked() );
1257 mask.
setSize( mMaskBufferSizeSpinBox->value() );
1258 mask.
setOpacity( mMaskOpacityWidget->opacity() );
1259 mask.
setSizeUnit( mMaskBufferUnitWidget->unit() );
1261 mask.
setJoinStyle( mMaskJoinStyleComboBox->penJoinStyle() );
1271 background.
setEnabled( mShapeDrawChkBx->isChecked() );
1273 background.
setSvgFile( mShapeSVGPathLineEdit->text() );
1275 background.
setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
1276 background.
setSizeUnit( mShapeSizeUnitWidget->unit() );
1279 background.
setRotation( mShapeRotationDblSpnBx->value() );
1280 background.
setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
1283 background.
setRadii( QSizeF( mShapeRadiusXDbSpnBx->value(), mShapeRadiusYDbSpnBx->value() ) );
1284 background.
setRadiiUnit( mShapeRadiusUnitWidget->unit() );
1287 background.
setFillColor( mShapeFillColorBtn->color() );
1292 background.
setOpacity( mBackgroundOpacityWidget->opacity() );
1293 background.
setBlendMode( mShapeBlendCmbBx->blendMode() );
1300 format.setBackground( background );
1304 shadow.
setEnabled( mShadowDrawChkBx->isChecked() );
1315 shadow.
setOpacity( mShadowOpacityWidget->opacity() );
1316 shadow.
setScale( mShadowScaleSpnBx->value() );
1317 shadow.
setColor( mShadowColorBtn->color() );
1319 format.setShadow( shadow );
1321 if ( includeDataDefinedProperties )
1352 if ( mButtons.contains( key ) )
1361void QgsTextFormatWidget::optionsStackedWidget_CurrentChanged(
int )
1363 mLabelingOptionsListWidget->blockSignals(
true );
1364 QWidget *currentPage = mLabelStackedWidget->currentWidget();
1365 if ( currentPage == mLabelPage_Text )
1366 mLabelingOptionsListWidget->setCurrentItem(
mTextItem );
1367 else if ( currentPage == mLabelPage_Formatting )
1369 else if ( currentPage == mLabelPage_Mask )
1370 mLabelingOptionsListWidget->setCurrentItem(
mMaskItem );
1371 if ( currentPage == mLabelPage_Buffer )
1372 mLabelingOptionsListWidget->setCurrentItem(
mBufferItem );
1373 if ( currentPage == mLabelPage_Background )
1375 if ( currentPage == mLabelPage_Shadow )
1376 mLabelingOptionsListWidget->setCurrentItem(
mShadowItem );
1377 if ( currentPage == mLabelPage_Callouts )
1378 mLabelingOptionsListWidget->setCurrentItem(
mCalloutItem );
1379 if ( currentPage == mLabelPage_Rendering )
1381 if ( currentPage == mLabelPage_Placement )
1383 mLabelingOptionsListWidget->blockSignals(
false );
1390 if (
auto *lExpressionContext =
mContext.expressionContext() )
1392 mPreviewExpressionContext = *lExpressionContext;
1397 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
1400 symbolWidget->setMapCanvas(
mContext.mapCanvas() );
1401 symbolWidget->setMessageBar(
mContext.messageBar() );
1405void QgsTextFormatWidget::collapseSample(
bool collapse )
1409 QList<int> splitSizes = mFontPreviewSplitter->sizes();
1410 if ( splitSizes[0] > groupBox_mPreview->height() )
1412 const int delta = splitSizes[0] - groupBox_mPreview->height();
1413 splitSizes[0] -= delta;
1414 splitSizes[1] += delta;
1415 mFontPreviewSplitter->setSizes( splitSizes );
1420void QgsTextFormatWidget::changeTextColor(
const QColor &color )
1426void QgsTextFormatWidget::updateFont(
const QFont &newFont )
1429 if ( newFont != mRefFont )
1438 QFont symbolFont = mRefFont;
1439 symbolFont.setPointSize( font().pointSize() );
1440 mDirectSymbLeftLineEdit->setFont( symbolFont );
1441 mDirectSymbRightLineEdit->setFont( symbolFont );
1443 blockFontChangeSignals(
true );
1444 mFontFamilyCmbBx->setCurrentFont( symbolFont );
1445 populateFontStyleComboBox();
1446 mFontUnderlineBtn->setChecked( mRefFont.underline() );
1447 mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
1448 mKerningCheckBox->setChecked( mRefFont.kerning() );
1449 blockFontChangeSignals(
false );
1457void QgsTextFormatWidget::blockFontChangeSignals(
bool blk )
1459 mFontFamilyCmbBx->blockSignals( blk );
1460 mFontStyleComboBox->blockSignals( blk );
1461 mFontCapitalsComboBox->blockSignals( blk );
1462 mFontUnderlineBtn->blockSignals( blk );
1463 mFontStrikethroughBtn->blockSignals( blk );
1464 mFontWordSpacingSpinBox->blockSignals( blk );
1465 mFontLetterSpacingSpinBox->blockSignals( blk );
1466 mKerningCheckBox->blockSignals( blk );
1481 lblFontPreview->setFormat(
format() );
1484void QgsTextFormatWidget::scrollPreview()
1486 scrollArea_mPreview->ensureVisible( 0, 0, 0, 0 );
1491 mPreviewBackgroundColor = color;
1493 scrollArea_mPreview->widget()->setStyleSheet( QStringLiteral(
"background: rgb(%1, %2, %3);" ).arg( QString::number( color.red() ), QString::number( color.green() ), QString::number( color.blue() ) ) );
1496void QgsTextFormatWidget::changeBufferColor(
const QColor &color )
1505 bool showLineFrame =
false;
1506 bool showCentroidFrame =
false;
1507 bool showQuadrantFrame =
false;
1508 bool showFixedQuadrantFrame =
false;
1509 bool showPlacementPriorityFrame =
false;
1510 bool showOffsetTypeFrame =
false;
1511 bool showOffsetFrame =
false;
1512 bool showDistanceFrame =
false;
1513 bool showMaximumDistanceFrame =
false;
1514 bool showPrioritizationFrame =
false;
1515 bool showRotationFrame =
false;
1516 bool showMaxCharAngleFrame =
false;
1521 bool enableMultiLinesFrame =
true;
1527 showDistanceFrame =
true;
1528 showMaximumDistanceFrame =
true;
1536 showQuadrantFrame =
true;
1537 showFixedQuadrantFrame =
true;
1538 showOffsetFrame =
true;
1539 showRotationFrame =
true;
1543 showDistanceFrame =
true;
1544 showMaximumDistanceFrame =
true;
1545 showPlacementPriorityFrame =
true;
1546 showPrioritizationFrame =
true;
1547 showOffsetTypeFrame =
true;
1554 showLineFrame =
true;
1555 showDistanceFrame =
true;
1558 const bool offline = chkLineAbove->isChecked() || chkLineBelow->isChecked();
1559 chkLineOrientationDependent->setEnabled( offline );
1560 mPlacementDistanceFrame->setEnabled( offline );
1564 showMaxCharAngleFrame = isCurved;
1566 enableMultiLinesFrame = !isCurved;
1571 showDistanceFrame =
true;
1574 mPlacementLineFrame->setVisible( showLineFrame );
1575 mPlacementPolygonFrame->setVisible( showPolygonPlacementOptions );
1576 mPlacementCentroidFrame->setVisible( showCentroidFrame );
1577 mPlacementQuadrantFrame->setVisible( showQuadrantFrame );
1578 mPlacementFixedQuadrantFrame->setVisible( showFixedQuadrantFrame );
1579 mPlacementCartographicFrame->setVisible( showPlacementPriorityFrame );
1580 mPlacementOffsetFrame->setVisible( showOffsetFrame );
1581 mPlacementDistanceFrame->setVisible( showDistanceFrame );
1582 mPlacementMaximumDistanceFrame->setVisible( showMaximumDistanceFrame );
1583 mPlacementPrioritizationFrame->setVisible( showPrioritizationFrame );
1584 mPlacementOffsetTypeFrame->setVisible( showOffsetTypeFrame );
1585 mPlacementRotationFrame->setVisible( showRotationFrame );
1589 mPlacementMaxCharAngleFrame->setVisible( showMaxCharAngleFrame );
1591 mMultiLinesFrame->setEnabled( enableMultiLinesFrame );
1595 switch ( currentPlacement )
1599 helperText = tr(
"Arranges label candidates in a clockwise circle around the feature, preferring placements to the top-right of the feature." );
1601 helperText = tr(
"Arranges label candidates in a cluster around the feature's centroid, preferring placements directly over the centroid." );
1605 helperText = tr(
"Arranges label candidates directly over the feature or at a preset offset from the feature." );
1607 helperText = tr(
"Arranges label candidates directly over the feature's centroid, or at a preset offset from the centroid." );
1611 helperText = tr(
"Arranges label candidates parallel to a generalised line representing the feature. Placements which fall over straighter portions of the line are preferred." );
1613 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." );
1617 helperText = tr(
"Arranges candidates following the curvature of a line feature. Placements which fall over straighter portions of the line are preferred." );
1621 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." );
1623 helperText = tr(
"Label candidates are arranged horizontally along the length of the feature." );
1627 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." );
1631 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." );
1635 helperText = tr(
"Arranges candidates following the curvature of the feature's perimeter. Placements which fall over straighter portions of the perimeter are preferred." );
1639 helperText = tr(
"Label candidates are placed outside of the features, preferring placements which give greatest visual association between the label and the feature." );
1642 mPlacementModeDescriptionLabel->setText( QStringLiteral(
"<i>%1</i>" ).arg( helperText ) );
1645void QgsTextFormatWidget::populateFontCapitalsComboBox()
1650#if defined( HAS_KDE_QT5_SMALL_CAPS_FIX ) || QT_VERSION >= QT_VERSION_CHECK( 6, 3, 0 )
1660void QgsTextFormatWidget::populateFontStyleComboBox()
1662 mFontStyleComboBox->clear();
1663 const QStringList styles = mFontDB.styles( mRefFont.family() );
1664 const auto constStyles = styles;
1665 for (
const QString &style : constStyles )
1667 mFontStyleComboBox->addItem( style );
1670 QString targetStyle = mFontDB.styleString( mRefFont );
1671 if ( !styles.contains( targetStyle ) )
1674 targetStyle = QFontInfo( f ).styleName();
1675 mRefFont.setStyleName( targetStyle );
1678 const int stylIndx = mFontStyleComboBox->findText( targetStyle );
1679 if ( stylIndx > -1 )
1684 mFontStyleComboBox->setCurrentIndex( curIndx );
1687void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged(
double d )
1689 mRefFont.setPointSizeF( d );
1690 updateFont( mRefFont );
1693void QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged(
const QFont &f )
1696 updateFont( mRefFont );
1699void QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged(
const QString &text )
1702 updateFont( mRefFont );
1705void QgsTextFormatWidget::mFontUnderlineBtn_toggled(
bool ckd )
1707 mRefFont.setUnderline( ckd );
1708 updateFont( mRefFont );
1711void QgsTextFormatWidget::mFontStrikethroughBtn_toggled(
bool ckd )
1713 mRefFont.setStrikeOut( ckd );
1714 updateFont( mRefFont );
1717void QgsTextFormatWidget::kerningToggled(
bool checked )
1719 mRefFont.setKerning( checked );
1720 updateFont( mRefFont );
1723void QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged(
double spacing )
1725 mRefFont.setWordSpacing( spacing );
1726 updateFont( mRefFont );
1729void QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged(
double spacing )
1731 mRefFont.setLetterSpacing( QFont::AbsoluteSpacing, spacing );
1732 updateFont( mRefFont );
1735void QgsTextFormatWidget::mFontSizeUnitWidget_changed()
1740 mFontLimitPixelChkBox->setChecked(
false );
1746 mFontLimitPixelChkBox->setChecked(
true );
1748 updateFont( mRefFont );
1751void QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged(
int px )
1754 mFontMaxPixelSpinBox->setMinimum( px );
1755 mFontMaxPixelSpinBox->update();
1758void QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged(
int px )
1761 if ( px < mFontMinPixelSpinBox->value() )
1763 mFontMaxPixelSpinBox->blockSignals(
true );
1764 mFontMaxPixelSpinBox->setValue( mFontMinPixelSpinBox->value() );
1765 mFontMaxPixelSpinBox->blockSignals(
false );
1767 mFontMaxPixelSpinBox->setMinimum( mFontMinPixelSpinBox->value() );
1770void QgsTextFormatWidget::mBufferUnitWidget_changed()
1772 updateFont( mRefFont );
1775void QgsTextFormatWidget::mMaskBufferUnitWidget_changed()
1777 updateFont( mRefFont );
1780void QgsTextFormatWidget::mCoordXDDBtn_changed()
1782 updateDataDefinedAlignment();
1785void QgsTextFormatWidget::mCoordXDDBtn_activated(
bool isActive )
1790 mCoordPointDDBtn->setActive(
false );
1793void QgsTextFormatWidget::mCoordYDDBtn_changed()
1795 updateDataDefinedAlignment();
1798void QgsTextFormatWidget::mCoordYDDBtn_activated(
bool isActive )
1803 mCoordPointDDBtn->setActive(
false );
1806void QgsTextFormatWidget::mCoordPointDDBtn_changed()
1808 updateDataDefinedAlignment();
1811void QgsTextFormatWidget::mCoordPointDDBtn_activated(
bool isActive )
1816 mCoordXDDBtn->setActive(
false );
1817 mCoordYDDBtn->setActive(
false );
1820void QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged(
int )
1828 showBackgroundRadius( isRect );
1830 mShapeSVGPathFrame->setVisible( isSVG );
1831 mBackgroundMarkerSymbolButton->setVisible( isMarker );
1832 mBackgroundFillSymbolButton->setVisible( !isSVG && !isMarker );
1836 mShapeSizeYLabel->setVisible( !isSVG && !isMarker );
1837 mShapeSizeYSpnBx->setVisible( !isSVG && !isMarker );
1838 mShapeSizeYDDBtn->setVisible( !isSVG && !isMarker );
1839 mShapeSizeXLabel->setText( tr(
"Size%1" ).arg( !isSVG && !isMarker ? tr(
" X" ) : QString() ) );
1842 mShapeFillColorBtn->setAllowOpacity( !isSVG );
1843 mShapeFillColorBtn->setButtonBackground();
1844 mShapeStrokeColorBtn->setAllowOpacity( !isSVG );
1845 mShapeStrokeColorBtn->setButtonBackground();
1848 mShapeFillColorLabel->setVisible( isSVG );
1849 mShapeFillColorLabel->setEnabled( isSVG );
1850 mShapeFillColorBtn->setVisible( isSVG );
1851 mShapeFillColorBtn->setEnabled( isSVG );
1852 mShapeFillColorDDBtn->setVisible( isSVG );
1853 mShapeFillColorDDBtn->setEnabled( isSVG );
1854 mShapeStrokeColorLabel->setVisible( isSVG );
1855 mShapeStrokeColorLabel->setEnabled( isSVG );
1856 mShapeStrokeColorBtn->setVisible( isSVG );
1857 mShapeStrokeColorBtn->setEnabled( isSVG );
1858 mShapeStrokeColorDDBtn->setVisible( isSVG );
1859 mShapeStrokeColorDDBtn->setEnabled( isSVG );
1860 mShapeStrokeWidthLabel->setVisible( isSVG );
1861 mShapeStrokeWidthLabel->setEnabled( isSVG );
1862 mShapeStrokeWidthSpnBx->setVisible( isSVG );
1863 mShapeStrokeWidthSpnBx->setEnabled( isSVG );
1864 mShapeStrokeWidthDDBtn->setVisible( isSVG );
1865 mShapeStrokeWidthDDBtn->setEnabled( isSVG );
1868 mShapeSVGParamsBtn->setVisible( isSVG );
1871 updateSvgWidgets( mShapeSVGPathLineEdit->text() );
1875 mShapeSVGUnitsLabel->setVisible( isSVG );
1876 mShapeStrokeWidthUnitWidget->setVisible(
false );
1877 mShapeStrokeUnitsDDBtn->setVisible(
false );
1878 mShapeStrokeUnitsDDBtn->setEnabled(
false );
1880 updateAvailableShadowPositions();
1883void QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged(
const QString &text )
1885 updateSvgWidgets( text );
1890 const int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) + ( chkLineBelow->isChecked() ? 1 : 0 ) + ( chkLineOn->isChecked() ? 1 : 0 );
1892 if ( numOptionsChecked == 1 )
1895 chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
1896 chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
1897 chkLineOn->setEnabled( !chkLineOn->isChecked() );
1901 chkLineAbove->setEnabled(
true );
1902 chkLineBelow->setEnabled(
true );
1903 chkLineOn->setEnabled(
true );
1913void QgsTextFormatWidget::previewScaleChanged(
double scale )
1915 lblFontPreview->setScale( scale );
1918void QgsTextFormatWidget::updateSvgWidgets(
const QString &svgPath )
1920 if ( mShapeSVGPathLineEdit->text() != svgPath )
1922 mShapeSVGPathLineEdit->setText( svgPath );
1925 QString resolvedPath;
1926 bool validSVG =
true;
1927 if ( !svgPath.startsWith( QLatin1String(
"base64:" ), Qt::CaseInsensitive ) )
1930 validSVG = QFileInfo::exists( resolvedPath );
1934 resolvedPath = svgPath;
1939 mShapeSVGPathLineEdit->setStyleSheet( !validSVG ? QStringLiteral(
"QLineEdit{ color: rgb(225, 0, 0); }" ) : QString() );
1940 mShapeSVGPathLineEdit->setToolTip( !validSVG ? tr(
"File not found" ) : resolvedPath );
1942 QColor fill, stroke;
1943 double strokeWidth = 0.0;
1944 bool fillParam =
false, strokeParam =
false, strokeWidthParam =
false;
1950 mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || strokeParam || strokeWidthParam ) );
1952 mShapeFillColorLabel->setEnabled( validSVG && fillParam );
1953 mShapeFillColorBtn->setEnabled( validSVG && fillParam );
1954 mShapeFillColorDDBtn->setEnabled( validSVG && fillParam );
1955 if ( mLoadSvgParams && validSVG && fillParam )
1956 mShapeFillColorBtn->setColor( fill );
1958 mShapeStrokeColorLabel->setEnabled( validSVG && strokeParam );
1959 mShapeStrokeColorBtn->setEnabled( validSVG && strokeParam );
1960 mShapeStrokeColorDDBtn->setEnabled( validSVG && strokeParam );
1961 if ( mLoadSvgParams && validSVG && strokeParam )
1962 mShapeStrokeColorBtn->setColor( stroke );
1964 mShapeStrokeWidthLabel->setEnabled( validSVG && strokeWidthParam );
1965 mShapeStrokeWidthSpnBx->setEnabled( validSVG && strokeWidthParam );
1966 mShapeStrokeWidthDDBtn->setEnabled( validSVG && strokeWidthParam );
1967 if ( mLoadSvgParams && validSVG && strokeWidthParam )
1968 mShapeStrokeWidthSpnBx->setValue( strokeWidth );
1974 mShapeSVGUnitsLabel->setEnabled( validSVG && strokeWidthParam );
1977void QgsTextFormatWidget::updateAvailableShadowPositions()
1979 if ( mShadowUnderCmbBx->count() == 0
1985 mShadowUnderCmbBx->clear();
1993 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( currentPlacement ) );
1994 if ( mShadowUnderCmbBx->currentIndex() == -1 )
1995 mShadowUnderCmbBx->setCurrentIndex( 0 );
1999void QgsTextFormatWidget::updateProperty()
2001 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
2007void QgsTextFormatWidget::createAuxiliaryField()
2012 QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer *>(
mLayer );
2020 QgsNewAuxiliaryLayerDialog dlg( vLayer,
this );
2028 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
2039 property.setActive(
true );
2048void QgsTextFormatWidget::updateShapeFrameStatus()
2050 mShapeFrame->setEnabled( mShapeDrawDDBtn->isActive() || mShapeDrawChkBx->isChecked() );
2053void QgsTextFormatWidget::updateBufferFrameStatus()
2055 mBufferFrame->setEnabled( mBufferDrawDDBtn->isActive() || mBufferDrawChkBx->isChecked() );
2058void QgsTextFormatWidget::updateShadowFrameStatus()
2060 mShadowFrame->setEnabled( mShadowDrawDDBtn->isActive() || mShadowDrawChkBx->isChecked() );
2063void QgsTextFormatWidget::updateCalloutFrameStatus()
2065 mCalloutFrame->setEnabled( mCalloutDrawDDBtn->isActive() || mCalloutsDrawCheckBox->isChecked() );
2068void QgsTextFormatWidget::updateDataDefinedAlignment()
2071 mCoordAlignmentFrame->setEnabled( ( mCoordXDDBtn->isActive() && mCoordYDDBtn->isActive() ) || mCoordPointDDBtn->isActive() );
2074void QgsTextFormatWidget::overlapModeChanged()
2076 QString description;
2080 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.)" );
2083 description = tr(
"If a label cannot otherwise be placed for a feature then an overlapping label is permitted." );
2086 description = tr(
"Labels from this layer may freely overlap other labels or label obstacles without penalty." );
2090 mOverlapModeDescriptionLabel->setText( QStringLiteral(
"<i>%1</i>" ).arg( description ) );
2095 if ( name.isEmpty() )
2138 saveDlg.
setDefaultTags( mTextFormatsListWidget->currentTagFilter() );
2139 if ( !saveDlg.exec() )
2142 if ( saveDlg.
name().isEmpty() )
2152 const int res = QMessageBox::warning(
this, tr(
"Save Text Format" ), tr(
"Format with name '%1' already exists. Overwrite?" ).arg( saveDlg.
name() ), QMessageBox::Yes | QMessageBox::No );
2153 if ( res != QMessageBox::Yes )
2160 const QStringList symbolTags = saveDlg.
tags().split(
',' );
2167void QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked()
2170 svgDlg.setWindowTitle( tr(
"Select SVG file" ) );
2171 svgDlg.svgSelector()->setSvgPath( mShapeSVGPathLineEdit->text().trimmed() );
2173 if ( svgDlg.exec() == QDialog::Accepted )
2175 const QString svgPath = svgDlg.svgSelector()->currentSvgPath();
2176 if ( !svgPath.isEmpty() )
2178 mShapeSVGPathLineEdit->setText( svgPath );
2184void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
2186 const QString svgPath = mShapeSVGPathLineEdit->text();
2187 mLoadSvgParams =
true;
2188 updateSvgWidgets( svgPath );
2189 mLoadSvgParams =
false;
2192void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged(
int index )
2198void QgsTextFormatWidget::mPreviewTextEdit_textChanged(
const QString &text )
2200 lblFontPreview->setText( text );
2204void QgsTextFormatWidget::mPreviewTextBtn_clicked()
2206 mPreviewTextEdit->setText( QStringLiteral(
"Lorem Ipsum" ) );
2210void QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged(
const QColor &color )
2215void QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked()
2217 bool gotChar =
false;
2219 const QChar initial = !mDirectSymbLeftLineEdit->text().isEmpty() ? mDirectSymbLeftLineEdit->text().at( 0 ) : QChar();
2220 const QChar dirSymb = mCharDlg->selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
2225 if ( !dirSymb.isNull() )
2226 mDirectSymbLeftLineEdit->setText( QString( dirSymb ) );
2229void QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked()
2231 bool gotChar =
false;
2232 const QChar initial = !mDirectSymbRightLineEdit->text().isEmpty() ? mDirectSymbRightLineEdit->text().at( 0 ) : QChar();
2233 const QChar dirSymb = mCharDlg->selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
2238 if ( !dirSymb.isNull() )
2239 mDirectSymbRightLineEdit->setText( QString( dirSymb ) );
2242void QgsTextFormatWidget::chkLineOrientationDependent_toggled(
bool active )
2246 chkLineAbove->setText( tr(
"Left of line" ) );
2247 chkLineBelow->setText( tr(
"Right of line" ) );
2251 chkLineAbove->setText( tr(
"Above line" ) );
2252 chkLineBelow->setText( tr(
"Below line" ) );
2257void QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked()
2262 QgsSubstitutionListWidget *widget =
new QgsSubstitutionListWidget( panel );
2270 QgsSubstitutionListDialog dlg(
this );
2272 if ( dlg.exec() == QDialog::Accepted )
2279void QgsTextFormatWidget::configureTabStops()
2284 QgsTabPositionWidget *widget =
new QgsTabPositionWidget( panel );
2287 widget->
setUnit( mTabDistanceUnitWidget->unit() );
2297 QgsTabPositionDialog dlg(
this );
2299 dlg.setUnit( mTabDistanceUnitWidget->unit() );
2300 if ( dlg.exec() == QDialog::Accepted )
2309void QgsTextFormatWidget::showBackgroundRadius(
bool show )
2311 mShapeRadiusLabel->setVisible( show );
2312 mShapeRadiusXDbSpnBx->setVisible( show );
2314 mShapeRadiusYDbSpnBx->setVisible( show );
2316 mShapeRadiusUnitWidget->setVisible( show );
2318 mShapeRadiusDDBtn->setVisible( show );
2319 mShapeRadiusUnitsDDBtn->setVisible( show );
2324 if (
auto *lExpressionContext =
mContext.expressionContext() )
2325 return *lExpressionContext;
2330 expContext =
mMapCanvas->createExpressionContext();
2352 if ( mGeometryGeneratorGroupBox->isChecked() )
2366 : QDialog( parent, fl )
2368 setWindowTitle( tr(
"Text Settings" ) );
2371 mFormatWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
2373 QVBoxLayout *layout =
new QVBoxLayout(
this );
2374 layout->addWidget( mFormatWidget );
2376 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, Qt::Horizontal,
this );
2377 layout->addWidget( mButtonBox );
2379 setLayout( layout );
2382 connect( mButtonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked,
this, &QDialog::accept );
2383 connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked,
this, &QDialog::reject );
2384 connect( mButtonBox->button( QDialogButtonBox::Help ), &QAbstractButton::clicked,
this, &QgsTextFormatDialog::showHelp );
2389 return mFormatWidget->format();
2392void QgsTextFormatDialog::showHelp()
2394 QgsHelp::openHelp( QStringLiteral(
"style_library/label_settings.html#formatting-the-label-text" ) );
2399 mFormatWidget->setContext( context );
2410 mFormatWidget = qobject_cast<QgsTextFormatWidget *>(
widget() );
2412 if ( !mBlockSignals )
2419 return mFormatWidget->format();
2424 mBlockSignals =
true;
2425 mFormatWidget->setFormat(
format );
2426 mBlockSignals =
false;
2431 mFormatWidget->setContext( context );
2436 mFormatWidget->setDockMode(
dockMode );
@ FromPoint
Offset distance applies from point geometry.
@ FromSymbolBounds
Offset distance applies from rendered symbol bounds.
@ PreferCloser
Prefer closer labels, falling back to alternate positions before larger distances.
@ PreferPositionOrdering
Prefer labels follow position ordering, falling back to more distance labels before alternate positio...
LabelPlacement
Placement modes which determine how label candidates are generated for a feature.
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
@ Curved
Arranges candidates following the curvature of a line feature. Applies to line layers only.
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
@ Free
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...
@ OrderedPositionsAroundPoint
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
@ Horizontal
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
@ PerimeterCurved
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only.
@ OutsidePolygons
Candidates are placed outside of polygon boundaries. Applies to polygon layers only.
Capitalization
String capitalization options.
@ AllSmallCaps
Force all characters to small caps.
@ MixedCase
Mixed case, ie no change.
@ AllLowercase
Convert all characters to lowercase.
@ TitleCase
Simple title case conversion - does not fully grammatically parse the text and uses simple rules only...
@ SmallCaps
Mixed case small caps.
@ ForceFirstLetterToCapital
Convert just the first letter of each word to uppercase, leave the rest untouched.
@ AllUppercase
Convert all characters to uppercase.
TextOrientation
Text orientations.
@ Vertical
Vertically oriented text.
@ RotationBased
Horizontally or vertically oriented text based on rotation (only available for map labeling).
@ Horizontal
Horizontally oriented text.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
@ Percentage
Percentage of another measurement (e.g., canvas size, feature size).
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes).
@ MetersInMapUnits
Meters value as Map units.
LabelOverlapHandling
Label overlap handling.
@ AllowOverlapAtNoCost
Labels may freely overlap other labels, at no cost.
@ AllowOverlapIfRequired
Avoids overlapping labels when possible, but permit overlaps if labels for features cannot otherwise ...
@ PreventOverlap
Do not allow labels to overlap other labels.
@ FlipUpsideDownLabels
Upside-down labels (90 <= angle < 270) are shown upright.
@ AlwaysAllowUpsideDown
Show upside down for all labels, including dynamic ones.
@ AllowUpsideDownWhenRotationIsDefined
Show upside down when rotation is layer- or data-defined.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
void collapsedStateChanged(bool collapsed)
Signal emitted when groupbox collapsed/expanded state is changed, and when first shown.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
QgsFillSymbol * clone() const override
Returns a deep copy of this symbol.
static QFont createFont(const QString &family, int pointSize=-1, int weight=-1, bool italic=false)
Creates a font with the specified family.
static bool fontFamilyMatchOnSystem(const QString &family, QString *chosen=nullptr, bool *match=nullptr)
Check whether font family is on system.
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
static void setFontFamily(QFont &font, const QString &family)
Sets the family for a font object.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
static QIcon iconForWkbType(Qgis::WkbType type)
Returns the icon for a vector layer whose geometry type is provided.
@ SymbolLeftRight
Place direction symbols on left/right of label.
@ SymbolAbove
Place direction symbols on above label.
@ SymbolBelow
Place direction symbols on below label.
static void warning(const QString &msg)
Goes to qWarning.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
Contains configuration for rendering maps.
A marker symbol type, for rendering Point and MultiPoint geometries.
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
Property
Data definable properties.
@ PositionX
X-coordinate data defined label position.
@ LinePlacementOptions
Line placement flags.
@ FontSizeUnit
Font size units.
@ LabelRotation
Label rotation.
@ FontStyle
Font style name.
@ Italic
Use italic style.
@ ShapeOpacity
Shape opacity.
@ AllowDegradedPlacement
Allow degraded label placements.
@ MaskEnabled
Whether the mask is enabled.
@ PredefinedPositionOrder
@ OverlapHandling
Overlap handling technique.
@ PositionY
Y-coordinate data defined label position.
@ MaximumScale
Maximum map scale (ie most "zoomed in").
@ Vali
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top).
@ MinimumScale
Minimum map scale (ie most "zoomed out").
@ FontStretchFactor
Font stretch factor, since QGIS 3.24.
@ PolygonLabelOutside
Whether labels outside a polygon feature are permitted, or should be forced.
@ BufferOpacity
Buffer opacity.
@ MaskJoinStyle
Mask join style.
@ Strikeout
Use strikeout.
@ LabelAllParts
Whether all parts of multi-part features should be labeled.
@ LabelMarginDistance
Minimum distance from labels for this feature to other labels.
@ Underline
Use underline.
@ FontBlendMode
Text blend mode.
@ FontCase
Label text case.
@ Hali
Horizontal alignment for data defined label position (Left, Center, Right).
@ MaskOpacity
Mask opacity.
@ OverrunDistance
Distance which labels can extend past either end of linear features.
@ MaskBufferUnit
Mask buffer size unit.
@ FontOpacity
Text opacity.
@ FontWordSpacing
Word spacing.
@ CalloutDraw
Show callout.
@ MaskBufferSize
Mask buffer size.
@ FontLetterSpacing
Letter spacing.
@ TabStopDistance
Tab stop distance, since QGIS 3.38.
@ ShadowOpacity
Shadow opacity.
@ RemoveDuplicateLabels
Whether this feature can cause removal of duplicate labels.
@ PositionPoint
Point-coordinate data defined label position.
@ MaximumDistance
Maximum distance of label from feature.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the labeling property definitions.
QgsStyle * styleAtPath(const QString &path)
Returns a reference to the style database associated with the project with matching file path.
QVector< double > mapScales() const
Returns the list of custom project map scales.
static QgsProject * instance()
Returns the QgsProject singleton instance.
const QgsProjectStyleSettings * styleSettings() const
Returns the project's style settings, which contains settings and properties relating to how a QgsPro...
const QgsProjectViewSettings * viewSettings() const
Returns the project's view settings, which contains settings and properties relating to how a QgsProj...
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.
QSet< int > propertyKeys() const final
Returns a list of property keys contained within the collection.
bool isActive(int key) const final
Returns true if the collection contains an active property with the specified key.
QgsProperty property(int key) const final
Returns a matching property from the collection, if one exists.
A store for object properties.
void setField(const QString &field)
Sets the field name the property references.
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
A collection of string replacements (specified using QgsStringReplacement objects).
A dialog for setting properties of a newly saved style.
bool isFavorite() const
Returns true if the favorite is checked for the symbol.
QString name() const
Returns the entered name for the new symbol.
void setDefaultTags(const QString &tags)
Sets the default tags for the newly created item.
QString tags() const
Returns any tags entered for the new symbol (as a comma separated value list).
QgsStyle * destinationStyle()
Returns the destination style database.
A database of saved style entities, including symbols, color ramps, text formats and others.
QgsTextFormat textFormat(const QString &name) const
Returns the text format with the specified name.
QStringList textFormatNames() const
Returns a list of names of text formats in the style.
bool removeTextFormat(const QString &name)
Removes a text format from the style.
StyleEntity
Enum for Entities involved in a style.
@ LabelSettingsEntity
Label settings.
@ TextFormatEntity
Text formats.
@ SmartgroupEntity
Smart groups.
@ Symbol3DEntity
3D symbol entity
@ ColorrampEntity
Color ramps.
@ LegendPatchShapeEntity
Legend patch shape.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
QStringList labelSettingsNames() const
Returns a list of names of label settings in the style.
static QgsTextFormat defaultTextFormatForProject(QgsProject *project, QgsStyle::TextFormatContext context=QgsStyle::TextFormatContext::Labeling)
Returns the default text format to use for new text based objects for the specified project,...
bool addTextFormat(const QString &name, const QgsTextFormat &format, bool update=false)
Adds a text format with the specified name to the style.
QgsPalLayerSettings labelSettings(const QString &name) const
Returns the label settings with the specified name.
bool saveTextFormat(const QString &name, const QgsTextFormat &format, bool favorite, const QStringList &tags)
Adds a text format to the database.
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth, bool blocking=false) const
Tests if an SVG file contains parameters for fill, stroke color, stroke width.
A dialog for selection of an SVG file.
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
static QgsSymbol * defaultSymbol(Qgis::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Container for settings relating to a text background object.
QgsMapUnitScale strokeWidthMapUnitScale() const
Returns the map unit scale object for the shape stroke width.
void setRadiiUnit(Qgis::RenderUnit units)
Sets the units used for the shape's radii.
void setFillSymbol(QgsFillSymbol *symbol)
Sets the current fill symbol for the background shape.
RotationType rotationType() const
Returns the method used for rotating the background shape.
QString svgFile() const
Returns the absolute path to the background SVG file, if set.
QSizeF size() const
Returns the size of the background shape.
QSizeF radii() const
Returns the radii used for rounding the corners of shapes.
QgsMapUnitScale radiiMapUnitScale() const
Returns the map unit scale object for the shape radii.
void setOpacity(double opacity)
Sets the background shape's opacity.
void setStrokeColor(const QColor &color)
Sets the color used for outlining the background shape.
Qgis::RenderUnit radiiUnit() const
Returns the units used for the shape's radii.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape size.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the background shape.
SizeType
Methods for determining the background shape size.
bool enabled() const
Returns whether the background is enabled.
double opacity() const
Returns the background shape's opacity.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape stroke width.
double rotation() const
Returns the rotation for the background shape, in degrees clockwise.
QColor fillColor() const
Returns the color used for filing the background shape.
void setMarkerSymbol(QgsMarkerSymbol *symbol)
Sets the current marker symbol for the background shape.
void setRadii(QSizeF radii)
Sets the radii used for rounding the corners of shapes.
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
Qgis::RenderUnit strokeWidthUnit() const
Returns the units used for the shape's stroke width.
ShapeType type() const
Returns the type of background shape (e.g., square, ellipse, SVG).
double strokeWidth() const
Returns the width of the shape's stroke (stroke).
void setSizeType(SizeType type)
Sets the method used to determine the size of the background shape (e.g., fixed size or buffer around...
ShapeType
Background shape types.
@ ShapeMarkerSymbol
Marker symbol.
@ ShapeSquare
Square - buffered sizes only.
@ ShapeRectangle
Rectangle.
void setFillColor(const QColor &color)
Sets the color used for filing the background shape.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the background shape.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units used for the shape's size.
Qgis::RenderUnit offsetUnit() const
Returns the units used for the shape's offset.
QColor strokeColor() const
Returns the color used for outlining the background shape.
void setRotationType(RotationType type)
Sets the method used for rotating the background shape.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape offset.
QgsFillSymbol * fillSymbol() const
Returns the fill symbol to be rendered in the background.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the background shape.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
void setType(ShapeType type)
Sets the type of background shape to draw (e.g., square, ellipse, SVG).
Qgis::RenderUnit sizeUnit() const
Returns the units used for the shape's size.
RotationType
Methods for determining the rotation of the background shape.
@ RotationSync
Shape rotation is synced with text rotation.
void setEnabled(bool enabled)
Sets whether the text background will be drawn.
QgsMarkerSymbol * markerSymbol() const
Returns the marker symbol to be rendered in the background.
void setRadiiMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape radii.
void setRotation(double rotation)
Sets the rotation for the background shape, in degrees clockwise.
void setStrokeWidthUnit(Qgis::RenderUnit units)
Sets the units used for the shape's stroke width.
void setOffsetUnit(Qgis::RenderUnit units)
Sets the units used for the shape's offset.
void setOffset(QPointF offset)
Sets the offset used for drawing the background shape.
void setSize(QSizeF size)
Sets the size of the background shape.
const QgsPaintEffect * paintEffect() const
Returns the current paint effect for the background shape.
void setSvgFile(const QString &file)
Sets the path to the background SVG file.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shape offset.
void setStrokeWidth(double width)
Sets the width of the shape's stroke (stroke).
QPointF offset() const
Returns the offset used for drawing the background shape.
Container for settings relating to a text buffer.
void setFillBufferInterior(bool fill)
Sets whether the interior of the buffer will be filled in.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the buffer.
Qgis::RenderUnit sizeUnit() const
Returns the units for the buffer size.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
double size() const
Returns the size of the buffer.
void setColor(const QColor &color)
Sets the color for the buffer.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
void setOpacity(double opacity)
Sets the buffer opacity.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
bool enabled() const
Returns whether the buffer is enabled.
double opacity() const
Returns the buffer opacity.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units used for the buffer size.
bool fillBufferInterior() const
Returns whether the interior of the buffer will be filled in.
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the buffer.
const QgsPaintEffect * paintEffect() const
Returns the current paint effect for the buffer.
QColor color() const
Returns the color of the buffer.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the buffer.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
void setSize(double size)
Sets the size of the buffer.
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
QgsTextFormatDialog(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QgsMapLayer *layer=nullptr)
Constructor for QgsTextFormatDialog.
void setFormat(const QgsTextFormat &format)
Sets the format to show in the widget.
QgsTextFormatPanelWidget(const QgsTextFormat &format, QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsMapLayer *layer=nullptr)
Constructor for QgsTextFormatPanelWidget.
void setDockMode(bool dockMode) override
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
QgsTextFormat format() const
Returns the current formatting settings defined by the widget.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
A widget for customizing text formatting settings.
void updatePlacementWidgets()
Updates label placement options to reflect current state of widget.
QListWidgetItem * mMaskItem
Mask widget item.
QButtonGroup * mUpsidedownBtnGrp
Upside down labels button group.
int mMinPixelLimit
Pixel size font limit.
QListWidgetItem * mBackgroundItem
Background widget item.
void setDockMode(bool enabled)
Sets whether the widget should be shown in a compact dock mode.
QgsMapCanvas * mMapCanvas
Associated map canvas.
void setPropertyOverrideButtonsVisible(bool visible)
Toggles whether data defined buttons should be shown in the widget.
QgsSymbolWidgetContext context() const
Returns the context in which the widget is shown, e.g., the associated map canvas and expression cont...
QgsTextFormatWidget(const QgsTextFormat &format=QgsTextFormat(), QgsMapCanvas *mapCanvas=nullptr, QWidget *parent=nullptr, QgsMapLayer *layer=nullptr)
Constructor for QgsTextFormatWidget.
QListWidgetItem * mFormattingItem
Formatting widget item.
~QgsTextFormatWidget() override
void deactivateField(QgsPalLayerSettings::Property key)
Deactivate a field from data defined properties and update the corresponding button.
void setFormat(const QgsTextFormat &format)
Sets the current formatting settings.
QListWidgetItem * mTextItem
Text widget item.
Qgis::GeometryType mGeomType
Geometry type for layer, if known.
QButtonGroup * mDirectSymbBtnGrp
Symbol direction button group.
void updateWidgetForFormat(const QgsTextFormat &format)
Updates the widget's state to reflect the settings in a QgsTextFormat.
QList< QgsSymbolLayerReference > mMaskedSymbolLayers
void widgetChanged()
Emitted when the text format defined by the widget changes.
void setPreviewBackground(const QColor &color)
Sets the background color for the text preview widget.
QButtonGroup * mQuadrantBtnGrp
Quadrant button group.
QListWidgetItem * mShadowItem
Shadow widget item.
QList< QgsTextFormat::Tab > mTabPositions
Tab positions.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsSymbolWidgetContext mContext
Context in which widget is shown.
QListWidgetItem * mBufferItem
Buffer widget item.
void updateLinePlacementOptions()
Updates line placement options to reflect current state of widget.
QListWidgetItem * mCalloutItem
Callout widget item.
void populateDataDefinedButtons()
Sets up connections required for data defined buttons, or updates the existing definition of these bu...
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
QListWidgetItem * mRenderingItem
Rendering widget item.
void updatePreview()
Updates the text preview.
QListWidgetItem * mPlacementItem
Placement widget item.
void auxiliaryFieldCreated()
Emitted when an auxiliary field is created in the widget.
virtual void setFormatFromStyle(const QString &name, QgsStyle::StyleEntity type, const QString &stylePath)
Sets the current text settings from a style entry.
Qgis::GeometryType labelGeometryType() const
Returns the geometry type which will be used by the labeling engine when registering labels for the l...
QgsMapLayer * mLayer
Associated vector layer.
QgsStringReplacementCollection mSubstitutions
Text substitution list.
@ Text
Default mode, show text formatting settings only.
@ Labeling
Show labeling settings in addition to text formatting settings.
virtual void saveFormat()
Saves the current text settings to a style entry.
QgsPropertyCollection mDataDefinedProperties
Data defined properties as defined in the widget.
Container for all settings relating to text rendering.
Container for settings relating to a selective masking around a text.
void setEnabled(bool)
Returns whether the mask is enabled.
void setMaskedSymbolLayers(const QList< QgsSymbolLayerReference > &maskedLayers)
Sets the symbol layers that will be masked by this buffer.
Qgis::RenderUnit sizeUnit() const
Returns the units for the buffer size.
QList< QgsSymbolLayerReference > maskedSymbolLayers() const
Returns a list of references to symbol layers that are masked by this buffer.
void setSize(double size)
Sets the size of the buffer.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
double size() const
Returns the size of the buffer.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the mask.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
double opacity() const
Returns the mask's opacity.
bool enabled() const
Returns whether the mask is enabled.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units used for the buffer size.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the mask.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
void setOpacity(double opacity)
Sets the mask's opacity.
Container for settings relating to a text shadow.
int offsetAngle() const
Returns the angle for offsetting the position of the shadow from the text.
void setBlurRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow blur radius.
void setBlurRadiusUnit(Qgis::RenderUnit units)
Sets the units used for the shadow's blur radius.
bool enabled() const
Returns whether the shadow is enabled.
void setOffsetUnit(Qgis::RenderUnit units)
Sets the units used for the shadow's offset.
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
Qgis::RenderUnit offsetUnit() const
Returns the units used for the shadow's offset.
void setShadowPlacement(QgsTextShadowSettings::ShadowPlacement placement)
Sets the placement for the drop shadow.
double opacity() const
Returns the shadow's opacity.
QgsMapUnitScale blurRadiusMapUnitScale() const
Returns the map unit scale object for the shadow blur radius.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow offset distance.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the drop shadow.
void setColor(const QColor &color)
Sets the color for the drop shadow.
QColor color() const
Returns the color of the drop shadow.
void setOffsetGlobal(bool global)
Sets whether the global shadow offset should be used.
ShadowPlacement
Placement positions for text shadow.
@ ShadowBuffer
Draw shadow under buffer.
@ ShadowShape
Draw shadow under background shape.
@ ShadowLowest
Draw shadow below all text components.
@ ShadowText
Draw shadow under text.
void setScale(int scale)
Sets the scaling used for the drop shadow (in percentage of original size).
void setBlurAlphaOnly(bool alphaOnly)
Sets whether only the alpha channel for the shadow should be blurred.
QgsTextShadowSettings::ShadowPlacement shadowPlacement() const
Returns the placement for the drop shadow.
Qgis::RenderUnit blurRadiusUnit() const
Returns the units used for the shadow's blur radius.
double offsetDistance() const
Returns the distance for offsetting the position of the shadow from the text.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the drop shadow.
void setOffsetDistance(double distance)
Sets the distance for offsetting the position of the shadow from the text.
void setOpacity(double opacity)
Sets the shadow's opacity.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shadow offset distance.
bool blurAlphaOnly() const
Returns whether only the alpha channel for the shadow will be blurred.
bool offsetGlobal() const
Returns true if the global shadow offset will be used.
void setOffsetAngle(int angle)
Sets the angle for offsetting the position of the shadow from the text.
double blurRadius() const
Returns the blur radius for the shadow.
void setBlurRadius(double blurRadius)
Sets the blur radius for the shadow.
void setEnabled(bool enabled)
Sets whether the text shadow will be drawn.
QList< Qgis::RenderUnit > RenderUnitList
List of render units.
Represents a vector layer which manages a vector based dataset.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.