50#include <QButtonGroup>
54#include "moc_qgstextformatwidget.cpp"
56using namespace Qt::StringLiterals;
64 setWidgetMode(
Text );
78 setWidgetMode( mode );
81void QgsTextFormatWidget::initWidget()
85 mGeometryGeneratorGroupBox->setCollapsed(
true );
87 mTextItem =
new QListWidgetItem( tr(
"Text" ), mLabelingOptionsListWidget );
89 mTextItem->setToolTip( tr(
"Text style" ) );
91 mFormattingItem =
new QListWidgetItem( tr(
"Formatting" ), mLabelingOptionsListWidget );
95 mBufferItem =
new QListWidgetItem( tr(
"Buffer" ), mLabelingOptionsListWidget );
99 mMaskItem =
new QListWidgetItem( tr(
"Mask" ), mLabelingOptionsListWidget );
103 mBackgroundItem =
new QListWidgetItem( tr(
"Background" ), mLabelingOptionsListWidget );
107 mShadowItem =
new QListWidgetItem( tr(
"Shadow" ), mLabelingOptionsListWidget );
111 mCalloutItem =
new QListWidgetItem( tr(
"Callouts" ), mLabelingOptionsListWidget );
115 mPlacementItem =
new QListWidgetItem( tr(
"Placement" ), mLabelingOptionsListWidget );
119 mRenderingItem =
new QListWidgetItem( tr(
"Rendering" ), mLabelingOptionsListWidget );
123#if ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR < 10 )
124 mDuplicatesStackedWidget->setCurrentWidget( mDuplicatesNotAvailableWidget );
125 mLabelSpacingStackedWidget->setCurrentWidget( mLabelSpacingNotAvailableWidget );
128 mLabelingOptionsListWidget->addItem(
mTextItem );
130 mLabelingOptionsListWidget->addItem(
mBufferItem );
131 mLabelingOptionsListWidget->addItem(
mMaskItem );
133 mLabelingOptionsListWidget->addItem(
mShadowItem );
138 QObject::connect( mOptionsTab, &QTabWidget::currentChanged,
this, [
this](
int index ) {
139 if ( index == mOptionsTab->indexOf( textTab ) )
140 mLabelStackedWidget->setCurrentWidget( mLabelPage_Text );
141 else if ( index == mOptionsTab->indexOf( formattingTab ) )
142 mLabelStackedWidget->setCurrentWidget( mLabelPage_Formatting );
143 else if ( index == mOptionsTab->indexOf( maskTab ) )
144 mLabelStackedWidget->setCurrentWidget( mLabelPage_Mask );
145 else if ( index == mOptionsTab->indexOf( bufferTab ) )
146 mLabelStackedWidget->setCurrentWidget( mLabelPage_Buffer );
147 else if ( index == mOptionsTab->indexOf( backgroundTab ) )
148 mLabelStackedWidget->setCurrentWidget( mLabelPage_Background );
149 else if ( index == mOptionsTab->indexOf( shadowTab ) )
150 mLabelStackedWidget->setCurrentWidget( mLabelPage_Shadow );
151 else if ( index == mOptionsTab->indexOf( calloutsTab ) )
152 mLabelStackedWidget->setCurrentWidget( mLabelPage_Callouts );
153 else if ( index == mOptionsTab->indexOf( placementTab ) )
154 mLabelStackedWidget->setCurrentWidget( mLabelPage_Placement );
155 else if ( index == mOptionsTab->indexOf( renderingTab ) )
156 mLabelStackedWidget->setCurrentWidget( mLabelPage_Rendering );
159 QObject::connect( mLabelingOptionsListWidget, &QListWidget::currentRowChanged,
this, [
this](
int ) {
160 QListWidgetItem *currentItem = mLabelingOptionsListWidget->currentItem();
164 mLabelStackedWidget->setCurrentWidget( mLabelPage_Text );
166 mLabelStackedWidget->setCurrentWidget( mLabelPage_Formatting );
168 mLabelStackedWidget->setCurrentWidget( mLabelPage_Mask );
170 mLabelStackedWidget->setCurrentWidget( mLabelPage_Buffer );
172 mLabelStackedWidget->setCurrentWidget( mLabelPage_Background );
174 mLabelStackedWidget->setCurrentWidget( mLabelPage_Shadow );
176 mLabelStackedWidget->setCurrentWidget( mLabelPage_Callouts );
178 mLabelStackedWidget->setCurrentWidget( mLabelPage_Placement );
180 mLabelStackedWidget->setCurrentWidget( mLabelPage_Rendering );
183 QObject::connect( mLabelingOptionsListWidget, &QListWidget::currentRowChanged, mLabelStackedWidget, &QStackedWidget::setCurrentIndex );
185 connect( mShapeSVGPathLineEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged );
186 connect( mFontSizeSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontSizeSpinBox_valueChanged );
187 connect( mFontFamilyCmbBx, &QFontComboBox::currentFontChanged,
this, &QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged );
188 connect( mFontStyleComboBox, &QComboBox::currentTextChanged,
this, &QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged );
189 connect( mFontUnderlineBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontUnderlineBtn_toggled );
190 connect( mFontStrikethroughBtn, &QToolButton::toggled,
this, &QgsTextFormatWidget::mFontStrikethroughBtn_toggled );
191 connect( mFontWordSpacingSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged );
192 connect( mFontLetterSpacingSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged );
194 connect( mFontMinPixelSpinBox,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged );
195 connect( mFontMaxPixelSpinBox,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ),
this, &QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged );
204 connect( mShapeTypeCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged );
205 connect( mShapeRotationCmbBx,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged );
206 connect( mShapeSVGParamsBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGParamsBtn_clicked );
207 connect( mShapeSVGSelectorBtn, &QPushButton::clicked,
this, &QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked );
208 connect( mPreviewTextEdit, &QLineEdit::textChanged,
this, &QgsTextFormatWidget::mPreviewTextEdit_textChanged );
209 connect( mPreviewTextBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mPreviewTextBtn_clicked );
211 connect( mDirectSymbLeftToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked );
212 connect( mDirectSymbRightToolBtn, &QToolButton::clicked,
this, &QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked );
213 connect( chkLineOrientationDependent, &QCheckBox::toggled,
this, &QgsTextFormatWidget::chkLineOrientationDependent_toggled );
214 connect( mToolButtonConfigureSubstitutes, &QToolButton::clicked,
this, &QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked );
215 connect( mKerningCheckBox, &QCheckBox::toggled,
this, &QgsTextFormatWidget::kerningToggled );
216 connect( mComboOverlapHandling, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::overlapModeChanged );
217 connect( mTabStopsButton, &QToolButton::clicked,
this, &QgsTextFormatWidget::configureTabStops );
220 mOptionsTab->setIconSize( QSize( iconSize, iconSize ) );
221 mLabelingOptionsListWidget->setIconSize( QSize( iconSize, iconSize ) );
227 mPreviewTextBtn->setIconSize( QSize( iconSize16, iconSize16 ) );
228 mPointOffsetAboveLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
229 mPointOffsetAbove->setIconSize( QSize( iconSize32, iconSize18 ) );
230 mPointOffsetAboveRight->setIconSize( QSize( iconSize32, iconSize18 ) );
231 mPointOffsetLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
232 mPointOffsetOver->setIconSize( QSize( iconSize32, iconSize18 ) );
233 mPointOffsetRight->setIconSize( QSize( iconSize32, iconSize18 ) );
234 mPointOffsetBelowLeft->setIconSize( QSize( iconSize32, iconSize18 ) );
235 mPointOffsetBelow->setIconSize( QSize( iconSize32, iconSize18 ) );
236 mPointOffsetBelowRight->setIconSize( QSize( iconSize32, iconSize18 ) );
241 mFontUnderlineBtn->setMinimumSize( buttonSize, buttonSize );
242 mFontUnderlineBtn->setMaximumSize( buttonSize, buttonSize );
243 mFontStrikethroughBtn->setMinimumSize( buttonSize, buttonSize );
244 mFontStrikethroughBtn->setMaximumSize( buttonSize, buttonSize );
245 mFontBoldBtn->setMinimumSize( buttonSize, buttonSize );
246 mFontBoldBtn->setMaximumSize( buttonSize, buttonSize );
247 mFontItalicBtn->setMinimumSize( buttonSize, buttonSize );
248 mFontItalicBtn->setMaximumSize( buttonSize, buttonSize );
250 mPreviewScaleComboBox->setMapCanvas(
mMapCanvas );
251 mPreviewScaleComboBox->setShowCurrentScaleButton(
true );
254 const auto unitWidgets = findChildren<QgsUnitSelectionWidget *>();
255 for ( QgsUnitSelectionWidget *unitWidget : unitWidgets )
276 mFontLineHeightSpinBox->setClearValue( 100.0 );
277 mShapeRotationDblSpnBx->setClearValue( 0.0 );
278 mShapeOffsetXSpnBx->setClearValue( 0.0 );
279 mShapeOffsetYSpnBx->setClearValue( 0.0 );
280 mPointOffsetXSpinBox->setClearValue( 0.0 );
281 mPointOffsetYSpinBox->setClearValue( 0.0 );
282 mPointAngleSpinBox->setClearValue( 0.0 );
283 mFontLetterSpacingSpinBox->setClearValue( 0.0 );
284 mFontWordSpacingSpinBox->setClearValue( 0.0 );
285 mZIndexSpinBox->setClearValue( 0.0 );
286 mLineDistanceSpnBx->setClearValue( 0.0 );
287 mMaximumDistanceSpnBx->setMinimum( 0 );
288 mMaximumDistanceSpnBx->setClearValue( 0.0, tr(
"Not set" ) );
289 mSpinStretch->setClearValue( 100 );
290 mTabStopDistanceSpin->setMinimum( 0 );
294 mFontLineHeightSpinBox->setClearValue( 100.0 );
296 mFontLineHeightSpinBox->setClearValue( 10.0 );
320 connect( mComboCurvedLabelMode, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsTextFormatWidget::updateCurvedLabelDescription );
321 QFont font = mCurvedModeDescriptionLabel->font();
322 font.setItalic(
true );
323 mCurvedModeDescriptionLabel->setFont( font );
324 updateCurvedLabelDescription();
330 updateAvailableShadowPositions();
333 mBackgroundMarkerSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
334 mBackgroundMarkerSymbolButton->registerExpressionContextGenerator(
this );
335 mBackgroundMarkerSymbolButton->setMapCanvas(
mMapCanvas );
337 mBackgroundFillSymbolButton->setDialogTitle( tr(
"Background Symbol" ) );
338 mBackgroundFillSymbolButton->registerExpressionContextGenerator(
this );
339 mBackgroundFillSymbolButton->setMapCanvas(
mMapCanvas );
341 mCharDlg =
new QgsCharacterSelectorDialog(
this );
343 mRefFont = lblFontPreview->font();
346 connect( mShadowOffsetAngleDial, &QAbstractSlider::valueChanged, mShadowOffsetAngleSpnBx, &QSpinBox::setValue );
347 connect( mShadowOffsetAngleSpnBx,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ), mShadowOffsetAngleDial, &QAbstractSlider::setValue );
348 connect( mLimitLabelChkBox, &QAbstractButton::toggled, mLimitLabelSpinBox, &QWidget::setEnabled );
349 connect( mCheckBoxSubstituteText, &QAbstractButton::toggled, mToolButtonConfigureSubstitutes, &QWidget::setEnabled );
359 populateFontCapitalsComboBox();
362 mPreviewBackgroundBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
363 mPreviewBackgroundBtn->setContext( u
"labeling"_s );
364 mPreviewBackgroundBtn->setColor( QColor( 255, 255, 255 ) );
365 btnTextColor->setColorDialogTitle( tr(
"Select Text Color" ) );
366 btnTextColor->setContext( u
"labeling"_s );
367 btnTextColor->setDefaultColor( Qt::black );
368 btnBufferColor->setColorDialogTitle( tr(
"Select Buffer Color" ) );
369 btnBufferColor->setContext( u
"labeling"_s );
370 btnBufferColor->setDefaultColor( Qt::white );
371 mShapeStrokeColorBtn->setColorDialogTitle( tr(
"Select Stroke Color" ) );
372 mShapeStrokeColorBtn->setContext( u
"labeling"_s );
373 mShapeFillColorBtn->setColorDialogTitle( tr(
"Select Fill Color" ) );
374 mShapeFillColorBtn->setContext( u
"labeling"_s );
375 mShadowColorBtn->setColorDialogTitle( tr(
"Select Shadow Color" ) );
376 mShadowColorBtn->setContext( u
"labeling"_s );
377 mShadowColorBtn->setDefaultColor( Qt::black );
379 mFontColorDDBtn->registerLinkedWidget( btnTextColor );
380 mBufferColorDDBtn->registerLinkedWidget( btnBufferColor );
381 mShapeStrokeColorDDBtn->registerLinkedWidget( mShapeStrokeColorBtn );
382 mShapeFillColorDDBtn->registerLinkedWidget( mShapeFillColorBtn );
383 mShadowColorDDBtn->registerLinkedWidget( mShadowColorBtn );
424 const auto groupBoxes = findChildren<QgsCollapsibleGroupBox *>();
425 for ( QgsCollapsibleGroupBox *grpbox : groupBoxes )
427 grpbox->setSettingGroup( u
"mAdvLabelingDlg"_s );
433 mLabelingOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect,
false );
435 const QgsSettings settings;
438 QSizePolicy policy( mLabelingOptionsListFrame->sizePolicy() );
439 policy.setHorizontalStretch( 0 );
440 mLabelingOptionsListFrame->setSizePolicy( policy );
441 if ( !settings.
contains( u
"/Windows/Labeling/OptionsSplitState"_s ) )
444 QList<int> splitsizes;
446 mLabelingOptionsSplitter->setSizes( splitsizes );
450 connect( mLabelStackedWidget, &QStackedWidget::currentChanged,
this, &QgsTextFormatWidget::optionsStackedWidget_CurrentChanged );
453 mFontPreviewSplitter->restoreState( settings.
value( u
"Windows/Labeling/FontPreviewSplitState"_s ).toByteArray() );
454 mLabelingOptionsSplitter->restoreState( settings.
value( u
"Windows/Labeling/OptionsSplitState"_s ).toByteArray() );
456 mLabelingOptionsListWidget->setCurrentRow( settings.
value( u
"Windows/Labeling/Tab"_s, 0 ).toInt() );
460 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
464 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
468 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
470 overlapModeChanged();
474 QList<QWidget *> widgets;
475 widgets << btnBufferColor
477 << mComboMultipartBehavior
481 << chkLineOrientationDependent
483 << chkPreserveRotation
485 << comboBufferBlendMode
487 << mBufferJoinStyleComboBox
488 << mBufferTranspFillChbx
489 << mBufferOpacityWidget
490 << mCentroidInsideCheckBox
492 << mCoordRotationUnitComboBox
494 << mDirectSymbLeftLineEdit
495 << mDirectSymbRevChkBx
496 << mDirectSymbRightLineEdit
497 << mFitInsidePolygonCheckBox
498 << mFontCapitalsComboBox
499 << mFontLetterSpacingSpinBox
500 << mFontLimitPixelChkBox
501 << mFontLineHeightSpinBox
502 << mLineHeightUnitWidget
503 << mFontMaxPixelSpinBox
504 << mFontMinPixelSpinBox
505 << mFontMultiLineAlignComboBox
507 << mFontStyleComboBox
508 << mTextOrientationComboBox
509 << mTextOpacityWidget
511 << mFontWordSpacingSpinBox
513 << mFormatNumDecimalsSpnBx
514 << mFormatNumPlusSignChkBx
516 << mLimitLabelSpinBox
517 << mLineDistanceSpnBx
518 << mLineDistanceUnitWidget
519 << mMaximumDistanceSpnBx
520 << mMaximumDistanceUnitWidget
521 << mMaxCharAngleInDSpinBox
522 << mMaxCharAngleOutDSpinBox
524 << mOffsetTypeComboBox
525 << mCheckAllowDegradedPlacement
526 << mComboOverlapHandling
527 << mPointAngleSpinBox
528 << mPointOffsetUnitWidget
529 << mPointOffsetXSpinBox
530 << mPointOffsetYSpinBox
531 << mPreviewBackgroundBtn
534 << mRepeatDistanceSpinBox
535 << mRepeatDistanceUnitWidget
536 << mOverrunDistanceSpinBox
537 << mOverrunDistanceUnitWidget
538 << mLabelMarginSpinBox
539 << mLabelMarginUnitWidget
540 << mScaleBasedVisibilityChkBx
546 << mShadowOffsetAngleSpnBx
547 << mShadowOffsetGlobalChkBx
548 << mShadowOffsetSpnBx
549 << mShadowOffsetUnitWidget
550 << mShadowRadiusAlphaChkBx
551 << mShadowRadiusDblSpnBx
552 << mShadowRadiusUnitWidget
554 << mShadowOpacityWidget
557 << mShapeStrokeColorBtn
558 << mShapeStrokeWidthSpnBx
559 << mShapeStrokeWidthUnitWidget
561 << mShapeFillColorBtn
562 << mShapeOffsetXSpnBx
563 << mShapeOffsetYSpnBx
564 << mShapeOffsetUnitWidget
565 << mShapeRadiusXDbSpnBx
566 << mShapeRadiusYDbSpnBx
567 << mShapeRotationCmbBx
568 << mShapeRotationDblSpnBx
569 << mShapeRadiusUnitWidget
570 << mShapeSVGPathLineEdit
572 << mShapeSizeUnitWidget
575 << mBackgroundOpacityWidget
580 << mAutoWrapLengthSpinBox
581 << mAutoWrapTypeComboBox
582 << mCentroidRadioVisible
583 << mCentroidRadioWhole
584 << mDirectSymbRadioBtnAbove
585 << mDirectSymbRadioBtnBelow
586 << mDirectSymbRadioBtnLR
587 << mUpsidedownRadioAll
588 << mUpsidedownRadioDefined
589 << mUpsidedownRadioOff
590 << mPlacementModeComboBox
591 << mFieldExpressionWidget
592 << mCheckBoxSubstituteText
593 << mGeometryGeneratorGroupBox
594 << mGeometryGenerator
595 << mGeometryGeneratorType
596 << mBackgroundMarkerSymbolButton
597 << mBackgroundFillSymbolButton
598 << mCalloutsDrawCheckBox
599 << mCalloutStyleComboBox
602 << mMaskJoinStyleComboBox
603 << mMaskBufferSizeSpinBox
604 << mMaskOpacityWidget
605 << mCheckAllowLabelsOutsidePolygons
606 << mHtmlFormattingCheckBox
607 << mPrioritizationComboBox
608 << mComboCurvedLabelMode
609 << mTabDistanceUnitWidget
610 << mTabStopDistanceSpin
612 << mCheckWhitespaceIsNotACollision;
614 connectValueChanged( widgets );
619 connect( mBufferDrawChkBx, &QCheckBox::stateChanged,
this, [
this](
int ) {
620 updateBufferFrameStatus();
623 connect( mShapeDrawChkBx, &QCheckBox::stateChanged,
this, [
this](
int ) {
624 updateShapeFrameStatus();
627 connect( mShadowDrawChkBx, &QCheckBox::stateChanged,
this, [
this](
int ) {
628 updateShadowFrameStatus();
631 connect( mCalloutsDrawCheckBox, &QCheckBox::stateChanged,
this, [
this](
int ) {
632 updateCalloutFrameStatus();
640 whileBlocking( mOptionsTab )->setCurrentIndex( mLabelStackedWidget->currentIndex() );
641 mOptionsTab->tabBar()->setUsesScrollButtons(
true );
646 lblFontPreview->setMapUnits(
mMapCanvas->mapSettings().mapUnits() );
647 mPreviewScaleComboBox->setScale(
mMapCanvas->mapSettings().scale() );
669 const int prevIndex = mOptionsTab->currentIndex();
679 mOptionsTab->removeTab( mOptionsTab->indexOf( renderingTab ) );
680 mOptionsTab->removeTab( mOptionsTab->indexOf( placementTab ) );
681 mOptionsTab->removeTab( mOptionsTab->indexOf( calloutsTab ) );
682 mOptionsTab->removeTab( mOptionsTab->indexOf( maskTab ) );
683 mLabelStackedWidget->removeWidget( mLabelPage_Rendering );
684 mLabelStackedWidget->removeWidget( mLabelPage_Callouts );
685 mLabelStackedWidget->removeWidget( mLabelPage_Mask );
686 mLabelStackedWidget->removeWidget( mLabelPage_Placement );
696 mLabelStackedWidget->setCurrentIndex( prevIndex - 1 );
697 mOptionsTab->setCurrentIndex( prevIndex - 1 );
704 mLabelStackedWidget->setCurrentIndex( 0 );
705 mOptionsTab->setCurrentIndex( 0 );
709 mStackedWidgetLabelWith->hide();
710 mDirectSymbolsFrame->hide();
711 mFormatNumFrame->hide();
712 mFormatNumChkBx->hide();
713 mFormatNumDDBtn->hide();
714 mCheckBoxSubstituteText->hide();
715 mToolButtonConfigureSubstitutes->hide();
716 mLabelWrapOnCharacter->hide();
717 wrapCharacterEdit->hide();
718 mWrapCharDDBtn->hide();
719 mLabelWrapLinesTo->hide();
720 mAutoWrapLengthSpinBox->hide();
721 mAutoWrapLengthDDBtn->hide();
722 mAutoWrapTypeComboBox->hide();
723 mFontMultiLineLabel->hide();
724 mFontMultiLineAlignComboBox->hide();
725 mFontMultiLineAlignDDBtn->hide();
735 const QList<QgsPropertyOverrideButton *> buttons = findChildren<QgsPropertyOverrideButton *>();
738 button->setVisible( visible );
744 mOptionsTab->setVisible( enabled );
745 if (
int tabIndex = mOptionsTab->indexOf( textTab ); tabIndex >= 0 )
746 mOptionsTab->setTabToolTip( tabIndex, tr(
"Text" ) );
747 if (
int tabIndex = mOptionsTab->indexOf( formattingTab ); tabIndex >= 0 )
748 mOptionsTab->setTabToolTip( tabIndex, tr(
"Formatting" ) );
749 if (
int tabIndex = mOptionsTab->indexOf( bufferTab ); tabIndex >= 0 )
750 mOptionsTab->setTabToolTip( tabIndex, tr(
"Buffer" ) );
751 if (
int tabIndex = mOptionsTab->indexOf( maskTab ); tabIndex >= 0 )
752 mOptionsTab->setTabToolTip( tabIndex, tr(
"Mask" ) );
753 if (
int tabIndex = mOptionsTab->indexOf( backgroundTab ); tabIndex >= 0 )
754 mOptionsTab->setTabToolTip( tabIndex, tr(
"Background" ) );
755 if (
int tabIndex = mOptionsTab->indexOf( shadowTab ); tabIndex >= 0 )
756 mOptionsTab->setTabToolTip( tabIndex, tr(
"Shadow" ) );
757 if (
int tabIndex = mOptionsTab->indexOf( calloutsTab ); tabIndex >= 0 )
758 mOptionsTab->setTabToolTip( tabIndex, tr(
"Callouts" ) );
759 if (
int tabIndex = mOptionsTab->indexOf( placementTab ); tabIndex >= 0 )
760 mOptionsTab->setTabToolTip( tabIndex, tr(
"Placement" ) );
761 if (
int tabIndex = mOptionsTab->indexOf( renderingTab ); tabIndex >= 0 )
762 mOptionsTab->setTabToolTip( tabIndex, tr(
"Rendering" ) );
764 mLabelingOptionsListFrame->setVisible( !enabled );
765 groupBox_mPreview->setVisible( !enabled );
769void QgsTextFormatWidget::connectValueChanged(
const QList<QWidget *> &widgets )
771 const auto constWidgets = widgets;
772 for ( QWidget *widget : constWidgets )
778 else if ( QgsFieldExpressionWidget *w = qobject_cast<QgsFieldExpressionWidget *>( widget ) )
782 else if ( QgsOpacityWidget *w = qobject_cast<QgsOpacityWidget *>( widget ) )
786 else if ( QgsScaleWidget *w = qobject_cast<QgsScaleWidget *>( widget ) )
790 else if ( QgsUnitSelectionWidget *w = qobject_cast<QgsUnitSelectionWidget *>( widget ) )
794 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
798 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
802 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
806 else if ( QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
810 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
814 else if ( QRadioButton *w = qobject_cast<QRadioButton *>( widget ) )
818 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
822 else if ( QSlider *w = qobject_cast<QSlider *>( widget ) )
826 else if ( QGroupBox *w = qobject_cast<QGroupBox *>( widget ) )
830 else if ( QgsCodeEditorExpression *w = qobject_cast<QgsCodeEditorExpression *>( widget ) )
836 QgsLogger::warning( u
"Could not create connection for widget %1"_s.arg( widget->objectName() ) );
869 mDirectSymbDDBtn->registerCheckedWidget( mDirectSymbChkBx );
877 mFormatNumDDBtn->registerCheckedWidget( mFormatNumChkBx );
892 mEnableMaskDDBtn->registerCheckedWidget( mEnableMaskChkBx );
900 mShapeDrawDDBtn->registerCheckedWidget( mShapeDrawChkBx );
922 mShadowDrawDDBtn->registerCheckedWidget( mShadowDrawChkBx );
969 updateDataDefinedAlignment();
972 const QString ddScaleVisInfo = tr(
"Value < 0 represents a scale closer than 1:1, e.g. -10 = 10:1<br>"
973 "Value of 0 disables the specific limit." );
975 mScaleBasedVisibilityDDBtn->registerCheckedWidget( mScaleBasedVisibilityChkBx );
977 mScaleBasedVisibilityMinDDBtn->setUsageInfo( ddScaleVisInfo );
979 mScaleBasedVisibilityMaxDDBtn->setUsageInfo( ddScaleVisInfo );
985 mMinScaleWidget->setPredefinedScales( scales );
986 mMaxScaleWidget->setPredefinedScales( scales );
991 mMinScaleWidget->updateScales();
992 mMaxScaleWidget->updateScales();
996 mFontLimitPixelDDBtn->registerCheckedWidget( mFontLimitPixelChkBox );
1019 if ( !mButtons.contains( key ) )
1024 mButtons[key] = button;
1044 mBufferDrawChkBx->setChecked( buffer.
enabled() );
1045 mBufferFrame->setEnabled( buffer.
enabled() );
1046 spinBufferSize->setValue( buffer.
size() );
1047 mBufferUnitWidget->setUnit( buffer.
sizeUnit() );
1049 btnBufferColor->setColor( buffer.
color() );
1050 mBufferOpacityWidget->setOpacity( buffer.
opacity() );
1051 mBufferJoinStyleComboBox->setPenJoinStyle( buffer.
joinStyle() );
1053 comboBufferBlendMode->setBlendMode( buffer.
blendMode() );
1055 mBufferEffect.reset( lPaintEffect->clone() );
1059 mBufferEffect->setEnabled(
false );
1061 mBufferEffectWidget->setPaintEffect( mBufferEffect.get() );
1065 mEnableMaskChkBx->setChecked( mask.
enabled() );
1066 mMaskBufferSizeSpinBox->setValue( mask.
size() );
1067 mMaskBufferUnitWidget->setUnit( mask.
sizeUnit() );
1069 mMaskOpacityWidget->setOpacity( mask.
opacity() );
1070 mMaskJoinStyleComboBox->setPenJoinStyle( mask.
joinStyle() );
1072 mMaskEffect.reset( lPaintEffect->clone() );
1076 mMaskEffect->setEnabled(
false );
1078 mMaskEffectWidget->setPaintEffect( mMaskEffect.get() );
1080 mFontSizeUnitWidget->setUnit(
format.sizeUnit() );
1081 mFontSizeUnitWidget->setMapUnitScale(
format.sizeMapUnitScale() );
1082 mRefFont =
format.font();
1083 mFontSizeSpinBox->setValue(
format.size() );
1084 btnTextColor->setColor(
format.color() );
1086 mTextOpacityWidget->setOpacity(
format.opacity() );
1087 comboBlendMode->setBlendMode(
format.blendMode() );
1088 mTextOrientationComboBox->setCurrentIndex( mTextOrientationComboBox->findData(
static_cast<int>(
format.orientation() ) ) );
1089 mHtmlFormattingCheckBox->setChecked(
format.allowHtmlFormatting() );
1091 mFontWordSpacingSpinBox->setValue(
format.font().wordSpacing() );
1092 mFontLetterSpacingSpinBox->setValue(
format.font().letterSpacing() );
1095 mTabDistanceUnitWidget->setUnit(
format.tabStopDistanceUnit() );
1096 mTabDistanceUnitWidget->setMapUnitScale(
format.tabStopDistanceMapUnitScale() );
1099 whileBlocking( mFontCapitalsComboBox )->setCurrentIndex( mFontCapitalsComboBox->findData(
static_cast<int>(
format.capitalization() ) ) );
1101 updateFont( mRefFont );
1104 mFontMissingLabel->setVisible( !
format.fontFound() );
1105 if ( !
format.fontFound() )
1107 const QString missingTxt = tr(
"%1 not found. Default substituted." );
1108 QString txtPrepend = tr(
"Chosen font" );
1109 if ( !
format.resolvedFontFamily().isEmpty() )
1111 txtPrepend = u
"'%1'"_s.arg(
format.resolvedFontFamily() );
1113 mFontMissingLabel->setText( missingTxt.arg( txtPrepend ) );
1116 mLabelingOptionsListWidget->setCurrentItem(
mTextItem );
1117 whileBlocking( mOptionsTab )->setCurrentIndex( mOptionsTab->indexOf( textTab ) );
1120 mLineHeightUnitWidget->setUnit(
format.lineHeightUnit() );
1123 mShapeDrawChkBx->setChecked( background.
enabled() );
1124 mShapeFrame->setEnabled( background.
enabled() );
1125 mShapeTypeCmbBx->blockSignals(
true );
1126 mShapeTypeCmbBx->setCurrentIndex( mShapeTypeCmbBx->findData( background.
type() ) );
1127 mShapeTypeCmbBx->blockSignals(
false );
1128 updateAvailableShadowPositions();
1129 mShapeSVGPathLineEdit->setText( background.
svgFile() );
1131 mShapeSizeCmbBx->setCurrentIndex( background.
sizeType() );
1132 mShapeSizeXSpnBx->setValue( background.
size().width() );
1133 mShapeSizeYSpnBx->setValue( background.
size().height() );
1134 mShapeSizeUnitWidget->setUnit( background.
sizeUnit() );
1136 mShapeRotationCmbBx->setCurrentIndex( background.
rotationType() );
1139 mShapeRotationDblSpnBx->setValue( background.
rotation() );
1140 mShapeOffsetXSpnBx->setValue( background.
offset().x() );
1141 mShapeOffsetYSpnBx->setValue( background.
offset().y() );
1142 mShapeOffsetUnitWidget->setUnit( background.
offsetUnit() );
1144 mShapeRadiusXDbSpnBx->setValue( background.
radii().width() );
1145 mShapeRadiusYDbSpnBx->setValue( background.
radii().height() );
1146 mShapeRadiusUnitWidget->setUnit( background.
radiiUnit() );
1149 mShapeFillColorBtn->setColor( background.
fillColor() );
1150 mShapeStrokeColorBtn->setColor( background.
strokeColor() );
1151 mShapeStrokeWidthSpnBx->setValue( background.
strokeWidth() );
1155 mBackgroundOpacityWidget->setOpacity( background.
opacity() );
1156 mShapeBlendCmbBx->setBlendMode( background.
blendMode() );
1158 mLoadSvgParams =
false;
1159 mShapeTypeCmbBx_currentIndexChanged( background.
type() );
1161 if (
auto *lPaintEffect = background.
paintEffect() )
1162 mBackgroundEffect.reset( lPaintEffect->clone() );
1166 mBackgroundEffect->setEnabled(
false );
1168 mBackgroundEffectWidget->setPaintEffect( mBackgroundEffect.get() );
1174 mShadowDrawChkBx->setChecked( shadow.
enabled() );
1175 mShadowFrame->setEnabled( shadow.
enabled() );
1176 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( shadow.
shadowPlacement() ) );
1177 mShadowOffsetAngleSpnBx->setValue( shadow.
offsetAngle() );
1179 mShadowOffsetUnitWidget->setUnit( shadow.
offsetUnit() );
1181 mShadowOffsetGlobalChkBx->setChecked( shadow.
offsetGlobal() );
1183 mShadowRadiusDblSpnBx->setValue( shadow.
blurRadius() );
1186 mShadowRadiusAlphaChkBx->setChecked( shadow.
blurAlphaOnly() );
1187 mShadowOpacityWidget->setOpacity( shadow.
opacity() );
1188 mShadowScaleSpnBx->setValue( shadow.
scale() );
1190 mShadowColorBtn->setColor( shadow.
color() );
1191 mShadowBlendCmbBx->setBlendMode( shadow.
blendMode() );
1193 mPreviewBackgroundBtn->setColor(
format.previewBackgroundColor() );
1194 mPreviewBackgroundBtn->setDefaultColor(
format.previewBackgroundColor() );
1203 settings.
setValue( u
"Windows/Labeling/FontPreviewSplitState"_s, mFontPreviewSplitter->saveState() );
1204 settings.
setValue( u
"Windows/Labeling/OptionsSplitState"_s, mLabelingOptionsSplitter->saveState() );
1206 int prevIndex = mLabelingOptionsListWidget->currentRow();
1207 if ( mWidgetMode ==
Text )
1209 switch ( prevIndex )
1218 settings.
setValue( u
"Windows/Labeling/Tab"_s, prevIndex );
1224 format.setColor( btnTextColor->color() );
1225 format.setFont( mRefFont );
1226 format.setSize( mFontSizeSpinBox->value() );
1227 format.setNamedStyle( mFontStyleComboBox->currentText() );
1228 format.setOpacity( mTextOpacityWidget->opacity() );
1229 format.setStretchFactor( mSpinStretch->value() );
1230 format.setBlendMode( comboBlendMode->blendMode() );
1231 format.setSizeUnit( mFontSizeUnitWidget->unit() );
1232 format.setSizeMapUnitScale( mFontSizeUnitWidget->getMapUnitScale() );
1234 format.setLineHeightUnit( mLineHeightUnitWidget->unit() );
1235 format.setPreviewBackgroundColor( mPreviewBackgroundColor );
1237 format.setAllowHtmlFormatting( mHtmlFormattingCheckBox->isChecked() );
1239 format.setTabStopDistance( mTabDistanceUnitWidget->unit() ==
Qgis::RenderUnit::Percentage ? ( mTabStopDistanceSpin->value() / 100 ) : mTabStopDistanceSpin->value() );
1240 format.setTabStopDistanceUnit( mTabDistanceUnitWidget->unit() );
1241 format.setTabStopDistanceMapUnitScale( mTabDistanceUnitWidget->getMapUnitScale() );
1246 buffer.
setEnabled( mBufferDrawChkBx->isChecked() );
1247 buffer.
setSize( spinBufferSize->value() );
1248 buffer.
setColor( btnBufferColor->color() );
1249 buffer.
setOpacity( mBufferOpacityWidget->opacity() );
1252 buffer.
setJoinStyle( mBufferJoinStyleComboBox->penJoinStyle() );
1254 buffer.
setBlendMode( comboBufferBlendMode->blendMode() );
1259 format.setBuffer( buffer );
1263 mask.
setEnabled( mEnableMaskChkBx->isChecked() );
1264 mask.
setSize( mMaskBufferSizeSpinBox->value() );
1265 mask.
setOpacity( mMaskOpacityWidget->opacity() );
1266 mask.
setSizeUnit( mMaskBufferUnitWidget->unit() );
1268 mask.
setJoinStyle( mMaskJoinStyleComboBox->penJoinStyle() );
1278 background.
setEnabled( mShapeDrawChkBx->isChecked() );
1280 background.
setSvgFile( mShapeSVGPathLineEdit->text() );
1282 background.
setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
1283 background.
setSizeUnit( mShapeSizeUnitWidget->unit() );
1286 background.
setRotation( mShapeRotationDblSpnBx->value() );
1287 background.
setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
1290 background.
setRadii( QSizeF( mShapeRadiusXDbSpnBx->value(), mShapeRadiusYDbSpnBx->value() ) );
1291 background.
setRadiiUnit( mShapeRadiusUnitWidget->unit() );
1294 background.
setFillColor( mShapeFillColorBtn->color() );
1299 background.
setOpacity( mBackgroundOpacityWidget->opacity() );
1300 background.
setBlendMode( mShapeBlendCmbBx->blendMode() );
1307 format.setBackground( background );
1311 shadow.
setEnabled( mShadowDrawChkBx->isChecked() );
1322 shadow.
setOpacity( mShadowOpacityWidget->opacity() );
1323 shadow.
setScale( mShadowScaleSpnBx->value() );
1324 shadow.
setColor( mShadowColorBtn->color() );
1326 format.setShadow( shadow );
1328 if ( includeDataDefinedProperties )
1359 if ( mButtons.contains( key ) )
1368void QgsTextFormatWidget::optionsStackedWidget_CurrentChanged(
int )
1370 mLabelingOptionsListWidget->blockSignals(
true );
1371 QWidget *currentPage = mLabelStackedWidget->currentWidget();
1372 if ( currentPage == mLabelPage_Text )
1373 mLabelingOptionsListWidget->setCurrentItem(
mTextItem );
1374 else if ( currentPage == mLabelPage_Formatting )
1376 else if ( currentPage == mLabelPage_Mask )
1377 mLabelingOptionsListWidget->setCurrentItem(
mMaskItem );
1378 if ( currentPage == mLabelPage_Buffer )
1379 mLabelingOptionsListWidget->setCurrentItem(
mBufferItem );
1380 if ( currentPage == mLabelPage_Background )
1382 if ( currentPage == mLabelPage_Shadow )
1383 mLabelingOptionsListWidget->setCurrentItem(
mShadowItem );
1384 if ( currentPage == mLabelPage_Callouts )
1385 mLabelingOptionsListWidget->setCurrentItem(
mCalloutItem );
1386 if ( currentPage == mLabelPage_Rendering )
1388 if ( currentPage == mLabelPage_Placement )
1390 mLabelingOptionsListWidget->blockSignals(
false );
1397 if (
auto *lExpressionContext =
mContext.expressionContext() )
1399 mPreviewExpressionContext = *lExpressionContext;
1404 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
1407 symbolWidget->setMapCanvas(
mContext.mapCanvas() );
1408 symbolWidget->setMessageBar(
mContext.messageBar() );
1412void QgsTextFormatWidget::collapseSample(
bool collapse )
1416 QList<int> splitSizes = mFontPreviewSplitter->sizes();
1417 if ( splitSizes[0] > groupBox_mPreview->height() )
1419 const int delta = splitSizes[0] - groupBox_mPreview->height();
1420 splitSizes[0] -= delta;
1421 splitSizes[1] += delta;
1422 mFontPreviewSplitter->setSizes( splitSizes );
1427void QgsTextFormatWidget::changeTextColor(
const QColor &color )
1433void QgsTextFormatWidget::updateFont(
const QFont &newFont )
1436 if ( newFont != mRefFont )
1445 QFont symbolFont = mRefFont;
1446 symbolFont.setPointSize( font().pointSize() );
1447 mDirectSymbLeftLineEdit->setFont( symbolFont );
1448 mDirectSymbRightLineEdit->setFont( symbolFont );
1450 blockFontChangeSignals(
true );
1451 mFontFamilyCmbBx->setCurrentFont( symbolFont );
1452 populateFontStyleComboBox();
1453 mFontUnderlineBtn->setChecked( mRefFont.underline() );
1454 mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
1455 mKerningCheckBox->setChecked( mRefFont.kerning() );
1456 blockFontChangeSignals(
false );
1464void QgsTextFormatWidget::blockFontChangeSignals(
bool blk )
1466 mFontFamilyCmbBx->blockSignals( blk );
1467 mFontStyleComboBox->blockSignals( blk );
1468 mFontCapitalsComboBox->blockSignals( blk );
1469 mFontUnderlineBtn->blockSignals( blk );
1470 mFontStrikethroughBtn->blockSignals( blk );
1471 mFontWordSpacingSpinBox->blockSignals( blk );
1472 mFontLetterSpacingSpinBox->blockSignals( blk );
1473 mKerningCheckBox->blockSignals( blk );
1488 lblFontPreview->setFormat(
format() );
1491void QgsTextFormatWidget::scrollPreview()
1493 scrollArea_mPreview->ensureVisible( 0, 0, 0, 0 );
1498 mPreviewBackgroundColor = color;
1500 scrollArea_mPreview->widget()->setStyleSheet( u
"background: rgb(%1, %2, %3);"_s.arg( QString::number( color.red() ), QString::number( color.green() ), QString::number( color.blue() ) ) );
1503void QgsTextFormatWidget::changeBufferColor(
const QColor &color )
1512 bool showLineFrame =
false;
1513 bool showCentroidFrame =
false;
1514 bool showQuadrantFrame =
false;
1515 bool showFixedQuadrantFrame =
false;
1516 bool showPlacementPriorityFrame =
false;
1517 bool showOffsetTypeFrame =
false;
1518 bool showOffsetFrame =
false;
1519 bool showDistanceFrame =
false;
1520 bool showMaximumDistanceFrame =
false;
1521 bool showPrioritizationFrame =
false;
1522 bool showRotationFrame =
false;
1523 bool showMaxCharAngleFrame =
false;
1524 bool showCurvedLabelModeFrame =
false;
1525 bool showWhitespaceCollisionFrame =
false;
1530 bool enableMultiLinesFrame =
true;
1536 showDistanceFrame =
true;
1537 showMaximumDistanceFrame =
true;
1545 showQuadrantFrame =
true;
1546 showFixedQuadrantFrame =
true;
1547 showOffsetFrame =
true;
1548 showRotationFrame =
true;
1552 showDistanceFrame =
true;
1553 showMaximumDistanceFrame =
true;
1554 showPlacementPriorityFrame =
true;
1555 showPrioritizationFrame =
true;
1556 showOffsetTypeFrame =
true;
1563 showLineFrame =
true;
1564 showDistanceFrame =
true;
1569 const bool offline = chkLineAbove->isChecked() || chkLineBelow->isChecked();
1570 chkLineOrientationDependent->setEnabled( offline );
1571 mPlacementDistanceFrame->setEnabled( offline );
1575 showMaxCharAngleFrame = isCurved;
1577 enableMultiLinesFrame = !isCurved;
1582 showDistanceFrame =
true;
1585 mPlacementLineFrame->setVisible( showLineFrame );
1586 mPlacementPolygonFrame->setVisible( showPolygonPlacementOptions );
1587 mPlacementCentroidFrame->setVisible( showCentroidFrame );
1588 mPlacementQuadrantFrame->setVisible( showQuadrantFrame );
1589 mPlacementFixedQuadrantFrame->setVisible( showFixedQuadrantFrame );
1590 mPlacementCartographicFrame->setVisible( showPlacementPriorityFrame );
1591 mPlacementOffsetFrame->setVisible( showOffsetFrame );
1592 mPlacementDistanceFrame->setVisible( showDistanceFrame );
1593 mPlacementMaximumDistanceFrame->setVisible( showMaximumDistanceFrame );
1594 mPlacementPrioritizationFrame->setVisible( showPrioritizationFrame );
1595 mPlacementOffsetTypeFrame->setVisible( showOffsetTypeFrame );
1596 mWhitespaceCollisionFrame->setVisible( showWhitespaceCollisionFrame );
1597 mPlacementRotationFrame->setVisible( showRotationFrame );
1601 mPlacementMaxCharAngleFrame->setVisible( showMaxCharAngleFrame );
1602 mCurvedLabelModeFrame->setVisible( showCurvedLabelModeFrame );
1604 mMultiLinesFrame->setEnabled( enableMultiLinesFrame );
1608 switch ( currentPlacement )
1612 helperText = tr(
"Arranges label candidates in a clockwise circle around the feature, preferring placements to the top-right of the feature." );
1614 helperText = tr(
"Arranges label candidates in a cluster around the feature's centroid, preferring placements directly over the centroid." );
1618 helperText = tr(
"Arranges label candidates directly over the feature or at a preset offset from the feature." );
1620 helperText = tr(
"Arranges label candidates directly over the feature's centroid, or at a preset offset from the centroid." );
1624 helperText = tr(
"Arranges label candidates parallel to a generalised line representing the feature. Placements which fall over straighter portions of the line are preferred." );
1626 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." );
1630 helperText = tr(
"Arranges candidates following the curvature of a line feature. Placements which fall over straighter portions of the line are preferred." );
1634 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." );
1636 helperText = tr(
"Label candidates are arranged horizontally along the length of the feature." );
1640 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." );
1644 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." );
1648 helperText = tr(
"Arranges candidates following the curvature of the feature's perimeter. Placements which fall over straighter portions of the perimeter are preferred." );
1652 helperText = tr(
"Label candidates are placed outside of the features, preferring placements which give greatest visual association between the label and the feature." );
1655 mPlacementModeDescriptionLabel->setText( u
"<i>%1</i>"_s.arg( helperText ) );
1658void QgsTextFormatWidget::populateFontCapitalsComboBox()
1669void QgsTextFormatWidget::populateFontStyleComboBox()
1671 mFontStyleComboBox->clear();
1672 const QStringList styles = mFontDB.styles( mRefFont.family() );
1673 const auto constStyles = styles;
1674 for (
const QString &style : constStyles )
1676 mFontStyleComboBox->addItem( style );
1679 QString targetStyle = mFontDB.styleString( mRefFont );
1680 if ( !styles.contains( targetStyle ) )
1683 targetStyle = QFontInfo( f ).styleName();
1684 mRefFont.setStyleName( targetStyle );
1687 const int stylIndx = mFontStyleComboBox->findText( targetStyle );
1688 if ( stylIndx > -1 )
1693 mFontStyleComboBox->setCurrentIndex( curIndx );
1696void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged(
double d )
1698 mRefFont.setPointSizeF( d );
1699 updateFont( mRefFont );
1702void QgsTextFormatWidget::mFontFamilyCmbBx_currentFontChanged(
const QFont &f )
1705 updateFont( mRefFont );
1708void QgsTextFormatWidget::mFontStyleComboBox_currentIndexChanged(
const QString &text )
1711 updateFont( mRefFont );
1714void QgsTextFormatWidget::mFontUnderlineBtn_toggled(
bool ckd )
1716 mRefFont.setUnderline( ckd );
1717 updateFont( mRefFont );
1720void QgsTextFormatWidget::mFontStrikethroughBtn_toggled(
bool ckd )
1722 mRefFont.setStrikeOut( ckd );
1723 updateFont( mRefFont );
1726void QgsTextFormatWidget::kerningToggled(
bool checked )
1728 mRefFont.setKerning( checked );
1729 updateFont( mRefFont );
1732void QgsTextFormatWidget::mFontWordSpacingSpinBox_valueChanged(
double spacing )
1734 mRefFont.setWordSpacing( spacing );
1735 updateFont( mRefFont );
1738void QgsTextFormatWidget::mFontLetterSpacingSpinBox_valueChanged(
double spacing )
1740 mRefFont.setLetterSpacing( QFont::AbsoluteSpacing, spacing );
1741 updateFont( mRefFont );
1744void QgsTextFormatWidget::mFontSizeUnitWidget_changed()
1749 mFontLimitPixelChkBox->setChecked(
false );
1755 mFontLimitPixelChkBox->setChecked(
true );
1757 updateFont( mRefFont );
1760void QgsTextFormatWidget::mFontMinPixelSpinBox_valueChanged(
int px )
1763 mFontMaxPixelSpinBox->setMinimum( px );
1764 mFontMaxPixelSpinBox->update();
1767void QgsTextFormatWidget::mFontMaxPixelSpinBox_valueChanged(
int px )
1770 if ( px < mFontMinPixelSpinBox->value() )
1772 mFontMaxPixelSpinBox->blockSignals(
true );
1773 mFontMaxPixelSpinBox->setValue( mFontMinPixelSpinBox->value() );
1774 mFontMaxPixelSpinBox->blockSignals(
false );
1776 mFontMaxPixelSpinBox->setMinimum( mFontMinPixelSpinBox->value() );
1779void QgsTextFormatWidget::mBufferUnitWidget_changed()
1781 updateFont( mRefFont );
1784void QgsTextFormatWidget::mMaskBufferUnitWidget_changed()
1786 updateFont( mRefFont );
1789void QgsTextFormatWidget::mCoordXDDBtn_changed()
1791 updateDataDefinedAlignment();
1794void QgsTextFormatWidget::mCoordXDDBtn_activated(
bool isActive )
1799 mCoordPointDDBtn->setActive(
false );
1802void QgsTextFormatWidget::mCoordYDDBtn_changed()
1804 updateDataDefinedAlignment();
1807void QgsTextFormatWidget::mCoordYDDBtn_activated(
bool isActive )
1812 mCoordPointDDBtn->setActive(
false );
1815void QgsTextFormatWidget::mCoordPointDDBtn_changed()
1817 updateDataDefinedAlignment();
1820void QgsTextFormatWidget::mCoordPointDDBtn_activated(
bool isActive )
1825 mCoordXDDBtn->setActive(
false );
1826 mCoordYDDBtn->setActive(
false );
1829void QgsTextFormatWidget::mShapeTypeCmbBx_currentIndexChanged(
int )
1837 showBackgroundRadius( isRect );
1839 mShapeSVGPathFrame->setVisible( isSVG );
1840 mBackgroundMarkerSymbolButton->setVisible( isMarker );
1841 mBackgroundFillSymbolButton->setVisible( !isSVG && !isMarker );
1845 mShapeSizeYLabel->setVisible( !isSVG && !isMarker );
1846 mShapeSizeYSpnBx->setVisible( !isSVG && !isMarker );
1847 mShapeSizeYDDBtn->setVisible( !isSVG && !isMarker );
1848 mShapeSizeXLabel->setText( tr(
"Size%1" ).arg( !isSVG && !isMarker ? tr(
" X" ) : QString() ) );
1851 mShapeFillColorBtn->setAllowOpacity( !isSVG );
1852 mShapeFillColorBtn->setButtonBackground();
1853 mShapeStrokeColorBtn->setAllowOpacity( !isSVG );
1854 mShapeStrokeColorBtn->setButtonBackground();
1857 mShapeFillColorLabel->setVisible( isSVG );
1858 mShapeFillColorLabel->setEnabled( isSVG );
1859 mShapeFillColorBtn->setVisible( isSVG );
1860 mShapeFillColorBtn->setEnabled( isSVG );
1861 mShapeFillColorDDBtn->setVisible( isSVG );
1862 mShapeFillColorDDBtn->setEnabled( isSVG );
1863 mShapeStrokeColorLabel->setVisible( isSVG );
1864 mShapeStrokeColorLabel->setEnabled( isSVG );
1865 mShapeStrokeColorBtn->setVisible( isSVG );
1866 mShapeStrokeColorBtn->setEnabled( isSVG );
1867 mShapeStrokeColorDDBtn->setVisible( isSVG );
1868 mShapeStrokeColorDDBtn->setEnabled( isSVG );
1869 mShapeStrokeWidthLabel->setVisible( isSVG );
1870 mShapeStrokeWidthLabel->setEnabled( isSVG );
1871 mShapeStrokeWidthSpnBx->setVisible( isSVG );
1872 mShapeStrokeWidthSpnBx->setEnabled( isSVG );
1873 mShapeStrokeWidthDDBtn->setVisible( isSVG );
1874 mShapeStrokeWidthDDBtn->setEnabled( isSVG );
1877 mShapeSVGParamsBtn->setVisible( isSVG );
1880 updateSvgWidgets( mShapeSVGPathLineEdit->text() );
1884 mShapeSVGUnitsLabel->setVisible( isSVG );
1885 mShapeStrokeWidthUnitWidget->setVisible(
false );
1886 mShapeStrokeUnitsDDBtn->setVisible(
false );
1887 mShapeStrokeUnitsDDBtn->setEnabled(
false );
1889 updateAvailableShadowPositions();
1892void QgsTextFormatWidget::mShapeSVGPathLineEdit_textChanged(
const QString &text )
1894 updateSvgWidgets( text );
1899 const int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) + ( chkLineBelow->isChecked() ? 1 : 0 ) + ( chkLineOn->isChecked() ? 1 : 0 );
1901 if ( numOptionsChecked == 1 )
1904 chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
1905 chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
1906 chkLineOn->setEnabled( !chkLineOn->isChecked() );
1910 chkLineAbove->setEnabled(
true );
1911 chkLineBelow->setEnabled(
true );
1912 chkLineOn->setEnabled(
true );
1922void QgsTextFormatWidget::previewScaleChanged(
double scale )
1924 lblFontPreview->setScale( scale );
1927void QgsTextFormatWidget::updateSvgWidgets(
const QString &svgPath )
1929 if ( mShapeSVGPathLineEdit->text() != svgPath )
1931 mShapeSVGPathLineEdit->setText( svgPath );
1934 QString resolvedPath;
1935 bool validSVG =
true;
1936 if ( !svgPath.startsWith(
"base64:"_L1, Qt::CaseInsensitive ) )
1939 validSVG = QFileInfo::exists( resolvedPath );
1943 resolvedPath = svgPath;
1948 mShapeSVGPathLineEdit->setStyleSheet( !validSVG ? u
"QLineEdit{ color: rgb(225, 0, 0); }"_s : QString() );
1949 mShapeSVGPathLineEdit->setToolTip( !validSVG ? tr(
"File not found" ) : resolvedPath );
1951 QColor fill, stroke;
1952 double strokeWidth = 0.0;
1953 bool fillParam =
false, strokeParam =
false, strokeWidthParam =
false;
1959 mShapeSVGParamsBtn->setEnabled( validSVG && ( fillParam || strokeParam || strokeWidthParam ) );
1961 mShapeFillColorLabel->setEnabled( validSVG && fillParam );
1962 mShapeFillColorBtn->setEnabled( validSVG && fillParam );
1963 mShapeFillColorDDBtn->setEnabled( validSVG && fillParam );
1964 if ( mLoadSvgParams && validSVG && fillParam )
1965 mShapeFillColorBtn->setColor( fill );
1967 mShapeStrokeColorLabel->setEnabled( validSVG && strokeParam );
1968 mShapeStrokeColorBtn->setEnabled( validSVG && strokeParam );
1969 mShapeStrokeColorDDBtn->setEnabled( validSVG && strokeParam );
1970 if ( mLoadSvgParams && validSVG && strokeParam )
1971 mShapeStrokeColorBtn->setColor( stroke );
1973 mShapeStrokeWidthLabel->setEnabled( validSVG && strokeWidthParam );
1974 mShapeStrokeWidthSpnBx->setEnabled( validSVG && strokeWidthParam );
1975 mShapeStrokeWidthDDBtn->setEnabled( validSVG && strokeWidthParam );
1976 if ( mLoadSvgParams && validSVG && strokeWidthParam )
1977 mShapeStrokeWidthSpnBx->setValue( strokeWidth );
1983 mShapeSVGUnitsLabel->setEnabled( validSVG && strokeWidthParam );
1986void QgsTextFormatWidget::updateAvailableShadowPositions()
1988 if ( mShadowUnderCmbBx->count() == 0
1994 mShadowUnderCmbBx->clear();
2002 mShadowUnderCmbBx->setCurrentIndex( mShadowUnderCmbBx->findData( currentPlacement ) );
2003 if ( mShadowUnderCmbBx->currentIndex() == -1 )
2004 mShadowUnderCmbBx->setCurrentIndex( 0 );
2008void QgsTextFormatWidget::updateProperty()
2010 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
2016void QgsTextFormatWidget::createAuxiliaryField()
2021 QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer *>(
mLayer );
2029 QgsNewAuxiliaryLayerDialog dlg( vLayer,
this );
2037 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
2048 property.setActive(
true );
2057void QgsTextFormatWidget::updateShapeFrameStatus()
2059 mShapeFrame->setEnabled( mShapeDrawDDBtn->isActive() || mShapeDrawChkBx->isChecked() );
2062void QgsTextFormatWidget::updateBufferFrameStatus()
2064 mBufferFrame->setEnabled( mBufferDrawDDBtn->isActive() || mBufferDrawChkBx->isChecked() );
2067void QgsTextFormatWidget::updateShadowFrameStatus()
2069 mShadowFrame->setEnabled( mShadowDrawDDBtn->isActive() || mShadowDrawChkBx->isChecked() );
2072void QgsTextFormatWidget::updateCalloutFrameStatus()
2074 mCalloutFrame->setEnabled( mCalloutDrawDDBtn->isActive() || mCalloutsDrawCheckBox->isChecked() );
2077void QgsTextFormatWidget::updateDataDefinedAlignment()
2080 mCoordAlignmentFrame->setEnabled( ( mCoordXDDBtn->isActive() && mCoordYDDBtn->isActive() ) || mCoordPointDDBtn->isActive() );
2083void QgsTextFormatWidget::overlapModeChanged()
2085 QString description;
2089 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.)" );
2092 description = tr(
"If a label cannot otherwise be placed for a feature then an overlapping label is permitted." );
2095 description = tr(
"Labels from this layer may freely overlap other labels or label obstacles without penalty." );
2099 mOverlapModeDescriptionLabel->setText( u
"<i>%1</i>"_s.arg( description ) );
2102void QgsTextFormatWidget::updateCurvedLabelDescription()
2107 mCurvedModeDescriptionLabel->hide();
2110 mCurvedModeDescriptionLabel->setText( tr(
"Places individual characters from the label at each corresponding vertex in the line." ) );
2111 mCurvedModeDescriptionLabel->show();
2114 mCurvedModeDescriptionLabel->setText( tr(
"Stretches (or shrinks) character spacing so that the curved label fits the whole line." ) );
2115 mCurvedModeDescriptionLabel->show();
2118 mCurvedModeDescriptionLabel->setText( tr(
"Stretches (or shrinks) word spacing so that the curved label fits the whole line." ) );
2119 mCurvedModeDescriptionLabel->show();
2126 if ( name.isEmpty() )
2169 saveDlg.
setDefaultTags( mTextFormatsListWidget->currentTagFilter() );
2170 if ( !saveDlg.exec() )
2173 if ( saveDlg.
name().isEmpty() )
2183 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 );
2184 if ( res != QMessageBox::Yes )
2191 const QStringList symbolTags = saveDlg.
tags().split(
',' );
2198void QgsTextFormatWidget::mShapeSVGSelectorBtn_clicked()
2201 svgDlg.setWindowTitle( tr(
"Select SVG file" ) );
2202 svgDlg.svgSelector()->setSvgPath( mShapeSVGPathLineEdit->text().trimmed() );
2204 if ( svgDlg.exec() == QDialog::Accepted )
2206 const QString svgPath = svgDlg.svgSelector()->currentSvgPath();
2207 if ( !svgPath.isEmpty() )
2209 mShapeSVGPathLineEdit->setText( svgPath );
2215void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
2217 const QString svgPath = mShapeSVGPathLineEdit->text();
2218 mLoadSvgParams =
true;
2219 updateSvgWidgets( svgPath );
2220 mLoadSvgParams =
false;
2223void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged(
int index )
2229void QgsTextFormatWidget::mPreviewTextEdit_textChanged(
const QString &text )
2231 lblFontPreview->setText( text );
2235void QgsTextFormatWidget::mPreviewTextBtn_clicked()
2237 mPreviewTextEdit->setText( u
"Lorem Ipsum"_s );
2241void QgsTextFormatWidget::mPreviewBackgroundBtn_colorChanged(
const QColor &color )
2246void QgsTextFormatWidget::mDirectSymbLeftToolBtn_clicked()
2248 bool gotChar =
false;
2250 const QChar initial = !mDirectSymbLeftLineEdit->text().isEmpty() ? mDirectSymbLeftLineEdit->text().at( 0 ) : QChar();
2251 const QChar dirSymb = mCharDlg->selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
2256 if ( !dirSymb.isNull() )
2257 mDirectSymbLeftLineEdit->setText( QString( dirSymb ) );
2260void QgsTextFormatWidget::mDirectSymbRightToolBtn_clicked()
2262 bool gotChar =
false;
2263 const QChar initial = !mDirectSymbRightLineEdit->text().isEmpty() ? mDirectSymbRightLineEdit->text().at( 0 ) : QChar();
2264 const QChar dirSymb = mCharDlg->selectCharacter( &gotChar, mRefFont, mFontDB.styleString( mRefFont ), initial );
2269 if ( !dirSymb.isNull() )
2270 mDirectSymbRightLineEdit->setText( QString( dirSymb ) );
2273void QgsTextFormatWidget::chkLineOrientationDependent_toggled(
bool active )
2277 chkLineAbove->setText( tr(
"Left of line" ) );
2278 chkLineBelow->setText( tr(
"Right of line" ) );
2282 chkLineAbove->setText( tr(
"Above line" ) );
2283 chkLineBelow->setText( tr(
"Below line" ) );
2288void QgsTextFormatWidget::mToolButtonConfigureSubstitutes_clicked()
2293 QgsSubstitutionListWidget *widget =
new QgsSubstitutionListWidget( panel );
2301 QgsSubstitutionListDialog dlg(
this );
2303 if ( dlg.exec() == QDialog::Accepted )
2310void QgsTextFormatWidget::configureTabStops()
2315 QgsTabPositionWidget *widget =
new QgsTabPositionWidget( panel );
2318 widget->
setUnit( mTabDistanceUnitWidget->unit() );
2328 QgsTabPositionDialog dlg(
this );
2330 dlg.setUnit( mTabDistanceUnitWidget->unit() );
2331 if ( dlg.exec() == QDialog::Accepted )
2340void QgsTextFormatWidget::showBackgroundRadius(
bool show )
2342 mShapeRadiusLabel->setVisible( show );
2343 mShapeRadiusXDbSpnBx->setVisible( show );
2345 mShapeRadiusYDbSpnBx->setVisible( show );
2347 mShapeRadiusUnitWidget->setVisible( show );
2349 mShapeRadiusDDBtn->setVisible( show );
2350 mShapeRadiusUnitsDDBtn->setVisible( show );
2355 if (
auto *lExpressionContext =
mContext.expressionContext() )
2356 return *lExpressionContext;
2361 expContext =
mMapCanvas->createExpressionContext();
2383 if ( mGeometryGeneratorGroupBox->isChecked() )
2397 : QDialog( parent, fl )
2399 setWindowTitle( tr(
"Text Settings" ) );
2402 mFormatWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
2404 QVBoxLayout *layout =
new QVBoxLayout(
this );
2405 layout->addWidget( mFormatWidget );
2407 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, Qt::Horizontal,
this );
2408 layout->addWidget( mButtonBox );
2410 setLayout( layout );
2413 connect( mButtonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked,
this, &QDialog::accept );
2414 connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked,
this, &QDialog::reject );
2415 connect( mButtonBox->button( QDialogButtonBox::Help ), &QAbstractButton::clicked,
this, &QgsTextFormatDialog::showHelp );
2420 return mFormatWidget->format();
2423void QgsTextFormatDialog::showHelp()
2425 QgsHelp::openHelp( u
"style_library/label_settings.html#formatting-the-label-text"_s );
2430 mFormatWidget->setContext( context );
2441 mFormatWidget = qobject_cast<QgsTextFormatWidget *>(
widget() );
2443 if ( !mBlockSignals )
2450 return mFormatWidget->format();
2455 mBlockSignals =
true;
2456 mFormatWidget->setFormat(
format );
2457 mBlockSignals =
false;
2462 mFormatWidget->setContext( context );
2467 mFormatWidget->setDockMode(
dockMode );
CurvedLabelMode
Modes which determine how curved labels are generated and placed.
@ StretchCharacterSpacingToFitLine
Increases (or decreases) the character spacing used for each label in order to fit the entire text ov...
@ Default
Default curved placement, characters are placed in an optimal position along the line....
@ StretchWordSpacingToFitLine
Increases (or decreases) the word spacing used for each label in order to fit the entire text over th...
@ PlaceCharactersAtVertices
Each individual character from the label text is placed such that their left-baseline position is loc...
@ LabelLargestPartOnly
Place a label only on the largest part from the geometry.
@ SplitLabelTextLinesOverParts
Splits the label text over the parts of the geometry, such that each consecutive part is labeled with...
@ LabelEveryPartWithEntireLabel
Place the (same) entire label over every part from the geometry.
@ 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.
@ WhitespaceCollisionHandling
Whitespace collision handling.
@ 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
Multipart geometry behavior.
@ 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.
@ CurvedLabelMode
Mode which determine how curved labels are generated and placed.
@ 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.