Skip to content

Commit

Permalink
Fix trying to create new color ramp from first page in style
Browse files Browse the repository at this point in the history
manager dialog does nothing
  • Loading branch information
nyalldawson committed Oct 19, 2020
1 parent 1d5bfb2 commit 34fb646
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
27 changes: 14 additions & 13 deletions src/gui/symbology/qgsstylemanagerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -400,7 +407,7 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent,
mMenuBtnAddItemSymbol3D->addAction( item );

connect( mMenuBtnAddItemColorRamp, &QMenu::triggered,
this, static_cast<bool ( QgsStyleManagerDialog::* )( QAction * )>( &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.
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/gui/symbology/qgsstylemanagerdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 34fb646

Please sign in to comment.