24#include "moc_qgslabellineanchorwidget.cpp"
26using namespace Qt::StringLiterals;
51 connect( mPercentPlacementComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
55 if ( mPercentPlacementComboBox->currentData().toDouble() < 0 )
56 mCustomPlacementSpinBox->setEnabled(
true );
59 mCustomPlacementSpinBox->setEnabled(
false );
61 mCustomPlacementSpinBox->setValue( mPercentPlacementComboBox->currentData().toDouble() * 100 );
62 mBlockSignals =
false;
65 connect( mCustomPlacementSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double ) {
70 connect( mAnchorTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
74 updateAnchorTypeHint();
77 connect( mClippingComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
82 connect( mAnchorTextPointComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
86 updateAnchorTextPointHint();
93 updateAnchorTypeHint();
94 updateAnchorTextPointHint();
100 const int comboIndex = mPercentPlacementComboBox->findData(
settings.lineAnchorPercent() );
101 if ( comboIndex >= 0 )
103 mPercentPlacementComboBox->setCurrentIndex( comboIndex );
108 mPercentPlacementComboBox->setCurrentIndex( mPercentPlacementComboBox->findData( -1.0 ) );
109 mCustomPlacementSpinBox->setValue(
settings.lineAnchorPercent() * 100.0 );
111 mCustomPlacementSpinBox->setEnabled( mPercentPlacementComboBox->currentData().toDouble() < 0 );
113 mAnchorTypeComboBox->setCurrentIndex( mAnchorTypeComboBox->findData(
static_cast<int>(
settings.anchorType() ) ) );
114 mClippingComboBox->setCurrentIndex( mClippingComboBox->findData(
static_cast<int>(
settings.anchorClipping() ) ) );
115 mAnchorTextPointComboBox->setCurrentIndex( mAnchorTextPointComboBox->findData(
static_cast<int>(
settings.anchorTextPoint() ) ) );
116 mBlockSignals =
false;
123 if ( mPercentPlacementComboBox->currentData().toDouble() >= 0 )
125 settings.setLineAnchorPercent( mPercentPlacementComboBox->currentData().toDouble() );
129 settings.setLineAnchorPercent( mCustomPlacementSpinBox->value() / 100.0 );
146void QgsLabelLineAnchorWidget::updateAnchorTypeHint()
152 hint = tr(
"Labels are placed exactly on the label anchor only, and no other fallback placements are permitted." );
156 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." );
159 mAnchorTypeHintLabel->setText( hint );
162void QgsLabelLineAnchorWidget::updateAnchorTextPointHint()
168 hint = tr(
"Labels are placed so that the start of their text is placed at the anchor point." );
171 hint = tr(
"Labels are placed so that the center of their text is placed at the anchor point." );
174 hint = tr(
"Labels are placed so that the end of their text is placed at the anchor point." );
177 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." );
180 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.