22#include "moc_qgslabellineanchorwidget.cpp"
31 mPercentPlacementComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionLabelAnchorCenter.svg" ) ), tr(
"Center of Line" ), 0.5 );
32 mPercentPlacementComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionLabelAnchorStart.svg" ) ), tr(
"Start of Line" ), 0.0 );
33 mPercentPlacementComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionLabelAnchorEnd.svg" ) ), tr(
"End of Line" ), 1.0 );
34 mPercentPlacementComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionLabelAnchorCustom.svg" ) ), tr(
"Custom…" ), -1.0 );
47 connect( mPercentPlacementComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
51 if ( mPercentPlacementComboBox->currentData().toDouble() < 0 )
52 mCustomPlacementSpinBox->setEnabled(
true );
55 mCustomPlacementSpinBox->setEnabled(
false );
57 mCustomPlacementSpinBox->setValue( mPercentPlacementComboBox->currentData().toDouble() * 100 );
58 mBlockSignals =
false;
61 connect( mCustomPlacementSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double ) {
66 connect( mAnchorTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
70 updateAnchorTypeHint();
73 connect( mClippingComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
78 connect( mAnchorTextPointComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
82 updateAnchorTextPointHint();
89 updateAnchorTypeHint();
90 updateAnchorTextPointHint();
96 const int comboIndex = mPercentPlacementComboBox->findData(
settings.lineAnchorPercent() );
97 if ( comboIndex >= 0 )
99 mPercentPlacementComboBox->setCurrentIndex( comboIndex );
104 mPercentPlacementComboBox->setCurrentIndex( mPercentPlacementComboBox->findData( -1.0 ) );
105 mCustomPlacementSpinBox->setValue(
settings.lineAnchorPercent() * 100.0 );
107 mCustomPlacementSpinBox->setEnabled( mPercentPlacementComboBox->currentData().toDouble() < 0 );
109 mAnchorTypeComboBox->setCurrentIndex( mAnchorTypeComboBox->findData(
static_cast<int>(
settings.anchorType() ) ) );
110 mClippingComboBox->setCurrentIndex( mClippingComboBox->findData(
static_cast<int>(
settings.anchorClipping() ) ) );
111 mAnchorTextPointComboBox->setCurrentIndex( mAnchorTextPointComboBox->findData(
static_cast<int>(
settings.anchorTextPoint() ) ) );
112 mBlockSignals =
false;
119 if ( mPercentPlacementComboBox->currentData().toDouble() >= 0 )
121 settings.setLineAnchorPercent( mPercentPlacementComboBox->currentData().toDouble() );
125 settings.setLineAnchorPercent( mCustomPlacementSpinBox->value() / 100.0 );
142void QgsLabelLineAnchorWidget::updateAnchorTypeHint()
148 hint = tr(
"Labels are placed exactly on the label anchor only, and no other fallback placements are permitted." );
152 hint = tr(
"The label anchor is treated as a hint for the preferred label placement, but other placements close to the anchor point are permitted." );
155 mAnchorTypeHintLabel->setText( hint );
158void QgsLabelLineAnchorWidget::updateAnchorTextPointHint()
164 hint = tr(
"Labels are placed so that the start of their text is placed at the anchor point." );
167 hint = tr(
"Labels are placed so that the center of their text is placed at the anchor point." );
170 hint = tr(
"Labels are placed so that the end of their text is placed at the anchor point." );
173 hint = tr(
"The text justification is determined based on the anchor point. Anchors close to the start of the line will use the start of the text, anchors close to the end will use the end of the text, and central values will use the center of the text." );
176 mAnchorTextPointHintLabel->setText( hint );
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Contains settings related to how the label engine places and formats labels for line features (or pol...
AnchorType
Line anchor types.
@ Strict
Line anchor is a strict placement, and other placements are not permitted.
@ HintOnly
Line anchor is a hint for preferred placement only, but other placements close to the hint are permit...
AnchorClipping
Clipping behavior for line anchor calculation.
@ UseEntireLine
Entire original feature line geometry is used when calculating the line anchor for labels.
@ UseVisiblePartsOfLine
Only visible parts of lines are considered when calculating the line anchor for labels.
AnchorTextPoint
Anchor point of label text.
@ EndOfText
Anchor using end of text.
@ StartOfText
Anchor using start of text.
@ CenterOfText
Anchor using center of text.
@ FollowPlacement
Automatically set the anchor point based on the lineAnchorPercent() value. Values <25% will use the s...
@ LineAnchorType
Line anchor type.
@ LineAnchorClipping
Clipping mode for line anchor calculation.
@ LineAnchorPercent
Portion along line at which labels should be anchored.
@ LineAnchorTextPoint
Line anchor text point.
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
Represents a vector layer which manages a vector based dataset.