20 #include <QFileDialog>
21 #include <QAbstractButton>
22 #include <QDialogButtonBox>
23 #include <QMessageBox>
30 connect( mButtonAddColor, &QToolButton::clicked,
this, &QgsPresetColorRampWidget::mButtonAddColor_clicked );
31 mTreeColors->setScheme( &mRamp );
39 connect( mTreeColors->model(), &QAbstractItemModel::dataChanged,
this, &QgsPresetColorRampWidget::schemeChanged );
40 connect( mTreeColors->model(), &QAbstractItemModel::rowsRemoved,
this, &QgsPresetColorRampWidget::schemeChanged );
53 mTreeColors->setScheme( &mRamp );
58 void QgsPresetColorRampWidget::updatePreview()
60 const QSize size( 300, 40 );
64 void QgsPresetColorRampWidget::setColors()
70 void QgsPresetColorRampWidget::mButtonAddColor_clicked()
85 if ( !newColor.isValid() )
95 void QgsPresetColorRampWidget::schemeChanged()
97 mTreeColors->saveColorsToScheme();
102 void QgsPresetColorRampWidget::newColorChanged(
const QColor &color )
104 const int row = mTreeColors->model()->rowCount() - 1;
105 const QModelIndex colorIndex = mTreeColors->model()->index( row, 0 );
106 mTreeColors->model()->setData( colorIndex, color );
112 QVBoxLayout *vLayout =
new QVBoxLayout();
116 vLayout->addWidget( mWidget );
117 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
118 connect( mButtonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
119 connect( mButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
120 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsPresetColorRampDialog::showHelp );
121 vLayout->addWidget( mButtonBox );
122 setLayout( vLayout );
123 setWindowTitle( tr(
"Color Presets Ramp" ) );
132 void QgsPresetColorRampDialog::showHelp()
134 QgsHelp::openHelp( QStringLiteral(
"style_library/style_manager.html#setting-a-color-ramp" ) );