27#include <QDialogButtonBox>
40 mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
41 verticalLayout->insertWidget( 0, mMessageBar );
45 mTextRenderFormatComboBox->addItem( tr(
"Always Render Labels as Paths (Recommended)" ),
static_cast< int >( Qgis::TextRenderFormat::AlwaysOutlines ) );
46 mTextRenderFormatComboBox->addItem( tr(
"Always Render Labels as Text" ),
static_cast< int >( Qgis::TextRenderFormat::AlwaysText ) );
48 mPlacementVersionComboBox->addItem( tr(
"Version 1" ),
static_cast< int >( Qgis::LabelPlacementEngineVersion::Version1 ) );
49 mPlacementVersionComboBox->addItem( tr(
"Version 2 (Recommended)" ),
static_cast< int >( Qgis::LabelPlacementEngineVersion::Version2 ) );
52 mPlacementVersionComboBox->setCurrentIndex( mPlacementVersionComboBox->findData(
static_cast< int >( mPreviousEngineVersion ) ) );
53 connect( mPlacementVersionComboBox, &QComboBox::currentTextChanged,
this, [ = ]()
57 mMessageBar->pushMessage( QString(), tr(
"Version changes will alter label placement in the project." ), Qgis::MessageLevel::Warning );
61 spinCandLine->setClearValue( 5 );
62 spinCandPolygon->setClearValue( 2.5 );
75 mUnplacedColorButton->setAllowOpacity(
false );
76 mUnplacedColorButton->setDefaultColor( QColor( 255, 0, 0 ) );
77 mUnplacedColorButton->setWindowTitle( tr(
"Unplaced Label Color" ) );
79 mTextRenderFormatComboBox->setCurrentIndex( mTextRenderFormatComboBox->findData(
static_cast< int >( engineSettings.
defaultTextRenderFormat() ) ) );
92 mWidgetMenu =
new QMenu(
this );
93 QAction *resetAction =
new QAction( tr(
"Restore Defaults" ),
this );
94 mWidgetMenu->addAction( resetAction );
96 QAction *helpAction =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionHelpContents.svg" ) ), tr(
"Help…" ),
this );
97 mWidgetMenu->addAction( helpAction );
108 return tr(
"Additional Options" );
138 spinCandLine->setValue( 5 );
139 spinCandPolygon->setValue( 10 );
140 chkShowCandidates->setChecked(
false );
141 chkShowMetrics->setChecked(
false );
142 chkShowAllLabels->setChecked(
false );
144 mTextRenderFormatComboBox->setCurrentIndex( mTextRenderFormatComboBox->findData(
static_cast< int >( Qgis::TextRenderFormat::AlwaysOutlines ) ) );
145 mPlacementVersionComboBox->setCurrentIndex( mPlacementVersionComboBox->findData(
static_cast< int >( Qgis::LabelPlacementEngineVersion::Version2 ) ) );
150 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/vector_properties.html#setting-the-automated-placement-engine" ) );
161 setWindowTitle( mWidget->windowTitle() );
162 QVBoxLayout *vLayout =
new QVBoxLayout();
163 vLayout->addWidget( mWidget );
164 QDialogButtonBox *bbox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::RestoreDefaults, Qt::Horizontal );
165 connect( bbox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
166 connect( bbox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
168 connect( bbox->button( QDialogButtonBox::RestoreDefaults ), &QAbstractButton::clicked,
170 vLayout->addWidget( bbox );
171 setLayout( vLayout );
173 setObjectName( QStringLiteral(
"QgsLabelSettingsWidgetDialog" ) );
@ DrawCandidates
Whether to draw rectangles of generated candidates (good for debugging)
@ DrawLabelMetrics
Whether to render label metric guides (for debugging). Since QGIS 3.30.
@ DrawUnplacedLabels
Whether to render unplaced labels as an indicator/warning for users.
@ UseAllLabels
Whether to draw all labels even if there would be collisions.
@ UsePartialCandidates
Whether to use also label candidates that are partially outside of the map view.
TextRenderFormat
Options for rendering text.
LabelPlacementEngineVersion
Labeling placement engine version.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
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.
QgsLabelEngineConfigDialog(QgsMapCanvas *canvas, QWidget *parent=nullptr)
constructor
Stores global configuration for labeling engine.
Qgis::TextRenderFormat defaultTextRenderFormat() const
Returns the default text rendering format for the labels.
void setDefaultTextRenderFormat(Qgis::TextRenderFormat format)
Sets the default text rendering format for the labels.
void setFlag(Qgis::LabelingFlag f, bool enabled=true)
Sets whether a particual flag is enabled.
void setPlacementVersion(Qgis::LabelPlacementEngineVersion version)
Sets the placement engine version, which dictates how the label placement problem is solved.
void setMaximumPolygonCandidatesPerCmSquared(double candidates)
Sets the maximum number of polygon label candidates per centimeter squared.
QColor unplacedLabelColor() const
Returns the color to use when rendering unplaced labels.
Qgis::LabelPlacementEngineVersion placementVersion() const
Returns the placement engine version, which dictates how the label placement problem is solved.
bool testFlag(Qgis::LabelingFlag f) const
Test whether a particular flag is enabled.
void setUnplacedLabelColor(const QColor &color)
Sets the color to use when rendering unplaced labels.
double maximumPolygonCandidatesPerCmSquared() const
Returns the maximum number of polygon label candidate positions per centimeter squared.
void setMaximumLineCandidatesPerCm(double candidates)
Sets the maximum number of line label candidates per centimeter.
double maximumLineCandidatesPerCm() const
Returns the maximum number of line label candidate positions per centimeter.
Map canvas is a class for displaying all GIS data types on a canvas.
void refreshAllLayers()
Reload all layers (including refreshing layer properties from their data sources),...
A bar for displaying non-blocking messages to the user.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void setLabelingEngineSettings(const QgsLabelingEngineSettings &settings)
Sets project's global labeling engine settings.
const QgsLabelingEngineSettings & labelingEngineSettings() const
Returns project's global labeling engine settings.
bool showPartialLabels() const
Returns whether partial labels should be allowed.