24#include <QDialogButtonBox>
26#include "moc_qgscolorramplegendnodewidget.cpp"
36 mOrientationComboBox->addItem( tr(
"Vertical" ), Qt::Vertical );
37 mOrientationComboBox->addItem( tr(
"Horizontal" ), Qt::Horizontal );
41 mMinLabelLineEdit->setPlaceholderText( tr(
"Default" ) );
45 mMinLabelLineEdit->setShowClearButton(
false );
49 mMaxLabelLineEdit->setPlaceholderText( tr(
"Default" ) );
53 mMaxLabelLineEdit->setShowClearButton(
false );
56 mFontButton->setShowNullFormat(
true );
57 mFontButton->setNoFormatString( tr(
"Default" ) );
59 connect( mUseContinuousLegendCheckBox, &QCheckBox::stateChanged,
this, [
this](
bool checked ) {
60 mLayoutGroup->setEnabled( checked );
61 mLabelsGroup->setEnabled( checked );
65 connect( mMinLabelLineEdit, &QLineEdit::textChanged,
this, &QgsColorRampLegendNodeWidget::onChanged );
66 connect( mMaxLabelLineEdit, &QLineEdit::textChanged,
this, &QgsColorRampLegendNodeWidget::onChanged );
67 connect( mPrefixLineEdit, &QLineEdit::textChanged,
this, &QgsColorRampLegendNodeWidget::onChanged );
68 connect( mSuffixLineEdit, &QLineEdit::textChanged,
this, &QgsColorRampLegendNodeWidget::onChanged );
69 connect( mDirectionComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsColorRampLegendNodeWidget::onChanged );
70 connect( mOrientationComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsColorRampLegendNodeWidget::onOrientationChanged );
71 connect( mNumberFormatPushButton, &QPushButton::clicked,
this, &QgsColorRampLegendNodeWidget::changeNumberFormat );
76 mPrefixLineEdit->hide();
81 mSuffixLineEdit->hide();
86 mNumberFormatPushButton->hide();
87 mNumberFormatLabel->hide();
94 settings.setUseContinuousLegend( mUseContinuousLegendCheckBox->isChecked() );
96 settings.setOrientation(
static_cast<Qt::Orientation
>( mOrientationComboBox->currentData().toInt() ) );
97 settings.setMinimumLabel( mMinLabelLineEdit->text() );
98 settings.setMaximumLabel( mMaxLabelLineEdit->text() );
99 settings.setPrefix( mPrefixLineEdit->text() );
100 settings.setSuffix( mSuffixLineEdit->text() );
101 settings.setNumericFormat( mSettings.numericFormat()->clone() );
102 settings.setTextFormat( mFontButton->textFormat() );
108 mBlockSignals =
true;
111 mUseContinuousLegendCheckBox->setChecked(
settings.useContinuousLegend() );
112 mMinLabelLineEdit->setText(
settings.minimumLabel() );
113 mMaxLabelLineEdit->setText(
settings.maximumLabel() );
114 mPrefixLineEdit->setText(
settings.prefix() );
115 mSuffixLineEdit->setText(
settings.suffix() );
116 mDirectionComboBox->setCurrentIndex( mDirectionComboBox->findData(
settings.direction() ) );
117 mOrientationComboBox->setCurrentIndex( mOrientationComboBox->findData(
settings.orientation() ) );
118 mFontButton->setTextFormat(
settings.textFormat() );
119 onOrientationChanged();
120 mBlockSignals =
false;
125 mUseContinuousLegendCheckBox->setVisible( visible );
128void QgsColorRampLegendNodeWidget::changeNumberFormat()
141void QgsColorRampLegendNodeWidget::onOrientationChanged()
143 switch (
static_cast<Qt::Orientation
>( mOrientationComboBox->currentData().toInt() ) )
146 mDirectionComboBox->setItemText( 0, tr(
"Maximum on Top" ) );
147 mDirectionComboBox->setItemText( 1, tr(
"Minimum on Top" ) );
151 mDirectionComboBox->setItemText( 0, tr(
"Maximum on Right" ) );
152 mDirectionComboBox->setItemText( 1, tr(
"Minimum on Right" ) );
159void QgsColorRampLegendNodeWidget::onChanged()
174 QVBoxLayout *vLayout =
new QVBoxLayout();
176 vLayout->addWidget( mWidget );
177 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
178 connect( mButtonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
179 connect( mButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
180 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, [] {
181 QgsHelp::openHelp( QStringLiteral(
"working_with_raster/raster_properties.html#raster-legend-settings" ) );
184 vLayout->addWidget( mButtonBox );
185 setLayout( vLayout );
186 setWindowTitle( tr(
"Legend Node Settings" ) );
193 return mWidget->settings();
203 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.