24#include <QDialogButtonBox>
27#include "moc_qgscolorramplegendnodewidget.cpp"
29using namespace Qt::StringLiterals;
39 mOrientationComboBox->addItem( tr(
"Vertical" ), Qt::Vertical );
40 mOrientationComboBox->addItem( tr(
"Horizontal" ), Qt::Horizontal );
44 mMinLabelLineEdit->setPlaceholderText( tr(
"Default" ) );
48 mMinLabelLineEdit->setShowClearButton(
false );
52 mMaxLabelLineEdit->setPlaceholderText( tr(
"Default" ) );
56 mMaxLabelLineEdit->setShowClearButton(
false );
59 mFontButton->setShowNullFormat(
true );
60 mFontButton->setNoFormatString( tr(
"Default" ) );
62 connect( mUseContinuousLegendCheckBox, &QCheckBox::stateChanged,
this, [
this](
bool checked ) {
63 mLayoutGroup->setEnabled( checked );
64 mLabelsGroup->setEnabled( checked );
68 connect( mMinLabelLineEdit, &QLineEdit::textChanged,
this, &QgsColorRampLegendNodeWidget::onChanged );
69 connect( mMaxLabelLineEdit, &QLineEdit::textChanged,
this, &QgsColorRampLegendNodeWidget::onChanged );
70 connect( mPrefixLineEdit, &QLineEdit::textChanged,
this, &QgsColorRampLegendNodeWidget::onChanged );
71 connect( mSuffixLineEdit, &QLineEdit::textChanged,
this, &QgsColorRampLegendNodeWidget::onChanged );
72 connect( mDirectionComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsColorRampLegendNodeWidget::onChanged );
73 connect( mOrientationComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsColorRampLegendNodeWidget::onOrientationChanged );
74 connect( mNumberFormatPushButton, &QPushButton::clicked,
this, &QgsColorRampLegendNodeWidget::changeNumberFormat );
79 mPrefixLineEdit->hide();
84 mSuffixLineEdit->hide();
89 mNumberFormatPushButton->hide();
90 mNumberFormatLabel->hide();
97 settings.setUseContinuousLegend( mUseContinuousLegendCheckBox->isChecked() );
99 settings.setOrientation(
static_cast<Qt::Orientation
>( mOrientationComboBox->currentData().toInt() ) );
100 settings.setMinimumLabel( mMinLabelLineEdit->text() );
101 settings.setMaximumLabel( mMaxLabelLineEdit->text() );
102 settings.setPrefix( mPrefixLineEdit->text() );
103 settings.setSuffix( mSuffixLineEdit->text() );
104 settings.setNumericFormat( mSettings.numericFormat()->clone() );
105 settings.setTextFormat( mFontButton->textFormat() );
111 mBlockSignals =
true;
114 mUseContinuousLegendCheckBox->setChecked(
settings.useContinuousLegend() );
115 mMinLabelLineEdit->setText(
settings.minimumLabel() );
116 mMaxLabelLineEdit->setText(
settings.maximumLabel() );
117 mPrefixLineEdit->setText(
settings.prefix() );
118 mSuffixLineEdit->setText(
settings.suffix() );
119 mDirectionComboBox->setCurrentIndex( mDirectionComboBox->findData(
settings.direction() ) );
120 mOrientationComboBox->setCurrentIndex( mOrientationComboBox->findData(
settings.orientation() ) );
121 mFontButton->setTextFormat(
settings.textFormat() );
122 onOrientationChanged();
123 mBlockSignals =
false;
128 mUseContinuousLegendCheckBox->setVisible( visible );
131void QgsColorRampLegendNodeWidget::changeNumberFormat()
144void QgsColorRampLegendNodeWidget::onOrientationChanged()
146 switch (
static_cast<Qt::Orientation
>( mOrientationComboBox->currentData().toInt() ) )
149 mDirectionComboBox->setItemText( 0, tr(
"Maximum on Top" ) );
150 mDirectionComboBox->setItemText( 1, tr(
"Minimum on Top" ) );
154 mDirectionComboBox->setItemText( 0, tr(
"Maximum on Right" ) );
155 mDirectionComboBox->setItemText( 1, tr(
"Minimum on Right" ) );
162void QgsColorRampLegendNodeWidget::onChanged()
177 QVBoxLayout *vLayout =
new QVBoxLayout();
179 vLayout->addWidget( mWidget );
180 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
181 connect( mButtonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
182 connect( mButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
183 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, [] {
184 QgsHelp::openHelp( u
"working_with_raster/raster_properties.html#raster-legend-settings"_s );
187 vLayout->addWidget( mButtonBox );
188 setLayout( vLayout );
189 setWindowTitle( tr(
"Legend Node Settings" ) );
196 return mWidget->settings();
206 mWidget->setUseContinuousRampCheckBoxVisibility( visible );
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 setNumericFormat(QgsNumericFormat *format)
Sets the numeric format used for numbers in the scalebar.
const QgsNumericFormat * numericFormat() const
Returns the numeric format used for numbers in the scalebar.
Direction
Ramp directions.
@ MaximumToMinimum
Maximum value on bottom, minimum value on top.
@ MinimumToMaximum
Minimum value on bottom, maximum value on top.
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.