diff --git a/python/gui/auto_generated/symbology/qgsstylemanagerdialog.sip.in b/python/gui/auto_generated/symbology/qgsstylemanagerdialog.sip.in index 353859c3fec..29a016a101e 100644 --- a/python/gui/auto_generated/symbology/qgsstylemanagerdialog.sip.in +++ b/python/gui/auto_generated/symbology/qgsstylemanagerdialog.sip.in @@ -226,7 +226,7 @@ Context menu for the listItems ( symbols list ) %End protected slots: - bool addColorRamp( QAction *action ); + bool addColorRamp( const QString &type = QString() ); void addFavoriteSelectedSymbols(); %Docstring Add selected symbols to favorites @@ -288,10 +288,6 @@ Populates the list view with color ramps of the current type with the given name bool addSymbol( int symbolType = -1 ); %Docstring add a new symbol to style -%End - bool addColorRamp(); -%Docstring -add a new color ramp to style %End bool editSymbol(); diff --git a/src/gui/symbology/qgsstylemanagerdialog.cpp b/src/gui/symbology/qgsstylemanagerdialog.cpp index 8c104f75e01..9745b07d7e2 100644 --- a/src/gui/symbology/qgsstylemanagerdialog.cpp +++ b/src/gui/symbology/qgsstylemanagerdialog.cpp @@ -346,12 +346,19 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent, connect( item, &QAction::triggered, this, [ = ]( bool ) { addSymbol( QgsSymbol::Fill ); } ); mMenuBtnAddItemAll->addAction( item ); mMenuBtnAddItemAll->addSeparator(); - for ( const QString &rampType : qgis::as_const( rampTypes ) ) + for ( const std::pair< QString, QString > &rampType : + { + std::pair< QString, QString > { tr( "Gradient…" ), tr( "Gradient" ) }, + std::pair< QString, QString > { tr( "Color presets…" ), tr( "Color presets" ) }, + std::pair< QString, QString > { tr( "Random…" ), tr( "Random" ) }, + std::pair< QString, QString > { tr( "Catalog: cpt-city…" ), tr( "Catalog: cpt-city" ) }, + std::pair< QString, QString > { tr( "Catalog: ColorBrewer…" ), tr( "Catalog: ColorBrewer" ) } + } ) { - item = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "styleicons/color.svg" ) ), rampType, this ); - connect( item, &QAction::triggered, this, [ = ]( bool ) { addColorRamp( item ); } ); + item = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "styleicons/color.svg" ) ), rampType.first, this ); + connect( item, &QAction::triggered, this, [ = ]( bool ) { addColorRamp( rampType.second ); } ); mMenuBtnAddItemAll->addAction( item ); - mMenuBtnAddItemColorRamp->addAction( new QAction( rampType, this ) ); + mMenuBtnAddItemColorRamp->addAction( new QAction( rampType.first, this ) ); } mMenuBtnAddItemAll->addSeparator(); item = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "mIconFieldText.svg" ) ), tr( "Text Format…" ), this ); @@ -400,7 +407,7 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent, mMenuBtnAddItemSymbol3D->addAction( item ); connect( mMenuBtnAddItemColorRamp, &QMenu::triggered, - this, static_cast( &QgsStyleManagerDialog::addColorRamp ) ); + this, [ = ]( QAction * action ) { addColorRamp( action->data().toString() ); } ); } // Context menu for symbols/colorramps. The menu entries for every group are created when displaying the menu. @@ -1519,16 +1526,10 @@ void QgsStyleManagerDialog::activate() activateWindow(); } -bool QgsStyleManagerDialog::addColorRamp() -{ - return addColorRamp( nullptr ); -} - -bool QgsStyleManagerDialog::addColorRamp( QAction *action ) +bool QgsStyleManagerDialog::addColorRamp( const QString &type ) { // pass the action text, which is the color ramp type - QString rampName = addColorRampStatic( this, mStyle, - action ? action->text() : QString() ); + QString rampName = addColorRampStatic( this, mStyle, type ); if ( !rampName.isEmpty() ) { mModified = true; diff --git a/src/gui/symbology/qgsstylemanagerdialog.h b/src/gui/symbology/qgsstylemanagerdialog.h index e9e2cac9615..79592e4afd0 100644 --- a/src/gui/symbology/qgsstylemanagerdialog.h +++ b/src/gui/symbology/qgsstylemanagerdialog.h @@ -254,7 +254,7 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan void listitemsContextMenu( QPoint ); protected slots: - bool addColorRamp( QAction *action ); + bool addColorRamp( const QString &type = QString() ); //! Add selected symbols to favorites void addFavoriteSelectedSymbols(); //! Remove selected symbols from favorites @@ -300,8 +300,6 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan //! add a new symbol to style bool addSymbol( int symbolType = -1 ); - //! add a new color ramp to style - bool addColorRamp(); bool editSymbol(); bool editColorRamp();