Skip to content
Permalink
Browse files

[FEATURE] Show an alpha slider in color button drop down menu

Allows quick tweaks to the color alpha
  • Loading branch information
nyalldawson committed Dec 9, 2016
1 parent 5aa1539 commit ee55c4bc6608a07684a118f8b65c16aa8349b46a
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/gui/qgscolorbutton.cpp
@@ -462,9 +462,21 @@ void QgsColorButton::prepareMenu()
colorWheel->setColor( color() );
QgsColorWidgetAction* colorAction = new QgsColorWidgetAction( colorWheel, mMenu, mMenu );
colorAction->setDismissOnColorSelection( false );
connect( colorAction, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
connect( colorAction, &QgsColorWidgetAction::colorChanged, this, &QgsColorButton::setColor );
mMenu->addAction( colorAction );

if ( mAllowAlpha )
{
QgsColorRampWidget* alphaRamp = new QgsColorRampWidget( mMenu, QgsColorWidget::Alpha, QgsColorRampWidget::Horizontal );
alphaRamp->setColor( color() );
QgsColorWidgetAction* alphaAction = new QgsColorWidgetAction( alphaRamp, mMenu, mMenu );
alphaAction->setDismissOnColorSelection( false );
connect( alphaAction, &QgsColorWidgetAction::colorChanged, this, &QgsColorButton::setColor );
connect( alphaAction, &QgsColorWidgetAction::colorChanged, colorWheel, [colorWheel]( const QColor& color ) { colorWheel->setColor( color, false ); }
);
connect( colorAction, &QgsColorWidgetAction::colorChanged, alphaRamp, [alphaRamp]( const QColor& color ) { alphaRamp->setColor( color, false ); }
);
mMenu->addAction( alphaAction );
}

if ( mColorSchemeRegistry )
{

2 comments on commit ee55c4b

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Dec 9, 2016

Yay!

@3nids

This comment has been minimized.

Copy link
Member

@3nids 3nids replied Dec 9, 2016

💯

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