22 #include <QAbstractButton>
23 #include <QDialogButtonBox>
26 static void updateColorButton( QAbstractButton *button, QColor color )
30 button->setIcon( QIcon( p ) );
45 cboSchemeName->setIconSize(
iconSize );
48 const auto constSchemes = schemes;
49 for (
const QString &schemeName : constSchemes )
55 cboSchemeName->addItem( icon, schemeName );
59 connect( cboSchemeName,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsColorBrewerColorRampWidget::setSchemeName );
60 connect( cboColors,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsColorBrewerColorRampWidget::setColors );
70 void QgsColorBrewerColorRampWidget::populateVariants()
72 QString oldVariant = cboColors->currentText();
75 QString schemeName = cboSchemeName->currentText();
77 const auto constVariants = variants;
78 for (
int variant : constVariants )
80 cboColors->addItem( QString::number( variant ) );
84 int idx = cboColors->findText( oldVariant );
88 idx = cboColors->count() - 1;
90 cboColors->setCurrentIndex( idx );
93 void QgsColorBrewerColorRampWidget::updatePreview()
95 QSize size( 300, 40 );
99 void QgsColorBrewerColorRampWidget::updateUi()
103 whileBlocking( cboColors )->setCurrentIndex( cboColors->findText( QString::number( mRamp.
colors() ) ) );
107 void QgsColorBrewerColorRampWidget::setSchemeName()
117 void QgsColorBrewerColorRampWidget::setColors()
119 int num = cboColors->currentText().toInt();
128 QVBoxLayout *vLayout =
new QVBoxLayout();
131 vLayout->addWidget( mWidget );
132 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
133 connect( mButtonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
134 connect( mButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
135 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsColorBrewerColorRampDialog::showHelp );
136 vLayout->addWidget( mButtonBox );
137 setLayout( vLayout );
138 setWindowTitle( tr(
"ColorBrewer Ramp" ) );
147 void QgsColorBrewerColorRampDialog::showHelp()
149 QgsHelp::openHelp( QStringLiteral(
"style_library/style_manager.html#setting-a-color-ramp" ) );