19#include "moc_qgscolorramplegendnodewidget.cpp"
23#include <QDialogButtonBox>
33 mOrientationComboBox->addItem( tr(
"Vertical" ), Qt::Vertical );
34 mOrientationComboBox->addItem( tr(
"Horizontal" ), Qt::Horizontal );
38 mMinLabelLineEdit->setPlaceholderText( tr(
"Default" ) );
42 mMinLabelLineEdit->setShowClearButton(
false );
46 mMaxLabelLineEdit->setPlaceholderText( tr(
"Default" ) );
50 mMaxLabelLineEdit->setShowClearButton(
false );
53 mFontButton->setShowNullFormat(
true );
54 mFontButton->setNoFormatString( tr(
"Default" ) );
56 connect( mUseContinuousLegendCheckBox, &QCheckBox::stateChanged,
this, [=](
bool checked ) {
57 mLayoutGroup->setEnabled( checked );
58 mLabelsGroup->setEnabled( checked );
62 connect( mMinLabelLineEdit, &QLineEdit::textChanged,
this, &QgsColorRampLegendNodeWidget::onChanged );
63 connect( mMaxLabelLineEdit, &QLineEdit::textChanged,
this, &QgsColorRampLegendNodeWidget::onChanged );
64 connect( mPrefixLineEdit, &QLineEdit::textChanged,
this, &QgsColorRampLegendNodeWidget::onChanged );
65 connect( mSuffixLineEdit, &QLineEdit::textChanged,
this, &QgsColorRampLegendNodeWidget::onChanged );
66 connect( mDirectionComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsColorRampLegendNodeWidget::onChanged );
67 connect( mOrientationComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsColorRampLegendNodeWidget::onOrientationChanged );
68 connect( mNumberFormatPushButton, &QPushButton::clicked,
this, &QgsColorRampLegendNodeWidget::changeNumberFormat );
73 mPrefixLineEdit->hide();
78 mSuffixLineEdit->hide();
83 mNumberFormatPushButton->hide();
84 mNumberFormatLabel->hide();
105 mBlockSignals =
true;
113 mDirectionComboBox->setCurrentIndex( mDirectionComboBox->findData(
settings.
direction() ) );
114 mOrientationComboBox->setCurrentIndex( mOrientationComboBox->findData(
settings.
orientation() ) );
116 onOrientationChanged();
117 mBlockSignals =
false;
122 mUseContinuousLegendCheckBox->setVisible( visible );
125void QgsColorRampLegendNodeWidget::changeNumberFormat()
138void QgsColorRampLegendNodeWidget::onOrientationChanged()
140 switch (
static_cast<Qt::Orientation
>( mOrientationComboBox->currentData().toInt() ) )
143 mDirectionComboBox->setItemText( 0, tr(
"Maximum on Top" ) );
144 mDirectionComboBox->setItemText( 1, tr(
"Minimum on Top" ) );
148 mDirectionComboBox->setItemText( 0, tr(
"Maximum on Right" ) );
149 mDirectionComboBox->setItemText( 1, tr(
"Minimum on Right" ) );
156void QgsColorRampLegendNodeWidget::onChanged()
171 QVBoxLayout *vLayout =
new QVBoxLayout();
173 vLayout->addWidget( mWidget );
174 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
175 connect( mButtonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
176 connect( mButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
177 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, [=] {
178 QgsHelp::openHelp( QStringLiteral(
"working_with_raster/raster_properties.html#raster-legend-settings" ) );
181 vLayout->addWidget( mButtonBox );
182 setLayout( vLayout );
183 setWindowTitle( tr(
"Legend Node Settings" ) );
void setUseContinuousRampCheckBoxVisibility(bool visible)
Sets visibility for the "Use Continuous Legend" checkbox in the legend settings dialog to visible.
QgsColorRampLegendNodeDialog(const QgsColorRampLegendNodeSettings &settings, QWidget *parent SIP_TRANSFERTHIS=nullptr, QgsColorRampLegendNodeWidget::Capabilities capabilities=QgsColorRampLegendNodeWidget::Capability::AllCapabilities)
Constructor for QgsColorRampLegendNodeDialog, initially showing the specified settings.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsColorRampLegendNodeSettings settings() const
Returns the legend node settings as defined by the dialog.
Settings for a color ramp legend node.
void setDirection(QgsColorRampLegendNodeSettings::Direction direction)
Sets the direction of the ramp.
void setMaximumLabel(const QString &label)
Sets the label for the maximum value on the ramp.
void setNumericFormat(QgsNumericFormat *format)
Sets the numeric format used for numbers in the scalebar.
bool useContinuousLegend() const
Returns true if a continuous gradient legend will be used.
const QgsNumericFormat * numericFormat() const
Returns the numeric format used for numbers in the scalebar.
QString maximumLabel() const
Returns the label for the maximum value on the ramp.
QString suffix() const
Returns the suffix to show after legend text.
void setPrefix(const QString &prefix)
Sets the prefix to show before legend text.
void setUseContinuousLegend(bool useContinuousLegend)
Sets the flag to use a continuous gradient legend to useContinuousLegend.
void setOrientation(Qt::Orientation orientation)
Sets the ramp orientation (i.e.
Direction
Ramp directions.
@ MaximumToMinimum
Maximum value on bottom, minimum value on top.
@ MinimumToMaximum
Minimum value on bottom, maximum value on top.
void setSuffix(const QString &suffix)
Sets the suffix to show after legend text.
QString prefix() const
Returns the prefix to show before legend text.
Qt::Orientation orientation() const
Returns the ramp orientation (i.e.
QgsColorRampLegendNodeSettings::Direction direction() const
Returns the direction of the ramp.
QgsTextFormat textFormat() const
Returns the text format used to render text in the legend item.
void setMinimumLabel(const QString &label)
Sets the label for the minimum value on the ramp.
void setTextFormat(const QgsTextFormat &format)
Sets the text format used to render text in the legend item.
QString minimumLabel() const
Returns the label for the minimum value on the ramp.
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.