mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-19 00:04:52 -04:00
[gui] Fix style manager's add button when the 'all' tab is selected
This commit is contained in:
parent
4022c5fc38
commit
df1d47b86a
@ -279,7 +279,7 @@ Populates the list view with color ramps of the current type with the given name
|
|||||||
int currentItemType();
|
int currentItemType();
|
||||||
QString currentItemName();
|
QString currentItemName();
|
||||||
|
|
||||||
bool addSymbol();
|
bool addSymbol( int symbolType = -1 );
|
||||||
%Docstring
|
%Docstring
|
||||||
add a new symbol to style
|
add a new symbol to style
|
||||||
%End
|
%End
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include "qgsstylemanagerdialog.h"
|
#include "qgsstylemanagerdialog.h"
|
||||||
#include "qgsstylesavedialog.h"
|
#include "qgsstylesavedialog.h"
|
||||||
|
|
||||||
#include "qgsstyle.h"
|
|
||||||
#include "qgssymbol.h"
|
#include "qgssymbol.h"
|
||||||
#include "qgssymbollayerutils.h"
|
#include "qgssymbollayerutils.h"
|
||||||
#include "qgscolorramp.h"
|
#include "qgscolorramp.h"
|
||||||
@ -296,9 +295,28 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent,
|
|||||||
QStringList rampTypes;
|
QStringList rampTypes;
|
||||||
rampTypes << tr( "Gradient" ) << tr( "Color presets" ) << tr( "Random" ) << tr( "Catalog: cpt-city" );
|
rampTypes << tr( "Gradient" ) << tr( "Color presets" ) << tr( "Random" ) << tr( "Catalog: cpt-city" );
|
||||||
rampTypes << tr( "Catalog: ColorBrewer" );
|
rampTypes << tr( "Catalog: ColorBrewer" );
|
||||||
|
|
||||||
|
mMenuBtnAddItemAll = new QMenu( this );
|
||||||
mMenuBtnAddItemColorRamp = new QMenu( this );
|
mMenuBtnAddItemColorRamp = new QMenu( this );
|
||||||
|
|
||||||
|
QAction *item = new QAction( tr( "Marker" ), this );
|
||||||
|
connect( item, &QAction::triggered, this, [ = ]( bool ) { addSymbol( QgsSymbol::Marker ); } );
|
||||||
|
mMenuBtnAddItemAll->addAction( item );
|
||||||
|
item = new QAction( tr( "Line" ), this );
|
||||||
|
connect( item, &QAction::triggered, this, [ = ]( bool ) { addSymbol( QgsSymbol::Line ); } );
|
||||||
|
mMenuBtnAddItemAll->addAction( item );
|
||||||
|
item = new QAction( tr( "Fill" ), this );
|
||||||
|
connect( item, &QAction::triggered, this, [ = ]( bool ) { addSymbol( QgsSymbol::Fill ); } );
|
||||||
|
mMenuBtnAddItemAll->addAction( item );
|
||||||
|
mMenuBtnAddItemAll->addSeparator();
|
||||||
for ( const QString &rampType : qgis::as_const( rampTypes ) )
|
for ( const QString &rampType : qgis::as_const( rampTypes ) )
|
||||||
|
{
|
||||||
|
item = new QAction( rampType, this );
|
||||||
|
connect( item, &QAction::triggered, this, [ = ]( bool ) { addColorRamp( item ); } );
|
||||||
|
mMenuBtnAddItemAll->addAction( item );
|
||||||
mMenuBtnAddItemColorRamp->addAction( new QAction( rampType, this ) );
|
mMenuBtnAddItemColorRamp->addAction( new QAction( rampType, this ) );
|
||||||
|
}
|
||||||
|
|
||||||
connect( mMenuBtnAddItemColorRamp, &QMenu::triggered,
|
connect( mMenuBtnAddItemColorRamp, &QMenu::triggered,
|
||||||
this, static_cast<bool ( QgsStyleManagerDialog::* )( QAction * )>( &QgsStyleManagerDialog::addColorRamp ) );
|
this, static_cast<bool ( QgsStyleManagerDialog::* )( QAction * )>( &QgsStyleManagerDialog::addColorRamp ) );
|
||||||
}
|
}
|
||||||
@ -417,7 +435,20 @@ void QgsStyleManagerDialog::tabItemType_currentChanged( int )
|
|||||||
// when in Color Ramp tab, add menu to add item button and hide "Export symbols as PNG/SVG"
|
// when in Color Ramp tab, add menu to add item button and hide "Export symbols as PNG/SVG"
|
||||||
const bool isSymbol = currentItemType() != 3;
|
const bool isSymbol = currentItemType() != 3;
|
||||||
searchBox->setPlaceholderText( isSymbol ? tr( "Filter symbols…" ) : tr( "Filter color ramps…" ) );
|
searchBox->setPlaceholderText( isSymbol ? tr( "Filter symbols…" ) : tr( "Filter color ramps…" ) );
|
||||||
btnAddItem->setMenu( isSymbol || mReadOnly ? nullptr : mMenuBtnAddItemColorRamp );
|
|
||||||
|
if ( !mReadOnly && !isSymbol ) // color ramp tab
|
||||||
|
{
|
||||||
|
btnAddItem->setMenu( mMenuBtnAddItemColorRamp );
|
||||||
|
}
|
||||||
|
else if ( !mReadOnly && tabItemType->currentIndex() == 0 ) // all symbols tab
|
||||||
|
{
|
||||||
|
btnAddItem->setMenu( mMenuBtnAddItemAll );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btnAddItem->setMenu( nullptr );
|
||||||
|
}
|
||||||
|
|
||||||
actnExportAsPNG->setVisible( isSymbol );
|
actnExportAsPNG->setVisible( isSymbol );
|
||||||
actnExportAsSVG->setVisible( isSymbol );
|
actnExportAsSVG->setVisible( isSymbol );
|
||||||
|
|
||||||
@ -701,12 +732,12 @@ void QgsStyleManagerDialog::addItem()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsStyleManagerDialog::addSymbol()
|
bool QgsStyleManagerDialog::addSymbol( int symbolType )
|
||||||
{
|
{
|
||||||
// create new symbol with current type
|
// create new symbol with current type
|
||||||
QgsSymbol *symbol = nullptr;
|
QgsSymbol *symbol = nullptr;
|
||||||
QString name = tr( "new symbol" );
|
QString name = tr( "new symbol" );
|
||||||
switch ( currentItemType() )
|
switch ( symbolType == -1 ? currentItemType() : symbolType )
|
||||||
{
|
{
|
||||||
case QgsSymbol::Marker:
|
case QgsSymbol::Marker:
|
||||||
symbol = new QgsMarkerSymbol();
|
symbol = new QgsMarkerSymbol();
|
||||||
|
@ -297,7 +297,7 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan
|
|||||||
QString currentItemName();
|
QString currentItemName();
|
||||||
|
|
||||||
//! add a new symbol to style
|
//! add a new symbol to style
|
||||||
bool addSymbol();
|
bool addSymbol( int symbolType = -1 );
|
||||||
//! add a new color ramp to style
|
//! add a new color ramp to style
|
||||||
bool addColorRamp();
|
bool addColorRamp();
|
||||||
|
|
||||||
@ -381,6 +381,9 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan
|
|||||||
//! Menu for the "Add item" toolbutton when in colorramp mode
|
//! Menu for the "Add item" toolbutton when in colorramp mode
|
||||||
QMenu *mMenuBtnAddItemColorRamp = nullptr;
|
QMenu *mMenuBtnAddItemColorRamp = nullptr;
|
||||||
|
|
||||||
|
//! Menu for the "Add item" toolbutton when in all symbols mode
|
||||||
|
QMenu *mMenuBtnAddItemAll = nullptr;
|
||||||
|
|
||||||
QAction *mActionCopyToDefault = nullptr;
|
QAction *mActionCopyToDefault = nullptr;
|
||||||
|
|
||||||
int mBlockGroupUpdates = 0;
|
int mBlockGroupUpdates = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user