Skip to content

Commit

Permalink
[FEATURE] Show an alpha slider in color button drop down menu
Browse files Browse the repository at this point in the history
Allows quick tweaks to the color alpha
  • Loading branch information
nyalldawson committed Dec 9, 2016
1 parent 5aa1539 commit ee55c4b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/gui/qgscolorbutton.cpp
Expand Up @@ -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 )
{
Expand Down

2 comments on commit ee55c4b

@nirvn
Copy link
Contributor

@nirvn nirvn commented on ee55c4b Dec 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

@3nids
Copy link
Member

@3nids 3nids commented on ee55c4b Dec 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Please sign in to comment.