Fix trying to create new color ramp from first page in style

manager dialog does nothing
This commit is contained in:
Nyall Dawson 2020-10-18 16:28:59 +10:00
parent 1d5bfb2cfe
commit 34fb646f7a
3 changed files with 16 additions and 21 deletions

View File

@ -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();

View File

@ -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 :
{
item = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "styleicons/color.svg" ) ), rampType, this );
connect( item, &QAction::triggered, this, [ = ]( bool ) { addColorRamp( item ); } );
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.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<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.
@ -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;

View File

@ -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();