Skip to content
Permalink
Browse files

Hide color schemes from color button menu if they contain no colors

  • Loading branch information
nyalldawson committed Aug 14, 2014
1 parent 11686c7 commit b3dbe74155f257652d695eaafe385a4f545ea9be
Showing with 16 additions and 0 deletions.
  1. +5 −0 python/gui/qgscolorswatchgrid.sip
  2. +6 −0 src/gui/qgscolorswatchgrid.cpp
  3. +5 −0 src/gui/qgscolorswatchgrid.h
@@ -53,6 +53,11 @@ class QgsColorSwatchGrid: QWidget
* @see baseColor
*/
void setBaseColor( const QColor baseColor );

/**Gets the list of colors shown in the grid
* @returns list of colors currently shown in the grid
*/
QgsNamedColorList* colors();

public slots:

@@ -335,11 +335,15 @@ QgsColorSwatchGridAction::QgsColorSwatchGridAction( QgsColorScheme* scheme, QMen
, mSuppressRecurse( false )
{
mColorSwatchGrid = new QgsColorSwatchGrid( scheme, context, parent );

setDefaultWidget( mColorSwatchGrid );
connect( mColorSwatchGrid, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) );

connect( this, SIGNAL( hovered() ), this, SLOT( onHover() ) );
connect( mColorSwatchGrid, SIGNAL( hovered() ), this, SLOT( onHover() ) );

//hide the action if no colors to be shown
setVisible( mColorSwatchGrid->colors()->count() > 0 );
}

QgsColorSwatchGridAction::~QgsColorSwatchGridAction()
@@ -370,6 +374,8 @@ void QgsColorSwatchGridAction::setContext( const QString context )
void QgsColorSwatchGridAction::refreshColors()
{
mColorSwatchGrid->refreshColors();
//hide the action if no colors shown
setVisible( mColorSwatchGrid->colors()->count() > 0 );
}

void QgsColorSwatchGridAction::setColor( const QColor &color )
@@ -71,6 +71,11 @@ class GUI_EXPORT QgsColorSwatchGrid: public QWidget
*/
void setBaseColor( const QColor baseColor );

/**Gets the list of colors shown in the grid
* @returns list of colors currently shown in the grid
*/
QgsNamedColorList* colors() { return &mColors; }

public slots:

/**Reload colors from scheme and redraws the widget

0 comments on commit b3dbe74

Please sign in to comment.
You can’t perform that action at this time.